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

int main(){
	int N,M;
  	cin >> N >> M;
	vector<int> A(N),B(N);
	for(int i =0; i<N;i++){
		cin >> A[i] >> B[i];
		//cin >> B(i);
	}
	//
	vector<pair<int,int>> AB(N);
	for(int i =0;i<N;i++){
		AB[i] = make_pair(A[i],B[i]);
	}
	//価格の順番
	sort(AB.begin(),AB.end());
	
	long long ans = 0;
	for(int i = 0;i<N;i++){
		if(M >= AB[i].second){
		M -= AB[i].second;
		ans += (long long) AB[i].first * AB[i].second;
		}else{
		ans += (long long) M*AB[i].first;
		break;
		}
	}
	cout << ans<< endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int ans=0;
  REP(i,n){
    if(i%2==0){
      ans += a[i];
    }else{
      ans -= a[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int Partition(int *,int,int);
int main()
{
  int i,n,q;
  int A[2000000];

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

  q=Partition(A,0,n-1);

  for(i=0;i<q;i++){
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[q]);
  for(i=q+1;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  return 0;
}

int Partition(int *A,int p,int r)
{
  int x,i,j,temp;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++; 
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}  

Measured memory_bytes: 2972
#include<bits/stdc++.h>
using namespace std;
int n,m,a[101][101];
bool f[101][101];
int maxx;
void dfs(int x,int y,int sum)
{
    if(x<1||x>2||y<1||y>n) return;
    if(x==2&&y==n) maxx=max(maxx,sum);
    dfs(x+1,y,sum+a[x+1][y]);
    dfs(x,y+1,sum+a[x][y+1]);
}
int main()
{
    //ios::sync_with_stdio(false);
    int i,j;
    cin>>n;
    for(i=1;i<=2;i++)
    {
        for(j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }
    }
    dfs(1,1,a[1][1]);
    cout<<maxx;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}
use std::collections::VecDeque;
fn main() {
    input!(N: usize);
    let mut A = vec![];
    for _ in 0..N {
        input!(t: usize);
        A.push(t);
    }
    let mut d: VecDeque<usize> = VecDeque::new();
    for (_, &a) in A.iter().enumerate() {
        //let v: Vec<&usize> = d.iter().collect();
        let p: usize = lower_bound(&d, &&a);
        if p == 0 {
            d.push_front(a);
        } else {
            d[p - 1] = a;
        }
    }
    let ans = d.len();
    println!("{}", ans);
}

use std::cmp::Ordering;

fn lower_bound<T: Ord>(d: &VecDeque<T>, x: &T) -> usize {
    let mut low = 0;
    let mut high = d.len();

    while low != high {
        let mid = (low + high) / 2;
        match d[mid].cmp(x) {
            Ordering::Less => {
                low = mid + 1;
            }
            Ordering::Equal | Ordering::Greater => {
                high = mid;
            }
        }
    }
    low
}


Measured memory_bytes: 4800
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int main()
{
	int n,m;
	cin>>n>>m;
	cout<<(n-1)/(m-1)+((n-1)%(m-1)?1:0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution(){
	int n; cin >> n;
	vector<int> A(n); for(int& x : A) cin >> x;
	int g = A[0];
	int m = *max_element(all(A));
	vector<int> c(m+1,0);
	for(int x : A){
		g = __gcd((unsigned)g,(unsigned)x);
		c[x]++;
	}
	if(g > 1){
		cout << "not coprime" << endl;
		return;
	}
	for(int i = 2; i <= m; i++){
		int cur = 0;
		for(int j = i; j <= m; j += i){
			cur += c[j];
		}
		if(cur > 1){
			cout << "setwise coprime" << endl;
			return;
		}
	}
	cout << "pairwise coprime" << endl;
	return;
}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 11128
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	cout<<((x+r<=w&&x>=r&&y+r<=h&&y>=r)?"Yes":"No")<<endl;
	return 0;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout  << "Balanced" << endl;    
  }
  else {
    cout  << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f(i,l,r) for(int i=l;i<r;i++)
using namespace std;
double dp[3000][3000],p[3000];
ll n;
double solve(ll i, ll h)
{
    if(dp[i][h]!=-1)    return dp[i][h];
    else
    {
        if(i==n)
        {
            if(h<=(n/2))    return 0;
            else
            {
                return 1;
            }
        }
        return dp[i][h]=p[i]*solve(i+1,h+1)+(1-p[i])*solve(i+1,h);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    f(i,0,3000) f(j,0,3000) dp[i][j]=-1;
    cin>>n;
    for(int i=0;i<n;i++)    cin>>p[i];
    double ans=solve(0,0);
    printf("%.10lf",ans);
    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[110000], d[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    int s = 0, ans = 1;
    rep(i, N - 1) {
        if (s < 0 && A[i] < A[i + 1]) { s = 0, ans++; }
        else if (s > 0 && A[i] > A[i + 1]) { s = 0, ans++; }
        else if (s == 0) { s = sign(A[i + 1] - A[i]); }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4356
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Hi[] = new int[N];
        
        for(int i = 0; i < N; i++){
            Hi[i] = sc.nextInt();
        }
        
        int rightMoveCount[] = new int[N];
        rightMoveCount[N-1] = 0;
        
        int rightMoveCountMax = 0;
        
        for(int i = N -2; i >= 0; i--){
            if(Hi[i] >= Hi[i+1]){
                rightMoveCount[i] = rightMoveCount[i+1] + 1;
            } else {
                rightMoveCount[i] = 0;
            }
            
            rightMoveCountMax = Math.max(rightMoveCount[i],rightMoveCountMax);
        }
        
        System.out.println(rightMoveCountMax);
    }
}


Measured memory_bytes: 48816
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(n) for(int i=0;i<n;i++)
#define rf(n) for(int i=n-1;i>=0;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
signed main()
{
	string s;
	cin>>s;
	string s1=s;
	reverse(all(s1));
	int n=(s.length()-1)/2;
	string temp=s.substr(0,n);
	string temp1=s.substr(((s.length()+3)/2)-1,n);
	string temp3=temp,temp4=temp1;
	reverse(all(temp));
    	reverse(all(temp1));
	if(temp3==temp && temp4==temp1 && s1==s)
	{
		cout<<"Yes";
	}
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N = one_int()

P=many_int()

count=0
mins=100000000
for i in range(N):
    flg=True
    if P[i]<mins:
        count+=1
        mins=P[i]

print(count)

Measured memory_bytes: 25716
#include <stdio.h>


int S[100000];
int T[100000];


int main(){

  int n,q,i,j,key,count=0;


  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    key = T[i];

    for(j=0;j<n;j++){
      if(S[j] == key){
	count++;
	break;
      }

    }
  }

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

  return 0;
}
    

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll unsigned long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	ll n, a, b;
	cin >> n >> a >> b;

	if (a==0)
	{
		cout << 0;
		return 0;
	}

	if (n%(a+b)==0)
	{
		ll t = n/(a+b);
		cout << t*a;
	}
	else
	{
		ll t = n/(a+b);
		ll res = n%(a+b);

		ll ans = 0;
		ans += t*a;

		ans += min(res, a);

		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 256
heap = []
while True:
    try:
        n = int(raw_input())
        if len(heap) == 0:
            heap.append(n)
        elif len(heap) == 1:
            if n <= heap[0]:
                heap.append(n)
            else:
                heap.insert(0, n)
        elif len(heap) == 2:
            if n > heap[0]:
                heap.insert(0, n)
            elif n <= heap[1]:
                heap.append(n)
            else:
                heap.insert(1, n)
        elif n > heap[2]:
            if n >= heap[0]:
                heap.insert(0, n)
            elif n >= heap[1]:
                heap.insert(1, n)
            else:
                heap.insert(2, n)
            heap.pop()
    except (EOFError):
        break
for num in heap:
    print num

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int n,k;
    cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    for (int i = k; i < n; ++i)
    {
    	if(a[i] > a[i-k]) {
    		show("Yes");
    	}
    	else{
    		show("No");
    	}
    }
    return 0;
}

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


int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> check(n, false);
    vector<int> count_wa(n);
    int ac=0, wa=0;
    for (int i=0; i<m; i++){
        int p;
        string ans;
        cin >> p >> ans;
        if (check[p]) continue;
        if (ans=="WA"){
            count_wa[p]++;
        }
        else{
            ac++;
            check[p] = true;
            wa += count_wa[p];
        }
    }
    cout << ac << " " << wa << endl;

    return 0;
}

Measured memory_bytes: 640
def calc (n):
  tmp = (n + 1) // 2
  if n % 2 == 0:
    ans = n ^ (tmp % 2)
  else:
    ans = tmp % 2
  return ans

def func (A, B):
  return calc(A-1) ^ calc(B)


a = list(map(int, input().split()))

A = a[0]
B = a[1]

ans = func(A, B)
print(ans)



Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=3011;
int f[MAXN][MAXN],fac[MAXN],pw2[MAXN],pw22[MAXN],ifac[MAXN],inv[MAXN],N,mod,F[MAXN],Ans,pw=-1;
int ksm(int a,int b){int ans=1;while(b){if(b&1) ans*=a,ans%=mod;a*=a,a%=mod;b>>=1;}return ans;}
int C(int a,int b){return fac[a]*ifac[b]%mod*ifac[a-b]%mod;}
signed main(){
    N=read(),mod=read();fac[0]=fac[1]=ifac[0]=ifac[1]=inv[1]=1;pw2[0]=pw22[0]=1;for(int i=1;i<MAXN;i++) pw2[i]=pw2[i-1]*2%mod,pw22[i]=pw22[i-1]*2%(mod-1);
    for(int i=2;i<MAXN;i++) fac[i]=fac[i-1]*i%mod,inv[i]=(mod-mod/i)*inv[mod%i]%mod,ifac[i]=ifac[i-1]*inv[i]%mod;
    f[0][0]=1;for(int i=1;i<MAXN;i++){for(int j=1;j<=i;j++) f[i][j]=f[i-1][j-1]+j*f[i-1][j],f[i][j]%=mod;}
    for(int i=0;i<=N;i++) for(int j=0;j<=i;j++) {F[i]+=C(N,i)*f[i+1][j+1]%mod*ksm(2,pw22[N-i])%mod*ksm(pw2[N-i],j)%mod,F[i]%=mod;}
    for(int i=0;i<=N;i++) pw*=-1,Ans=(Ans+pw*F[i]+mod)%mod;
    printf("%lld\n",Ans);return 0;
}


Measured memory_bytes: 49688
#include<stdio.h>
int main()
{
    int A,B,C,D,i,j;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    i=A>=C?A:C;
    j=B<=D?B:D;
    if(j-i>0)printf("%d",j-i);
    else printf("0");
    return 0;
}


Measured memory_bytes: 128
/* kop Chy_Chy*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll , ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define si(x)   scanf("%d", &x)
#define sl(x)   scanf("%lld", &x)
#define pi(x)   printf("%d\n", x)
#define pl(x)   printf("%lld\n", x)
#define deb(x)  cout<< #x << " = " << x << endl // debugging kop 
#define mp      make_pair
#define pb      push_back
#define MOD     1000000007
#define PI      acos(-1)
#define ff      first
#define ss      second
#define newline printf("\n")
ll binpow(ll a, ll b); // binary exponentiation kop
void prime_factorization(ll n, vll &prime_factors); // prime factorization kop
ll gcd(ll a, ll b); // greatest common divisor kop. Use LONG LONG
void speedup() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}

int main(){
    speedup();
    int t = 1;
    // cin>> t;
    while(t--){
        // khela final Mamooo
        ll a; cin>> a; 
        ll ans = a + binpow(a, 2) + binpow(a, 3);
        cout<< ans << "\n";
        
        
        
    }
    // kop kop return 
    return 0;
}


// kop kop functions:
ll binpow(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b & 1) res *= a;
        a = a* a;b = b >> 1;}
    return res;
}
/*---------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
/*---------------------------------------------------------------------------------------------------------------*/
void prime_factorization(ll n, vll &prime_factors){
    // first two step taking care of composite number
    // taking care of 2
    while(n%2 == 0){
        prime_factors.pb(2);
        n = n / 2;
    }
    // now n must be odd. And the remaining prime divisors are odd. so we start from 3 and increamenting 2
    for(ll i = 3; i <= sqrt(n); i = i + 2){
        while(n%i == 0){
            prime_factors.pb(i);
            n = n / i;
        }
    }
    // now we are taking care of  n is prime number and greater than 2
    if(n > 2){
        prime_factors.pb(n);
    }
}
/*---------------------------------------------------------------------------------------------------------------*/














Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;


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

int main() {
    int a, b, c = 0;
    cin >> a >> b;
    while(a <= b) {
        if(palin(a)) c++;
        a++;
    }
    printf("%d\n", c);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct Pyi {
    int p, y, i;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n + 1);
    vector<Pyi> pyi(m);
    for (int i = 0; i < m; ++i) {
        cin >> pyi[i].p >> pyi[i].y;
        pyi[i].i = i;
    }

    sort(begin(pyi), end(pyi), [](auto a, auto b) {
        return a.y < b.y;
    });    

    vector<string> ans(m);
    for (auto a : pyi) {
        string s(12, '0');
        char cs[13];
        sprintf(cs, "%06d%06d", a.p, ++cnt[a.p]);
        copy(begin(cs), end(cs), begin(s));
        ans[a.i] = s;
    }
    
    for (int i = 0; i < m; ++i) {
        cout << ans[i] << '\n';
    }
    return 0;
}

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

signed main(){
	int n,p;
	string str;
	cin>>n>>p>>str;
	if(p==2||p==5){
		int res=0;
		for(int i=0;i<str.size();i++)
			if((str[i]-'0')%p==0) res+=i+1;
		cout<<res<<'\n';
		return 0;
	}
	map<int,int> mp;
	reverse(str.begin(),str.end());
	int ans=0,sum=0,mul=1;
	mp[0]=1;
	for(int i=0;i<str.size();i++){
		sum=(sum+((str[i]-'0')*mul))%p;
		mul*=10;mul%=p;
		ans+=mp[sum];
		mp[sum]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1028
# ARC057A

import numpy as np

def resid(a, mean):
    res = 0
    for i in a:
        res += (i - mean)**2
    return int(res)

def f(n, a):
    mean = sum(a) / n
    mean_ceil = np.ceil(mean)
    mean_floor = np.floor(mean)
    print(min(resid(a, mean_ceil), resid(a, mean_floor)))

n = int(input())
a = list(map(int, input().split()))
f(n, a)


Measured memory_bytes: 20520
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;

// _ÀWð^Æ·é
typedef complex<double> P;
// ÎÌè`
#define PI 3.1415926535898

// e·éë·Ã
#define EPS (1e-10)
//XYÀW
#define X real()
#define Y imag()

//QÂÌdouble^Ìlªµ¢©Ç¤©
bool equal(double a, double b){
	return ( abs( a-b ) < EPS )? true : false ;
}
	
// Op`NX
class Triangle{

private:
	//Op`ÌR_ÌÀW
	P a, b, c;
	//Op`ÌRÓÌ·³
	double edgeA,edgeB,edgeC;
	//Op`ÌRpÌå«³(WA)
	double angleA,angleB,angleC;
	//]·è©çRÂÌpxðßéÖ
	double LawOfCosines(double a,double b, double c){
		return acos( (b*b+c*c-a*a) / (2.0*b*c) );
	}
	
public:
	//RXgN^(RÂÌ_ÆÓÆpxðú»)
	Triangle(P p1, P p2, P p3){
		a = p1;
		b = p2;
		c = p3;
		edgeB = abs(c-a);
		edgeA = abs(b-c);
		edgeC = abs(a-b);
		angleA = LawOfCosines(edgeA,edgeB,edgeC);
		angleB = LawOfCosines(edgeB,edgeC,edgeA);
		angleC = LawOfCosines(edgeC,edgeA,edgeB);
	}
	double getAngleC(){//pCÌpxðÏ¦·
		return angleC;
	}
};

int main(){
	double x1, x2, x3, y1, y2, y3, xp, yp, angle;

	while( cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp ){
		P a( x1 , y1 );
		P b( x2 , y2 );
		P c( x3 , y3 );
		P p( xp , yp );
		Triangle Tr1(a,b,p);
		Triangle Tr2(b,c,p);
		Triangle Tr3(c,a,p);
		angle = Tr1.getAngleC() + Tr2.getAngleC() + Tr3.getAngleC();
		( equal( 2.0*PI , angle) )? cout << "YES" : cout << "NO" ;
		cout << endl;
	}
}

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

int main(){
  int a,b,c,k;
  cin >>a >>b >>c >>k;
  int sum = a+b+c;
  int m = max(max(a,b),c);
  sum += m*((1<<k)-1);
  cout << sum << endl;
  return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n, k, ans = 0;
    cin >> n >> k;

    rep(i, 0, n) {
        int h;
        cin >> h;
        if (h >= k) { ++ans; }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a < b:
    if a < c:
        if c < b:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if b < c:
        if c < a:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int n,k;
  cin>>n>>k;
  P p[n];
  for(int i=0;i<n;i++) cin>>p[i].first>>p[i].second;
  sort(p,p+n);
  for(int i=0;i<n;i++){
    if(k>p[i].second) k-=p[i].second;
    else{
      cout<<p[i].first<<endl;
      return 0;
    }
  }
  return 0;
}

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

#define int long long

using namespace std;

typedef pair <int, int> ii;
typedef pair <ii, ii> iiii;

map <iiii, int> mm;
int h, w, n, ans[10];
vector <ii> v;

bool inside (int x, int y) {
    return (x >= 1 && x <= h && y >= 1 && y <= w);
}

signed main(){
    scanf("%lld %lld %lld", &h, &w, &n);
    for (int i = 1; i <= n; i++) {
        int x, y;
        scanf("%lld %lld", &x, &y);
        v.push_back(make_pair(x, y));
    }

    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < v.size(); i++) {
        for (int dx = -2; dx <= 0; dx++) {
            for (int dy = -2; dy <= 0; dy++) {
                int start_x = v[i].first + dx;
                int start_y = v[i].second + dy;
                int end_x = start_x + 2;
                int end_y = start_y + 2;

                if (!inside(start_x, start_y) || !inside(end_x, end_y)) continue;
                mm[make_pair(make_pair(start_x, start_y), make_pair(end_x, end_y))]++;
            }
        }
    }

    for (map <iiii, int>::iterator it = mm.begin(); it != mm.end(); it++) ans[it->second]++;
    int sum = 0;
    for (int i = 1; i <= 9; i++) sum += ans[i];
    ans[0] = (h - 2) * (w - 2) - sum;
    for (int i = 0; i < 10; i++) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 72176
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int n, a, i, min, max;
	long long sum;

	cin >> n;
	cin >> a;

	min = a;
	max = a;
	sum = a;
	
	for (i = 1; i < n; i++) {
		cin >> a;
		if (a < min)
			min = a;
		
		if (a > max)
			max = a;

		sum += a;
	}

	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en,h) for(int i=st; i<=en; i+=h)
#define eb emplace_back
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,ans,p,q;
string s,sb;
bool k;
int main(){
  cin.tie(nullptr); ios::sync_with_stdio(false);

  cin>>n>>s;
  int l=0,r=1;
  while(r<n){
    if(r<=l)r++;
    //cout<<l<<' '<<r<<' ';
    sb=s.substr(l,r-l);
    //cout<<sb<<' ';
    k=false;
    for (int i = 0; i < n-r; i++){
      //cout<<s.substr(r+i,r-l)<<' ';
      if(s.substr(r+i,r-l)==sb){k=true; break;}
    }
    if(k){
      cmax(ans,r-l); r++;
    }else l++;
    //cout<<ans<<'\n';
  } 
  END
}

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


long long int fn[200001];
int n;


void insert(int i,long long int v){
	for(int x=i;x<=n;x+=x&-x){
		fn[x]=max(fn[x],v);
	}
}

long long int query(int i){
	long long int ans=0;
	for(int x=i;x>0;x-=x&-x){
		ans=max(ans,fn[x]);
	}
	return ans;
}

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

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

	cin >> n;
	long long int a[n],h[n],dp[n];
	for(int i=0;i<n;i++) cin >> h[i];
	for(int i=0;i<n;i++) cin >> a[i];
	long long int ans=0;
	for(int i=0;i<n;i++){
		long long int temp = query(h[i]-1);
		dp[i] = temp+a[i];
		insert(h[i],dp[i]);
		ans=max(ans,dp[i]);
	}
	cout << ans;



	
	




	
	




	

}


Measured memory_bytes: 6528
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 998244353
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

int main()
{
    Minato_Namikaze
    
    
    ll n;
    cin >> n;
    ll x;
    ll ans = 0, mx = INF;
    for(ll i = 0; i < n ; ++i)
    {
        cin >> x;
        if(x < mx)
          ans++;
        mx = min(mx,x);
    }
    cout << ans ;


    return 0;
    
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll counts[100100];

/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  int N;
  //vector<ll> count(N+1, 0);
  cin >> N;
  int M=0;
  rep(i, N){
    int tmp; cin >> tmp;
    if(i==0 and tmp!=0){
      cout << 0;
      return 0;
    }
    counts[tmp]+=1;
    M = max(M, tmp);
  }
  
  ll ans = 1;
  for(int i=M;i>=1;i--){
    //cout << counts[i-1] << " " << counts[i] << endl;
    ans = mod(ans * modpow( counts[i-1], counts[i], 998244353), 998244353);
  }
  if(counts[0] == 1){
    cout << mod(ans, 998244353);
  }else{
    cout << 0;
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<lint, lint>;

// cout << fixed << setprecision(12)

lint modpow(lint a, lint n, lint m = MOD){
  lint ans = 1;
  while(n>0){
    if(n%2==1) ans *= a; 
    ans %= m;
    a *= a; 
    a %= m;
    n /= 2;
  }
  return ans;
}

lint inv(lint a, lint m = MOD){
  return modpow(a, m-2, m);
}

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

int main(){
  lint N; cin>>N;
  lint money = 1000;
  // lint stock = 0;
  vi A(N);
  for(lint i=0; i<N; i++) cin>>A[i];
  
  for(lint i=1; i<N; i++){
    if(A[i]>A[i-1]){
      lint tmp = money / A[i-1];
      money += tmp * (A[i]-A[i-1]);
    }
  }
  
  cout << money << endl;
}
      
    
    
    
  

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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    string line;
    cin >> line;
    cout << '#' << line << '#' << endl;
  }
  
  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  
  cout << endl;
  
  
}

Measured memory_bytes: 256
N = input()

lst_A = input().split()

ans = 0

flag = True

for i in range(len(lst_A)):
    lst_A[i] = int(lst_A[i])

while 1:
    for i in range(len(lst_A)):
        W = lst_A[i] % 2
        if W == 1:
            flag = False
            break

    if flag == False:
        break

    for i in range(len(lst_A)):
        lst_A[i] = lst_A[i] / 2

    ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//Binary Indexed Tree
//添字は1から始まる！！
//v[a] += w
ll n; //bit[1]~bit[n]を使用するということ
vector<vector<ll>> bit(500005,vector<ll>(26,0));
void add(ll a, ll w, char ch){
    for(ll x=a; x<=n; x+=x&-x) bit[x][ch-'a']+=w;
}
//v[1]+...+v[a]
ll sum(ll a, char ch){
    ll ret=0;
    for(ll x=a; x>0; x-=x&-x) ret+=bit[x][ch-'a'];
    return ret;
}//v_x=1で初期化はbit[x]=x&-x;
//v_xで初期化はfor(int x=1; x<n; ++x) bit[x+(x&-x)]+=bit[x];

int main(){
    cin>>n;
    string s; cin>>s;
    ll q; cin>>q;
    rep(i,n){
        add(i+1,1,s[i]);
    }
    rep(k,q){
        ll id; cin>>id;
        if(id==1){
            ll i; char c; cin>>i>>c;
            add(i,-1,s[i-1]);
            add(i,1,c);
            s[i-1]=c;
        }else{
            ll l,r; cin>>l>>r;
            ll cnt=0;
            rep(j,26){
                if(sum(r,'a'+j)-sum(l-1,'a'+j)>0) cnt++;
            }
            cout<<cnt<<endl;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
  int x;
  cin >> x;
  if (x <= 599) {
    cout << 8 << endl;
  } else if (x <= 799) {
    cout << 7 << endl;
  } else if (x <= 999) {
    cout << 6 << endl;
  } else if (x <= 1199) {
    cout << 5 << endl;
  } else if (x <= 1399) {
    cout << 4 << endl;
  } else if (x <= 1599) {
    cout << 3 << endl;
  } else if (x <= 1799) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

using VL = vector<long long>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;

void show(VVL &vv) {
	cout << "------" << endl;
	for (auto v: vv) {
		for (auto x: v) {
			printf("%10lld ", x);
		}
		printf("\n");
	}
}

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

	vector<int> w(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}

	VVL dp(N + 1, VL(W+1, -1));
	dp[0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < W; j++) {
			if (dp[i][j] == -1) {
				continue;
			}

			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);

			int nw = j + w[i];
			if (nw <= W) {
				dp[i+1][nw] = max(dp[i+1][nw], dp[i][j] + v[i]);
			}
		}
	}

	// show(dp);

	long long ans = *max_element(dp[N].begin(), dp[N].end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 80256
/*input
2
1 2
2 3
*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}

void solve(){
    ll i,j,k;
    ll n;
    cin>>n;
    ll a[n],b[n];
    ll x[n],y[n];
    rep(i,0,n)cin>>a[i]>>b[i];
    sort(a,a+n),sort(b,b+n);
    if(n%2)cout<<b[(n+1)/2-1]-a[(n+1)/2-1]+1<<endl;
    else {
        cout<<b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1<<endl;
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}




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

using namespace std;

int main(int argc, char *argv[]) {
	int N = 0;  // N人が参加
	int D = 0;  // D日間合宿
	int X = 0;  // 終了後に残っていたチョコレート
	cin >> N >> D >> X;

	int rate = 0;
	std::map<int, std::vector<int>> user_rates_map;
	for (int i = 0; i < N; i++) {
		cin >> rate;
		std::vector<int> rates;
		for (int j = 0, k = 0; j <= D; j = k * rate + 1, k++) {
			if (j != 0) {
				rates.push_back(j);
			}
		}
		user_rates_map[i] = rates;
	}
	
	for (auto pair: user_rates_map) {
		for (auto day: pair.second) {
			X++;
		}
	}

	cout << X << endl;
	return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())

alist = [1, 3, 5, 7, 8, 10, 12]
blist = [4, 6, 9, 11]
clist = [2]

xg = ''
yg = ''

for i in alist:
    if i == x:
        xg = 'A'

    if i == y:
        yg = 'A'

for i in blist:
    if i == x:
        xg = 'B'

    if i == y:
        yg = 'B'

for i in clist:
    if i == x:
        xg = 'C'

    if i == y:
        yg = 'C'

if xg == yg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    soundhound2018SummerQualB()
}

fun soundhound2018SummerQualB() {
    val s = readLine()!!
    val w = readLine()!!.toInt()

    val answer = s.filterIndexed { index, c -> index % w == 0 }

    println(answer)
}


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

int main()
{
    int N;
    double ans;
    
    cin >> N;
    for(int i=0; i<N; i++){
        double a;
        cin >> a;
        ans += 1/a;
    }
    cout.precision(17);
    cout << fixed << 1/ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

ll dp[55][55][2510];

int main(void){
  int n,a;
  int x[50];
  scanf("%d %d",&n,&a);
  int i,ma=0;
  for(i=0;i<n;i++){
    scanf(" %d",&x[i]);
    ma += x[i];
  }
  for(i=0;i<55;i++){
    dp[i][0][0] = 1ll;
  }
  int j,k,s;
  for(j=0;j<n;j++){
    for(k=1;k<=n;k++){
      for(s=1;s<=ma;s++){
        if(s<x[j]) dp[j+1][k][s] = dp[j][k][s];
        else  dp[j+1][k][s] = dp[j][k][s] + dp[j][k-1][s-x[j]];
      }
    }
  }
  ll ans=0;
  for(k=1;k<=n;k++){
    ans += dp[n][k][k*a];
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 49664
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso
  #ifndef ONLINE_JUDGE
  //ffe
  #endif
  ll n,q;
  cin >> n;
  ll a[200010];
  ll fr[200010];
  memset(fr,0,sizeof(fr));
  ll sum = 0;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    fr[a[i]]++;
  }
  for(int i=0;i<n;i++) {
    sum += a[i]; 
  }

  cin >> q;
    ll b,c;
  for(int i=0;i<q;i++) {
    cin >> b >> c;
    sum -= fr[b]*b;
    sum += fr[b]*c;
    fr[c] += fr[b];
    fr[b] = 0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 5992
A, V = [int(n) for n in input().split()]
B, W = [int(n) for n in input().split()]
T = int(input())
 
if V <= W:
    print('NO')
    exit()
    
d = abs(A - B)

if V > W and d <= (V - W) * T:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9052
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
// int gcd(int a, int b) { 
//     if (a == 0) return b; 
//     return gcd(b % a, a); 
// }
// ll power(int base, int power) {
// 	ll prod = 1;
// 	ll b = base;
// 	while(power) {
// 		if (power & 1) {
// 			prod = f(prod*b);
// 		}
// 		b = f(b*b);
// 		power/=2;
// 	}
// 	return prod;
// }
ll n, k;
void solve() {
	cin >> n >> k;
	set<ll> s;
	ll best = n;
	while(true) {
		if (n == 0) break;
		if (s.find(n) != s.end()) break;
		s.insert(n);
		if (n > k) {
			n = n % k;
		} else {
			n = k - n;
		}
		best = min(n,best);
	}
	cout << best << endl;
}
int main() {
	// int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 256
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
dh = []
dw = []
for i in range(h):
  if not('#' in a[i]):
    dh.append(i)
for j in range(w):
  cal = ''
  for k in range(h):
    cal += a[k][j]
    if k == h-1 and not('#' in cal):
      dw.append(j)

for hl in sorted(dh, reverse=True):
  a.pop(hl)

for wl in sorted(dw, reverse=True):
  for i in range(h-len(dh)):
    a[i].pop(wl)

for i in range(len(a)):
  print(''.join(a[i]))

Measured memory_bytes: 9296
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	lli xyz[3], sp[3], n;
	cin >> xyz[0] >> xyz[1] >> xyz[2] >> sp[0] >> sp[1] >> sp[2] >> n;
	
	vector<lli> num(n, 0);
	num[0] = 1;
	lli scale = 1;
	for(int d=0; d<3; d++){
		lli len[2] = {sp[d], xyz[d]-sp[d]-1};
		vector<lli> add(n, 0);
		for(int i=0; i<2; i++){
			for(int j=0; j<n; j++){
				add[j] += scale*(len[i]/n);
			}
			len[i] %= n;
			for(int j=0; j<n; j++){
				for(int k=0; k<len[i]; k++){
					add[(j+k+1)%n] += num[j];
				}
			}
		}
		for(int i=0; i<n; i++){
			num[i] += add[i];
		}
		scale *= xyz[d];
	}
	
	for(int i=0; i<n-1; i++){
		cout << num[i] << " ";
	}
	cout << num[n-1] << endl;
	return 0;
}



Measured memory_bytes: 3120
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll x; cin >> x; 
  if(x % 2 == 0) x--;
  
  cout << x/2 << endl;
  
  
}

Measured memory_bytes: 3636
arr = [0, 0]
while line = gets
    a, b, c = line.chomp.split(',').map(&:to_i)
    arr[0] += 1 if a ** 2 + b ** 2 == c ** 2
    arr[1] += 1 if a == b
end
puts arr[0]
puts arr[1]


Measured memory_bytes: 6868
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 100, INF = 1e9, MOD = 1e9 + 7;

bool gt[SIZE];

int main()
{
    fastInp;

    string s;

    cin >> s;
    gt[s.size()] = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (i < s.size() - 4 && gt[i + 5] == 1 && s[i] == 'd' && s[i + 1] == 'r' && s[i + 2] == 'e' && s[i + 3] == 'a' && s[i + 4] == 'm') gt[i] = 1;

        if (i < s.size() - 4 && gt[i + 5] == 1 && s[i] == 'e' && s[i + 1] == 'r' && s[i + 2] == 'a' && s[i + 3] == 's' && s[i + 4] == 'e') gt[i] = 1;

        if (i < s.size() - 5 && gt[i + 6] == 1 && s[i] == 'e' && s[i + 1] == 'r' && s[i + 2] == 'a' && s[i + 3] == 's' && s[i + 4] == 'e' && s[i + 5] == 'r') gt[i] = 1;

        if (i < s.size() - 6 && gt[i + 7] == 1 && s[i] == 'd' && s[i + 1] == 'r' && s[i + 2] == 'e' && s[i + 3] == 'a' && s[i + 4] == 'm' && s[i + 5] == 'e' && s[i + 6] == 'r') gt[i] = 1;
    }

    if (gt[0] == 1) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 3864