akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n+1).map { sc.nextLong() }
  val b = (1..n).map { sc.nextLong() }.toLongArray()

  val aa = a.toLongArray()

  for (i in 0 until n) {
    if (aa[i] <= b[i]) {
      val tmp = b[i] - aa[i]
      aa[i] = 0
      aa[i+1] = Math.max(0, aa[i + 1] - tmp)
    } else {
      aa[i] -= b[i]
    }
  }

  println(a.sum() - aa.sum())
}

Measured memory_bytes: 79240
import java.util.*;

import sun.net.www.content.text.plain;

import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = n*(n-1)+m*(m-1);
        ans/=2;
        System.out.println(ans);
    }       
}






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

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int length = sc.nextInt();
    int[] bruh = new int[length];
    for(int i = 0; i < bruh.length; i++)
    	bruh[i] = sc.nextInt();
    int max = 0; 
    int mov = 0;
    for(int i = bruh.length-2; i >= 0; i--)
    {
      if(bruh[i+1] > bruh[i])
        mov = 0;
      else
        mov++;
      if(mov > max)
        max = mov;
    }
	System.out.println(max);
  }
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll N;
    cin >> N;
    int ans = 0;
    for ( int i = 1; i <= N; i += 2){
        vector<ll> res = enum_divisors(i);
        ll s = res.size();
        //cout << s << endl;
        if ( s == 8 ) ++ans;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(void){
    int A, B;
    cin >> A >> B;
    vector<int> x(3);

    x[0] = A + B;
    x[1] = A - B;
    x[2] = A * B;

    int ans = *max_element(x.begin(), x.end());

    cout << ans << endl;
  
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int H=0,W=0,i,j;
        while(true){
        	H=scan.nextInt();
        	W=scan.nextInt();
        	if(H==0 && W==0)break;
        	for(i=0;i<H;i++){
        		for(j=0;j<W;j++){
        			if(i==0 || i==H-1){
        				System.out.print("#");
        			}
        			else if(j==0 || j==W-1){
        				System.out.print("#");
        			}
        			else{
        				System.out.print(".");
        			}
        		}
        		System.out.println("");
        	}
        	System.out.println("");
        }
    }
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL A, B, N; cin >> A >> B >> N;
  LL ans = 1e15;
  for(LL i=1;i<=N;++i)
	for(LL j=1;j<=N;++j){
	  if(B%j != 0) continue;
	  LL tar = i * B / j;
	  ans = min(ans, abs(A-tar));
	}
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3220
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  var ans ="No";
  for(i=0;i*7<=n;i++){
    for(j=0;j*4<=n-i*7;j++){
      if(n==i*7+j*4){
        ans="Yes";
      }
    }
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

using T = tuple<int,int,int>;

int main(){
  int n, q; cin >> n >> q;
  vector<T> v;
  rep(i,0,n){
    int a, b, c; cin >> a >> b >> c;
    v.emplace_back(a-c,0,c);
    v.emplace_back(b-c,-1,c);
  }
  rep(i,0,q){
    int d;cin >> d;
    v.emplace_back(d,1,i);
  }
  sort(v.begin(),v.end());
  vector<int> ans(q,-1);
  multiset<int> mst;
  for(auto&e:v){
    int a,b,c; tie(a,b,c) = e;
    if(b == -1) mst.erase(c);
    else if(b == 0) mst.insert(c);
    else if(!mst.empty()) ans[c] = *mst.begin();
  }
  for(auto&e:ans) cout << e << endl;
  return 0;
}


Measured memory_bytes: 20072
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let mut cur = 0;
    for i in s.iter() {
        if *i == 'E' {
            cur += 1;
        }
    }
    let mut ans = cur;
    for i in 0..n {
        if s[i] == 'E' {
            cur -= 1;
        } else {
            cur += 1;
        }
        ans = std::cmp::min(ans, cur);
    }
    println!("{}", ans);
}


Measured memory_bytes: 3584
#include<iostream>
#include<array>
#include<string>

using namespace std;

int main(){
    string s;
    int length,number=0,ans;
    cin>>s;
    length = static_cast<int>(s.size());
    if(length%2 == 0){
        int i = length/2 - 1;
        int j = length/2;
        while(s[i] == s[j] && s[i] == s[i+1]){
            i--;
            j++;
            number++;
        }
        ans = (length+2*number)/2;
    }else{
        int i = (length-1)/2-1;
        int j = (length-1)/2+1;
        while(s[i] == s[j] && s[i] == s[i+1] && i >= 0){
            i--;
            j++;
            number++;
        }
        ans = (length + 2*number + 1)/2;
    }
//  cout<<number<<endl;
    cout<<ans<<endl;

}

Measured memory_bytes: 512
#include<stdio.h> 
int main(void){
  int n, i;
  scanf("%d", &n);
  long long a[n], A = 1;
  for(i=0; i<n; i++){
    scanf("%lld", &a[i]);
    if(a[i]==0){
      printf("0");
      return 0;
    }
    A*=a[i];
  }
  if((A>0)&&(A<=1000000000000000000)){
    printf("%lld",A);
    }else{
    printf("-1");
  }
  return 0;
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  sort(all(a));
  for(int i=0; i<n-1; i++) {
    if (a[i] == a[i+1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

// EOF



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> S;
    
    ans = S[0] + S[1] + S[2] - 3*'0';
    cout << ans << endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector <int> wa(n + 1, 0);
  vector <bool> ac(n + 1, false);
  REP(i, m) {
	int p;
	string s;
	cin >> p >> s;
	if (s == "AC") {
		ac[p] = true;
	  } else if (!ac[p]) {
		wa[p]++;
	  }
  }
  int acc = 0;
  int pen = 0;
  REP1(i, n) {
	if (ac[i]) {
		acc++;
		pen += wa[i];
	  }
  }
  cout << acc << " " << pen << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n,m,a[10000];
    cin>>n>>m;
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(double(a[i])>=double(sum)/double(4*m)){
            ans++;
        }
    }
    if(ans>=m) cout<<"Yes";
    else cout<<"No";
}


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

int func[7][7] = {
    {7, 8, 9, 0, 1, 2, 3},
    {8, 10, 0, 1, 12, 3, 4},
    {9, 0, 11, 2, 3, 13, 5},
    {0, 1, 2, 3, 4, 5, 6},
    {1, 12, 3, 4, 14, 6, 16},
    {2, 3, 13, 5, 6, 15, 17},
    {3, 4, 5, 6, 16, 17, 18}
};

char buf[256];
int val[256];

int solve(int bit, int x) {
    int idx = 0;
    for(int i=6; i>=0; i--) {
        int f = func[x][i];
        idx = (idx << 1) | (bit >> f & 1);
    }
    return val[idx];
}

int main() {
    while(scanf("%s", buf)) {
        if(buf[0] == '#') break;
        for(int i=0; i<(1<<7); i++) {
            val[i] = buf[i] - '0';
        }

        bool ok = true;
        for(int bit=0; bit<(1<<19); bit++) {
            int vec[7] = {};
            for(int i=0; i<7; i++) {
                vec[i] = solve(bit, i);
            }

            int nbit = 0;
            for(int i=6; i>=0; i--) {
                nbit = (nbit << 1) | vec[i];
            }

            int sec = solve(nbit, 3);
            ok &= (sec == vec[3]);
        }
        printf("%s\n", ok ? "yes" : "no");
    }
    return 0;
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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 MOD 1000000007 //998244353


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

    // solution comes here

    ll N;
    cin >> N;

    vl A(N);
    rep(i, N) cin >> A[i];

    sortup(A);

    rep(i, N) if(i) A[i] += A[i-1];

    ll i=N-2;
    for(    ; i>=0; i--) {
        if(A[i]*2 < A[i+1]-A[i]) break;
    }

    cout << N-1-i << nl;
}


Measured memory_bytes: 1024
#coding:utf-8

n,m = map(int,input().split())
a = input().split()
alist = []
count = 0
ans = "Yes"
for i in a:
    s = int(i)
    count += s
    alist.append(s)

alist.sort(reverse=True)
thres = count / (4 * m)
for i in range(m):
    t = alist[i]
    if t < thres:
        ans = "No"
        break

print(ans)

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

int main(){

    int d,n,ans;

    cin>>d>>n;
    if(n==100)n++;
    if(d==0)cout<<n;
    else if(d==1)cout<<n<<0<<0;
    else if(d==2)cout<<n<<0<<0<<0<<0;
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    vector<LL> rui(N+1);
    rui[0] = 0;
    rep(i,N){
        rui[i+1] = rui[i] + A[i];
        rui[i+1] %= MOD;
    }

    LL ans = 0;

    for(int i = 0;i < N-1;i++){
        LL tmp = A[i] * (rui[N] - rui[i+1]);
        tmp %= MOD;
        tmp += MOD;
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    ans += MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 6360
// https://atcoder.jp/contests/abc065/tasks/abc065_b

#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, o;
  vector<int> a;
  set<int> v;

  cin >> n;

  REP(i, n)
  {
    int ai;
    cin >> ai;
    a.push_back(ai);
  }

  int c = 1;
  while (true)
  {
    if (c == 2)
      break;
    else
    {
      int ns = v.size();
      v.insert(c);
      if (ns == v.size())
        break;
      c = a[c - 1];
    }
  }

  o = c == 2 ? v.size() : -1;

  cout << o << '\n';

  return 0;
}


Measured memory_bytes: 5368
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main() {
  int n, m;
  while (cin >> n >> m) {
    vint a(n), b(n), c(m), d(m);
    REP(i,n) cin >> a[i] >> b[i];
    REP(i,m) cin >> c[i] >> d[i];

    REP(i,n) {
      int result = 1 << 30;
      int pos;
      REP(j,m) {
        int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
        if (dist < result) { result = dist; pos = j; }
      }
      cout << pos + 1 << endl;
    }
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    set<int> s = { 4,6,9,11 };
    int a, b;
    cin >> a >> b;
    cout << ((a == 2 || b == 2 ) ? "No" : (s.count(a) ^ s.count(b) ? "No" : "Yes" )) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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 n;
ll a[100010];

ll solve(int sign) {
    ll ans = 0;
    ll sum = 0;
    rep(i, n) {
        sum += a[i];
        if (sign == 1) {
            if (sum <= 0) {
                ans += 1 - sum;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                ans += 1 + sum;
                sum = -1;
            }
        }
        sign *= -1;
    }
    return ans;
}

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    cout << min(solve(1), solve(-1)) << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		String S = in.next();
		String T = in.next();

		System.out.println(T+S);


	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  double d=0.0;
  int r;
  int a=n;
  if(n>=k) {
  r=n-k+1;
  n=k-1;}
  else {
  	r=0;
  }
  int i=1;
  int h,l=n;
  while(h!=1)
  { 
  if(k % (int)pow(2,i)==0)
    h=k/pow(2,i);

  else h=(k/(int)pow(2,i))+1;
  
   if(h<=l)
   {
   d+=(double)(l-h+1)/pow(2,i);
   l=h-1;
   }
   else
   {
   	l=n;
   }
  // cout<<l<<' '<<h<<' '<<d<<' '<<i<<endl;
   i++;
   
  }
  d+=r;
  d/=a;
     cout << fixed << setprecision(10) << d << endl;
 }
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
int main()
{
    ll n,sum=0,x;
    cin >> n;
    x = n;
    for(;x;x/=10)sum+=(x%10);
    if(n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3596
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 0;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	if(n-1<=m){
		cout<<nCr(n*2-1,n)<<endl;
		return 0;
	}

	int out=0;
	rep(i,m+1){
		int t=nCr(n,i)*nCr(n-1,n-i-1)%MOD;
		(out+=t)%=MOD;
	}
	cout<<out<<endl;
}









Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	if(a+b>c+d) cout<<"Left"<<endl;
	else if(a+b==c+d) cout<<"Balanced"<<endl;
	else cout<<"Right"<<endl;
	return 0;
} 

Measured memory_bytes: 256
/**
 *		author:  zvm
 *		created: 25.09.2020 13:41:56
**/

#include <bits/stdc++.h>

using namespace std ;

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

	string l, r ;
	cin >> l >> r ;
	
	reverse(r.begin(),r.end());
	cout << ( l == r ? "YES" : "NO" ) << endl ;
}


Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

string s[30][30];

int main() {
	int H, W;
	cin >> H >> W;
	int ansx, ansy;
	rep(i, H) rep(j, W) {
		cin >> s[i][j];
		if (s[i][j] == "snuke") {
			ansy = i;
			ansx = j;
		}
	}
	cout << (char)('A' + ansx);
	cout << ansy + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

int check(int div, vector<int> &a, int k);
				
int32_t main() {
	fast_cin();  
	int n, k; cin >> n >> k;
	vector<int> a(n);
	int sum = 0, ans = 1;
	for (int &i : a) {
		cin >> i;
		sum += i;
	}
	for (int i = 1; i * i <= sum; ++i) {
		if (sum % i == 0) {
			ans = max(ans, check(i, a, k));
			ans = max(ans, check(sum / i, a, k));
		}
	}
	cout << ans << endl;
	return 0;
}

int check(int div, vector<int> &a, int k) {
	int total = 0;
	multiset<int> st;
	for (int &i : a) {
		int rem = i % div;
		if (rem > 0) {
			total += div - rem;
			st.insert(rem);
		}
	}
	int used = 0;
	for (int rem : st) {
		used += rem, total -= (div - rem);
		if (used == total and used <= k) return div;
	}
	return 1;
}

Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main() {
    int n, x;

    cin >> n >> x;

    int a[100010];

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

    long long ans = 0;

    ans += max(a[0] - x, 0);
    a[0] = min(x, a[0]);

    for (int i = 0; i < n-1; i++) {
        ans += max(a[i] + a[i+1] - x, 0);
        a[i+1] = min(x - a[i], a[i+1]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 764
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M,X=map(int,input().split())
    A=list(map(int,input().split()))
    print(min(bisect_right(A,X),len(A)-bisect_right(A,X)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)  //*最大公约数*
{
    return (b>0)?gcd(b,a%b):a;
}
int main()
{
    int n,i,j,k;
    cin>>n;
    int s=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                s+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<string, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>>kp(m);
	vector<vector<int>>cond(m);
	rep(i, m) {
		int k;
		cin >> k;
		kp[i].F = k;
		rep(j, k) {
			int c;
			cin >> c;
			c--;
			cond[i].push_back(c);
		}

	}
	rep(i, m) {
		cin >> kp[i].second;
	}
	int answ = 0;
	int i = 0;
	while (i < pow(2, n)) {
		int tmp = i;
		vector<int>temp(n);
		rep(s, n) {
			temp[s] = tmp % 2;
			tmp /= 2;
		}

		bool ans = true;
		rep(j, m) {
			int dif = 0;
			//cout << "a" << endl;
			//cout << j << endl;
			rep(k, kp[j].F) {
				//cout <<"k"<< k << endl;
				dif += temp[cond[j][k]];
			}
			if (dif % 2 != kp[j].S) {
				ans = false;
				break;
			}
		}
		if (ans) {
			answ++;
		}
		i++;

	}
	cout << answ << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a,b,c; cin >> a >> b >> c;
    if(a[a.size()-1]!=b[0]){
        cout << "NO" << endl;
        return 0;
    }
    if(b[b.size()-1]!=c[0]){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
int a[2][450][450];
bool can[2][450][450];
int n, ma, mb;
void solve() {
    cin >> n >> ma >> mb;
    int x, y, z;
    int cur = 0;
    while(n--) {
        //int t1, t2, t3;
        //cin >> t1 >> t2 >> t3;
        cin >> x >> y >> z;

            for (int i = 1; i <= 400; i++) {
                for (int j = 1; j <= 400; j++) {
                    can[cur ^ 1][i][j] = can[cur][i][j];
                    a[cur ^ 1][i][j] = a[cur][i][j];
                }
            }
            for (int i = 1; i <= 400; i++) {
                for (int j = 1; j <= 400; j++) {
                    if(!can[cur][i][j]) continue;
                    //cout << i << " " << j << endl;
                    int tx = x + i;
                    int ty = y + j;
                    //int d = __gcd(tx, ty);
                    //tx /= d; ty /= ty;
                    if(tx > 400 || ty > 400) continue;
                    //cout << n << " " << tx << " " << ty << endl;
                    if(!can[cur ^ 1][tx][ty] || a[cur ^ 1][tx][ty] > z + a[cur][i][j]) {
                        can[cur ^ 1][tx][ty] = 1;
                        a[cur ^ 1][tx][ty] = z + a[cur][i][j];
                    }
                }
            }

            if(!can[cur ^ 1][x][y] || a[cur ^ 1][x][y] > z) {
                can[cur ^ 1][x][y] = 1;
                a[cur ^ 1][x][y] = z;
                //cout << cur << " " << x << " " << y << endl;
            }
            cur ^= 1;
        }

    //cur ^= 1;
    bool f = 0;
    int res = 400000;
    //cout << cur << " " << ma << " " << mb << endl;
    for (int i = 1; ma * i <= 400 && mb * i <= 400; i++) {
        int x = i *ma, y = i * mb;
        if(can[cur][x][y]) {
            f = 1;
            res = min(res, a[cur][x][y]);
        }
    }
    //if(can[ma][mb]) cout << a[ma][mb] << endl;
    //else cout << -1 << endl;
    if(f) cout << res << endl;
    else cout << -1 << endl;
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 2048
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    ll a,k; cin>>a>>k;
    vec<vec<ll>> l(k, vec<ll>());
    for(int q=0; q<a; q++){
        ll x,y; cin>>x>>y;
        if(x>k) continue;
        l[x-1].pb(y);
    }
    multiset<ll> s;
    ll o = 0;
    for(int q=0; q<k; q++){
        for(ll i : l[q]) s.insert(i);
        if(s.size()) o+=*prev(s.end()), s.erase(prev(s.end()));
    }
    cout<<o;
}

Measured memory_bytes: 8320
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool no=false;
    sort(s.begin(),s.end());
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!='a'+i){
            no=true;
            break;
        }
    }
    if(no)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int A, B, C, D;
  rd(A);
  rd(B);
  rd(C);
  rd(D);
  A += B;
  C += D;
  if(A>C){
    wt_L("Left");
    wt_L('\n');
  }
  else if(A<C){
    wt_L("Right");
    wt_L('\n');
  }
  else{
    wt_L("Balanced");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190630-1

// --- original code ---
// {
//   int A, B, C, D;
//   rd(A,B,C,D);
//   A += B;
//   C += D;
//   wt( if[A>C, "Left", A<C, "Right", "Balanced"] );
// }


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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i <= _##i poi i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i < _##i poi i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i >= _##i poi i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i > _##i poi i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

using namespace std;

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

template<class T> T gcd(T a, T b){
    if(b) return gcd(b, a % b) poi
    else return a poi
}

int main(){
    int n, pyon = 100000 poi
    cin >> n poi
    times(n, i){
        pyon *= 1.05 poi
        pyon = fuwafuwa(pyon, 1000) poi
    }
    cout << pyon poipoi poi
    return 0 poi
}

Measured memory_bytes: 1160
/*
selectSort(A, N)
    for i from 0 to N - 2
        minIndex = i
        j = i + 1
        while j < N
            if (A[j] < A[minIndex])
                minIndex = j
            ++j
        if i != minIndex
            A[i] 和 A[minIndex] 互换
      ++i
*/
#include <iostream>
using namespace std;

void swap(int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void selectSort(int A[], int N, int &count) {
    for(int i = 0 ; i < N; ++i) {
        int minIndex = i;
        int j = i;
        while (j < N) {
            if (A[j] < A[minIndex])
                minIndex = j;
            ++j;
        }
        
        if (i != minIndex) {
            swap(A[i], A[minIndex]);
            count += 1;
        }
    }
}

int main() {
    int N = 0;
    int A[100];
    int count = 0;
    cin >> N;
    for(int i = 0; i < N; ++i) {cin >> A[i];}
    selectSort(A, N, count);
    for(int i = 0; i < N; ++i) {
        if (i > 0)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C082
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] a0 = Console.ReadLine().Split(' ');
            List<int> a1 = a0.Select(x => int.Parse(x)).ToList();
            var a = a1.ToLookup(x => x).ToDictionary(x => x.Key,x=>x.Count());

            long counter = 0;
            foreach(var p in a)
            {
                if (p.Key < p.Value)
                {
                    counter += p.Value - p.Key;
                }
                else if(p.Key>p.Value)
                {
                    counter += p.Value;
                }
            }
            Console.WriteLine(counter);
        }

    }
}


Measured memory_bytes: 34652
#include<cstdio>
#define re register
#define int long long
using namespace std;
int n,a,b,c,d;
inline int gcd(re int x,re int y){
	return x%y?gcd(y,x%y):y;
}
signed main(){
	scanf("%lld%lld",&a,&b);
printf("%lld",a*b/gcd(a,b));
}

Measured memory_bytes: 128
#include<iostream>
#include<set>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<stdlib.h>
#include<stdio.h>
#include<queue>
#include<stack>
#include<string.h>
#include<limits.h>
using namespace std;
typedef long long ull;

int main(){
    int a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]+a[1]==a[2]){
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define LEN 100005

using namespace std;

typedef struct pp{
  string name;
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;

}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
  
}

int main()
{
  int elaps = 0;
  int c, q;
  P u;

  cin >> n >> q;

  for(int i = 1; i <= n ; i++){
    cin >> Q[i].name >> Q[i].t;
  }

  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = q < u.t ? q : u.t;
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);

    else cout << u.name << " " << elaps << endl;
      
  }

  return 0;

}



Measured memory_bytes: 6920
import math
a,b,x=map(int,input().split())

h=x/a/a
A=h*a

if A<=b*a/2:
    L=A/b*2
    ans=math.degrees(math.atan(b/L))
else:
    L=A*2/a-b
    ans=math.degrees(math.atan((b-L)/a))

print(ans)


Measured memory_bytes: 9324
#!/usr/bin/ruby
# coding: utf-8

ok = false

while true
  line = gets
  if line == nil
    break
  end
  id, kg, m = line.chomp.split(',')
  kg = kg.to_f
  m = m.to_f
  bmi = kg/m/m
  if bmi >= 25.0
    ok = true
    puts id
  end
end

if not ok
  puts "該当なし"
end

Measured memory_bytes: 6100
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
//#define double long double
using namespace std; const int N=2000010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int X,n,a[N],book[N];
signed main()
{
    X=read()+100, n=read();
    for(ri int i=1;i<=n;i++) a[i]=read()+100, book[a[i]]=1;
    int mi=1e9, g=0;
    for(ri int i=0;i<=300;i++)
    {
        if(book[i]) continue;
        if(abs(i-X)<mi) mi=abs(i-X), g=i;
    }
    printf("%lld\n",g-100);
    return 0;
}

Measured memory_bytes: 3744
def main():
    N, K = map(int, input().split())
    MOD = 998244353
    L = [0] * K
    R = [0] * K
    for i in range(K):
        L[i], R[i] = map(int, input().split())

    
    dp = [0] * (N + 1)
    dpsum = [0] * (N + 1)
    dp[1] = 1
    dpsum[1] = 1
    for i in range(2,N+1):
        for j in range(K):
            l = i - R[j]
            r = i - L[j]
            if r <= 0:
                continue
            l = max(1,l)
            dp[i] += dpsum[r] - dpsum[l-1]
            dp[i] %= MOD
        dpsum[i] = dpsum[i-1] + dp[i]
        dpsum[i] %= MOD

    print(dp[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 77024
#include <bits/stdc++.h>
#define ll long long
const long double PI=acos(-1);
using namespace std;
void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}
bool p(int a,int b)
{
    return a>b;
}
int modpow(int a,int b,int c)
{
    if(b==0)
        return 1%c;
    int u = modpow(a,b/2,c);
    u=(u*u)%c;
    if(b&1)
        u=(u*a)%c;
    return u;
}
bool cmp(const pair<ll,ll>&q,const pair<ll,ll>&f)
{
    return q.second>f.second;
}
ll prime(ll x)
{
    if(x<2)
    {
        return false;
    }
    else
    {
        for(int i=2;i*i<=x;i++)
        {
            if(x%i==0)
            {
                return false;
            }
        }
        return true;
    }
}

int main() {
    fast();
    ll x,z=0;
    cin>>x;
    for(int i=1;i<=x-1;i++)
    {
       z+=x/i-(x%i==0);
    }
    cout<<z<<endl;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main(){
    long long  x ;
    long long  m = 100.0;
    long long  y = 0;
    cin >> x;


    while(m < x){
        m = m * 1.01;
       // m += m / 100;
        y++;
    }
    cout << y << endl;

    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = a+b;
    int d = a-b;
    int e = a*b;
    if (c >= d &&  c >= e){
      System.out.println(c);
    }
    else if (d >= c &&  d >= e){
      System.out.println(d);   
    }
    else if (e >= d &&  e >= c){
      System.out.println(e);  
    }
  }
}
      


Measured memory_bytes: 23892
#include <cstdio>

const float kProbability = 1.0f / 6.0f;
const int kMaxSquare = 128;
const int kMaxTurn = 128;

enum BoardState{
	BLANK, LOSE, BACK
};

BoardState board[kMaxSquare];

float bp(const int N, const int T){
	float prob[kMaxTurn][kMaxSquare];
	for (int i = 0; i <= T; i++)
		for (int j = 0; j <= N; j++)
			prob[i][j] = 0.0f;
	prob[0][0] = 1.0f;

	for (int t = 0; t < T; t++){
		for (int n = 0; n < N; n++){
			if (prob[t][n] == 0.0f) continue;
			for (int dice = 1; dice <= 6; dice++){
				int pos = (n + dice <= N) ? n + dice : N - (n + dice - N);
				switch (board[pos]){
				case BLANK:
					prob[t + 1][pos] += prob[t][n] * kProbability;
					break;
				case LOSE:
					prob[t + 2][pos] += prob[t][n] * kProbability;
					break;
				case BACK:
					prob[t + 1][0] += prob[t][n] * kProbability;
				}
			}
		}
	}

	float res = 0.0f;
	for (int i = 1; i <= T; i++)
		res += prob[i][N];
	return res;
}

int main(){
	while (1){
		int N, T, L, B;
		scanf("%d %d %d %d", &N, &T, &L, &B);
		if (N == 0) return 0;
		for (int i = 0; i <= N; i++) 
			board[i] = BLANK;
		for (; L > 0; L--){
			int l;
			scanf("%d", &l);
			board[l] = LOSE;
		}
		for (; B > 0; B--){
			int b;
			scanf("%d", &b);
			board[b] = BACK;
		}
		printf("%.6f\n", bp(N, T));
	}
}

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

int main(void){
    int n,s,min_s=100,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        ans += s;
        if(s%10!=0) min_s = min(min_s,s);
    }
    if(ans%10==0) ans -= min_s;
    if(min_s==100) ans = 0;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n&1)
    {
        cout << 0 << endl;
        return 0;
    }
    n>>=1;
    ll ans = 0;
    while(n)
    {
        ans += (n/5);
        n /= 5;
    }
    cout << ans << endl;
}


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

int main()
{
  uint64_t a, b;
  cin >> a >> b;

  uint64_t x[] {a * 1 + 0,
                a * 0 + 1,
                a * 1 + 1,
                a * 0 + 0};

  uint64_t y[] {b * 1 + 0,
                b * 0 + 1,
                b * 1 + 1,
                b * 0 + 0};

  cout << (a xor x[a % 4] xor y[b % 4]) << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:
#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " ",err(++it, args...);
}


const int wlimit = 20000;
ll dp[1010][wlimit + 10];

int main(void){
	int n;
	cin >> n;
	using state = tuple<int,int,int>;
	vector<state> ary;
	rep(i,n){
		int w,s,v;
		cin >> w >> s >> v;
		ary.push_back(state(s + w,w,v));
	}
	sort(begin(ary),end(ary));

	rep(i,n){
		int s,w,v;
		tie(s,w,v) = ary[i];
		rep(j,wlimit+1){
			chmax(dp[i + 1][j], dp[i][j]);
			if(j + w > s) continue;
			chmax(dp[i + 1][j + w], dp[i][j] + v);
		}
	}

	ll ans = 0LL;
	rep(j,wlimit+1) chmax(ans, dp[n][j]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 156928