akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500*i + 100*j + 50*k == X) res++;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

//KULASIS
public class Main{

	int[] f(int x){
		int[] r = new int[4];
		int k = 0;
		while(x>0){
			r[k++] = x%4;
			x/=4;
		}
		return r;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		int[] p = {0, 60, 70, 80};
		int[][] k = new int[256][];
		for(int i=0;i<256;i++)k[i]=f(i);
		int T = sc.nextInt();
		while(T--!=0){
			int[][] a = new int[5][5];
			for(int i=0;i<5;i++)for(int j=0;j<5;j++)a[i][j]=sc.nextInt()-1;
			int[] dp = new int[256];
			for(int i=0;i<256;i++){
				for(int j=0;j<5;j++){
					int s = a[0][j];
					if(s==-1)continue;
					if(j<4)s+=k[i][j];
					if(j>0)s+=k[i][j-1];
					dp[i] += p[s%4];
				}
			}
			for(int n=1;n<4;n++){
				int[] next = new int[256];
				//niÚÌóÔ
				for(int i=0;i<256;i++){
					int[] pre = k[i];
					int max = 0;
					//n-1iÚÌóÔ
					for(int j=0;j<256;j++){
						int[] now = k[j];
						int sum = 0;
						for(int v=0;v<5;v++){
							if(a[n][v]==-1)continue;
							int s = a[n][v];
							if(v<4)s+=now[v]+pre[v];
							if(v>0)s+=now[v-1]+pre[v-1];
							sum += p[s%4];
						}
						max = Math.max(max, dp[j]+sum);
					}
					next[i] = max;
				}
				dp = next;
			}
			int res = 0;
			for(int i=0;i<256;i++){
				int sum = 0;
				for(int j=0;j<5;j++){
					if(a[4][j]==-1)continue;
					int s = a[4][j];
					if(j<4)s+=k[i][j];
					if(j>0)s+=k[i][j-1];
					sum += p[s%4];
				}
				res = Math.max(res, dp[i]+sum);
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

int t;
ll a, b, c, d;

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

bool solve(){
    if(a<b) return false;
    if(d<b) return false;

    if(c>=b) return true;

    ll g=gcd(b,d);
    ll chk = a%b + (b-1-a%b)/g*g;
    return chk<=c;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>t;
    for(int i=1; i<=t; i++){
        cin>>a>>b>>c>>d;
        cout<<(solve() ? "Yes" : "No")<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=998244353;
signed main(){
    int n,d[100000];
    map<int,int>mp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
        mp[d[i]]++;
    }
    if(d[0]!=0){
        cout<<0<<endl;
        return 0;
    }
    int ans=1;
    for(int i=1;i<n;i++)
        (ans*=mp[d[i]-1])%=mod;
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<vector<ll>> a(n, vector<ll>(m));

    for(i = 0; i < n; i++) {
        for(j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    vector<ll> used(m + 1, 0), sport(m + 1, 0);
    for(i = 0; i < n; i++) {
        sport[a[i][0]]++;
    }
    ll ret = 0, now;
    for(i = 0; i < m + 1; i++) {
        ret = max(ret, sport[i]);
        if(ret==sport[i])now = i;
    }
    used[now] = 1;
    for(k = 0; k < m - 2; k++) {
        for(i = 0; i < m + 1; i++) {
            sport[i] = 0;
        }
        for(i = 0; i < n; i++) {
            j = 0;
            while(used[a[i][j]] == 1)
                j++;
            sport[a[i][j]]++;
        }
        ll tret = 0, now = 0;
        for(i = 0; i < m + 1; i++) {
            tret = max(tret, sport[i]);
            if(tret==sport[i])now = i;
        }
        ret = min(ret,tret);
        used[now] = 1;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>

#define Rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())

#define eb emplace_back
#define dbg(x) cout<<#x" = "<<((x))<<endl
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll N;

  cin >> N;

#ifdef DEBUG
  cout << "N=" << N << endl;
#endif

  unordered_map<int, int> stato;
  unordered_map<int, int> state;
  Rep(i, N){
    int k;
    cin >> k;
    if(i % 2 == 0){
      if(state.find(k) == state.end()) state[k] = 0;
      state[k]++;
    } else {
      if(stato.find(k) == stato.end()) stato[k] = 0;
      stato[k]++;
    }
  }

  int maxe = 0;
  int maxe2 = 0;
  int maxeval = 0;
  int maxo = 0;
  int maxo2 = 0;
  int maxoval = 0;
  for(auto i = state.begin(); i != state.end(); i++){
    if((*i).sc > maxe) {
      maxe2 = maxe;
      maxe = (*i).sc;
      maxeval = (*i).fs;
    } else if ((*i).sc > maxe2) {
      maxe2 = (*i).sc;
    }
  }
  for(auto i = stato.begin(); i != stato.end(); i++){
    if((*i).sc > maxo) {
      maxo2 = maxo;
      maxo = (*i).sc;
      maxoval = (*i).fs;
    } else if ((*i).sc > maxo2) {
      maxo2 = (*i).sc;
    }
  }

  
  if(maxeval == maxoval) cout << min(N - maxe - maxo2, N - maxe2 -maxo) << endl;
  else cout << N - maxe - maxo << endl;

  
  return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int n;
  cin >> n;
  int a[200010];
  for (auto i = 0; i < n; ++i) {
    cin >> a[i];
  }
  deque<int> Q;
  bool is_back = true;
  for (auto i = 0; i < n; ++i) {
    if (is_back) {
      Q.push_back(a[i]);
    } else {
      Q.push_front(a[i]);
    }
    is_back = !is_back;
  }
  vector<int> V;
  for (auto x : Q) {
    V.push_back(x);
  }
  if (!is_back) {
    reverse(V.begin(), V.end());
  }
  for (auto i = 0; i < n; ++i) {
    cout << V[i];
    if (i < n-1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}


Measured memory_bytes: 4728
def examC():
    N = I()
    ans = (N // 11) * 2
    cur = N%11
    if 1<=cur:
        ans += 1
    if 6<cur:
        ans +=1
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 3572
n,k = map(int,input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


limit = min(k,n-k+1)
temp = n-k+1


for i in range(1,k+1):
    if i > limit:
        print(0)
    else:
        first = cmb(temp,i,mod)
        second = cmb(k-1,i-1,mod)
        ans = first*second
        ans = ans%mod
        print(ans)

Measured memory_bytes: 43120
fn main() {
    let n: u64 = read();
    let mut power = 1u64;

    for i in 1..n + 1 {
        power = power * i % 1_000_000_007
    }
    println!("{}", power);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    use std::io::prelude::*;

    let stdin = std::io::stdin();
    let s: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse().ok().unwrap()
}


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

int main (){
  int K, N;
  cin >> K >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p.at(i);
  
  int ans = 0;
  
  for (int i = 0; i < N; i++){
    int d = 0;
    if (i == 0){
      d += p.at(N-1) - p.at(0);
      ans = d;
    }
    else {
      d += p.at(i-1) + K - p.at(i);
    }
    if (ans > d) ans = d;
  }    
  cout << ans << endl;
}

Measured memory_bytes: 1024
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 100001;

void solve()
{
    int n;
    
    cin>>n;

    ll a[n];
    loop(i,0,n){
        cin>>a[i];
    }

    ll ans=0;
    loop(i, 1, n)
    {
       ans += max(a[i-1]-a[i],(ll)0);
       a[i] = max(a[i],a[i-1]);
    }

    cout << ans << "\n";
}
int main()
{
    io;

    solve();

    return 0;
}


Measured memory_bytes: 5212
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const scBufSize = 1 * 1024 * 1024 // 1MB
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, scBufSize), scBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func main() {
	n := scani()
	k := scani()
	l := scani()

	road := NewUnion(n)
	rail := NewUnion(n)
	for i := 0; i < k+l; i++ {
		o, d := scanRoad()
		if i < k {
			road.unite(o, d)
		} else {
			rail.unite(o, d)
		}
	}
	group := map[[2]int]int{}
	for i := 0; i < n; i++ {
		road.parent[i] = road.root(i)
		rail.parent[i] = rail.root(i)
		group[[2]int{road.parent[i], rail.parent[i]}]++
	}
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = strconv.Itoa(group[[2]int{road.parent[i], rail.parent[i]}])
	}
	fmt.Println(strings.Join(ret, " "))
}

type union struct {
	parent []int
}

func NewUnion(n int) union {
	u := union{parent: make([]int, n)}
	for i := 0; i < n; i++ {
		u.parent[i] = i
	}
	return u
}

func (u union) root(x int) int {
	if u.parent[x] == x {
		return x
	}
	u.parent[x] = u.root(u.parent[x])
	return u.parent[x]
}

func (u union) unite(x, y int) {
	r1 := u.root(x)
	r2 := u.root(y)
	if r1 == r2 {
		return
	}
	u.parent[r2] = r1
}

func scani() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanRoad() (o, d int) {
	o = scani() - 1
	d = scani() - 1
	return
}


Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

int main(int argc, char *argv[]) {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	int ans = numeric_limits<int>::max();
	for (int i = 0; i < N; i++) {
		vector<vector<int>> seq(1);
		for (int j = 0; j < N; j++) {
			if (A[j] >= A[i]) {
				seq.back().push_back(A[j]);
			} else {
				if (!seq.back().empty())
					seq.push_back(vector<int>());
			}
		}

		vector<int> candid;
		for (auto &s : seq) {
			if (s.size() < K) continue;
			sort(begin(s), end(s)); 
			candid.insert(end(candid), begin(s), end(s) - (K - 1));
		}

		sort(begin(candid), end(candid));
		if (candid.size() >= Q)
			ans = min(ans, candid[Q - 1] - A[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define mod 1000000007
#define MOD mod
#define sec setprecision
#define RAND_MAX 0x7fffffff
using namespace std;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	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;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a)%mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

std::vector<std::vector<long long>> comb(int n, int r)
{
    std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
    for (int i = 0; i < v.size(); i++)
    {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++)
    {
        for (int k = 1; k < j; k++)
        {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
    return v;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> vc(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vc[i];
    }
    sort(vc.begin(), vc.end());
    // for (int i = 0; i < n; i++)
    // {
    //     cout << vc[i] << endl;
    // }
    ll store = vc[n - 1];
    double center;
    if (store % 2 == 0)
        center = store / 2;
    else
        center = store / 2 + 0.5;
    ll m = INF;
    ll flag = -1;
    cout << vc[vc.size() - 1] << " ";
    for (int i = 0; i < n - 1; i++)
    {
        if (m > abs(center - vc[i]))
        {
            flag = i;
            m = abs(center - vc[i]);
        }
    }
    cout << vc[flag] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define repe(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll x;
  cin >> x;
  ll cnt = 0;
  ll y = 100;
  while(1){
    if(y >= x) break;
    y = y*1.01;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main(){
int N,K;
  cin >>N>>K;
  int p=0;
  int A=1;
  while(p<N){
    if (A<K){
      A=A*2;
    }else{
      A+=K;
    }
    p++;
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    size_t n;
    cin >> n;
    for (size_t i = 0; i < n; ++i) {
        char c;
        cin >> c;
        if (c == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


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

int main() {
  long n,aaa=-1,bbb=1,ans=0;
  cin >> n;
  vector<long> a(n+1);
  for(long i=0;i<=n;i++) cin >> a[i];
  for(long i=0;i<=n;i++) {
    aaa+=a[i];
  }

  for(long i=0;i<=n;i++) {
    ans+=bbb;
    bbb-=a[i];
    if(bbb<0) {
      ans=-1;break;
    }
    long x=min(aaa,bbb);
    bbb+=x;
    aaa-=x;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	int res;
	for(int i=1;i<=b;i++){
		res=i*a;
		if(res%b==c){
		 cout<<"YES";
		return 0;
		}
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FALSE 0
#define TRUE 1

int main(){
    int A, B, C;
    int X;
    // vector<int64_t>     vP(100010);
    // map<int64_t, int>   mP;
    int res;

    cin >> A >> B >> C;
    cin >> X;

    res = 0;
    for (int a=0; a<=A; a++){
    for (int b=0; b<=B; b++){
    for (int c=0; c<=C; c++){
        if (a*500 + b*100 + c*50 == X)
            res++;
    }
    }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#python3
def main():
    s = input()
    flag = True 
    while flag:
        flag = False
        if s[-7:] == "dreamer":
            s = s[:-7]
            flag = True
        if s[-6:] == "eraser":
            s = s[:-6]
            flag = True
        if s[-5:] == "erase":
            s = s[:-5]
            flag = True
        if s[-5:] == "dream":
            s = s[:-5]
            flag = True
    if not s:
        print("YES")
    else:
        print("NO")

main()

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

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
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>;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int x  ,y;
   cin >> x >> y;
   for(int i = 0 ; i <= x ; ++i){
      int cr = i * 2 + (x - i) * 4;
      if(cr == y){
         cout << "Yes\n";
         return 0;
      }
   }
   cout << "No\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 28 21:00:07 JST 2020
 **/

signed main() {
    Int n, X, Y;
    std::cin >> n >> X >> Y;
    X--, Y--;
    std::vector<Int> cnt(n);
    REP(i, n) {
        REP(j, i + 1, n) {
            cnt[std::min(j - i, abs(i - X) + abs(j - Y) + 1LL)]++;
        }
    }
    REP(i, 1, n) std::cout << cnt[i] << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define infi            1e9
#define infl            1e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)
 
using namespace std;
 
inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
// inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}
 
// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle//freopen("in.txt", "r", stdin);//#endif
    //freopen("in.txt", "r", stdin);

    string str;
    cin >> str;

    int cnt1=0,cnt2=0;
    sort(str.begin(),str.end());
    loop(i,str.length()){
        if(str[i]==str[0])cnt1++;
        else if(str[i]==str[3])cnt2++;
    }    
    if(cnt1==2 && cnt2==2)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    int N;
    int d[110];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> d[i];
    }

    set <int> values;
    for (int i = 0; i < N; i++){
        values.insert(d[i]);
    }

    cout << values.size() << endl;
}

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

int main(){
    bool cards[4][14];
    int n,rank;
    char mark;
    for(int s = 0; s < 4; s++){
        for(int r = 1; r <= 13; r++){
            cards[s][r] = 0;
        }
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> mark >> rank;
        if(mark == 'S') cards[0][rank] = 1;
        if(mark == 'H') cards[1][rank] = 1;
        if(mark == 'C') cards[2][rank] = 1;
        if(mark == 'D') cards[3][rank] = 1;
    }
    for(int j = 0; j < 4; j++){
        for(int k = 1; k <=13; k++){
            if(cards[j][k]) continue;
            if(j == 0) cout << "S " << k << endl;
            if(j == 1) cout << "H " << k << endl; 
            if(j == 2) cout << "C " << k << endl; 
            if(j == 3) cout << "D " << k << endl;  
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int d[n][2];
    int counter = 0;
    for(int i=0;i<n;i++){
        cin >> d[i][0] >> d[i][1];
        if( d[i][0] == d[i][1]){
            if(counter<2)
                counter++;
            else{
                cout << "Yes";
                return 0;
                }
        }
        else
            counter = 0;
    }
    cout <<"No";
    return 0;

}

Measured memory_bytes: 3624
#include <iostream>

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

using namespace std;

int a[1123456];

int main(){
	int n;
	cin >> n;
	
	REP(i,n-1){
		int c;
		cin >> c;
		
		a[c-1]++;
	}
	REP(i,n){
		cout << a[i] << endl;
	}
	
}

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

int main(){
  int n,r;
  cin >> n >> r;
  if(n>=10){
    cout << r << endl;
    return 0;
  }
  cout << r+100*(10-n) << endl;
  return 0;
}


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

int main() {
  int n;
  int a[12], b[12];
  map<int, int> mp;

  while(cin >> n, n) {
    for(int i=0; i<n; i++) cin>>a[i];
    int cnt = 0;
    while(1) {
      mp.clear();
      for(int i=0; i<n; i++) mp[a[i]] ++;
      for(int i=0; i<n; i++) b[i] = mp[a[i]];

      bool fin = true;
      for(int i=0; i<n; i++) if( a[i] != b[i] ) fin = false;
      if( fin ) break;
      cnt ++;
      for(int i=0; i<n; i++) a[i] = b[i];
    }

    cout << cnt << endl;
    for(int i=0; i<n-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;
  }
  
  return 0;
}

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

int main(){
 
  long long N,X,T,res;
  string S;
  cin >> S;

  res = 0;
  for(int i=0;i<S.size();i++)
    res += S[i] - '0';
  
  if (res % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  //cout << res << "\n";

  return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)
void yesno(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
ll power(ll x, ll n, ll m){if(n==0)return 1;ll u=power(x,n/2,m);u=(u*u)%m;if(n%2)u=(u*x)%m;return u;}



int main (){
fastio;

int n;
cin>>n;

ll cnt[N];
memset(cnt,0,sizeof cnt);

ll sum=0;
int i;
for(i=0;i<n;i++){
    int temp;
    cin>>temp;
    cnt[temp]++;
    sum+=temp;
}

int q;
cin>>q;

while(q--){
    ll x,y;
    cin>>x>>y;
    sum-=cnt[x]*x;
    sum+=cnt[x]*y;
    cnt[y]+=cnt[x];
    cnt[x]=0;
    cout<<sum<<endl;
}



}


Measured memory_bytes: 4412
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
        long ans = 0;
        for(int alpha = 1; K+alpha<=N;++alpha){
            int b = K+alpha;
            int n = (N-K)/b;
            ans += n*alpha;
            if(K+n*b<=N)ans += Math.min(N, K+n*b+alpha-1) - (K+n*b)+1;
        }
        if(K==0)ans -=N;
        System.out.println(ans);
    }   
}

Measured memory_bytes: 23764
<?php
list($a,$b,$c)=explode(" ",trim(fgets(STDIN)));
if($a%2==1 or $b%2==1 or $c%2==1){
  echo 0;
  exit;
}
if($a==$b and $b==$c){
  echo -1;
  exit;
}
$ans=0;
while(1){
  ++$ans;
  $x=$a/2+$b/2;
  $y=$b/2+$c/2;
  $z=$c/2+$a/2;
  $a=$x;
  $b=$y;
  $c=$z;
  if($a%2==1 or $b%2==1 or $c%2==1){
    echo $ans;
    exit;
  }
}

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

int solve(int a, int b, int c) {
    vector<char> vis(60, 0);
    for (int t = 0, s = 0;;) {
        if (vis[s]) return -1; else vis[s] = 1;
        if (s <= c && c <= s + a) return 60 * t + c;
        if ((s += a + b) >= 60) s -= 60, t++;
    }
}

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << solve(a, b, c) << endl;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int ot = n/100;
		int tf = n%100;
		String result = "";
		if(ot > 0 && ot < 13) {//12xx
			if(tf > 0 && tf < 13) {//1212
				result = "AMBIGUOUS";
			} else {//1245
				result = "MMYY";
			}
		} else { //19XX
			if(tf > 0 && tf < 13) {//1905
				result = "YYMM";
			} else {//1925
				result = "NA";
			}
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
a,b = gets.split.map(&:to_i)


ans = 2018

if (b-a) < ans
  (b-a).times do |i|
    (b-a-i).times do |s|
      if ans > ((a+i)*(a+s+i+1)).modulo(2019)
        ans = ((a+i)*(a+s+i+1)).modulo(2019)
      end
    end
  end
else
  ans = 0
end

puts ans


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M;
    cin >> N >> M;
    string A, B;
    cin >> A >> B;
    ll l = lcm(N, M);
    bool ok = true;
    ll n1 = l / N, m1 = l / M;
    ll idx1 = 0, idx2 = 0;
    while (idx1 < N && idx2 < M) {
        if (A[idx1] != B[idx2]) {
            ok = false;
            break;
        }
        idx1 += m1;
        idx2 += n1;
    }
    if (ok) {
        prints()(l);
    }
    else {
        prints()(-1);
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  int N, wmax;
  cin >> N >> wmax;
  
  long long * dp = new long long[wmax + 1];
  for(int i=0;i<wmax + 1;i++){
    dp[i] = -1;
  }
  dp[0] = 0;
  
  for(int i=0;i<N;i++){
    int w;
    long long v;
    cin >> w >> v;
    
    for(int j=wmax;j>=w;j--){
      if( dp[j-w] >= 0 ){
        if( dp[j] < 0 ) dp[j] = 0;
        dp[j] = max( dp[j] , dp[j-w] + v );
      }
    }
  }
  
  long long maxv = 0;
  for(int i=0;i<=wmax;i++){
    if( dp[i] > maxv ) maxv = dp[i];
  }
  
  cout << maxv;
  return 0;
}



Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Collection;
import java.util.Scanner;
import java.util.Queue;
import java.util.Comparator;
import java.util.Collections;
import java.util.Arrays;


/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
    }

    static class Solver {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();

            Solver.Tuple[] operations = new Tuple[2*m];

            for (int i = 0; i < m; i++) {
                int a = in.nextInt(), b = in.nextInt();
                operations[i*2] = new Solver.Tuple(a,1,i);
                operations[i*2+1] = new Solver.Tuple(b,0,i);
            }
            Arrays.sort(operations, new NumberComparator());

            int res = 0;
            boolean[] deleted = new boolean[100001];
            int left = 0;
            for (int i = 0; i < 2*m; i++) {
                
                if (operations[i].type==1) {
                    
                }
                else if(deleted[operations[i].i]==false){
        
                    ++res;
                    for (; left <= i; left++) {
                        if(operations[left].type == 1){
                            deleted[operations[left].i] = true;
                        }
                    }
                }
            }

            System.out.println(res);
        }
        private static class Tuple {
            int pos;
            int type;//0は終点、1は始点
            int i;

            private Tuple(int pos, int type, int i) {
                this.pos = pos;
                this.type = type;
                this.i = i;
            }

        }

        public class NumberComparator implements Comparator<Tuple> {
            public int compare (Tuple l, Tuple r) {
                if(l.pos == r.pos){
                    if(l.type == r.type){
                        return 0;
                    }
                    return l.type - r.type;
                }
                return l.pos - r.pos;
            }
        }

    }
}



Measured memory_bytes: 96780
#include <stdio.h>

int main(void)
{
    int N=0;
    long number[100]={};
    long temp1=0;
    long temp2=0;
    long temp3=0;
    int count=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%ld",&number[i]);
    }
    if(N<3){
        printf("0");
        return 0;
    }

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(number[i]!=number[j]){
                for(int k=j+1;k<N;k++){
                    if(number[i]!=number[k] && number[j]!=number[k]){
                        temp1=number[i]+number[j]-number[k];
                        temp2=number[j]+number[k]-number[i];
                        temp3=number[k]+number[i]-number[j];
                        if(temp1>0 && temp2>0 && temp3>0){
                            count+=1;
                            //printf("%d %d %d\n",i+1,j+1,k+1);
                        }
                    }
                }
            }
        }
    }

    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<vector>
#include<cstdio>
#include<string.h>

//define N 100000

using namespace std;

int main(){
    int n,cou=0,res=0;
    cin >> n;
    char s,b;
    for(int i=0;i<n;i++){
        cin >> s;
        res = i+1;
        if(b=='x' && s=='x'){
            res--;
            break;
        }
        b=s;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3120
#include <cstdio>
#include <algorithm>

using namespace std;

int x[200000],y[200000],z[200000];
int i,n;
long long s;

inline bool cmp(int z1,int z2)
{
	return x[z1]+y[z1]>x[z2]+y[z2];
}

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]),z[i]=i;
	sort(z+1,z+n+1,cmp);
	for (i=1;i<=n;i++)
		if (i&1)
			s=s+x[z[i]];
		else
			s=s-y[z[i]];
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 1280
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Short       as B.Short
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.HashMap.Strict         as M
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    bs <- B.getLine
    print $ solve n bs

solve :: Int -> B.ByteString -> Int
solve n bs = sum [M.lookupDefault 0 pair rightFreq| pair<-lefts]
  where
    (left, right) = B.splitAt n bs
    lefts = pairs n left
    rights = pairs n $ B.reverse right
    !rightFreq = foldl' (\m pair -> M.insertWith (+) pair 1 m) M.empty rights

pairs n bs = [divide i bs|i<-[0..2^n-1]]
  where
    divide i bs = B.Short.pack $ map (B.unsafeIndex bs) xis ++ 0:map (B.unsafeIndex bs) yis
      where
        (xis, yis) = partition (testBit (i :: Int)) [0..n-1]


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

#define INF INT_MAX

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int main(void){
 	cin.tie(0);
    ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	int max_l = 1;
	int min_r = N;
	for(int i = 0;i < M; i++){
		int l,r;
		cin >> l >> r;
		if(l > max_l){
			max_l = l;
		}
		if(min_r > r){
			min_r = r;
		}
	}
	if(max_l > min_r)cout << 0 << endl;
	else cout << min_r - max_l + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int roop = s.size();
    rep(0, i, roop)
    {
        s = s.substr(0, N - 2);
        N = s.size();
        string s1 = s.substr(0, N / 2);
        string s2 = s.substr(N / 2, N / 2);
        if (s1 == s2)
        {
            cout << N << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int m = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        
        int count = 0;
        for(int month = 1; month <= m; month++){
            for(int day = 22; day <= d; day++){
                int d1 = day % 10;
                int d10 = day / 10;
                if(d1 < 2 || d10 < 2){
                    continue;
                }
                if(d1 * d10 == month){
                    count++;
                }
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,W,i,j;
    cin>>n>>W;
    ll v[n+1],w[n+1];
    for(i=1;i<=n;i++)
    {
    	cin>>w[i]>>v[i];
	}
	ll dp[W+1][n+1];
	memset(dp,0,sizeof(dp));
	
	for(i=1;i<=W;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(i<w[j])
			{
				dp[i][j]=dp[i][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i][j-1],v[j]+dp[i-w[j]][j-1]);
			}
		}
	}
	
	cout<<dp[W][n];
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C;
  for (int i = 1; i <= min(A, B); i++) {
    if (A % i == 0 && B % i == 0) {
      D = i;
    }
  }
  bool E = false;
  if (A < B) {
    if (B - A > C) {
      for (int i = 0; i < 100; i++) {
        if (B - A - D * i == C) {
          cout << "YES";
          E = true;
          break;
        }
      }
      if (!E) {
        cout << "NO";
      }
    }
    else {
      for (int i = 0; i < 100; i++) {
        if (B - A + D * i == C) {
          cout << "YES";
          E = true;
          break;
        }
      }
      if (!E) {
        cout << "NO";
      }
    }
  }
  else {
    if (A - B > C) {
      for (int i = 0; i < 100; i++) {
        if (A - B - D * i == C) {
          cout << "YES";
          E = true;
          break;
        }
      }
      if (!E) {
        cout << "NO";
      }
    }
    else {
      for (int i = 0; i < 100; i++) {
        if (A - B + D * i == C) {
          cout << "YES";
          E = true;
          break;
        }
      }
      if (!E) {
        cout << "NO";
      }
    }
  }
}

Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define all(x) x.begin(),x.end()
ld pie=3.141592653589793238462643383279;
int mod=1e9+7;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};


int fact[2000005];
int infact[2000005];

int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}

int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}

void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}

int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}

int n,m;

vector<int> adj[1000005];
bool vis[1000005];
bool vis2[1000005];
int ans[1000005];

bool poss=1;

int dfs(int c,int p){
  bool lp=1;
  int leaf=0;
  for(auto it : adj[c]){
    if(it!=p){
      lp=0;
      leaf+=dfs(it,c);
    }
  }
  if(lp) return 1;
  else{
    if(leaf<3) poss=0;
    return 0;
  }
  
}

void dfs2(int s,int val){
  if(vis2[s]) return ;
  vis2[s]=1; ans[s]=val;
  for(auto it : adj[s])
    dfs2(it,val);
}

int rev(int a){
  int r=0;
  while(a!=0){
    r+=a%10;
    r*=10;
    a/=10;
  }
  return r/10;
}
int32_t main(){ 

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int a; cin>>a;
  int r=a; r+=a*a; r+=a*a*a;
  cout<<r;
  return 0;
}


Measured memory_bytes: 27056
#include<cstdio>
#define maxn 100005
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define INF (LL)1e16
int n,p1,p2,siz[maxn];
LL ans=0,e=INF;
struct node { int v,w; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
void addedge(int u,int v,int w)
{
	ncnt++;
	ncnt->v=v,ncnt->w=w,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs1(int u,int fa)
{
	siz[u]=1;
	int msiz=0;
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(v==fa) continue;
		dfs1(v,u);
		siz[u]+=siz[v];
		msiz=max(msiz,siz[v]);
	}
	msiz=max(msiz,n-siz[u]);
	if(msiz<=n/2)
	{
		if(!p1) p1=u;
		else p2=u;
	}
}
void dfs2(int u,int fa,LL sum)
{
	ans+=2*sum;
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v,w=p->w;
		if(v==fa) continue;
		if(v==p2||(!p2&&u==p1)) e=min(e,1ll*w);
		dfs2(v,u,sum+w);
	}
}
int main()
{
	ncnt=&edge[0];
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		addedge(u,v,w); addedge(v,u,w);
	}
	dfs1(1,0);
	dfs2(p1,0,0);
	printf("%lld\n",ans-e);
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
long long r[4002],g[4002],b[4002];
int main()
{
	int n;
	string s;
	cin>>n>>s;
	long long sum=0;
	for(int i=n-1;i>=0;i--)
	{
		r[i]=r[i+1];g[i]=g[i+1];b[i]=b[i+1];
		if(s[i]=='R') r[i]=r[i]+1;
		if(s[i]=='G') g[i]=g[i]+1;
		if(s[i]=='B') b[i]=b[i]+1;
//		cout<<i<<" "<<r[i]<<" "<<g[i]<<" "<<b[i]<<endl;
	}
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			if(s[i]==s[j]) continue;
			
			if(s[i]=='R'&&s[j]=='G'||s[i]=='G'&&s[j]=='R')
		{
			sum+=b[j+1];
			if(s[2*j-i]=='B') sum--;
			
		}
		if(s[i]=='R'&&s[j]=='B'||s[i]=='B'&&s[j]=='R')
		{
			sum+=g[j+1];
			if(s[2*j-i]=='G') sum--;
		}
		if(s[i]=='B'&&s[j]=='G'||s[i]=='G'&&s[j]=='B')
		{
			sum+=r[j+1];
			if(s[2*j-i]=='R') sum--;
		}
	//	cout<<i<<" "<<j<<" "<<sum<<endl;
		}
		
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3660