akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int>> adj;
int dp[100005];
int k,ans=0;
void dfs(int ver)
{
    int mx=-2;
    for(auto i:adj[ver])
    {
        dfs(i);
        mx=max(mx,dp[i]);
    }
    dp[ver]=mx+1;
    if(dp[ver]==k-1 &&ver!=1)
    {
        dp[ver]=-1;        
        ans++;
    }

}

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,k;
    cin>>n>>k;
    int a[n];
    int g=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        g=__gcd(g,a[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(k<=a[i])
        if((a[i]-k)%g==0)
        {
            cout<<"POSSIBLE";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE";

} 


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    char a[10];
    gets(a);
    if(a[0]=='S')
        printf("Cloudy\n");
    if(a[0]=='C')
        printf("Rainy\n");
    if(a[0]=='R')
        printf("Sunny\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int k = sc.nextInt();
		long nn = n / k;
		long c = nn * nn * nn;
		if(k % 2 == 0) {
			long ne = n / (k / 2) - nn;
			c += ne * ne * ne;
		}
		System.out.println(c);
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = INF; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	vl P;
	for (i = 0; i < N-1; i++) {
		if (A[i] == A[i + 1]) {
			P.push_back(A[i]);
			i++;
		}
	}
	sort(P.begin(), P.end());
	reverse(P.begin(), P.end());
	if (P.size() < 2) cout << 0;
	else cout << P[0] * P[1];
}

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

int main(){
    int x;
    cin>>x;
    vector<bool> v(x+1,0);
    v[1]=1;
    for(int b=2;b<=sqrt(x);b++){
        for(int p=2;pow(b,p)<=x;p++) v[pow(b,p)]=1;
    }
    for(int i=x;;i--){
        if(v[i]==1){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=200010;

ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%mod;
        x=x*x%mod;
        b/=2;
    }
    return res;
}

vector<vector<ll> >G(MAX);
vector<ll>siz(MAX);

void dfs(ll i,ll p){
    for(auto e:G[i]){
        if(e==p)continue;
        dfs(e,i);
        siz[i]+=siz[e];
    }
    siz[i]++;
}
ll n;
ll ans;
void dfs2(ll i,ll p){
    ll sum=rui(2LL,n-siz[i])-1;
    for(auto e:G[i]){
        if(e==p)continue;
        sum=(sum+(rui(2LL,siz[e])-1))%mod;
        dfs2(e,i);
    }
    sum=(rui(2LL,n-1)-(1+sum)%mod)%mod;
    ans=(ans+sum)%mod;
}
signed main(){
    cin>>n;
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ans=0;
    dfs(0,-1);
    dfs2(0,-1);
    ll inv=rui(2LL,n);
    inv=rui(inv,mod-2LL);
    ans=ans*inv%mod;
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}

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

int main(void){
    int H, W, N;
    int bigger, ans;
    cin >> H >> W >> N;
    if(H >= W){
        bigger = H;
    }else{
        bigger = W;
    }

    ans = N/bigger;
    if(N%bigger != 0){
        ans += 1;
    }

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

Measured memory_bytes: 256
lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
A = array[1].split(" ").map(&:to_i)
H = array[1].split.inject(Hash.new(0)) { |h,v| h[v.to_i] += 1; h }

# p A.sort
# p H

count = 0

H.each do |k,v|
  if k == v
    next
  elsif k > v
    count += v
  else
    count += (v-k)
  end
end

puts count

Measured memory_bytes: 20220
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 200005
using namespace std;

int n,m,q,sx,sy;
char s[M], t[M];

int main()
{
    while (~scanf("%d %d %d",&n,&m,&q)) {
        scanf("%d %d",&sx,&sy);
        scanf("%s", s+1);
        scanf("%s", t+1);

        bool fail = false;
        int x1=1, x2=n;
        int y1=1, y2=m;
        for (int i=q; i>=1; i--) {
            if (t[i]=='U') x2 = min(n, x2+1);
            if (t[i]=='D') x1 = max(1, x1-1);
            if (t[i]=='L') y2 = min(m, y2+1);
            if (t[i]=='R') y1 = max(1, y1-1);

            if (s[i]=='U') x1++;
            if (s[i]=='D') x2--;
            if (s[i]=='L') y1++;
            if (s[i]=='R') y2--;
            if (x1>x2 || y1>y2) fail = true;
        }
        puts(x1<=sx && sx<=x2 && y1<=sy && sy<=y2 && !fail ? "YES" : "NO");
    }
    
    return 0;
}




Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

// read to vector
// for example M_RTV(as, int, n) expands to the below:
// ```
// vector<int> as(n);
// for(int lcnt = 0; lcnt < n; lcnt++) cin >> as[lcnt];
// ```
#define M_RTV(ident, type, cnt) \
    vector<type> ident(cnt);\
    do {\
        \
        for(int lcnt = 0; lcnt < cnt; lcnt++) cin >> ident[lcnt];\
    } while(false)

// shorthand for range
#define M_RG(ident) ident.begin(), ident.end()

// https://qiita.com/EqualL2/items/b4683db7ab4e90545bb2
int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

int main() {
    int n;
    cin >> n;
    M_RTV(xs, int, n);

    int sum_min = 1 << 30;
    for(int i = 1; i <= 100; i++) {
        int sum = 0;
        for(int x : xs) {
            sum += (x-i)*(x-i);
        }
        if(sum < sum_min) sum_min = sum;
    }
    cout << sum_min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    unordered_map<string, int> M;
    M["SAT"] = 1;
    M["FRI"] = 2;
    M["THU"] = 3;
    M["WED"] = 4;
    M["TUE"] = 5;
    M["MON"] = 6;
    M["SUN"] = 7;
    string S; cin >> S;
    cout << M[S] << "\n";
}

Measured memory_bytes: 256
n = int(input())
comments = {}
for i in range(n):
  a = int(input())
  comments[i] = []
  for _ in range(a):
    x, y = [int(x) for x in input().split()]
    comments[i].append([x-1, y==1])

ans = 0
for i in range(2**n):
  results = [None] * n
  for j in range(n):
    candidate = ((i >> j) & 1) == 1
    if results[j] is None:
      results[j] = candidate
    elif results[j] != candidate:
      break
    if candidate == False:
      continue
    elif candidate == True:
      failed = False
      for comment in comments[j]:
        if results[comment[0]] is None:
          results[comment[0]] = comment[1]
        if results[comment[0]] != comment[1]:
          failed = True
          break
      if failed:
        break
  else:
    cnt = len([r for r in results if r is True])
    if cnt > ans:
      ans = cnt

print(ans)

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    ll n,k; cin >> n >> k;
    vector<pair<ll,ll>> ab(n);
    rep(i, n) {
        ll a,b; cin >> a >> b;
        ab[i] = make_pair(a,b);
    }
    sort(ab.begin(), ab.end());

    ll now = 0;
    rep(i, n) {
        now += ab[i].second;
        if(now >= k) {
            cout << ab[i].first << endl;
            return 0;
        }
    }

    //cout << a[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto B = new long[](N+10);
    long ans = 0;

    foreach (a; A) B[a] += 1;
    foreach (b; B) ans += b * (b - 1) / 2;

    foreach (a; A) writeln(ans - B[a] * (B[a] - 1) / 2 + (B[a] - 1) * (B[a] - 2) / 2);
}

Measured memory_bytes: 13416
sx,sy,tx,ty=map(int,input().split())
d=tx-sx
h=ty-sy
s='U'*h+'R'*d+'D'*h+'L'*(1+d)+'U'*(1+h)+'R'*(1+d)+'D'+'R'+'D'*(h+1)+'L'*(d+1)+'U'
print(s)
                                           

Measured memory_bytes: 38256
#include <cstdio>
#include <algorithm>
using namespace std;
int m[101];
int main() {
	int N,X,i;
	scanf("%d %d",&N,&X);
	for(i=0;i<N;i++) scanf("%d",&m[i]);
	for(i=0;i<N;i++) X-=m[i];
	sort(m,m+N);
	printf("%d",N+X/m[0]);
	return 0;
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, R;
    cin >> N >> R;
    cout << (N >= 10 ? R : R + 100 * ( 10 - N ) ) << endl;
    return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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 main()
{
    cout << fixed << setprecision(15);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    while(A>0 && C > 0){
        C -= B;
        if(C<=0){
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A<=0){
            cout << "No" << endl;
            return 0;
        }

    }
    return 0;
}

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

const int MAXN = 200 + 10;

map<int, int> IDX, IDY;
int L[MAXN], R[MAXN], B[MAXN], T[MAXN];
bool vis[MAXN][MAXN], canX[MAXN][MAXN], canY[MAXN][MAXN];
int N, Nx, Ny;

bool floodfill(int x, int y) {
    if (x < 0 || x >= Nx || y < 0 || y >= Ny) return false;
    bool flag = true;
    if (!vis[x][y]) {
        vis[x][y] = true;
        if (canX[x][y]) flag &= floodfill(x - 1, y);
        if (canX[x + 1][y]) flag &= floodfill(x + 1, y);
        if (canY[x][y]) flag &= floodfill(x, y - 1);
        if (canY[x][y + 1]) flag &= floodfill(x, y + 1);
    }
    return flag;
}

int main() {
    while (scanf("%d", &N) == 1 && N) {
        IDX.clear(); IDY.clear();
        for (int i = 0; i < N; ++ i) {
            scanf("%d%d%d%d", L + i, T + i, R + i, B + i);
            IDX[B[i]] = 0; IDX[T[i]] = 0;
            IDY[L[i]] = 0; IDY[R[i]] = 0;
        }
        Nx = Ny = 0;
        for (auto &x : IDX) x.second = Nx ++;
        for (auto &y : IDY) y.second = Ny ++;
        for (int i = 0; i <= Nx; ++ i) {
            for (int j = 0; j <= Ny; ++ j) {
                canX[i][j] = canY[i][j] = true;
                vis[i][j] = false;
            }
        }
        for (int i = 0; i < N; ++ i) {
            L[i] = IDY[L[i]]; R[i] = IDY[R[i]];
            B[i] = IDX[B[i]]; T[i] = IDX[T[i]];
            for (int j = L[i]; j < R[i]; ++ j) canX[T[i]][j] = canX[B[i]][j] = false;
            for (int j = B[i]; j < T[i]; ++ j) canY[j][L[i]] = canY[j][R[i]] = false;
        }
        int ret = 1;
        for (int i= 0; i < Nx; ++ i) {
            for (int j = 0; j < Ny; ++ j) {
                if (!vis[i][j]) ret += floodfill(i, j);
            }
        }
        printf("%d\n", ret);
    }
    return 0;
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}
lli dp[3030][3030];

void solve(){
	lli n;cin>>n;
	lli arr[n];fr(i,n)cin>>arr[i];
	for(int len=1;len<=n;len++){
		for(int st=0;st+len-1<n;st++){
			int en=st+len-1;
			if(st==en){
				dp[st][en]=arr[st];
			}else{
				dp[st][en]=max(arr[st]-dp[st+1][en],arr[en]-dp[st][en-1]);
			}
		}
	}
	cout<<dp[0][n-1]<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

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

ll prime(ll n)
{
  ll i,j;
  for(i=n;;i++)
  {
    bool flag=true;
    for(j=2;j<=sqrt(i);j++)
    {
      if(i%j==0)
      {
        flag=false;
        break;
      }
    }
    if(flag)
    {
      return i;
    }
  }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin>>n;
  cout<<prime(n)<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, q = na()
s = ns()
ac = list()
now = 0
f = False
for si in s:
    if si == "C" and f:
        now += 1
        f = False
    elif si == "A":
        f = True
    else:
        f = False
    ac.append(now)
for _ in range(q):
    l, r = na()
    l -= 1; r -= 1
    print(ac[r] - ac[l])

Measured memory_bytes: 6336
#!/usr/bin/env python3
import sys

dic = {}

def list_sort(x):
    values = dic[x]
    values.sort()

    return {x: values}

def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    for i in range(N):
        dic[i + 1] = []
    
    for i in range(M):
        dic[P[i]].append(Y[i])

    sorted_dic = {}
    for key in dic.keys():
        tmp = {}
        values = dic[key]

        values.sort()
        for i in range(len(values)):
            tmp[values[i]] = i + 1

        sorted_dic[key] = tmp


    for m in range(M):
        key = P[m]
        value = Y[m]
        sorted_ranked_dic = sorted_dic[key]
        rank = sorted_ranked_dic[value]

        print('{0:06d}'.format(key, rank) + '{0:06d}'.format(rank))



    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 78304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int N;
  cin >> N;
  long A[N];
  long mx=0;
  long mn=1e10;
  rep(i,N) cin >> A[i];
  rep(i,N) {
    mx = max(A[i], mx);
    mn = min(A[i], mn);
  }
  cout << mx - mn << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  deque<int> dq;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if ((i & 1) == 0)
      dq.push_back(a);
    else
      dq.push_front(a);
  }
  for (int i = 0; i < n; ++i) {
    if ((n & 1) != 0) {
      cout << dq.back();
      dq.pop_back();
    } else {
      cout << dq.front();
      dq.pop_front();
    }
    if (i == n - 1)
      cout << endl;
    else
      cout << " ";
  }
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <climits>
#include <cmath>
#include <algorithm>


#define TEST(msg, cond) \
do { \
	if (cond) {\
		cout << msg << " => pass" << endl; \
	} else { \
		cout << msg << " => failed" << endl; \
	} \
} while(0)

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> a(n), b(n), c(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) cin>>c[i];

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		long long numOfAElem = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		long long numOfCElem = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());

		sum += numOfAElem * numOfCElem;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define REP(i,a,b) for(int i=a; i<b; i++)

const int MX=1e5+3;

int n, sum, mx;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	REP(i, 0, n){
		int a;
		cin>>a;
		mx=max(mx, a);
		sum+=a;
	}
	cout<<sum-mx/2<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

const int nax = 1e5 + 5;
VI edges[nax], visited(nax);
VI ts;

void dfs(int u, int p) {
    visited[u] = 1;
    for (int v : edges[u]) {
        if (v == p) continue;
        if (visited[v] == 0)
            dfs(v, u);
    }
    ts.push_back(u);
}

int main() {
    int n = nxt(), m = nxt();
    REP(i, m) {
        int a = nxt(), b = nxt();
        edges[a].push_back(b);
    }
    for (int i = 1; i <= n; i++)
        if (visited[i] == 0)
            dfs(i, -1);
    int ans = 0;
    reverse(all(ts));
    VI dist(n + 1, 0);
    for (int i = 0; i < n; i++) {
        for (int v : edges[ts[i]]) {
            dist[v] = max(dist[v], dist[ts[i]] + 1);
        }
        ans = max(ans, dist[ts[i]]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12120
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
  int n, m, d;
  cin >> n >> m >> d;

  double avg = 1.0 * (n - d) * (m - 1) / pow(n, 2);
  if (d)
    avg *= 2;
  printf("%.10f\n", avg);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////
ll N;
vector<ll> t;

bool judge() {
	vector<ll> u(N + 1, 0);
	repn(i, N) u[i] = t[i];
	sort(u.begin(), u.end());

	repn(i, N) {
		if (u[i] < i) { return false; }
	}

	repn(i, N) {
		if (u[i] > i) { return true; }
	}

	ll sw = 0;
	for (ll x = 1; t[x] != 1; x = t[x]) { sw++; }
	if (sw == N - 1) { return false; }
	return true;

}


int main() {
	cin >> N;
	vector<pair<ll, ll>> p(N + 1);
	repn(i, N)cin >> p[i].first;
	repn(i, N) cin >> p[i].second;
	sort(++p.begin(), p.end());

	vector<ll> A(N + 1, 0), B(N + 1, 0);
	repn(i, N) {
		A[i] = p[i].first;
		B[i] = p[i].second;
	}

	t.assign(N + 1, 0);
	repn(i, N) {
		auto itr = upper_bound(A.begin(), A.end(), B[i]);
		t[i] = distance(A.begin(), itr)-1;
	}

	//repn(i, N) cout << A[i] << " ";
	//cout << endl;
	//repn(i, N) cout << B[i] << " ";
	//cout << endl;
	//repn(i, N) cout << t[i] << " ";
	//cout << endl;

	if (judge()) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	
	
	system("PAUSE");
}


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

int main()
{
	int n,Y;
	scanf("%d %d",&n ,&Y);
	for(int x = 0; x < n+1; x++)
	{
		for(int y = 0; y < n+1; y++)
		{
			int z = n - (x + y);
			if(z < 0)
			{
				continue;
			}
			int yy = Y;
			yy -= ((10000 * x) + (5000 * y));
			if(yy == 1000*z)
			{
				printf("%d %d %d\n",x ,y ,z);
				return 0;
			}
			
		}
		
	}
	
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<string,string>ma;
set<int > s;
multiset<string> :: iterator it;

deque <char> q ;
int vis [55100];
int  visited[230];
int main()
{
    fast;
     string  s;
     cin>> s;
     int f=1;
     for(int i=0;i<s.sz;i++)
     {
         visited[s[i]]++;
     }
     for(int i=0;i<150;i++)
     {
         if(visited[i]%2)
         {
             f=0;
             break;
         }
     }
     pr(f);

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<int> v[4];

void solve(){
}
typedef long long LL;
int main(){
   // freopen("input", "r", stdin);
    LL N,W,ans=0;
    cin>>N>>W;
    LL ww,vt,wt;
    cin>>ww>>vt;
    v[0].push_back(vt);
    for(int i=1;i<N;i++)
     {
       cin>>wt>>vt;
       v[wt-ww].push_back(vt);
     }
     for(int i=0;i<4;i++)
        sort(v[i].begin(),v[i].end(),greater<int>());
     for(int i=0;i<4;i++)
        for(int j=1;j<v[i].size();j++)
             v[i][j]+=v[i][j-1];

    for(int i=0;i<=v[0].size();i++)
     for(int i2=0;i2<=v[1].size();i2++)
      for(int i3=0;i3<=v[2].size();i3++)
        for(int i4=0;i4<=v[3].size();i4++)
          if(W>=i*(ww)+i2*(ww+1)+i3*(ww+2)+i4*(ww+3)){
            LL t=0;
          //  cout<<i<<i2<<i3<<i4<<endl;
            if(i!=0)t+=v[0][i-1];
            if(i2!=0)t+=v[1][i2-1];
            if(i3!=0)t+=v[2][i3-1];
            if(i4!=0)t+=v[3][i4-1];
            if(t>ans)ans=t;
          //  cout<<t<<endl;
          }
     cout<<ans<<endl;
     return 0;
}


Measured memory_bytes: 256
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        distance = 0
        for k in range(d):
            distance += (x[i][k] - x[j][k])**2
        distance = distance**0.5
        if distance == int(distance):

            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <map>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    long long sum = 0;
    long long cost = 0;
    //偶数番目を正とするとき
    for(int i = 0; i < n; i++) {
        sum += a[i];
        if(i % 2 == 0 && sum < 0) {
            cost += 1-sum;
            sum += 1-sum;
        }
        if(i % 2 != 0 && sum > 0) {
            cost += 1+sum;
            sum -= 1+sum;
        }
        if(sum == 0 && i % 2 == 0) {
            sum++;
            cost++;
        }else if(sum == 0 && i % 2 != 0) {
            sum--;
            cost++;
        }
    }
    
    const long long even = cost;
    
    sum = 0;
    cost = 0;
    //偶数番目を負とするとき
    for(int i = 0; i < n; i++) {
        sum += a[i];
        if(i % 2 == 0 && sum > 0) {
            cost += 1+sum;
            sum -= 1+sum;
        }
        if(i % 2 != 0 && sum < 0) {
            cost += 1-sum;
            sum += 1-sum;
        }
        if(sum == 0 && i % 2 == 0) {
            sum--;
            cost++;
        }else if(sum == 0 && i % 2 != 0) {
            sum++;
            cost++;
        }
    }
    const long long odd = cost;
    
    cout << min(even,odd);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int ans = 700;
  rep(i,3) if(s[i]=='o') ans += 100;
  cout << ans << endl;
}


Measured memory_bytes: 256
s=list(input())
a=int(''.join(s[:2]))
b=int(''.join(s[2:]))
if 0<a and a<=12 and 0<b and b<=12:
    print("AMBIGUOUS")
elif((a==0 or a>12) and 0<b and b<=12):
    print("YYMM")
elif 0<a and a<=12 and (b==0 or b>12):
    print("MMYY")
else:
    print("NA")





Measured memory_bytes: 3060
#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 N;
    cin >> N;
    int d[N];
    rep(i, N) cin >> d[i];

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ");
#define MAX_C 1000000
long long mod_c[MAX_C + 1], mod_r[MAX_C + 1], mod_d;

long long mod_pow(long long x, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
void comb()
{
    if (mod_d == 0)
    {
        long long i;
        mod_c[0] = 1;
        mod_r[0] = 1;
        for (i = 1; i <= MAX_C; i++)
        {
            mod_c[i] = mod_c[i - 1] * i % 1000000007;
        }
        for (i = 1; i <= MAX_C; i++)
        {
            mod_r[i] = mod_pow(mod_c[i], 1000000005, 1000000007);
        }
        mod_d = 1;
    }
}
long long nck(long long n, long long k)
{
    comb();
    long long res = 1;
    res = res * mod_c[n] % 1000000007;
    res = res * mod_r[k] % 1000000007;
    res = res * mod_c[k - 1] % 1000000007;
    res %= 1000000007;
    return res;
}
int main()
{
    ll n;
    cin >> n;
    vl x(n);
    rp(i, 0, n) cin >> x[i];
    ll nb = 1;
    ll ans = 0;
    comb();
    ll mod = 1000000007;
    ll now = mod_c[n - 1];
    rp(i, 0, n - 1)
    {
        if (i >= 1)
        {
            ans += (x[i + 1] - x[i]) * (now + nck(n - 1, i + 1)) % mod;
            //   cout << (mod_c[n - 1] + nck(n - 1, i + 1)) << endl;
            now = now + nck(n - 1, i + 1);
        }
        else
        {
            ans += (x[i + 1] - x[i]) * (now);
        }
        ans %= 1000000007;
        // cout << ans << endl;
    }
    cout << ans << endl;
}

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
       dp[i]=min(abs(arr[i-1]-arr[i])+dp[i-1],abs(arr[i-2]-arr[i])+dp[i-2]);
    
    cout<<dp[n-1];
    
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
      
  if((A==B && B!=C) | (B==C && C!=A) | (C==A && A!=B)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
return 0;
}

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

int main() {
  int N,Y;
  cin >> N>>Y;
  int X=100000;
  int yy=100000;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <=N-x; y++) {
      if(9000*x+4000*y==Y-1000*N){
        X=x;
        yy=y;
      }
    }
  }
  if(X==100000&&yy==100000){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
  else{
  cout<<X<<" "<<yy<<" "<<N-X-yy<<endl;
  }
}






Measured memory_bytes: 256
from functools import lru_cache
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def solve():
    N, a, b, c, d = map(int, input().split())

    @lru_cache(maxsize=None)
    def F(n):
        if n == 0:
            return 0
        if n == 1:
            return d
        ans = n * d
        if n % 2 == 0:
            ans = min(ans, F(n//2) + a)
        if n % 2 == 1:
            up = F((n + 1) // 2) + a + d
            down = F((n - 1) // 2) + a + d
            ans = min(ans, up, down)
        if n % 3 == 0:
            ans = min(ans, F(n // 3) + b)
        if n % 3 == 1:
            up = F((n + 2) // 3) + b + d + d
            down = F((n - 1) // 3) + b + d
            ans = min(ans, up, down)
        if n % 3 == 2:
            up = F((n + 1) // 3) + b + d
            down = F((n - 2) // 3) + b + d + d
            ans = min(ans, up, down)
        if n % 5 == 0:
            ans = min(ans, F(n // 5) + c)
        if n % 5 == 1:
            up = F((n + 4) // 5) + c + d + d + d + d
            down = F((n - 1) // 5) + c + d
            ans = min(ans, up, down)
        if n % 5 == 2:
            up = F((n + 3) // 5) + c + d + d + d
            down = F((n - 2) // 5) + c + d + d
            ans = min(ans, up, down)
        if n % 5 == 3:
            up = F((n + 2) // 5) + c + d + d
            down = F((n - 3) // 5) + c + d + d + d
            ans = min(ans, up, down)
        if n % 5 == 4:
            up = F((n + 1) // 5) + c + d
            down = F((n - 4) // 5) + c + d + d + d + d
            ans = min(ans, up, down)
        return ans

    print(F(N))


T = int(input())
for _ in range(T):
    solve()

Measured memory_bytes: 20304
n=int(input())
if n==1000000:
  ans=90910
elif n>=100000:
  ans=90909
elif n>=10000:
  ans=909+(n-9999)
elif n>=1000:
  ans=909
elif n>=100:
  ans=9+(n-99)
elif n>=10:
  ans=9
else:
  ans=n
print(ans)

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

int main(){
	int N;
	cin >> N;
	if(N >= 64) cout << 64 << endl;
	else if(N >= 32) cout << 32 << endl;
	else if(N >= 16) cout << 16 << endl;
	else if(N >= 8) cout << 8 << endl;
	else if(N >= 4) cout << 4 << endl;
	else if(N >= 2) cout << 2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  string O,E;
  cin>>O>>E;
  for(int i=0;i<O.size()+E.size();i++){
    if(i%2==0)cout<<O[i/2];
    else cout<<E[i/2];
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int M, D; cin >> M >> D;
    int ans = 0;
    FOR(m, 1, M + 1) FOR(d, 1, D + 1){
        int d1 = d % 10, d10 = d / 10;
        if(d1 >= 2 && d10 >= 2 && d1 * d10 == m) ans++;
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
  l,r = map(int,input().split())
  L.append(l)
  R.append(r)
a = min(R)-max(L)+1
if a>=1:
  print(a)
else:
  print(0)

Measured memory_bytes: 10996
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, a, b = i_list()
    ss = s_input()

    kakuteisha = 0
    b_juni = 0
    for i in range(len(ss)):
        s = ss[i]
        if s == "a":
            if kakuteisha < a + b:
                kakuteisha += 1
                print("Yes")
            else:
                print("No")
        elif s == "b":
            if kakuteisha < a + b and b_juni + 1 <= b:
                kakuteisha += 1
                b_juni += 1
                print("Yes")
            else:
                print("No")
        else:
            print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 10616
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
int64_t INF = 10010010010;
// int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;
// int64_t INF = 998244353;

vvi mem(21,vi(0));

ll getSalary(ll i){
    if(mem.at(i).size()==0) return 1;
    if(mem.at(i).size()==1) return 2*getSalary(mem.at(i).at(0))+1;
    ll maxS = -1;
    ll minS = INF;
    for(ll j:mem.at(i)){
        maxS = max(maxS, getSalary(j));
        minS = min(minS, getSalary(j));
    }
    return maxS + minS + 1;
}
int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s.at(i);
    // 隣接した#が存在しないことを確認すればよい
    string res = "Yes";
    rep(i,h){
        rep(j,w){
            if(s.at(i).at(j)=='.') continue;
            // OK なら true, NG なら false
            bool a = j>0 && s.at(i).at(j) == s.at(i).at(j-1);
            bool b = j<w-1 && s.at(i).at(j) == s.at(i).at(j+1);
            bool c = i<h-1 && s.at(i).at(j) == s.at(i+1).at(j);
            bool d = i>0 && s.at(i).at(j) == s.at(i-1).at(j);
            if(!a&&!b&&!c&&!d) res = "No";
            // cout << "i:" << i << " j:" << j << " res:" << res << endl;
        }
    }
    cout << res << endl;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,anss,ansss,a,b,c,cmp,cmpp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

       cin >> a >> b >> c;
       if(a%2==0 || b%2==0 || c%2==0){
           Cout(0);
       }
       else{
           cmp=b*c*(a/2);
           cmpp=b*c*(a/2+1);
           ans=Abs(cmp,cmpp);
          // Cout(ans);
           cmp=a*c*(b/2);
           cmpp=a*c*(b/2+1);
           anss=Abs(cmp,cmpp);
           //Cout(anss);
           cmp=a*b*(c/2);
           cmpp=a*b*(c/2+1);
           ansss=Abs(cmp,cmpp);
           ans=min(ans,anss);
           ans=min(ans,ansss);
           Cout(ans);
       }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int i,n;
	char a[41];
	cin >> a;
	n = strlen(a);
	for(i=n-1;i>=0;i--)
	{
		cout << a[i];
	}
	cout << endl;
	return 0;
}

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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

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

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

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, di;
  vi d;
  cin >> n;
  ll ans = 0;
  while (cin >> di) {
    d.pb(di);
  }
  for (int i = 0; i < n; i++)
    for (int j = i+1; j < n; j++)
      ans += d[i]*d[j];
  cout << ans << ende;
  return 0;
}


Measured memory_bytes: 256