akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: i64);
    puts!("{}\n", (1000 - n % 1000) % 1000);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2196
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;



template<typename T,typename F>
struct DynamicSegmentTree{
  using ll=long long;
  struct node{
    node *lch,*rch;
    T val;
    node(T ti):lch(nullptr),rch(nullptr),val(ti){};
  };
  ll sz;
  F f;
  T ti;
  node* root;
  DynamicSegmentTree(ll n,F f,T ti):f(f),ti(ti){
    sz=1;
    while(sz<n)sz<<=1;
    root=new node(ti);
  }
  ~DynamicSegmentTree() {
    delete root; root = nullptr;
  }


  T query(ll a,ll b,node* n,ll l,ll r){
    if(a<=l&&r<=b)return n->val;
    if(r<=a||b<=l)return ti;
    T lv=ti,rv=ti;
    if(n->lch)lv=query(a,b,n->lch,l,(l+r)/2);
    if(n->rch)rv=query(a,b,n->rch,(l+r)/2,r);
    return f(lv,rv);
  }
  T query(ll a,ll b){
    return query(a,b,root,0,sz);
  }

  T update(ll i,T x,node* n,ll l,ll r){
    if(r-l==1)return n->val=x;
    ll m=(l+r)/2;
    T lv=ti,rv=ti;
    if(i<m){
      if(!n->lch)n->lch=new node(ti);
      if(n->rch)rv=n->rch->val;
      lv=update(i,x,n->lch,l,m);
    }
    else{
      if(n->lch)lv=n->lch->val;
      if(!n->rch)n->rch=new node(ti);
      rv=update(i,x,n->rch,m,r);
    }
    return n->val=f(lv,rv);
  }
  T update(ll i,T x){
    return update(i,x,root,0,sz);
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<pair<ll,ll>>xl(n);
  rep(i,n){
    cin>>xl[i].first>>xl[i].second;
    xl[i].first-=xl[i].second;
    xl[i].second*=2;
  }

  sort(all(xl));
  //rep(i,n)xl[i].first-=xl[i].second;
  rep(i,n-1){
    xl[i+1].first-=xl[0].first;
  }
  xl[0].first=0;

  auto ma=[](ll a,ll b){return max(a,b);};
  DynamicSegmentTree<ll,decltype(ma)>st(1e10,ma,0);
  st.update(0,0);
  rep(i,n){
    //cout<<xl[i].first<<" "<<xl[i].second<<endl;
    st.update(xl[i].first+xl[i].second,st.query(0,xl[i].first+1)+1);
  }
  cout<<st.query(0,1e10)<<endl;

  return 0;

}


Measured memory_bytes: 49152
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define pb push_back
/////

int const N = 2e5 + 41;
int const MOD = 1e9 + 7;
int const INF = 1e9 + 41;

void add(int &a, int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int mul(int a, int b){
	return a * 1LL * b % MOD;
}

int bp(int x, int d){
	if(!d) return 1;
	if(d&1) return mul(x, bp(x, d-1));
	int r = bp(x, d/2);
	return mul(r, r);
}

int f[N], invF[N];
int n, x, y;
vector<int> a[N];
vector<int> b;
int cur[N];

bool comp(int i, int j){
	if(sz(a[i]) == 0 && sz(a[j]) == 0) return i < j;
	if(sz(a[i]) == 0) return false;
	if(sz(a[j]) == 0) return true;
	return a[i][0] < a[j][0];
}

int calc(int id, int val, int maxi){
	int l = -1;
	int r = sz(a[id]);
	while(r-l>1){
		int m = (l+r)/2;
		if(a[id][m] + val <= maxi) l = m;
		else r = m;
	}
	return l;
}

void solve(){
	f[0] = invF[0] = 1;
	fi(1, N){
		f[i] = mul(f[i-1], i);
		invF[i] = bp(f[i], MOD-2);
	}

	scanf("%d %d %d",&n,&x,&y);
	fi(0, n){
		int ci, wi;
		scanf("%d %d",&ci,&wi);
		--ci;
		a[ci].pb(wi);
	}
	fi(0, n) sort(a[i].begin(), a[i].end());
	fi(0, n) b.pb(i);
	sort(b.begin(), b.end(), comp);

	int ans = 1;
	int mini = INF;
	fi(1, n){
		if(sz(a[b[i]])) mini = min(mini, a[b[i]][0]);
	}
	int sum = 0;
	fi(0, n){
		if(sz(a[b[i]]) == 0) continue;
		cur[i] = calc(b[i], mini, y);
		if(cur[i] == -1) continue;
		cur[i] = max(cur[i], calc(b[i], a[b[i]][0], x));
		sum += cur[i] + 1;
		mini = min(mini, a[b[i]][0]);
	}
	ans = f[sum];
	fi(0, n) ans = mul(ans, invF[cur[i]+1]);
	printf("%d\n",ans);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 12280
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long 
int main()
{
	 unsigned long long n;
	 cin>>n;
	 for (ull x=1;x<=3500;x++)
	   for (ull y=x;y<=3500;y++)
	   {
	   	  if ((ull)4*x*y-n*x-n*y>0)
	   	  {
	   	  	if ((ull)x*y*n%(4*x*y-n*x-n*y)==0 )    {
	   	  	  cout<<x<<" "<<y<<" "<<(ull)x*y*n/(4*x*y-n*x-n*y) <<endl;
	   	  	  return 0;
			 }
	   }    }
	   return 0;
 } 

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

int main() {
  long long x, a, b;
  cin >> x >> a >> b;
  cout << (-a + b <= 0 ? "delicious" : -a + b <= x ? "safe" : "dangerous") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>

using llint = long long int;
using namespace std;

namespace CsF {
#define MIN_INT -2147483648
#define MAX_INT 2147483647

#define nfor(I,J,K) for(int I = 0;I < J;I+=K)


	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}

	int GCD(int a, int b) {
		if (a < b)swap(a, b);
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	int LCM(int a, int b) {
		int n = a * b;
		return (n / GCD(a, b));
	}

	int Count(string s, char c) {
		int cou = 0;
		nfor(i, s.length(), 1) {
			if (s[i] == c)cou++;
		}
		return cou;
	}
}

using namespace CsF;


int main() {
	int a, b;
	cin >> a >> b;
	cout << ((a-1)*(b-1)) << endl;
	return 0;
}



Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A = sc.nextInt
  val B = sc.nextInt
  val K = sc.nextInt
  val result = (List(A, B).min to 1 by -1).filter(x => A % x == 0 && B % x == 0)(K - 1)
  println(result)
}

Measured memory_bytes: 25756
using System;

class A4{
  public static void Main(){
    int n,q;
    n = int.Parse(Console.ReadLine());
    string[] S = new string[n];
    string[] str = Console.ReadLine().Split(' ');

    for(int i = 0;i < n;i++){
      S[i] = str[i];
    }

    q = int.Parse(Console.ReadLine());
    string[] T = new string[q];
    string[] str2 = Console.ReadLine().Split(' ');

    for(int i = 0;i < q;i++){
      T[i] = str2[i];
    }

    Console.WriteLine(Serach(S,T));

  }

  static int Serach(string[] S,string[] T){
    int count = 0,l = 0;
    bool flag = false;
    string[] memory = new string[S.Length];

    for(int i = 0;i < T.Length;i++){
      if(flag == true) l++;
      flag = false;
      for(int j = 0;j < S.Length;j++){
        if(flag == true && memory[l].CompareTo(S[j]) == 0){
          continue;
        }
        else if(S[j].CompareTo(T[i]) == 0){
          memory[l] = T[i];
          flag = true;
          count++;
          }
      }
    }
    return count;
  }
}


Measured memory_bytes: 10444
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut ans = aa[0]/2;
    let mut rem = aa[0]%2;
    for i in 1..n {
        let mut a = aa[i];
        if rem > 0 && a > 0 {
            ans += 1;
            a -= 1;
        }
        ans += a/2;
        rem = a%2;
    }
    println!("{}", ans);
}


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

using namespace std;
const int mod = 1e9 + 7;
int x, y;
long long ans, f[1000001];
int binpow(int a, int b){
    if(b == 0){
        return 1;
    }
    if(b % 2 == 0){
        int c = binpow(a, b / 2);
        return (c * 1ll * c) % mod;
    }
    else{
        return (binpow(a, b - 1) * 1ll * a) % mod;
    }
}
int get(int n, int k){
    long long ans = f[n];
    return (f[n] * 1ll * ((binpow(f[k], mod - 2) * 1ll * binpow(f[n - k], mod - 2)) % mod)) % mod;
}
int main(){
    cin >> x >> y;
    f[0] = 1;
    for(int i = 1; i <= 1e6; i++){
        f[i] = (f[i - 1] * 1ll * i) % mod;
    }
    for(int i = 0; i <= x; i++){
        if((x - i) % 2 == 0 && (x - i) / 2 == (y - i * 2)){
            int kol = (x - i) / 2 + i;
            (ans += get(kol, i)) %= mod;
        }
    }
    cout << ans;
}


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

ll H,W,K;
char bd[1000][1000];
ll pat[1000][1000];

int main(){
  cin >> H >> W >> K;
  
  memset(pat,0,sizeof(pat));
  
  ll index = 1;
  
  bool flag3 = true;
  
  vector<int> a;
  
  rep(i,H){
    flag3 = true;
    rep(j,W){
      cin >> bd[i][j];
      if(bd[i][j] == '#'){
        pat[i][j] = index;
        index++;
        flag3 = false;
      }
    }
    if(flag3){
      a.PB(i);
    }
  }
      
  
  index = 1;
  bool flag,flag2 = false;
  
  
  rep(i,H){
    flag = false;
    rep(j,W){
      if(bd[i][j] == '.'){
        pat[i][j] = index;
      }else{
        if(flag)index++;
        flag = true;
      }
    }
    
    if(!flag){   //一行に#が１つもなかった
      if(i != 0){
      	rep(j,W){
 		   pat[i][j] = pat[i-1][j];   
      	}
      }else{
		flag2 = true;  //先頭変更しなきゃ
      }
    
      
    }
    
    if(flag) index++;
    
    
  }
  
  if(flag2){
    //cout << 'H' <<endl;
	for(int i = a.size() - 1;i >= 0;i--){
      //cout << 'H' << endl; 
      if(a[i] != H-1){
      rep(j,W){
        
          pat[a[i]][j] = pat[a[i]+1][j];
        
      }
      }
    }
  }
  

  rep(i,H){
    rep(j,W){
    cout << pat[i][j] << ' ';
    }cout << endl;
  }
  
  //rep(i,a.size())cout << a[i] << endl;

  
    
  
  
}
  
  

Measured memory_bytes: 8960
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,m[MAX][MAX];
int color[MAX],d[MAX],f[MAX],t;

void dfscnt(int u)
{
  int v;
  color[u]=GRAY;
  d[u]=++t;
  for(v=0;v<n;v++){
    if(m[u][v]==0)continue;
    if(color[v]==WHITE){
      dfscnt(v);
    }
  }
  color[u]=BLACK;
  f[u]=++t;
}


void dfs()
{
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  t=0;
  for(u=0;u<n;u++){
    if(color[u]==WHITE) dfscnt(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
int main()
{
  int i,j,u,v,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      m[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      m[u][v]=1;
    }
  }
  dfs();

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll a,b,k;
    cin>>a>>b>>k;

    rep(i,k){
        if(i%2==0){
            if(a%2==1)a--;
            a=a/2;
            b+=a;
        }else{
            if(b%2==1)b--;
            b=b/2;
            a+=b;
        }
    }
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    int n; 
    cin >> n;
    string s; 
    cin >> s;
    int oc = 0, cc = 0; 
    for (char c : s) {
        if (c == '(') {
            ++oc;
        } else {
            if (oc > 0) --oc;
            else ++cc;
        }
    } 
    string head(cc, '(');
    s = head + s;
    oc = 0; cc = 0; 
    per(i, s.size()) {
        char c = s[i];
        if (c == ')') {
            ++oc;
        } else {
            if (oc > 0) --oc;
            else ++cc;
        }
    } 
    string tail(cc,')');
    s += tail;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int f(char a)
{
    if(a=='A'||a=='T'||a=='C'||a=='G')
        return 1;
    else
        return 0;
}
int main()
{
    char a[10];
    cin>>a;
    int sum=0;
    for(int i=0;i<strlen(a);i++)
    {
        int j=i;
        while(f(a[j])&&j<strlen(a))
        {
            j++;
        }
        sum=j-i>sum?j-i:sum;
    }
    printf("%d",sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define X first
#define Y second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=998244353;
const ll MAXN=2e5+5;
const ll inf=1e17;

int main()
{
    fastio;
    ll n,k;
    cin>>n>>k;
    vector<ll >h(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>h[i]; sum+=h[i];
    }
    sort(h.begin(),h.end(),greater<int >());
    for(int i=0;i<k && i<n;i++) sum-=h[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n; string s, t;
	cin >> n >> s >> t;
	ll dp[52] = {};
	int i = 1;
	if (s[0] == t[0])dp[0] = (ll)3;
	else {
		dp[0] = (ll)6; i = 2;
	}
	while (i < n) {
		if (s[i] == t[i] && s[i - 1] == t[i - 1]) {
			dp[i] = (dp[i - 1] * (ll)2)%MOD;
		}
		else if (s[i] != t[i] && s[i - 1] == t[i - 1]) {
			dp[i] = (dp[i - 1] * (ll)2) % MOD; i++;
		}
		else if (s[i] != t[i] && s[i - 1] != t[i - 1]) {
			dp[i] = (dp[i - 2] * (ll)3) % MOD; i++;
		}
		else dp[i] = dp[i - 2];
		i++;
	}
	if (dp[n - 1] == 0)dp[n - 1] = dp[n - 2];
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 764
def main():
  import bisect
  n=int(input())
  a=list(map(int,input().split()))
  b=[a[i]+i+1 for i in range(n)]
  c=[i+1-a[i] for i in range(n)]
  b.sort()
  c.sort()
  ans=0
  for i in b:
    x=bisect.bisect_left(c,i)
    y=bisect.bisect_right(c,i)
    z=y-x
    ans+=z
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 117880
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def E(x):
    return (x*(x+1)//2)/x
def main():
    N, K = map(int, readline().split())
    e = [E(int(i)) for i in readline().split()]
    s = [0.]
    for i in range(N):
        s.append(s[i]+e[i])
    ans = 0.
    for i in range(N-K+1):
        ans = max(s[K+i]-s[i], ans)
    print('{:.12f}'.format(ans))
if __name__ == '__main__':
    main()


Measured memory_bytes: 19564
s = list(input())
MMYY = False
YYMM = False
for x in range(1,13):
    MMYY = MMYY or (x == int(''.join(s[:2])))
    YYMM = YYMM or (x == int(''.join(s[2:])))
if MMYY and YYMM:
    ans = 'AMBIGUOUS'
elif(YYMM):
    ans = 'YYMM'
elif(MMYY):
    ans = 'MMYY'
else:
    ans = 'NA'

print(ans)

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

int main() {

	int n; cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int b = 1; b <= n - 2; b++) {
		int lb = l[b];
		for (int a = 0; a < b; a++) {
			int la = l[a];
			for (int c = b + 1; c < n; c++) {
				int lc = l[c];
				if (lc < la + lb) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<string> s(2);
  rep(i, 2) cin >> s[i];

  vector<bool> c;
  rep(i, n) {
    if (s[0][i] == s[1][i]) c.push_back(false);
    else {
      c.push_back(true);
      i++;
    }
  }

  int m = c.size();
  bool res = c[0];
  ll ans = 3;
  if (c[0]) ans *= 2;
  FOR(i, 1, m) {
    if (res) {
      if (c[i]) ans = (ans * 3) % mod;
    }
    else ans = (ans * 2) % mod;
    res = c[i];
  }
  cout << ans << endl;






  
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ok_step = [1] * (n+1)
for i in range(m):
    ok_step[int(input())] = 0
dp = [0] * (n+1)
dp[0] = 1
for now_s in range(n+1):
    for next_s in range(now_s+1, min(n+1, now_s+3)):
        if ok_step[next_s]:
            dp[next_s] += dp[now_s]
            dp[next_s] %= 1000000007
print(dp[n])

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

int main(){
    int a, b;
    char op;
    while(cin >> a >> op >> b){
        if(op == '+') 
            cout<< a+b << endl;
        if(op == '-')
            cout<< a-b << endl; 
        if(op == '*')
            cout<< a*b << endl;
        if(op == '/')
            cout<< a/b << endl;
        if(op == '?')
            break;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++){
  cin >> vec.at(i);
  }
  int sum;
  for (int i = 0; i < n; i++){
  sum += vec.at(i);
  }
  vector <int> sum1(n);
  for (int i = 0; i < n; i++){
   for (int j = 0; j < i; j++){
   sum1.at(i) += vec.at(j);
   }
  }
  vector <int> sum2(n);
  for (int i = 0; i < n; i++){
  sum2.at(i) = abs(2*sum1.at(i) - sum);
  }
  sort(sum2.begin(),sum2.end());
  cout << sum2.at(0);
}

Measured memory_bytes: 256
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
ans = T[0]
for i in range(1,N):
  ans = ans*T[i]//gcd(ans,T[i])
print(ans)

Measured memory_bytes: 3060
S = input()
N = len(S)

Srev = "".join(list(reversed(S)))

if S != Srev:
  print('No')
  exit()

S1 = S[:(N-1)//2]
S1rev = "".join(list(reversed(S1)))
if S1 != S1rev:
  print('No')
  exit()

S2 = S[(N+3)//2 - 1:N]
S2rev = "".join(list(reversed(S2)))

if S2 != S2rev:
  print('No')
  exit()

print('Yes')

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int n;
vii yakusuu;
ll cnt = 0;
ll br(int i0, vector<bool> used, vl a) {
	for (int i = i0 + 1; i <= n/2; i++) {
		if (a[i] >= 0) {
			continue;
		}
		bool flag = false;
		for (int j = 0; j < yakusuu[i].size(); j++) {
			if (used[yakusuu[i][j]]) {
				flag = true;
				break;
			}
		}
		if (!flag) {
			ll ans1 = br(i, used, a);
			used[i] = true;
			for (int j = 1; i*j <= n; j++) {
				a[i*j] = 0;
			}
			ll ans2 = br(i, used, a);
			return max(ans1, ans2);
		}
	}
	ll res = 0;
	for (int j = 1; j <= n; j++) {
		res += a[j];
	}
	return res;
}

int main() {
	int i, j;
	cin >> n;
	yakusuu.resize(n + 1);
	vl a(n + 1);
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		if (i >= n / 2 + 1) {
			a[i] = max(0LL, a[i]);
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 2; j <= i; j++) {
			if (i%j == 0) {
				yakusuu[i].push_back(j);
			}
		}
	}
	vector<bool> used(n + 1, false);
	ll ans = 0;
	for (i = 2; i <= n; i++) {
		ll ans1 = 0, ans2 = 0;
		if (a[i] < 0) {
			ll ans1 = br(i, used, a);
			used[i] = true;
			for (j = 1; i*j <= n; j++) {
				a[i*j] = 0;
			}
			ll ans2 = br(i, used, a);
			ans = max(ans1, ans2);
			break;
		}
	}
	ll sum = 0;
	for (i = 1; i <= n; i++) {
		sum += a[i];
	}
	ans = max(ans, sum);
	ans = max(ans, 0LL);
	cout << ans << endl;
	/*
	vll b;
	vl s;
	s.push_back(sum);
	b.push_back(a);
	for (i = n / 2; i > 0; i--) {
		for (int k = 0; k < b.size(); k++) {
			if (b[k][i] < 0) {
				ll get = 0;
				for (j = 1; i*j <= n; j++) {
					get -= b[k][i*j];
				}
				if (get >= 0) {
					for (j = 1; i*j <= n; j++) {
						b[k][i*j] = 0;
					}
					s[k] += get;
				}
				else if (get == 0) {
					b.push_back(b[k]);
					s.push_back(s[k]);
					for (j = 1; i*j <= n; j++) {
						b[k][i*j] = 0;
					}
					s[k] += get;
				}
			}
		}
	}
	*/
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,y;
    char op;
    while(1){
        cin >> a >> op >> b;
        switch (op){
        case '+':
            y=a+b;
            break;
        case '-':
            y=a-b;
            break;
        case '*':
            y=a*b;
            break;
        case '/':
            y=a/b;
            break;
        default:
            return 0;
        }
        cout << y << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;++i){
        for(ll j=1;j<=n/i;++j)sum=sum+i*j;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll W,H;
    ll p[100010], q[100010];
    cin >> W >> H;
    rep(i,0,W){
        cin >> p[i];
    }
    rep(i,0,H){
        cin >> q[i];
    }
    ll ans = 0;
    ll check_x = 0, check_y = 0;
    vector<lpair> v;
    rep(i,0,W){
        v.push_back(make_pair(p[i],0));
    }
    rep(i,0,H){
        v.push_back(make_pair(q[i],1));
    }
    sort(v.begin(), v.end());
    rep(i,0,H+W){
        ll val = v[i].first;
        if(v[i].second == 0){
            ans += val * (H+1-check_y);
            check_x++;
        }else{
            ans += val * (W+1-check_x);
            check_y++;
        }
    }
    print(ans);
}


Measured memory_bytes: 8048
#include <iostream>

using namespace std;

bool ismonth(char *s) {
  bool b;
  
  if (s[0] == '1') {
    if (s[1] - '0' <= 2) return true;
    return false;
  } else if (s[0] == '0' && s[1] != '0') {
    return true;
  } else {
    return false;
  }
  return false;
}

int main(void) {
  char s[5];
  bool fm, lm;
  
  cin >> s;
  
  fm = ismonth(s);
  lm = ismonth(&s[2]);
  
  if (fm && lm) {
    cout << "AMBIGUOUS" << endl;
  } else if (fm) {
    cout << "MMYY" << endl;
  } else if (lm) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

"""
https://atcoder.jp/contests/agc029/tasks/agc029_a
"""

import sys
import re


s = sys.stdin.readline().rstrip()
e = 0
n = 0

for chr in s:
    if chr == 'W':
        e += n

    if chr == 'B':
        n += 1

print(e)


Measured memory_bytes: 3752
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

signed main(){
    int N;
    cin>>N;
    ll A[110000],sum=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        sum+=A[i];
    } 
    ll x=(ll)(N+1)*N/2;

    if(sum%x!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    ll a=sum/x;
    ll count=0;
    bool flag=true;
    for(int i=0;i<N;i++){
        ll t=A[(i+1)%N]-A[i];
        t-=a;
        if(t>0 || (-1*t)%N!=0){
            flag=false;
        }else count+=(-1*t)/N;
    }
    if(flag && count==a) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


Measured memory_bytes: 1024
# AOJ 0507: Square
# Python3 2018.6.29 bal4u

a = [0]*31
def rec(k, n, m):
	if n <= 0:
		print(*a[:k])
		return
	if n < m: m = n
	for i in range(m, 0, -1):
		a[k] = i
		rec(k+1, n-i, i)

while True:
	n = int(input())
	if n == 0: break
	rec(0, n, n)


Measured memory_bytes: 6304
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(){
  int x;cin >> x;
  if (x < 100){
    cout << 0 << endl;
    return 0;
  }
  
  int amari = x%100;
  int sho = x/100;

  if (amari == 0){
    cout << 1 << endl;
    return 0;
  }
  
  for (int a = 0; a <= sho; a++){
    for (int b = 0; b <= sho; b++){
      for (int c = 0; c <= sho; c++){
        for (int d = 0; d <= sho; d++){
          for (int e = 0; e <= sho; e++){
            for (int f = 0; f <= sho; f++){
                if (100*a + 101*b + 102*c + 103*d + 104*e + 105*f == x){
                  cout << 1 << endl;
                  return 0;
                }
            }
          }
        }
      }
    }
  }

  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	ll A, B, N;
	cin >> A >> B >> N;
	ll ans = 0;
	ll tmp = B;
	ll x = tmp;

	tmp = min(B - 1, N);
	ans = (A*tmp) / B - A * (tmp / B);
	ans = max(ans, (A*N) / B - A * (N / B));

	tmp = N - (N%B + 1);
	ans = max(ans, (A*tmp) / B - A * (tmp / B));


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

Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 6;
const int inf = 0x7fffffff;
int a[maxn], dp[maxn];
int n, ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    fill(dp, dp + n, inf);
    for (int i = 0; i < n; i++) {
        *lower_bound(dp, dp + n, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp + n, inf) - dp << endl;
    return 0;
}


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

#define REP(i, n) for(int i=0; i<n; i++)
#define REPA(i, a, n) for(int i=a; i<n; i++)
#define REPE(i, a, n) for(int i=a; i<=n; i++)
#define SetArray(a, n) for(int array_i=0; array_i<n; array_i++) cin >> a[array_i]
#define print(x) cout << x
#define printw(x) cout << x << " "
#define println(x) cout << x << endl
#define printl() cout << endl
#define sqr(x) (x)*(x)
#define cube(x) (x)*(x)*(x)
typedef long long ll;
typedef unsigned int uint;
typedef vector<int> vi;

int main(){
    int x, y;
    cin >> x >> y;

    if(y >= 2*x && y <= 4*x){
        if(y%2 == 0){
            println("Yes");
            return 0;
        }
    }

    println("No");
    return 0;
}




Measured memory_bytes: 3608
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;

xy_t P[110];

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

int main() {
  int N = 0;
  double x, y;
  while (~scanf("%lf, %lf", &x, &y)) {
    P[N++] = xy_t(x, y);
  }

  double sum = 0.0;
  for (int i=0; i+2<N; i++) {
    xy_t a = P[0], b = P[i+1], c = P[i+2];
    sum += cross_product(b-a, c-a)/2;
  }

  printf("%.6f\n", abs(sum));
}


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

const int MOD = (int) 1e9 + 7;
const int N = 9e5 + 7;
long long fact[N], invfact[N];

long long power(long long a, long long n) {
    long long res = 1;
    while (n != 0) {
        if (n % 2 != 0) res = res * a % MOD;
        a = a * a % MOD;
        n /= 2;
    }
    return res;
}

long long inverse(int a) {
    return power(a, MOD - 2);
}

long long c(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    fact[0] = 1;
    for (int i = 1; i < N; ++i) fact[i] = fact[i - 1] * i % MOD;
    for (int i = 0; i < N; ++i) invfact[i] = inverse(fact[i]);
    int n, m, k; cin >> n >> m >> k;
    int lft = 0, rgt = -1;
    long long sum = 0, res = 0;
    for (int l = 0; l <= m + k; ++l) {
        int newLft = l - min(l, k);
        int newRgt = min(l, m);
        while (rgt < newRgt) sum += c(l, ++rgt);
        while (rgt > newRgt) sum -= c(l, rgt--);
        while (lft < newLft) sum -= c(l, lft++);
        while (lft > newLft) sum += c(l, --lft);
        sum %= MOD;
        res = (res + sum * power(3, m + k - l) % MOD * c(n + l - 1, n - 1)) % MOD;
        sum = (sum * 2 - c(l, lft++) - c(l, rgt)) % MOD;
    }
    if (res < 0) res += MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 14336
nums = [int(n) for n in input().split()]
values = []
for i in range(2):
    n_a = nums[0] // nums[1 + 2 * i]
    n_b = nums[0] % nums[1 + 2 * i]
    if n_b == 0:
        values.append(n_a * nums[2 + 2 * i])
    else:
        values.append((n_a + 1) * nums[2 + 2 * i])

print(min(values))


Measured memory_bytes: 5604
<?php
// B
fscanf(STDIN, '%d', $s);
$n = 1000000;
$a = $s;
$c[$s] = true;
for ($i = 2; $i <= $n; $i++) {
    $a = ($a & 1) ? 3 * $a + 1 : $a / 2;
    if (isset($c[$a])) break;
    $c[$a] = true;
}
echo $i;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
// ncr *******************
const int M = 2e5+9;
long long fact[M], ifact[M], inv[M];
long long ncr(long long n, long long r) {
    assert(n < M);
    if(r < 0 || n < 0 || r > n) return 0;
    long long ret = fact[n] * ifact[n-r] % mod * ifact[r] % mod;
    return ret;
}
ll choose(int n) {
	return 1ll * n * (n + 1) / 2 % mod;
}
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    

    inv[1] = fact[0] = ifact[0] = fact[1] = ifact[1] = 1;
    for(int i = 2; i < M; i++) {
        fact[i] = fact[i-1] * i % mod;
        inv[i] = (mod - (mod/i) * inv[mod % i] % mod) % mod;
        ifact[i] = ifact[i-1] * inv[i] % mod;
    }
    int n, k; cin >> n >> k;
    ll ans = 0;
    for(int i = k; i <= n+1; i++) {
    	ans = (ans + choose(n) - choose(n-i) - choose(i-1) + 1) % mod;
    	ans %= mod;
    	ans = (ans + mod) % mod;
    	// cout << i << " " << ans << endl;
    	// ans = (ans + ncr(n, k)) % mod;
    }
    cout << ans << "\n";

    





    return 0;
    
}
	

Measured memory_bytes: 8352
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a%3==0){
    cout<<"Possible";
  }
  else{
    if(b%3==0){
      cout<<"Possible";
    }
    else if((a+b)%3==0){
      cout<<"Possible";
    }
    else{
      cout<<"Impossible";
    }
  }
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>

#define ll long long
#define md  1000000007

using namespace std;
long long n;


int main(){
    cin>>n;
    vector<int> p(0);
    for(int i=2; i<=n; i++){
	bool isp=true;
	for(int j=2; j*j<=i ; j++){
	    if(i%j==0){isp=false; break;}
	}
	if(isp) p.push_back(i);
    }
    vector<int> np(p.size(), 0);

    for(int i=2; i<=n; i++){
	int c = i;
	for(int j=0; j<p.size(); j++){
	    while(c>0 && c%p[j]==0){
		c/=p[j]; np[j]++;
	    }
	}
    }
    ll res=1;
    for(int i=0; i<p.size(); i++){
	res*=(np[i]+1); res%=md;
    }
    cout<<res;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  for(int i=1;i<=b*a;i++){
    if(a*i%b==c) {printf("YES");return 0;}
  }
  printf("NO");
  return 0;
}

Measured memory_bytes: 128
N=int(input())
S=input()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*g*b
for i in range(N):
  x=S[i]
  for j in range(i+1,N):
    if(S[j]!=x):
      y=S[j]
      if(2*j-i>=0 and 2*j-i<N):
        if(S[2*j-i]!=x and S[2*j-i]!=y):
          ans-=1
print(ans)

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

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  int ans = (n/x)*t;
  if (n%x > 0) {
    ans += t;
  }

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

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
int main(){
    while(true){
        int a,b,c;
        cin>>a>>b>>c;
        int ab=a+b;
        if(a==-1&&b==-1&&c==-1)break;
        if(a==-1||b==-1)cout<<'F'<<endl;
        else if(ab>=80){
            cout<<'A'<<endl;
        }else if(ab>=65){
            cout<<'B'<<endl;
        }else if(ab>=50||(ab>=30&&c>=50)){
            cout<<'C'<<endl;
        }else if(ab>=30){
            cout<<'D'<<endl;
        }else {
            cout<<'F'<<endl;
        }
        
        
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3136
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const int imax = ~(1 << 31);
const long long linf = 1ll << 61;
const long long lmax = ~(1ll << 63);

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

ll N, C;
ll x[100000];
ll v[100000];

ll for1[100001];
ll for2[100001];
ll rev1[100001];
ll rev2[100001];

int main(int argc, char* argv[])
{
	scanf("%lld%lld", &N, &C);
	for (int i = 0; i < N; i++) {
		scanf("%lld%lld", &x[i], &v[i]);
	}
	ll M1 = 0;
	ll M2 = 0;
	ll sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += v[i - 1];
		M1 = max(M1, sum - x[i - 1]);
		M2 = max(M2, sum - 2 * x[i - 1]);
		for1[i] = M1;
		for2[i] = M2;
	}
	M1 = 0; M2 = 0;
	sum = 0;
	for (int i = N - 1; i >= 0; i--) {
		sum += v[i];
		M1 = max(M1, sum - (C - x[i]));
		M2 = max(M2, sum - 2 * (C - x[i]));
		rev1[i] = M1;
		rev2[i] = M2;
	}
	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		ans = max(ans, max(for2[i] + rev1[i], for1[i] + rev2[i]));
	}

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

	return 0;
}


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

int main(void){
  long i;
  long N;
  long long K;
  long Q;
  long t;

  scanf("%ld %lld %ld", &N, &K, &Q);
  long A[N+1];
  memset(A, 0, sizeof(A));
  //A[i]がiに対応

  for(i=1; i<=Q; i++){
    scanf("%ld", &t);
    A[t]++;
  }

  // for(i=1; i<=N; i++) printf("%ld=%ld\n", i, A[i]);

  // printf("Q-K+1=%lld\n", Q-K+1);
  for(i=1; i<=N; i++){
    if(Q-K+1<=A[i]){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }

  return 0;
}


Measured memory_bytes: 1280
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
result = float("inf")
answer = None

for i, h in enumerate(H):
    if abs(A - (T - h*0.006)) < result:
        result = abs(A - (T - h*0.006))
        answer = i + 1

print(answer)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int a,b;
	int x=0,f=0,i;
	scanf("%d %d",&a,&b);
	if(b>=100) x=a*1000+b;
	else if(b>=10) x=a*100+b;
	else x=a*10+b;
	//printf("%d\n",x);
	for(i=1;i<=1000;i++){
		if(x==i*i){
			f=1;
		}
	}
	if(f==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n;
  long k;
  cin >> n >> k;
  vector<int> a(n);
  vector<long> b(n), c(100000);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
    int d = a.at(i);
    c.at(d-1) += b.at(i);
  }
  long count = 0, ans;
  for (int i = 0; i < 100000; i++) {
    count += c.at(i);
    if (count >= k) {
      ans = i+1;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n, m;
vector<pi> g[105];
map<pi, int> vis;
int dist[105], p[105];

void dijkstra(int s){
	rep(i, 105) dist[i] = 1e9, p[i] = -1;
	p[s] = -1;
	dist[s] = 0;
	set<pi> q;
	q.insert(mp(dist[s], s));
	while(!q.empty()){
		int cur = q.begin() -> se;
		q.erase(q.begin());
		for(pi x : g[cur]){
			if((dist[cur] + x.se) < (dist[x.fi])){
				q.erase(mp(dist[x.fi], x.fi));
				p[x.fi] = cur;
				dist[x.fi] = dist[cur] + x.se;
				q.insert(mp(dist[x.fi], x.fi));
			}
		}
	}
	rep(i, n){
		int prev = i;
		int pr = p[prev];
		while(pr != -1){
			vis[mp(pr, prev)] = 1;
			vis[mp(prev, pr)] = 1;
			prev = p[prev];
			pr = p[prev];
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> m;
	vi a(m), b(m), c(m);
	rep(i, m){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		g[a[i]].pb(mp(b[i], c[i]));
		g[b[i]].pb(mp(a[i], c[i]));
	}
	rep(i, n) dijkstra(i);
	int ans = 0;
	rep(i, m) if(!vis[mp(a[i], b[i])]) ans++;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long int
const int N = 1e6;
using namespace std;
int tree[2*N];
int hei[N];
int val[N];
signed main()
{
    int n,t;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        hei[i]=t-1;
    }
    
    for(int i=0;i<n;i++)
    cin>>val[i];
    
    for(int i=0;i<2*n;i++)
    tree[i] = 0;

    for(int i=0;i<n;i++)
    {
        int l = n;
        int r = n+hei[i];
        int best=0;
        for(;l<r;l>>=1,r>>=1)
        {
            if((l&1)==1) 
            best = max(best,tree[l++]);
            if((r&1)==1)
            best = max(best,tree[--r]);
        }
        tree[n+hei[i]] = max(tree[n+hei[i]],best + val[i]);
        r = n+hei[i];

        for(;r>1;r>>=1)
        {
            tree[r>>1] = max(tree[r],tree[r^1]);
        }
    }

    //for(int i=1;i<2*n;i++)
   // cout<<tree[i]<<endl;
    cout<<tree[1];
    return 0;
}


Measured memory_bytes: 12032
import math

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

x = []
y = []

for i in range(n):
  a,b = nm()
  x.append(a)
  y.append(b)

cnt = 0

def dist(xi,yi,xj,yj):
  return math.sqrt((xi-xj)**2+(yi-yj)**2)

def search(route):
  global cnt
  s = 0
  if len(route) == n:
    cnt += 1
    for i in range(n-1):
      s += dist(x[route[i]],y[route[i]],x[route[i+1]],y[route[i+1]])
    return s
  for i in range(n):
    if i not in route:
      s+=search(route+[i])
  return s

ans = search([])/cnt
print(ans)

Measured memory_bytes: 47068
#include<iostream>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#define nax 1000005
#define mod 1000000007
#define ll long long int
using namespace std;
int main(){
	int n=0,k=0;
	cin >> n>> k;
	cout << n-k+1;
	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 print(n) cout << n << endl
#define in(v) int v; cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  int n,k;cin>>n>>k;int d[n][k];
  rep(i,k){
    rep(j,n){
      d[j][i]=0;
    }
  }
  rep(i,k){
    in(di);
    rep(j,di){
      in(a);
      d[a-1][i]=1;
    }
  }
  int cnt=n;
  rep(i,n){
    rep(j,k){
      if(d[i][j]==1){
        cnt--;
        break;
      }
    }
  }
  print(cnt);
  return 0;
}

Measured memory_bytes: 3632