akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define mod 1000000007
using namespace std;
//using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
ll f(ll x)
{
    ll ans=1LL;
    for(ll i=1;i<=x;i++) ans=((ans%mod)*(i%mod))%mod;
    return ans;
}
ll pow(ll y,int z,int p)
{
    y%=p;
    ll ans=1;
    for(int i=z;i;i>>=1,y=y*y%p) if(i&1) ans=ans*y%p;
    return ans;
}
ll C(ll n,ll m,ll p)
{
    if(m>n) return 0;
    return ((f(n)*pow(f(m),p-2,p))%p*pow(f(n-m),p-2,p)%p);
}
ll Lucas(ll n,ll m,ll p)
{
    if(!m) return 1;
    return C(n%p,m%p,mod)*Lucas(n/p,m/p,mod)%p;
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	int x=read(),y=read();
	int cnt=0;
	bool ok=0;
	for(int a=0;a<=x;a++){
        if((x-a)%2==1) continue;
        else{
            int b=(x-a)/2;
            if((2*a+b)==y){
                cnt=a;
                ok=1;
            }
        }
	}
	if(ok==0) cout<<0<<endl;
	else{
        int a=cnt,b=(x-cnt)/2;
        printf("%lld\n",Lucas(a+b,a,mod));
	}
	return 0;
}


Measured memory_bytes: 256
def solve():
    N, K = map(int,input().split())
    mod = 10 ** 9 + 7

    cnt = [0] * (K+1)
    for g in range(K,0,-1):
        cnt[g] = pow(K // g, N, mod)
        gg = g * 2
        while gg <= K:
            cnt[g] -= cnt[gg]
            gg += g
    
    ans = 0
    for i in range(1,K+1):
        ans += cnt[i] * i % mod
    print(ans%mod)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 69852
/* ****Ragnar7**** */
/* It's Going to be Hard, but hard does not mean Impossible. */
#include<bits/stdc++.h>
#define ll          long long
#define hell        1000000007
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,k,m;
	cin>>n>>m;
	vector<ll> v(100005,0);ll x;
	string y;
	ll cnt=0,pen=0;
	for(ll i=0;i<m;i++)
	{

		cin>>x>>y;
		if(y=="WA")
		{
			if(v[x]!=hell)
				v[x]++;
		}
		else
		{
			if(v[x]!=hell)
			{
				cnt++;
				pen+=v[x];
				v[x]=hell;
			}
		}
	}
	cout<<cnt<<" "<<pen;
	return 0;
}

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

int main() {
  ll n;
  cin >> n;
  std::vector<ll> a(3*n);
  rep(i, 3*n) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());

  ll ans = 0;

  // rep(i, 3*n) cout << a[i] << endl;

  rep(i, n * 2) {
    if (i % 2 == 1)
      ans += a[i];
    }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 2560
use io::*;
use std::*;

fn solve(K: i64, A: i64, B: i64) {

if (A-1) /K == B/K {
    println!("{}","NG");
}else{
    println!("{}","OK");
}

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut K: i64;
    K = scanner.next();
    let mut A: i64;
    A = scanner.next();
    let mut B: i64;
    B = scanner.next();
    // 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(move || solve(K, A, B)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 2268
//SHIVANSH BHAT
//IIT ROORKEE

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
#define fi first
#define se second
#define pb push_back
ll modulo1=pow(10,9)+7;
int modulo2=998244353;
typedef long double ld;

vector<ll>fact;

ll binpower(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return binpower(n, pp-2, pp);
}

ll nCr(ll n,ll r){
    ll abc=fact[n-r]*fact[r];
    return fact[n]*modInverse(abc,modulo1);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    vector<ll>h(n+1);
    for (int i = 0; i <n ; ++i) {
        cin>>h[i+1];
    }
    vector<ll>dp(n+1,1e9+9);
    dp[1]=0;
    for (int i = 2; i <=n ; ++i) {
        ll x=0;
        for (int j = i-1; j >=1 ; j--) {
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
            x++;
            if(x==k)
                break;
        }
    }
    cout<<dp[n]<<"\n";
    return 0;
}


Measured memory_bytes: 4748
n,m=map(int,input().split())
foods=[0]*m
for i in range(n):
  inp=input().split()
  k=int(inp[0])
  answer=[int(i)-1 for i in inp[1:]]
  
  for j in range(k):
    foods[answer[j]]+=1
num=0
for i in range(m):
  if foods[i]==n:
    num+=1
print(num)

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO  = "No";

int func(long long N, std::vector<long long> H) {
    // cout << N << endl;

    // for (auto& e : H) {
    //     cout << e << " ";
    // }
    rep1r(i, N - 1) {
        // for (ll i = N - 1; i > 0; i--) {
        if (H[i - 1] <= H[i]) {
            continue;
            // } else if (H[i - 1] == H[i] + 1) {
        } else if (H[i] - H[i - 1] == -1) {
            H[i - 1]--;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    long long N;
    // scanf("%lld", &N);
    cin >> N;
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++) {
        // scanf("%lld", &H[i]);
        cin >> H[i];
    }
    func(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// ascii 97~122

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> vec(N,0);
    int a,b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        vec.at(a-1)++;
        vec.at(b-1)++;
    }
    for(int x: vec){
        cout << x <<endl;
    }
}

Measured memory_bytes: 3568
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll a[3], i, j;
	for(i=0; i<3; i++)
	cin>>a[i];
	
	sort(a, a+3);
	ll ans= a[0] + a[1];
	cout<<ans;
    return 0;
}























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}int a[maxn];
bool pd(int x,int y,int z){
    if(x+y>z&&x+z>y&&y+z>x)return true;
    return false;
}
signed main(){
    //file(a);
    n=read();rep(i,1,n)a[i]=read();
    sort(a+1,a+1+n);int ans=0;
    // rep(i,1,n)cout<<a[i]<<" ";cout<<endl;
    rep(i,1,n){
        int posj=i+1,posk;
        while(a[posj]==a[i])++posj;
        rep(j,posj,n){
            posk=j+1;
            while(a[posk]==a[j])++posk;
            rep(k,posk,n){
                if(pd(a[i],a[j],a[k]))++ans;
            }
        }
    }printf("%d\n",ans);


    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string S, T; cin >> S >> T;
  int A, B; cin >> A >> B;
  string U; cin >> U;
  if (U == S) --A;
  else --B;
  cout <<A << " " << B;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
        int n;
        scanf("%d",&n);

        int a[n];
        for(int i=0; i<n; i++){
                scanf("%d",&a[i]);
        }
        int count = 0;
        for (int i=1; i<n-1; i++){
                if (a[i-1] < a[i] && a[i] < a[i+1]){
                        count++;
                }else if (a[i-1] > a[i] && a[i] > a[i+1]){
                        count++;
                }
        }
        printf("%d",count);
        return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   int n,m;
   char c;
   while(cin >> n&&n){
      vector<char> a(2*n);
      rep(i,2*n) cin>>a[i];
     cin >> m;
     rep(i,m){
       cin>>c;
       rep(i,n)if(c==a[2*i]){
          c=a[2*i+1];
          break;
       }
       cout << c;
      }
      cout << endl;
   }
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
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;
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!"
             << "\n";
    else
        cout << ":("
             << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#define SIZE 10000005
#define rint register int
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
inline void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    return ;
}

char c;int a[SIZE],cnt1,cnt2,cnt3,b[SIZE],w[SIZE],ans=0x3f3f3f3f;

int main()
{
    int lenth=read();
    for(rint i=1;i<=lenth;++i)
    {
    	cin>>c;
    	if(c=='#')
		{
			a[i]=1;
			b[i]=b[i-1]+1;
			w[i]=w[i-1];
		} 
    	else 
		{
			a[i]=0;
			w[i]=w[i-1]+1;
			b[i]=b[i-1];
		}
	}
	for(rint i=0;i<=lenth;++i)
	  ans=min(ans,b[i]+w[lenth]-w[i+1]);
	cout<<ans;
    return 0;
}

Measured memory_bytes: 5120
#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>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define in(x, a, b) a <= x && x < b
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double 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 };




class WeightedUF {
public:
  vi par, ran, num;
  vl diff_weight; //親ノード(根ノードではない)との値の差分
  
  WeightedUF(int n) {
    par.resize(n); ran.resize(n);
    num.resize(n); diff_weight.resize(n);
    for (int i = 0; i < n; i++) {
      par[i] = i; ran[i] = 0;
      num[i] = 1; diff_weight[i] = 0;
    }
  }

  //木の根を求める
  int find(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      int root = find(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = root;
    }
  }

  ll weight(int x) {
    find(x); //経路圧縮
    return diff_weight[x];
  }

  //xからみたyの重み
  ll diff(int x, int y) {
    if (!same(x, y)) {
      return -INF;
    }
    else {
      return weight(y) - weight(x);
    }
  }
  
  //xからみたyの重みがwになるように併合
  bool unite(int x, int y, ll w) {
    w += weight(x); w -= weight(y);
    x = find(x); y = find(y);
    int numsum = num[x] + num[y];
    if (x == y) {
      if (diff(x, y) == w) {
	return true;
      }
      else {
	return false;
      }
    }
    if (ran[x]<ran[y]) {
      swap(x, y);
      w = -w;
    }
    par[y] = x;
    if (ran[x] == ran[y]) {
	ran[x]++;
    }
    diff_weight[y] = w;
    num[x] = num[y] = numsum;
    return true;
  }

  //xとyが同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }

};


int main() {
  int n, m;
  cin >> n >> m;
  WeightedUF uf(n);
  rep (i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    if (!uf.unite(l, r, d)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int cnt[100010] = {};
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	REP(i, 1, N) {
		if (cnt[i] % 2 != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, d, ans = 0;
	cin >> n >> d;

	vector<vector <int>> x(n, vector<int>(d));
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++)
			cin >> x.at(i).at(j);
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			double sq = 0;
			for(int k=0;k<d;k++){
				int s = x[i][k] - x[j][k];
				sq += s * s;
			}
			int s = sqrt(sq);
			if(s == sqrt(sq)) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(A==B){
		printf("%d\n",C);
	}else if(A==C){
		printf("%d\n",B);
	}else{
		printf("%d\n",A);
	}
	return 0;
}

Measured memory_bytes: 128
#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        m: i64,
        abs: [(i64, i64); n],
    }
    let mut abs = abs;
    abs.sort();
    let mut count = 0;
    let mut cost = 0;
    for ab in abs {
        let need = m - count;
        if need <= ab.1 {
            count += need;
            cost += need * ab.0;
            break;
        } else {
            count += ab.1;
            cost += ab.1 * ab.0;
        }
    }
    println!("{}", cost);
}


Measured memory_bytes: 6396
#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 pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> data(M, 0);
    REP(i, N)
    {
        int K, a;
        cin >> K;
        REP(j, K)
        {
            cin >> a;
            data.at(a - 1)++;
        }
    }

    int ans = 0;
    REP(i, M)
    {
        if (data.at(i) == N)
            ans++;
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    if (s=="ABC")
        cout<<"ARC";
    else 
        cout<<"ABC";
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int main() {
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	For(i,m,m+n-1) ans+=i;
	if(m+n-1<0) ans-=m+n-1;
	else if(m>0) ans-=m;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
/**
 * 最短経路の練習：「Warshall-Floyd法」
 * ABC160 D
 * https://atcoder.jp/contests/abc160/tasks/abc160_d
 * 
 * 期待する入力
 * N X Y
 * 3 <= N <= 2000
 * 1 <= X, Y <= N
 * X+1 < Y
 */

 package main

 import (
	 "fmt"
	 "bufio"
	 "os"
	 "strconv"
 )
 
 func main() {
	 sc := bufio.NewScanner(os.Stdin)
	 sc.Split(bufio.ScanWords)
 
	 N, X, Y := nextInt(sc), nextInt(sc), nextInt(sc)
	 
	 // 距離計算「Warshall-Floyd法」
	 // 今回、エッジの距離は全て１だが、可変でも行けるはず...
	 // 参考：https://qiita.com/ta-ka/items/a023a11efe17ab097433#warshall-floyd%E6%B3%95
	 distance := make([][]int, N)
	 counter := make([]int, N-1)
	 ks := []int{0, X-1, Y-1}
	 for _, k := range ks {
		 for i := 0; i < N; i++ {
			 if k == 0 {
				 distance[i] = make([]int, N)
				 if i == (X-1) {
					 distance[i][Y-1] = 1
				 } else if i == (Y-1) {
					 distance[i][X-1] = 1
				 }
			 }
			 //NOTE: 有向グラフの場合は、 j < i の部分を j < N に変更する
			 for j := 0; j < i; j++ {
				 if k == 0 {
					 isSetedDistance := false
					 isSetedDistance = isSetedDistance || i == j
					 isSetedDistance = isSetedDistance || i == (X - 1) && j == (Y - 1)
					 isSetedDistance = isSetedDistance || j == (X - 1) && i == (Y - 1)
					 if !isSetedDistance {
						 distance[i][j] = i - j
					 }
				 }
				 distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j])
				 distance[j][i] = distance[i][j]  // 無向グラフのため、対称行列
				 if k == Y-1 {
					 counter[distance[i][j]-1] += 1
				 }
			 }
		 }
	 }
 
	 // 表示
	 for _, num := range counter {
		 fmt.Println(num)
	 }
 
 }
 
 func min(a, b int) int {
	 if a < b {
		 return a
	 }
	 return b
 }
 
 func nextInt(sc *bufio.Scanner) int {
	 sc.Scan()
	 t, _ := strconv.Atoi(sc.Text())
	 return t
 }

Measured memory_bytes: 59904
import math

def Distance():
    
    num = list(map(int,input().split()))

    count = 0

    for i in range(num[0]):
        position = list(map(int,input().split()))
        
        distance = math.sqrt(position[0]*position[0] + position[1]*position[1])
        
        if distance <= num[1] :
            count = count + 1
    
    print(count)

if __name__ == '__main__':
    Distance()




Measured memory_bytes: 9128
def main():
  n,k=map(int,input().split())
  s=input()
  
  A=(('L','R'),('R','L'))
  B=[]
  Bappend=B.append
  cnt=0
  for i in range(n-1):
    tmp=(s[i],s[i+1])
    cnt+=1
    if tmp==A[0]:
      Bappend(cnt)
      cnt=0
    elif tmp==A[1]:
      Bappend(cnt)
      cnt=0
  cnt+=1
  Bappend(cnt)
  print(n-max(1,len(B)-2*k))
  
if __name__=='__main__':
  main()

Measured memory_bytes: 3956
#include<cstdio>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(void) {
	int N, M;
	long K;
	scanf("%d %d", &N, &M);
	scanf("%ld", &K);

	long a[200100], b[200100];
	a[0] = b[0] = 0;
	for (int i = 1; i < N + 1; i++) {
		scanf("%ld", &a[i]);
		a[i] = a[i - 1] + a[i];
	}
	for (int i = 1; i < M + 1; i++) {
		scanf("%ld", &b[i]);
		b[i] = b[i - 1] + b[i];
	}

	int ans = 0;
	int j = M;
	for (int i = 0; i < N + 1; i++) {
		if (a[i] > K) {
			break;
		}
		while (b[j] > K - a[i]) {
			j--;
		}
		ans = max(ans, i + j);
	}


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

	return 0;
}


Measured memory_bytes: 6936
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  X=int(pin())
  i=1
  while i<=X:
    if i*(i+1)>=2*X:
      print(i)
      return 
    i+=1
  return 
main()

Measured memory_bytes: 9180
N,K = map(int, input().split())
 
nlist = [i for i in range(1,N+1)]
 
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    if a in nlist:
      nlist.remove(a)
print(len(nlist))

Measured memory_bytes: 9180
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	string s;
	cin >> s;
	int c = 0;
	for(int i=0;i<3;i++) {
		char ca;
		cin >> ca;
		if(ca == s[i]) c++;
	}
	cout << c;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll i = 0; i < n; i++)
#define FORN(i, a, b) for (ll i = a; i < b; i++)
#define FORE(i, l) for (auto i : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) n.begin(), n.end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    ll x = 0;
    ll y = 0;
    FOR(i, n)
    {
        char cur = s[i];
        if (cur == 'c') cout << "No\n";
        else if (cur == 'a' && x < a + b)
        {
            cout << "Yes\n";
            x++;
        }
        else if (cur == 'b' && x < a + b && y < b)
        {
            cout << "Yes\n";
            x++; y++;
        }
        else cout << "No\n";
    }
}



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

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

int main() {
  int h,w;
  cin>>h>>w;
  int p=0;
  vector<string> field(h);
  for(int i=0;i<h;i++){
    cin>>field[i];
    for(int j=0;j<w;j++){
      if(field[i][j]=='#'){
        p++;
      }
    }
  }
  int sx=0,sy=0,gx=h-1,gy=w-1;
  int ans=0;
  vector<vector<int>> dist(h,vector<int>(w,-1)); 
  dist[sx][sy]=0;
  queue<pair<int,int>> que; 
  que.push(make_pair(sx,sy));
  while(!que.empty()){
    pair<int,int> current_pos=que.front();
    int x=current_pos.first;
    int y=current_pos.second;
    que.pop();
    for(int d=0;d<4;d++){
      int next_x=x+dx[d];
      int next_y=y+dy[d];
      if(next_x<0||next_x>=h||next_y<0||next_y>=w)continue;
      if(field[next_x][next_y]=='#')continue;
      if(dist[next_x][next_y]==-1){
        que.push(make_pair(next_x, next_y));
        dist[next_x][next_y]=dist[x][y]+1;
      }
    }
  }
  if(dist[gx][gy]==-1){
    cout<<-1<<endl;
    return 0;
  }
  cout<<h*w-dist[gx][gy]-1-p<<endl;
  return 0;
}

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

int main(){
    map<long long, long long> m;
    int N;
    long long a;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        if(m.find(a) == m.end()){
            m[a] = 1;
        }else{
            m[a]++;
        }
    }
    long long remove = 0;
    for(auto pair=m.begin(); pair!=m.end(); pair++){
        if(pair->second >= pair->first){
            remove += pair->second - pair->first;
        }else{
            remove += pair->second;
        }
    }
    cout << remove;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 6272
#include <stdio.h>
void maxHeapify(int);
int H,A[500001];
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}
void maxHeapify(int i){
  int l=i*2,r=i*2+1,large,tmp;
  if(l<=H && A[l]>A[i])large=l;
  else large=i;
  if(r<=H && A[r]>A[large])large=r;
  if(large!=i){
    tmp=A[i];
    A[i]=A[large];
    A[large]=tmp;
    maxHeapify(large);
  }
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(){
  int n, k, p,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&k,&p);
    if(k%p!=0){
    printf("%d\n",k%p);
    }else printf("%d\n",p);
  }
  
  return 0;
}

Measured memory_bytes: 596
import java.util.LinkedList;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextInt()) {
				int thing = sc.nextInt();
				int weight = 512;

				LinkedList<Integer> result = new LinkedList<Integer>();

				while (thing != 0) {
					if (thing < weight) {
						weight /= 2;
					} else {
						thing -= weight;
						result.push(weight);
					}
				}
				print(result);
			}
		} finally {
			sc.close();
		}
	}

	public static void print(LinkedList<Integer> list) {
		StringBuilder sb = new StringBuilder();
		for (int num : list) {
			sb.append(num).append(" ");
		}
		sb.deleteCharAt(sb.length() - 1);

		System.out.println(sb);
	}
}

Measured memory_bytes: 26228
//https://www.cnblogs.com/TetrisCandy/p/ABC169.html
//质因数分解 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxx=1000010;

bool tot[maxx];
ll cnt,phi[maxx],num[maxx];

void print(){//质因数分解 
	for(ll i=2;i<=1000000;i++){
		if(tot[i])continue;
		phi[++cnt]=i;//记录质数 
		for(ll j=2;j<=1000000/i;j++)
		tot[i*j]=1;
	}
}

int main()
{
	ll n;cin>>n;
	print();
	ll ans=0;
	for(ll i=1;i<=cnt;i++){
		ll p=phi[i];
		while(n%p==0)//统计幂次 
		n/=p,num[i]++;
		ll a=sqrt(num[i]*2);//反解x 
		if(a*(a+1)>num[i]*2)a--;//大了说明应该取x-1 
		ans+=a;
	}
	if(n!=1)ans++;//最后判断一下能否再用第三个条件 
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int p[N];
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  sort(p,p+N);
  p[N-1] = p[N-1]/2;
  int ans = 0;
  for(int i=0;i<N;i++){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
d = sorted(list(map(int, input().split())))
ans_list = [0,24]
for k,v in enumerate(d):
  ans_list.append(24-v) if k % 2 else ans_list.append(v)
ans_list.sort()
ans = 12
for i in range(len(ans_list)-1):
  ans = min(ans, ans_list[i+1]-ans_list[i])
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"

	"sort"
	"strconv"
	"strings"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func main() {
	con := NewConsole()
	defer con.Flush()

	m := make(map[int]struct{})
	lines, _ := ReadLongLines(4)
	a := strings.Split(lines[1], " ")
	for i := range a {
		n, _ := strconv.Atoi(a[i])
		m[n] = struct{}{}
	}
	b := strings.Split(lines[3], " ")
	for i := range b {
		n, _ := strconv.Atoi(b[i])
		m[n] = struct{}{}
	}
	result := make([]int, len(m))
	i := 0
	for k, _ := range m {
		result[i] = k
		i++
	}
	sort.Slice(result, func(lhs, rhs int) bool {
		return result[lhs] < result[rhs]
	})
	for j := range result {
		con.Printf("%d\n", result[j])
	}
}



Measured memory_bytes: 26360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
ll n,T,a[N];
int main()
{
	while(cin>>n>>T)
	{
		
		for(int i=1;i<=n;i++)
			scanf("%lld",&a[i]);
		if(n==1)
		{
			cout<<T<<endl;
			continue;
		}
		ll ans=0,cur=0;
		for(int i=2;i<=n;i++)
		{
			ll x=cur+T;
			if(a[i]>x)
				ans+=T;
			else
				ans+=a[i]-cur;
			cur=a[i];	
		}
		ans+=T;
		cout<<ans<<endl;
	}
	return 0;
}

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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int a, b, c; cin >> a >> b >> c;
  if (a == b && b == c)
    cout << "No" << ende;
  else if (a != b && b != c && c != a)
    cout << "No" << ende;
  else
    cout << "Yes" << ende;

  return 0;
}


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

int main() {
  int n,p=0;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  for(long long i = data.at(1);i > 0;i--){
    int c = 0;
    for(int j = 0;j < n;j++){
      if(data.at(j)%i != 0){
        c++;
      }
      if(c == 2){
        goto pass;
      }
      if(j == n-1){
        cout << i << endl;
        p = 1;
      }
    }
    if(p == 1){
      break;
    }
    pass:;
  }
}


Measured memory_bytes: 640
S=input()
x=['R','U','D']
y=['L','U','D']
l=len(S)
for i in range(l):
    if (i+1)%2!=0:
        if S[i] not in x:
            print('No')
            exit()
    else:
        if S[i] not in y:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 9124
#include <cstdio>
#include <map>
#include <string>
#include <queue>
#include <utility>
#include <iostream>

using namespace std;

typedef pair<int,string> P;

int main(){
  
  int d[4] = {-1,1,-4,4};
  
  map<string,int> ans;
  
  ans["01234567"] = 0;
  
  queue<P> que;
  
  que.push(P(0,"01234567"));
  
  while(que.size()){
    P p = que.front(); que.pop();
    int k = ans[p.second];
    for(int i = 0;i < 4;i++){
      
      int n = p.first + d[i];
      if(i == 0 && n == 3)continue;
      if(i == 1 && n == 4)continue;
      if(n >= 0 && n < 8){
	string tmp;
	tmp = p.second;
	swap(tmp[p.first],tmp[n]);
	if(ans.find(tmp) == ans.end()){
	  ans[tmp] = k + 1;
	  que.push(P(n,tmp));
	}
	
      }
    }   
  }
  string s;
  char t;
  while(cin >> t){
    s += t;
    for(int i = 0;i < 7;i++){
      cin >> t;
      s += t;
    }

    cout << ans[s] << endl;
    
    s.clear();
  }
  return 0;
  
}


Measured memory_bytes: 3448
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
const int maxn=2e3+10,P=1e9+7;

inline char gc(){
	return getchar();
	static const int maxs=1<<16;static char buf[maxs],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline ll rd(){
    ll x=0;char c=gc();bool neg=0;
    while(c<'0'||c>'9'){if(c=='-') neg=1;c=gc();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=gc();
    return neg?(~x+1):x;
}

int N,M,a[maxn],b[maxn];
int tr[maxn];

inline int lowbit(int x){return x&(-x);}
inline void add(int x,int y){x++;
	for(;x<=M+1;x+=lowbit(x)) tr[x]=(tr[x]+y)%P;
}
inline int query(int x){x++;
	int re=0;for(;x;x-=lowbit(x)) re=(re+tr[x])%P;
	return re;
}

int main(){
    //freopen("","r",stdin);
    N=rd(),M=rd();
    for(int i=1;i<=N;i++) a[i]=rd();
    for(int i=1;i<=M;i++) b[i]=rd();
    add(0,1);
    for(int i=1;i<=N;i++){
    	for(int j=M;j;j--){
    		if(a[i]!=b[j]) continue;
    		int now=query(j-1);
    		// printf("~%d %d %d\n",i,j,now);
    		add(j,now);
    	}
    }
    printf("%d\n",query(M));
    return 0;
}

Measured memory_bytes: 256
import bisect
n,q = map(int,input().split())

S = input()
aindex = []
for i in range(len(S)-1):
    if (S[i] == "A"):
        if(S[i+1] == "C"):
            aindex.append(i+1)

for i in range(q):
    l,r = map(int,input().split())
    x = bisect.bisect_left(aindex, l)
    y = bisect.bisect_left(aindex, r-1)
    if x == len(aindex):
        print("0")
        continue
    if y != len(aindex):
        if aindex[y] == r-1:print(y-x+1)
        else:print(y-x)
    else:
        print(y-x)

Measured memory_bytes: 60028
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string in;
	while(cin>>in) 
	{
		string ans="";
		for(int i = 0; i < in.size(); ++i)
		{
			if(in[i]!='@') ans+=in[i];
			else 
			{
				int j=in[i+1]-'0';
				while(j--) ans+=in[i+2];
				i+=2;
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

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

using namespace std;

int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  vector<long long> a(N);
  vector<pair<long long, int>> bc(M);
  vector<long long> c;
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < M; ++i) {
    int b; long long c;
    cin >> b >> c;
    bc[i] = make_pair(c, b);
  }

  sort(a.begin(), a.end());
  sort(bc.begin(), bc.end(), greater<pair<long long, int>>());

  int cur = 0;
  for (int i = 0; i < N; ++i) {
    if (cur >= bc.size()) break;
    if (a[i] < bc[cur].first) {
      a[i] = bc[cur].first;
      bc[cur].second--;
    }
    if (bc[cur].second <= 0) cur++;
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) ans += a[i];

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



Measured memory_bytes: 2560
import math
tmp=map(int, raw_input().split(" "))
num=int(raw_input())
en=0
arr=[]
k=1
for i in tmp:
    arr.append(float(i)/k)
    k=k*2

#print arr.index(min(arr))

n=num
while True:
    if n >= 2:
        target=arr.index(min(arr))
    else:# n >= 1:
        target=arr[0:3].index(min(arr[0:3]))
    #elif n >= 0.5:
    #    target=arr[0:2].index(min(arr[0:2]))
    #elif n >= 0.25:
    #    target=arr[0:1].index(min(arr[0:1]))

    #print "target",target
    if target==3:
        en+=n/2*tmp[target]
        n=n%2

    elif target==2:
        en+=n*tmp[target]
        break
        #n=float(n)%1
    elif target==1:
        en+=n*2*tmp[target]
        break
        #n=float(n)%0.5
    elif target==0:
        en+=n*4*tmp[target]
        #n=float(n)%0.25
        break
    #print n
    #print en,"en"
    if n==0:
        break
print int(en)


Measured memory_bytes: 2696
#include <stdio.h>
 
int main(void){
  char data[81], temp[81];
  int i, j, k, p, t=0;
 
  while(1){
    p=0;
    for(i = 0;i < 80;i++){
      if(scanf("%c", &data[i]) == EOF){
    t=1;
    break;
      }
      if(data[i] == '\n') break;
    }
    data[i] = '\0';
     
    for(i = 0;i < 27; i++){
      for(j = 0; data[j] != '\0';j++){
    temp[j] = data[j];
    if(data[j] >= 'a' && data[j] <= 'z'){
      for(k = 0; k < i; k++){
        temp[j]++;
        if(temp[j] > 'z') temp[j] -= 26;
      }
    }
      }
      temp[j] = '\0';
      for(j = 0; temp[j] != '\0';j++){
    if(temp[j] == 't'){
      if(temp[j+1] != '\0'){
        if(temp[j+1] == 'h'){
          if(temp[j+2] != '\0'){
        if(temp[j+2] == 'e'){
          p = 1;
          break;
        }
        if(temp[j+2] == 'i'){
          if(temp[j+3] != '\0'){
            if(temp[j+3] == 's'){
              p = 1;
              break;
            }
          }
        }
        if(temp[j+2] == 'a'){
          if(temp[j+3] != '\0'){
            if(temp[j+3] == 't'){
              p=1;
              break;
            }
          }
        }
          }
        }
      }
    }
      }
      if(p == 1) break;
    }
    for(i = 0;i < 80; i++){
      if(temp[i]=='\0') break;
      printf("%c", temp[i]);
    }
    if(t == 1) break;
    else printf("\n");
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	string s, t;
	cin >> s;
	cin >> t;
	cout << t << s<< endl;
	return 0;
}


Measured memory_bytes: 256
=begin
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
=end
arr = gets.chomp.split.map!{|x| x.to_i}
if arr.find{|x| x % 2 == 0}
    puts(0)
else
    puts(arr[0]*arr[1]*arr[2] / arr.max)
end

Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
//#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }


struct Edge {
public:
	ll from, to, cost;
	//bool used;
	Edge() {}
	Edge(int _from, int _to, int _cost) {
		from = _from;
		to = _to;
		cost = _cost;
		//used = false;
	}
	bool operator<(const Edge& e) const {
		return cost < e.cost;
	}
	bool operator>(const Edge& e) const {
		return cost > e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef pair<Edge, int> PE;


ll prim(Graph &G) {
	priority_queue<PE, vector<PE>, greater<PE> > que;
	vb visited(SZ(G));
	que.push(PE(Edge(-1, 0, 0), -1));
	ll ret = 0;
	while (!que.empty()) {
		PE p = que.top(); que.pop();
		int v = p.first.to;
		if (visited[v])continue;
		ret += p.first.cost;
		visited[v] = true;
		//G[p.first.from][p.second].used = true;
		REP(i, SZ(G[v])) {
			if (visited[G[v][i].to])continue;
			que.push(PE(G[v][i], i));
		}
	}
	return ret;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E;
	cin >> V >> E;
	Graph G(V);
	REP(i, E) {
		int s, t, w;
		cin >> s >> t >> w;
		G[s].push_back(Edge(s, t, w));
		G[t].push_back(Edge(t, s, w));
	}
	ll ans = prim(G);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 14912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;
const int maxN = 2e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const int inf = 1e9+10;
#define X first;
#define Y second;

ll a[maxN];
ll f[maxN];
int n;
bool check(ll x,ll k)
{
	for(int i=1;i<=n;i++)
	{
		if(a[i] * f[i] > x)
		{
			ll cnt = (a[i] * f[i] - x);
			if(cnt % f[i] == 0)
			{
				cnt /= f[i];
			}
			else
			{
				cnt = cnt/f[i]+1;
			}
			if(k>=cnt)
			{
				k -= cnt;
			}
			else
				return false;
		}
	}
	if(k>=0)
		return true;
	else
		return false;
}
int main() {
	ll k;
	scanf("%d %lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&f[i]);
	}
	sort(a+1,a+1+n);
	sort(f+1,f+1+n);
	reverse(f+1,f+1+n);
	ll R = 0;
	for(int i=1;i<=n;i++)
	{
		R = max(a[i] * f[i],R);
	}
	ll L = 0;
	ll ans = 0;
	while(L<=R)
	{
		ll mid = (L+R)/2;
		if(check(mid,k))
		{
			ans = mid;
			R = mid-1;
		}
		else
		{
			L = mid+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static int[][] mtx ;
        static List<int>[] tm;
        static int n;
        static int[] results;
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {
           // string[] s1 = Console.ReadLine().Split(' ');
            var n = int.Parse(Console.ReadLine());
            //int q = int.Parse(s1[1]);



            Console.WriteLine(n * n * n);
        }

 

    }

    class TreeMap
    {
        int vertex;
        List<int> children = new List<int>();
    }
}

Measured memory_bytes: 11092