akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;cin>>n>>m;
  bool ball[n+10]={};
  int num[n+10];
  fill_n(num,n+10,1);
  ball[1]=true;
  int ans=0;
  for(int i=0;i<m;i++){
    int x,y;cin>>x>>y;
    if(ball[x]==true){
      if(num[x]==1){
	ball[x]=false;
	ball[y]=true;
	num[x]--;
	num[y]++;
      }else{
	ball[y]=true;
	num[x]--;
	num[y]++;
      }
    }else{
      num[x]--;num[y]++;
    }
  }
  for(int i=1;i<=n;i++)
    if(ball[i])
      ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void) {

  int i, j;
  int h, w;

  while(1) {
    scanf("%d %d", &h, &w);

    if (h == 0 && w == 0) {
      break;
    } else {
      for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
          putchar('#');
        }
        putchar('\n');
      }
      putchar('\n');
    }
  }

  return 0;
}



Measured memory_bytes: 2040
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(std::string S) {
  ANS((S[1] == 'R' ? "ABC" : "ARC"));
}

// clang-format off
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll arr[100001],dp[100001]={0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        dp[arr[i]]++;
    }
    int flag=0,count=0;
    for(int i=0;i<n;i++)
    {
        if(dp[i]>2){
            flag=1;
            break;
        }
        else if(dp[i]==2)
        {
            count++;
        }
        //else if(dp[i]==1)
        //{
          //  flag=1;
            //break;
        //}
    }
    //cout<<count;
    int sar=0;
    if(n&1)
    {
        if(dp[0]!=1)
            sar=1;
    }

    if(sar||flag)
        cout<<"0"<<endl;
    else
    {
        ll ans=1;
        for(int i=0;i<count;i++)
        {
            ans=(ans%MOD)*2;
        }
        cout<<ans%MOD;
    }

    return 0;
}


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

int main(){
    int x,n;cin>>x>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int mark=0;
    int res=1000;
    int ans=1000;
    sort(p.begin(),p.end());
    for(int i=-100;i<110;i++){
        if(mark<n){
            if(i==p[mark]){
            mark++;
            continue;
        }
        }
        if(abs(x-i)<res){
            ans=i;
            res=abs(x-i);
        }
    }
    cout<<ans<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
ll memo[77][5][5];
ll mo=1000000007;

ll dfs(int d,int xm,int am) {
	if(d<0) return 1;
	if(memo[d][xm][am]>=0) return memo[d][xm][am];
	
	ll ret=0;
	// 0 0
	if(N&(1LL<<d)) {
		ret += dfs(d-1,1,min(2,am*2+1));
	}
	else {
		ret += dfs(d-1,xm,min(2,am*2));
	}
	// 1 0
	if(N&(1LL<<d)) {
		ret += dfs(d-1,xm,min(2,am*2));
	}
	else {
		if(am && xm) ret += dfs(d-1,xm,min(2,am*2-1));
	}
	// 1 1
	if(am) {
		if(N&(1LL<<d)) {
			ret += dfs(d-1,1,min(2,am*2-1));
		}
		else {
			ret += dfs(d-1,xm,min(2,am*2-2));
		}
	}
	
	return memo[d][xm][am]=ret%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	MINUS(memo);
	cout<<dfs(60,0,0)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
/*
  Krishnakant Tiwari
  Problem Link:

 */
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define eb	emplace_back
#define ppb	pop_back
#define pf	push_front
#define ppf	pop_front
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define precise(x)	cout<<fixed<<setprecision(x)
const ll MAX = 1000004;
const ll INF = 1e18L + 5;
template <class T, class U>
void chmin(T &t, const U &u)
{
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T &t, const U &u)
{
    if (t < u) t = u;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}
template <typename Arg1>
void pn(Arg1 &&arg1)
{
    cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << "\n";
    pn(args...);
}
template <typename Arg1>
void ps(Arg1 &&arg1)
{
    cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << " ";
    ps(args...);
}
template <typename Arg1>
void read(Arg1 &&arg1)
{
    cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1 &&arg1, Args &&... args)
{
    cin >> arg1;
    read(args...);
}

ll g[MAX];
ll a[MAX];

void solve()
{
    ll n;
    read(n);
    ll ans = 0;
    rep(i, 0, n)
    {
        read(a[i]);
        if(i){
        	if(a[i]<a[i-1]){
        		ans+=(a[i-1]-a[i]);
        		a[i]=a[i-1];
        	}
        }
    }
    pn(ans);
}

int main()
{

    _cin
// #ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// #endif
    // ll tc;
    // cin>>tc;
    // while(tc--){
    solve();
    // }

}


Measured memory_bytes: 5212
#include<stdio.h>
#include<string.h>
int main()
{
	char s[102],t[102],c,d;
	 
	while(scanf("%s%s",&s,&t)!=EOF)
	{
		c=0;
		d=strlen(s);
		for(int j=0;j<d;j++)
		{
			char a;
			a=s[d-1];
			for(int i=d-1;i>=0;i--)
			{
				s[i]=s[i-1];
			}
			s[0]=a;
			if(strcmp(s,t)==0)
			{
				printf("Yes\n");
				c=1;
				break;
			}
		}
		if(c==0)
			printf("No");
	}
	return 0;
}



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

const int N=203;
int a[N];

int main(){

    int n;
    scanf("%d", &n);
    for(int i=0; i<n; ++i)
        scanf("%d", a+i);

    int cnt=0;
    bool t=1;
    while(t){
        for(int i=0; i<n; ++i)
            if(a[i]%2)
                t=0;

        if(t){
            ++cnt;
            for(int i=0; i<n; ++i)
                a[i]/=2;
        }
    }

    printf("%d", cnt);





    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    int n; cin >> n;
    int d[n]; cinf(n,d);
    sort(d,d+n);
    cout << d[n/2] - d[n/2-1];
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<ll, ll> P;
ll x[100000], y[100000];
map<P, int> idx;
set<int> S;
set<P> Sx, Sy;
ll D;
void dfs(int v) {
	S.insert(v);
	Sx.erase(P(x[v], y[v]));
	Sy.erase(P(y[v], x[v]));
	while (1) {
		auto itr = Sx.lower_bound(P(x[v] - D, y[v] - D));
		if (itr == Sx.end() || itr->first != x[v] - D || itr->second > y[v] + D) break;
		int to = idx[*itr];
		dfs(to);
	}
	while (1) {
		auto itr = Sx.lower_bound(P(x[v] + D, y[v] - D));
		if (itr == Sx.end() || itr->first != x[v] + D || itr->second > y[v] + D) break;
		int to = idx[*itr];
		dfs(to);
	}
	while (1) {
		auto itr = Sy.lower_bound(P(y[v] - D, x[v] - D));
		if (itr == Sy.end() || itr->first != y[v] - D || itr->second > x[v] + D) break;
		int to = idx[P(itr->second, itr->first)];
		dfs(to);
	}
	while (1) {
		auto itr = Sy.lower_bound(P(y[v] + D, x[v] - D));
		if (itr == Sy.end() || itr->first != y[v] + D || itr->second > x[v] + D) break;
		int to = idx[P(itr->second, itr->first)];
		dfs(to);
	}
}
int main() {
	int N, a, b;
	cin >> N >> a >> b;
	a--; b--;
	vector<P> vx, vy;
	for (int i = 0; i < N; i++) {
		ll X, Y;
		cin >> X >> Y;
		x[i] = X - Y;
		y[i] = X + Y;
		idx[P(x[i], y[i])] = i;
		Sx.insert(P(x[i], y[i]));
		Sy.insert(P(y[i], x[i]));
		vx.emplace_back(x[i], y[i]);
		vy.emplace_back(y[i], x[i]);
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	D = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
	dfs(a);
	ll ans = 0;
	for (int v : S) {
		ans  += upper_bound(vx.begin(), vx.end(), P(x[v] - D, y[v] + D)) - lower_bound(vx.begin(), vx.end(), P(x[v] - D, y[v] - D));
		ans += upper_bound(vx.begin(), vx.end(), P(x[v] + D, y[v] + D)) - lower_bound(vx.begin(), vx.end(), P(x[v] + D, y[v] - D));
		ans += upper_bound(vy.begin(), vy.end(), P(y[v] - D, x[v] + D)) - lower_bound(vy.begin(), vy.end(), P(y[v] - D, x[v] - D));
		ans += upper_bound(vy.begin(), vy.end(), P(y[v] + D, x[v] + D)) - lower_bound(vy.begin(), vy.end(), P(y[v] + D, x[v] - D));
		for (int i = -1; i <= 1; i++) {
			if (i == 0) continue;
			for (int j = -1; j <= 1; j++) {
				if (j == 0) continue;
				if (upper_bound(vx.begin(), vx.end(), P(x[v] + i * D, y[v] + j * D)) != lower_bound(vx.begin(), vx.end(), P(x[v] + i * D, y[v] + j * D))) {
					ans--;
				}
			}
		}
	}
	cout << ans / 2 << endl;
}


Measured memory_bytes: 31484
/*input
56 25 31
*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int a,b,c;

	cin >> a >> b >> c;

	vector<int> v(3);
	v[0] = a;
	v[1] = b;
	v[2] = c;

	sort(v.begin(), v.end());

	if(v[0] + v[1] == v[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/

int A[1000000], n;

int binarySearch(int key)
{
	int left = 0;
	int right = n;
	int mid;
	
	while (left < right)
	{
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	
	return 0;
}

int main()
{
	int i, q, k, sum = 0;
	
	cin >> n;
	REP(n) cin >> A[i];
	cin >> q;
	REP(q)
	{
		cin >> k;
		if (binarySearch(k)) sum++;
	}
	
	cout << sum << endl;
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1548
import sys
from collections import deque
input = sys.stdin.readline
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  g[a - 1].append(b - 1)
  g[b - 1].append(a - 1)
q = deque([0])
dis = [-1] * n
dis[0] = 0
while q:
  d = q.popleft()
  for node in g[d]:
    if dis[node] == -1:
      q.append(node)
      dis[node] = dis[d] + 1
if dis[n - 1] == 2:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 40472
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int K;
  cin >> K;
  string S;
  cin >> S;
  if (S.size() <= K)
  {
    cout << S << endl;
  }
  else
  {
    cout << S.substr(0, K) + "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
N,K = map(int, input().split())

MOD = 10 ** 9 + 7

# just[X]: gcdがぴったり X になる個数
just = [0] * (K + 1)

for X in range(K, 0, -1):
    just[X] = pow(K // X, N, MOD)
    
    mul = X + X
    while mul <= K:
        just[X] -= just[mul]
        mul += X

ans = 0
for X in range(1, K + 1):
    ans += X * just[X] % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 11304
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }


	void solve() {
		IOS;
		ll a, b, c, k;
		cin >> a >> b >> c >> k;
		ll res = 0;
		ll t = min(a, k);
		res += t;
		k -= t;

		t = min(b, k);
		res += 0;
		k -= t;

		t = min(c, k);
		res -= t;
		k -= t;

		put(res);
	}
} // namespace idaten


int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 3652
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/9/7.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

int powe(int k){
    int ans=1;
    for(int i=1; i<=k; i++)
        ans*=2;
    return ans;
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int m, k; cin>>m>>k;
    if(k>=powe(m))
        cout<<"-1\n";
    else if(m==1){
        if(k==0){
            cout<<"0 1 1 0\n";
        }
        else if(k==1){
            cout<<"-1\n";
        }
    }
    else{
        for(int i=0; i<(1<<m); i++){
            if(i==k) continue;
            else cout<<i<<" ";
        }
        cout<<k<<" ";
        for(int i=(1<<m)-1; i>=0; i--){
            if(i==k) continue;
            else cout<<i<<" ";
        }
        cout<<k<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int getXth(int N, int P) {
  int c[8];
  REP(i, N) {
    c[N-1-i] = P % 10 - 1;
    P /= 10;
  }
  int coff[] = {5040, 720, 120, 24, 6, 2, 1, 0};
  int ret = 0;
  REP(i, N) {
    int x = c[i];
    REP(j, i) {
      if(c[j] < c[i]) --x;
    }
    ret += x * coff[8-N+i];
  }
  return ret;
}

int main(){
  int N, P = 0, Q = 0;
  cin >> N;
  REP(i, N) {
    int p;
    cin >> p;
    P = P * 10 + p;
  }
  REP(i, N) {
    int q;
    cin >> q;
    Q = Q * 10 + q;
  }
  int ret = getXth(N, P) - getXth(N, Q);
  if(ret < 0) ret = -ret;
  cout << ret << endl;
}

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

int a, b, c, d;
int main() {
    cin >> a >> b >> c >> d;
    if((a+b) > (c+d)) {
        cout << "Left" << endl;
    } else if((a+b) < (c+d)) {
        cout << "Right" << endl;
    } else if((a+b) == (c+d)) {
        cout << "Balanced" << endl;
    } 
}

Measured memory_bytes: 3604
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

R, G, B, N = mapint()

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        rg = r*R + g*G
        if rg>N:
            continue
        if (N-rg)%B==0:
            ans += 1
print(ans)

Measured memory_bytes: 67584
n = int(input())
cnt = 0
jud = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        cnt+=1
    else:
        cnt=0
    
    if cnt == 3:
        jud = 1
if jud == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int tans = C / B;
	int aans = A / D;

	if (C % B > 0) {
		tans += 1;
	}
	if (A % D > 0) {
		aans += 1;
	}

	if (tans <= aans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



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

int main() {
    int N;
    cin >> N;
    map<string, int> memo;
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        memo[s]++;
    }

    int memo_max=0;
    for(const auto& i : memo){
        if(memo_max < i.second) memo_max = i.second;
    }

    for(const auto& i : memo){
        if(i.second == memo_max) cout << i.first << endl;
    }

    return 0;
}


Measured memory_bytes: 25216
#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 long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int dp[100100][3];

int solve(int n, vector<vector<int>> v) {
	rep(j,3) {
		dp[0][j] = 0;
	}
	for (int i = 1; i < n + 1; i++) {
		rep(j,3) {
			dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + v[i - 1][j];
		}
	}
	return max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main() {
	int n;
	cin >> n;
	vector<vector<int>> v(n, vector<int>(3));
	rep(i,n) cin >> v[i][0] >> v[i][1] >> v[i][2];
	cout << solve(n, v) << endl;
}

Measured memory_bytes: 15316
#include <stdio.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}
int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int a,b,c;
  int maximam,minimum;

  scanf("%d%d%d",&a,&b,&c);

  maximam = max(a,b);
  maximam = max(maximam,c);
  minimum = min(a,b);
  minimum = min(minimum,c);

  printf("%d\n",maximam-minimum);

  return 0;
}

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

struct P{
	int x, y;
};

bool operator==(const P& lp, const P& rp){
	return (lp.x == rp.x) && (lp.y == rp.y);
}

const int INF = 1 << 24;

int main(){
	int matrix[100][100];
	int n;
	while(std::cin >> n, n){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				std::cin >> matrix[i][j];
			}
		}

		std::vector<P> sv, tv, temp_v;
		for(int i=0;i<n;i++){
			int s_height = INF;
			for(int j=0;j<n;j++){
				if(matrix[i][j] < s_height){
					temp_v.clear();
					temp_v.push_back({j, i});
					s_height = matrix[i][j];
				}else if(matrix[i][j] == s_height){
					temp_v.push_back({j, i});
				}
			}
			for(int k=0;k<temp_v.size();k++){
				sv.push_back(temp_v[k]);
			}
			temp_v.clear();

			int t_height = 0;
			for(int j=0;j<n;j++){
				if(matrix[j][i] > t_height){
					temp_v.clear();
					temp_v.push_back({i, j});
					t_height = matrix[j][i];
				}else if(matrix[j][i] == t_height){
					temp_v.push_back({i, j});
				}
			}
			for(int k=0;k<temp_v.size();k++){
				tv.push_back(temp_v[k]);
			}
			temp_v.clear();
		}

		int res = 0;
		for(int i=0;i<sv.size();i++){
			P p = sv[i];
			if(std::find(tv.begin(), tv.end(), p) != tv.end()){
				res = matrix[p.y][p.x];
				break;
			}
		}

		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 1228
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

def check01(s):

    if s[0]!="A":

        return False

    if s[2:-1].count("C")!=1:
    
        return False
    
    posi=s[2:-1].find("C",0)+2
    
    if any(s[i].isupper() for i in range(len(s)) if i!=0 and i!=posi):

        return False
    
    return True
    

arr_data = getinputdata()

s=arr_data[0][0]

print("AC" if check01(s) else "WA")

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

int main() {
    double n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (i * i < n) {
            ans++;
            if (n / i > i) ans += (ceil(n / i) - (i + 1)) * 2;
        } else
            break;
    }

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


Measured memory_bytes: 3720
import numpy as np
import copy

n = int(input())
c = np.zeros((n-1), dtype=np.int)
s = np.zeros((n-1), dtype=np.int)
f = np.zeros((n-1), dtype=np.int)
for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split(" "))

t = np.zeros(n, dtype=np.int)
for i in range(n-1):
    t[i] = s[i] + c[i]
    for j in range((i+1), (n-1), 1):
        if(s[j] >= t[i]):
            t[i] = s[j]
        elif(t[i] % f[j] != 0):
            t[i] += f[j] - (t[i] % f[j])
        t[i] += c[j]

for i in range(n):
    print(t[i])

Measured memory_bytes: 23316
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

struct Node * treeMinimum(struct Node *x){
  while(x->left != NIL) x=x->left;
  return x;
}

struct Node * find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

struct Node * treeSuccessor(struct Node *x){
  if(x->right != NIL) return treeMinimum(x->right);
  struct Node *y = x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(struct Node *z){
  struct Node *y;
  struct Node *x;
  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);
  if(y->left != NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }
    else{
    if(y==y->parent->left){
      y->parent->left=x;
    }
    else{
      y->parent->right=x;
    }
  }
  if(y!=z){
    z->key=y->key;
  }
  free(y);
}

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;


  while (x!=NIL){
          y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }

  z->parent = y;

  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
    printf(" %d",u->key);
  inorder(u->right);
}
void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[100];

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
       else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(com,"delete")==0){
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }
  return 0;
}






Measured memory_bytes: 20456
#include <stdio.h>
#include <ctype.h>
#include <string.h>

void inv_J(char* str) {
	char tmp;
	int i,max=strlen(str);
	tmp=str[max-1];
	for(i=max-1;i>0;i--) {
		str[i]=str[i-1];
	}
	str[0]=tmp;
}

void inv_C(char* str) {
	char tmp;
	int i,max=strlen(str);
	tmp=str[0];
	for(i=0;i<max-1;i++) {
		str[i]=str[i+1];
	}
	str[max-1]=tmp;
}

void inv_E(char* str) {
	char tmp;
	int i,max=strlen(str);
	int max2=max/2;
	for(i=0;i<max2;i++) {
		tmp=str[i];
		str[i]=str[max2+i+max%2];
		str[max2+i+max%2]=tmp;
	}
}

void inv_A(char* str) {
	char tmp;
	int i,max=strlen(str);
	int max2=max/2;
	for(i=0;i<max2;i++) {
		tmp=str[i];
		str[i]=str[max-i-1];
		str[max-i-1]=tmp;
	}
}

void inv_P(char* str) {
	int i,max=strlen(str);
	for(i=0;i<max;i++) {
		if(isdigit(str[i])) {
			str[i]--;
			if(str[i]<'0')str[i]+=10;
		}
	}
}

void inv_M(char* str) {
	int i,max=strlen(str);
	for(i=0;i<max;i++) {
		if(isdigit(str[i])) {
			str[i]++;
			if(str[i]>'9')str[i]-=10;
		}
	}
}

int main(void) {
	char messangers[8];
	char message[28];
	int data_num,cur_data;
	int i;
	scanf("%d",&data_num);
	for(cur_data=0;cur_data<data_num;cur_data++) {
		scanf("%s",messangers);
		scanf("%s",message);
		for(i=strlen(messangers)-1;i>=0;i--) {
			switch(messangers[i]) {
				case 'J':
					inv_J(message);
					break;
				case 'C':
					inv_C(message);
					break;
				case 'E':
					inv_E(message);
					break;
				case 'A':
					inv_A(message);
					break;
				case 'P':
					inv_P(message);
					break;
				case 'M':
					inv_M(message);
					break;
			}
		}
		puts(message);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

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

    int n; cin >> n;
    vector<pair<ll,ll>> v;
    for(int i = 0; i < n; i++){
        ll x, y; cin >> x >> y;
        v.push_back({x, y});
    }

    sort(v.begin(),v.end());
    ll a = 0, b = 0;
    ll ans = 0;
    for(int i = 0; i < v.size(); i++){
        if(i == 0){
            a = v[i].second;
            b = v[i].second; 
        }else{
            if(v[i].first == v[i - 1].first){
                ans = max(ans, max(abs(v[i].second - a), abs(v[i].second - b)));
                a = max(a, v[i].second);
                b = min(b, v[i].second);
            }else{
                a += (ll)(v[i].first - v[i - 1].first);
                b -= (ll)(v[i].first - v[i - 1].first);
                ans = max(ans, max(abs(v[i].second - a), abs(v[i].second - b)));
                a = max(a, v[i].second);
                b = min(b, v[i].second);
            }
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 7408
from cython import longlong
 
def main():
    n: longlong
    n=int(input())
    lp, lm = [], []
    for i in range(n):
        s=input()
        
        x: longlong
        y: longlong
        x,y=0,0
        
        for j in s:
            if j=="(":x+=1
            else:x-=1
            y=min(y,x)
        if x>0: lp.append((y,x))
        else: lm.append((y-x,-x))
    lp.sort()
    s: longlong
    s=0
 
    i: longlong
    j: longlong
    for i,j in lp[::-1]:
        if s+i<0:
            print("No")
            exit()
        s+=j
    lm.sort()
 
    t: longlong
    t=0
 
    i: longlong
    j: longlong
    for i,j in lm[::-1]:
        if t+i<0:
            print("No")
            exit()
        t+=j
    if s==t: print("Yes")
    else: print("No")
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 84532
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
using namespace std;
const int MOD = 1e9 +7;

int main(){
    int n;
    long long res =1;
    cin >>n;
    string s;
    cin >> s;
    map<char,int> mp;
    for(int i=0;i<n;i++){
        mp[s[i]]++;
    }
    for(char c ='a';c <= 'z';c++){
        res *= (mp[c] +1);
        res %= MOD;
    }
    cout << res -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 2e3 + 100;
VI e[MAXN];

void BFS(int x, int *d) {
  queue<int> q;
  d[x] = 0;
  q.push(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    debug("%d   %d\n", x, u);
    for (int v : e[u]) {
      if (d[v] != -1)
        continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
}

int ans[MAXN];
int dis[MAXN][MAXN];

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;

  for (int i = 1; i < N; i++) {
    e[i].PB(i + 1);
    e[i + 1].PB(i);
  }
  e[X].PB(Y);
  e[Y].PB(X);

  for (int i = 1; i <= N; i++) {
    fill(dis[i], dis[i] + N + 1, -1);
    BFS(i, dis[i]);
    for (int j = i + 1; j <= N; j++) {
      debug("%d %d %d\n", i, j, dis[i][j]);
      ans[dis[i][j]]++;
    }
  }

  for (int i = 1; i < N; i++)
    printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(){
    int a,b,c,a2,b2,c2;
    cin>>a>>b>>c;
    if(a==1&&b==1&&c==1)cout<<0<<endl;
    else if(a==b&&c==a)cout<<-1<<endl;
    else{
        int ans=0;
        while(a%2==0&&b%2==0&&c%2==0){
            ans++;
            a2=(b+c)/2;
            b2=(a+c)/2;
            c2=(a+b)/2;
            a=a2;
            b=b2;
            c=c2;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())

remarks = []
for _ in range(n):
    remarks.append(input())

a = 0
flag = True
for remark in remarks:
    if remark == "A":
        a += 1
    else:
        if a == 0:
            flag = False
            break
        else:
            a -= 1
else:
    if a != 0:
        flag = False

if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 5596
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	s := stringLineScan()
	if len(s)%2 == 1 {
		fmt.Println("No")
	} else {
		f := true
		for i := 0; i < len(s); i += 2 {
			if s[i:i+2] != "hi" {
				f = false
			}
		}
		if f {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 640
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int N,Y;

cin>>N>>Y;
bool ok=false;
int a=-1,b=-1,c=-1;

// 10000       5000
FOR(i,0,N)FOR(j,0,N-i){

	if( (N-i-j)>= 0 && Y == i * 10000 + j * 5000 + (N-i-j)*1000){ok=true; a=i; b=j; c=N-i-j;}

}

cout<<a<<" "<<b<<" "<<c<<" "<<endl;


return 0;

}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;

int n;
int main() {
	n = read();
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			int x = i ^ j;
			int c = 0;
			while(!(x & (1 << c))) ++c;
			printf("%d ", c + 1);
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 512
# - Qualification simulator
N, A,B = map(int, input().split())
S = input()
tmp = 0
tmp2 = 0

for i in range(N):
    if S[i] =="a":
        tmp += 1
    elif S[i] =="b":
        tmp2 += 1
    else:
        pass

    if S[i] =="a" and tmp <= A+B:
        print("Yes")
    elif S[i] =="b" and tmp+1 <= A+B and tmp2 <= B:
        tmp += 1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4016
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

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

    map<int, int> mapA;
    int tmp;
    rep(i, N) {
        cin >> tmp;
        mapA[tmp] += 1;
    }

    ll sum = 0;
    for (const auto& [key, value] : mapA){
        sum += key*value;
    }

    int Q;
    cin >> Q;

    rep(i, Q) {
        int b, c;
        cin >> b >> c;
        sum += (c-b)*mapA[b];
        mapA[c] += mapA[b];
        mapA[b] = 0;

        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 8056
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: [usize; 3]};
    let mut a: Vec<usize> = a;

    a.sort();

    let mut count = a[2] - a[1];
    a[0] += count;
    if a[0] != a[2] {
        count += (a[2] - a[0]) / 2;
        if (a[2] - a[0]) % 2 == 1 {
            count += 2;
        }
    }
    println!("{}", count)
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(void){
    string s;
    cin >> s;
    string T = "ATCG";
    int ans = 0,count=0;
    for(int i=0;i<s.size();i++){
        bool isATCG = false;
        for(int j=0;j<T.size();j++){
            if(s[i] == T[j]) isATCG = true;
        }
        if(!isATCG){
            count = 0;
        }else{
            count++;
            ans = max(count,ans);
        }
    }

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

Measured memory_bytes: 3588
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

import qualified Data.IntMap as IM
--import qualified Data.IntSet as S
import qualified Data.Sequence as S

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

main :: IO ()
main = do
    [n,k,q] <- r'
    as <- replicateM q readLn
    let asocL = zip [1..n] [0,0..]
    let mp = IM.fromList asocL
    let r = IM.toAscList (solve as mp)
    --forM_ r  (\t -> print t)
    forM_ r  (\(_,a) -> putStrLn $ if k+a > q then "Yes" else "No")
    --print 0


solve :: [Int] -> IM.IntMap Int -> IM.IntMap Int 
solve [] mp = mp
solve (a:as) mp = solve as (IM.adjust succ a mp)


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

using namespace std;
int main() {
    int N, M;
    vector <pair<int, int> > p;

    int rest;
    long long ans = 0;

    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        p.push_back(make_pair(a, b));
    }
    sort(p.begin(), p.end());

    rest = M;
    for (int i = 0; i < N; i++) {

        if (rest <= p[i].second) {
            ans += (long long)rest * p[i].first;
            break;
        } else {
            ans += (long long)p[i].first * p[i].second;
            rest -= p[i].second;
        }
    }

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



Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main() {
  	int N;
  	cin >> N;
  	string S[N];
  	for (int i = 0; i < N; i++) cin >> S[i];
  
  	set<string> Set;
  
  	for (int i = 0; i < N; i++){
      	Set.insert(S[i]);
    }
  
  	cout << Set.size() << endl;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int min_count = N;

/*    for (int i = 0; i < N; i++) {
        int count = 0;
        for (int j = 0; j < N; j++) {
            //cout << "i = " << i << " j = " << j << endl;
            if ( j < i && S[j] == 'W') {
                //cout << "j < i count++;" << endl;
                count++;
            } else if ( i < j && S[j] == 'E') {
                //cout << "i < j count++;" << endl;
                count++;
            }
            if (count > min_count) {
                break;
            }
        }
        min_count = min(min_count, count);
    }*/
    vector<pair<int, int>> E_W(N);
    int Enum = 0, Wnum = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'E') {
            Enum++;
        } else if (S[i] == 'W') {
            Wnum++;
        }
        E_W[i] = make_pair(Enum, Wnum);
    }

    for (int i = 0; i < N; i++) {
        int toE, toW;
        if (i == 0) {
            toE = 0;
            toW = E_W[N - 1].first - E_W[0].first;
        } else {
            toE = E_W[i - 1].second;
            toW = E_W[N - 1].first - E_W[i].first;
        }
        //cout << "i = " << i << ", toE = "<< toE << ", toW = " << toW << endl;
        min_count = min(min_count, toE + toW);
    }
    cout << min_count << endl;

    return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m,query;
  cin>>n>>m>>query;
  vector<int> l(m);
  vector<int> r(m);
  vector<int> p(query);
  vector<int> q(query);
  int i,j;
  rep(i,m)cin>>l[i]>>r[i];
  rep(i,query)cin>>p[i]>>q[i];
  vector<vector<int>> ls(n,vector<int>(n,0));
  rep(i,m)ls[l[i]-1][r[i]-1]++;
  rep(j,n)
  {
    for(i=j;i>=0;i--)
    {
      if(i!=j)
      {
        ls[i][j]+=ls[i+1][j]+ls[i][j-1]-ls[i+1][j-1];
      }
    }
  }
  rep(i,query)cout<<ls[p[i]-1][q[i]-1]<<endl;
}


Measured memory_bytes: 4224
//https://atcoder.jp/contests/abc163/tasks/abc163_c
#include <vector>
#include <iostream>

int main() {
	int N;
	std::cin >> N;
	std::vector<int> subs(N + 1);
	for (int i = 1; i < N; ++i) {
		int boss;
		std::cin >> boss;
		++subs[boss];
	}

	for (int i = 1; i <= N; ++i)
		std::cout << subs[i] << '\n';

}

Measured memory_bytes: 3680
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<fstream>
#include<sstream>
#include<vector>
#include<set>
#include<deque>
#include<cstring>
#include<queue>
#include<stdio.h>
#include<set>
#include<stack>
#include<numeric>
#include<map>
#include<cstdio>
#include<bitset>
#include<array>
#include<list>
using namespace std;
#define ll long long 
const ll mod = 1e9 + 7;

ifstream f1;
ofstream f2;

bool sub[300001];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	f1.open("INP.txt");
	f2.open("OUT.txt");
	ll n;
	cin >> n;
	vector<bool> hold;
	hold.push_back(0);
	for (ll i = 0; i < n; i++) {
		bool x;
		cin >> x;
		hold.push_back(x);
	}
	ll s = 0;
	for (ll i = n; i >= 1; i--) {
		if (i > n / 2) {
			sub[i] = hold[i];
			if (sub[i]) {
				s++;
			}
			continue;
		}
		ll sum = 0;
		ll j = i * 2;
		while (j <= n) {
			sum += sub[j];
			j += i;
		}
		if (sum % 2 != hold[i]) {
			sub[i] = 1;
		}
		if (sub[i]) {
			s++;
		}
	}
	cout << s << endl;
	for (ll i = 1; i <= n; i++) {
		if (sub[i]) {
			cout << i << " ";
		}
	}
	//system("pause");
	return 0;
}

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

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

    ll A, B, C;
    char dot;
    cin >> A >> B >> dot >> C;
    cout << A * (B * 100 + C) / 100 << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
   int dp[n];

  for(int i=0;i<n;i++)
  {cin>>a[i];
   }
  
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    if(i==1)
        dp[1]=abs(a[1]-a[0]);
	else
      dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
      
  }
    cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1024
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
int a[MAXN], b[MAXN];

int main() {
	int n; ni(n);
	nai(a, n);
	nai(b, n);
	priority_queue<pii> pq;
	for (int i = 0; i < n; i++)
		pq.push(mp(b[i],i));
	ll ans = 0;
	while (!pq.empty()) {
		pii cur = pq.top(); pq.pop();
		if (b[cur.se] != cur.fi || b[cur.se] == a[cur.se])
			continue;
		if (b[cur.se]-a[cur.se] < b[(cur.se+1)%n] + b[(cur.se-1+n)%n])
			return !pri(-1);
		ll val = (ll)((b[cur.se]-a[cur.se]) / (b[(cur.se+1)%n] + b[(cur.se-1+n)%n]));
		ans += val;
		b[cur.se] -= val * (ll)(b[(cur.se+1)%n] + b[(cur.se-1+n)%n]);
		cur.fi = b[cur.se];
		pq.push(cur);
		pq.push(mp(b[(cur.se-1+n)%n],(cur.se-1+n)%n));
		pq.push(mp(b[(cur.se+1)%n],(cur.se+1)%n));
	}
	prl(ans);
	return 0;
}


Measured memory_bytes: 11248
#!/usr/bin/env perl

use Math::BigInt;

$mod = 1_000_000_007;

chomp($_ = <STDIN>);
($n, $m) = split(/ /);

$res = 1;
for($p = 2;$p <= $m; $p++) {
  $b = 0;
  $v = Math::BigInt->new(1);
  while ($m % $p == 0) {
    $b++;
    $m /= $p;

    $v *= $n - 1 + $b;
    $v /= $b;
  }
  $res = $res * $v % $mod;

  if ($p < $m - 2 && $p * $p > $m) {
    $p = $m - 1;
  }
}

print $res;


Measured memory_bytes: 4608
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

void main()
{
	auto N = RD!long;
	auto C = RD!long;

	auto x = new long[](N);
	auto v = new long[](N);
	foreach (i; 0..N)
	{
		x[i] = RD!long;
		v[i] = RD!long;
	}

	auto dp = new long[2][2][](N+1);
	foreach (i; 0..N)
	{
		dp[i+1][0][0] = dp[i][0][0] + v[i];
		dp[i+1][0][1] = max(dp[i][0][1], dp[i+1][0][0] - x[i] * 2);
	}
	foreach_reverse (i; 0..N)
	{
		dp[i][1][0] = dp[i+1][1][0] + v[i];
		dp[i][1][1] = max(dp[i+1][1][1], dp[i][1][0] - (C - x[i]) * 2);
	}

	long ans;
	foreach (i; 0..N)
	{
		auto cal1 = dp[i+1][0][0] - x[i];
		auto cal2 = dp[i+1][1][1];
		ans = max(ans, cal1 + cal2);
	}
	foreach_reverse (i; 0..N)
	{
		auto cal1 = dp[i][1][0] - (C - x[i]);
		auto cal2 = dp[i][0][1];
		ans = max(ans, cal1 + cal2);
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 9596