akhauriyash/Code-Regression huggingface dataset:
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.20 01:57:52
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

constexpr int MOD = 998244353;
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((MOD+x)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    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) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    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 mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};
int main() {
    ll n,a,b;cin >> n >> a >> b;
    ll k;cin >> k;
    vector<mint> comb(n+1);
    mint ans = 0;
    comb[0] = 1;
    for (int i = 0; i < n; i++) {
        comb[i+1] = comb[i] * (n-i) / (i+1);
    }
    for (int i = 0; i <= n; i++) {
        if((k - a * i) >= 0 && (k - a * i) % b == 0 && (k - a * i) / b <= n) {
            ans += comb[(k - a * i) / b] * comb[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5588
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){

            int H = sc.nextInt();
            int W = sc.nextInt();

            if(H==0&&W==0){
                break;
            }

            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if((i+j)%2==0){
                    System.out.print("#");
                }else{
                    System.out.print(".");
                }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
    
}


Measured memory_bytes: 32868
#include<iostream>
using namespace std;
/*beginner contest 161B*/

//nこのうちからm個を選ぶが、1/4m以下の得票数の場合はNO
int main(){
	//整数入力
	int n,m;
	cin >> n >> m;
	int a[100];
	int sum = 0;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	//結局1/4m以上のものがm個以上あればいいのだ。
	int count = 0;
	for(int i = 0; i < n; i++){
		//割り切れない場合は正しく判定できない。
		if (a[i] >= float(sum)/4/m){
			count++;
		}
	}
	if (count >= m){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;		
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  char str[100000];
  while(scanf("%s", str) != EOF){
    int i, joi = 0, ioi = 0;
    for(i = 0;i < strlen(str) - 3;i++){
      if(str[i] =='J' && str[i + 1] == 'O' && str[i + 2] == 'I'){
        joi++;
      }
      if(str[i] =='I' && str[i + 1] == 'O' && str[i + 2] == 'I'){
        ioi++;
      }
    }
    printf("%d\n%d\n", joi, ioi);
  }
  return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

using ll = long long;
using namespace std;

int main(){
    int N;
    cin >> N;
    typedef pair<int, int> xy;
    vector<xy> A(N+1);
    rep1(i,N) cin >> A[i].first >> A[i].second;
    
    double dist = 0.0;
    rep1(i,N){
        for (int j = i + 1; j <= N; j++){
            int d_x = A[i].first - A[j].first;
            int d_y = A[i].second - A[j].second;
            dist += pow((double)d_x*d_x+d_y*d_y, 0.5);
        }
    }
    dist /= (double)N;
    dist*=2;
    printf("%.8lf",dist);
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(LL& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
LL n,f[100]={2,1};
main()
{
	re(n);
	for(LL i=2;i<=n;++i)f[i]=f[i-1]+f[i-2];
	printf("%lld\n",f[n]);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

class UF
{
private:
	vector<int> parent;

public:
	UF(int n)
	{
		parent = vector<int>(n, -1);
	}

	int getparent(int x)
	{
		if(parent[x] == -1) return x;
		else return parent[x] = getparent(parent[x]);
	}

	void connect(int x, int y)
	{
		x = getparent(x);
		y = getparent(y);
		if(x == y) return;
		if(x > y) swap(x, y);
		parent[y] = x;
	}
};

int main()
{
	int n, m;
	cin >> n >> m;
	int p[100001];
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	UF uf(n + 1);
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		uf.connect(x, y);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(uf.getparent(i + 1) == uf.getparent(p[i])) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
int main(){
    int n;
    int sum=100000;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        sum+=sum*0.05;
        if(sum%1000) sum=(sum/1000+1)*1000;
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int cnt[50];
int main(){
	for(int i=0;i<3;i++){
		int a,b;
		cin>>a>>b;
		cnt[a]++;cnt[b]++;
	}
	if(*max_element(cnt+1,cnt+5)>2){
		puts("NO");
	}else{
		puts("YES");
	}
	return 0;
}

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

void solve(long long N, std::vector<long double> x, std::vector<std::string> u){
    long double ans = 0.0;
    REP(i, N) {
        if (u[i] == "JPY") ans += x[i];
        else ans += x[i] * 380000.0;
    }
    printf("%.5Lf\n", ans);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    std::vector<long double> x(N);
    std::vector<std::string> u(N);
    for(int i = 0 ; i < N ; i++){
        cin >> x[i];
        std::cin >> u[i];
    }
    solve(N, std::move(x), std::move(u));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

int V;
struct edge{int f,t,c;};
vector<edge> G[100100];
int dist[100100];

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>V;
    rep(i,V-1){
        edge e; cin>>e.f>>e.t>>e.c;
        e.f--; e.t--;
        edge f=e; swap(f.f,f.t);
        G[e.f].push_back(e);
        G[f.f].push_back(f);
    }
    fill(dist,dist+100100,INF);
    dist[0]=0;
    queue<int> que;
    que.push(0);
    while(que.size()){
        int v=que.front(); que.pop();
        rep(i,G[v].size()){
            if(dist[G[v].at(i).t]>dist[v]+G[v].at(i).c){
                dist[G[v].at(i).t]=dist[v]+G[v].at(i).c;
                que.push(G[v].at(i).t);
            }
        }
    }
    rep(i,V){
        if(dist[i]%2==0)cout<<0<<endl;
        else cout<<1<<endl;
    }

}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
#include<string>
using namespace std;
int flag[101],flag1[101];
int main()
{
    string s="",s1="";
    ostringstream s5;

   int a,b,n,t,r,c=0,i,j,a1,b1;
   cin>>a>>b;
   a1=a,b1=b;

   if(a1>=b1)
   {
    s5<<b;
   string g=s5.str();
       for(i=0;i<a1;i++)
       {

           s+=g;
       }
       cout<<s<<"\n";
   }
    if(a1<b1)
   {
    s5<<a;
    string g=s5.str();
       for(i=0;i<b1;i++)
       {

           s+=g;
       }
       cout<<s<<"\n";
   }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 4005, mod = 924844033;
int f[N][N][2], g[N], A[N], fac[N];

inline void add(int &x,int y) { x += y; if (x >= mod) x -= y; }
int main() {
	int n = read(), k = read(), Ans = 0;
	int cnt = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = i; j <= n; j += k) A[++cnt] = (i == j);
		for (int j = i; j <= n; j += k) A[++cnt] = (i == j);
	}
	f[0][0][0] = 1;
	for (int i = 1; i <= (n << 1); ++i) 
		for (int j = 0; j <= i; ++j) {
			add(f[i][j][0], (f[i - 1][j][0] + f[i - 1][j][1]) % mod);
			if (!A[i] && j) add(f[i][j][1], f[i - 1][j - 1][0]);
		}
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
	for (int i = 0; i <= n; ++i) {
		int res = (f[n << 1][i][0] + f[n << 1][i][1]) % mod;
		Ans += 1ll * (i & 1 ? -1 : 1) * res * fac[n - i] % mod;
		Ans = (Ans % mod + mod) % mod;
	}
	cout << Ans;
	return 0;
}

Measured memory_bytes: 123776
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
// 木上の探索

int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  if(a>=k){cout<<a-k<<" "<<b<<endl;
  }else{
    if(a+b>k){
      cout<<0<<" "<<a+b-k<<endl;
    }else{
      cout<<0<<" "<<0<<endl;
    }
  }
}


Measured memory_bytes: 256
import math
ABC=input().split()
 
a=int(ABC[0])
b=int(ABC[1])
c=int(ABC[2])
 
if a*a+b*b+c*c-2*a*b-2*a*c-2*b*c>0 and a+b<c  :
    print ("Yes")
else :
    print ("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

void solve(string s)
{
  string t;
  while(s.size()>1)
  {
    t = "";
    REP(i,s.size()-1) t+=to_string((s[i]+s[i+1]-2*'0')%10);
    s = t;
  }
  cout << s << endl;
}

int main()
{
  string s;
  while(cin >> s) solve(s);
  return 0;
}

Measured memory_bytes: 3128
main = do
  (a:b:xs) <- map read . words <$> getLine
  putStrLn . show $ solve a b

solve :: Int -> Int -> Int
solve a b 
  | a > 1 && b > 1 = (a-2) * (b-2)
  | a == 1 && b == 1 = 1
  | a == 1 && b /= 1 = b-2
  | otherwise = a-2

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int M=in();
    vector<int> vec(M);
    REP(i,M){
        cin>>vec[i];
    }
    
    if(M==1||N>=M){
        cout<<0<<endl;
        return 0;
    }
    sort(all(vec));
    ll ans=0;
    ans=vec[vec.size()-1]-vec[0];
    vector<int> aida(M-1);
    int now;now=vec[0];
    REP(i,M-1){
        aida[i]=vec[i+1]-now;
        now=vec[i+1];
    }
    sort(all(aida));
    REP(i,N-1){
        ans-=aida[aida.size()-1-i];
    }
    cout<<ans<<endl;
    return 0;
}

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

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
int N;
bool dfs(vector<string> &S, int A, int B, int C, int i, string &ans){
    if(i==N){
        if(A>=0&&B>=0&&C>=0){
            return true;
        }else{
            return false;
        }
    }else if(!(A>=0&&B>=0&&C>=0)){
        return false;
    }else{
        if(S.at(i)=="AB"){
            if(A>B){
                ans.at(i)='B';
                return dfs(S, A-1, B+1, C, i+1, ans);
            }
            if(B>A){
                ans.at(i)='A';
                return dfs(S, A+1, B-1, C, i+1, ans);
            }
            if(dfs(S, A+1, B-1, C, i+1, ans)){
                ans.at(i)='A';
                return true;
            }else if(dfs(S, A-1, B+1, C, i+1, ans)){
                ans.at(i)='B';
                return true;
            }else{
                return false;
            }
        }else if(S.at(i)=="BC"){
            if(B>C){
                ans.at(i)='C';
                return dfs(S, A, B-1, C+1, i+1, ans);
            }
            if(C>B){
                ans.at(i)='B';
                return dfs(S, A, B+1, C-1, i+1, ans);
            }
            if(dfs(S, A, B+1, C-1, i+1, ans)){
                ans.at(i)='B';
                return true;
            }else if(dfs(S, A, B-1, C+1, i+1, ans)){
                ans.at(i)='C';
                return true;
            }else{
                return false;
            }
        }else{
            if(C>A){
                ans.at(i)='A';
                return dfs(S, A+1, B, C-1, i+1, ans);
            }
            if(A>C){
                ans.at(i)='C';
                return dfs(S, A-1, B, C+1, i+1, ans);
            }
            if(dfs(S, A-1, B, C+1, i+1, ans)){
                ans.at(i)='C';
                return true;
            }else if(dfs(S, A+1, B, C-1, i+1, ans)){
                ans.at(i)='A';
                return true;
            }else{
                return false;
            }
        }
    }
}
//Start from Here
int main(){
    int A, B, C;
    cin>>N>>A>>B>>C;
    vector<string> S;
    string c;
    rep(i, N){
        cin>>c;
        S.push_back(c);
    }
    string ans;
    rep(i, N){
        ans+="A";
    }
    if(dfs(S, A, B, C, 0, ans)){
        cout<<"Yes"<<endl;
        rep(i, N){
            cout<<ans.at(i)<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 9008
#include <stdio.h>
int main(void) {
    long n, i, ip, d;
    d=0;
    long a[200001];
    scanf("%ld", &n);
    for (i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }

    for (i=0; i<n; i++) {
        ip = i+1-d;
        if (a[i] != ip) {
            d++;
        }
    }

    if (d == n) {
        d = -1;
    }

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

Measured memory_bytes: 1664
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut a: [i64;n],
    }

    a.sort();
    let max_ = a.pop().unwrap();
    let mut acc = std::i64::MAX;
    for i in 0..n - 1 {
        if (a[i] - max_ / 2).abs() <= (acc - max_ / 2).abs() {
            acc = a[i];
        }
    }

    println!("{} {}", max_, acc);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
typedef pair<int,int> P;
int INF = 1000000000;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int H,W;
  cin >> H >> W;
  char s[H][W];
  int cnt_w = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> s[i][j];
      if(s[i][j]=='.') cnt_w++;
    }
  }

  int d[H][W];
  fill(d[0],d[H],INF);
  d[0][0] = 0;

  //bfs
  queue<P> que;
  que.push(P(0,0));

  while(que.size()){
    P p = que.front();
    que.pop();
    if(p.first == H-1 && p.second == W-1) break;

    for(int i=0;i<4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];

      if(0<=nx && nx<=H-1 && 0<=ny && ny<=W-1 && s[nx][ny]=='.' && d[nx][ny]==INF){
        que.push(P(nx,ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }



  if(d[H-1][W-1]==INF){
    cout << -1 << endl;
  }
  else{
    cout << cnt_w - d[H-1][W-1] - 1;
  }

  return 0;
}


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

#define ll long long
#define value(x) cout<<#x<<" "<<x<<'\n';
#define print_vec(vec) for(auto x: vec) cout<<x<<" "; \
                        cout<<endl;

void solve()
{
	char ch;
	cin >> ch;
	if (isupper(ch)) {
		cout << "A" << '\n';
	}
	else {
		cout << "a" << "\n";
	}
}

int main()
{
	int t = 1;
	// cin >> t;
	while (t--)
		solve();
}


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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main() {

    char c;
    cin >> c;
    c++;
    AA(c);
}

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

int main(){
    string s;
    cin >> s;
    int f3 = 0;
    bool f1 = false,f2 = false;
    for(int i = 0; i < s.size(); ++i){
        if(i == 0 && s[i] == 'A') f1 = true;
        if(i != 0 && s[i] >= 'A' && s[i] <= 'Z') f3++;
        if(i >= 2 && i < s.size() - 1 && s[i] == 'C') f2 = true;
    }

    if(f1 && f3 == 1 && f2) cout << "AC" << endl;
    else cout << "WA" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int A = 0;
        for (int i = 0; i < M; i++) {
            A += scanner.nextInt();
        }

        System.out.println(A > N ? "-1" : N - A);
    }
}


Measured memory_bytes: 46208
<?php
  $input = (int)fgets(STDIN);

$nums = explode(" ", fgets(STDIN));

foreach($nums as &$num){
	$num = (int)$num;
}
unset($num);

$ans = 0;
foreach($nums as &$num){
	$num = 1 / $num;
  $ans += $num;
}

$ans = 1/ $ans;

echo $ans;


Measured memory_bytes: 4728
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  for (int i = 0; i < H; ++i)
  {
    cin >> s[i];
  }
  int field[310][310] = {};
  vector<int> v[310];
  int itr = 1;
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      if (s[i][j] == '#')
      {
        field[i][j] = itr;
        itr++;
        v[i].push_back(j);
      }
    }
  }
  vector<int> t;
  for (int i = 0; i < H; ++i)
  {
    if (!v[i].empty())
    {
      t.push_back(i);
    }
    for (int j = 0; j < v[i].size(); ++j)
    {
      int x = v[i][j] + 1, y = v[i][j] - 1;
      while (x < W && field[i][x] == 0)
      {
        field[i][x] = field[i][v[i][j]];
        x++;
      }
      while (0 <= y && field[i][y] == 0)
      {
        field[i][y] = field[i][v[i][j]];
        y--;
      }
    }
  }
  for (int i = 0; i < t.size(); ++i)
  {
    int x = t[i] + 1, y = t[i] - 1;
    while (x < H && field[x][0] == 0)
    {
      for (int j = 0; j < W; ++j)
        field[x][j] = field[t[i]][j];
      x++;
    }
    while (0 <= y && field[y][0] == 0)
    {
      for (int j = 0; j < W; ++j)
        field[y][j] = field[t[i]][j];
      y--;
    }
  }
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      cout << field[i][j] << " \n"[j == W - 1];
    }
  }

  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,c;
    cin >> n >> c;

    vector<LL> x(n+1,0),v(n+1,0);

    for(int i = 1; i < n+1; i++){
        cin >> x[i] >> v[i];
    }

    vector<LL> lefttotal(n+1,0),maxlefttotal(n+1,0);
    for(int i = 1; i < n+1; i++){
        lefttotal[i] = lefttotal[i-1] + v[i];
    }

    for(int i = 1; i < n+1; i++){
        maxlefttotal[i] = max(maxlefttotal[i-1],lefttotal[i]-x[i]);
    }

    vector<LL> righttotal(n+1,0),maxrighttotal(n+1,0);
    for(int i = 1; i < n+1; i++){
        righttotal[i] = righttotal[i-1] + v[n-i+1];
    }
    
    for(int i = 1; i < n+1; i++){
        maxrighttotal[i] = max(maxrighttotal[i-1],righttotal[i] -(c - x[n+1-i]));
    }

    LL ans = 0;

    for(int i = 1; i < n+1; i++){
        ans = max(ans,lefttotal[i]-x[i]);
        ans = max(ans,lefttotal[i]-2*x[i]+maxrighttotal[n-i]);
        ans = max(ans,righttotal[i]-(c -x[n+1-i]));
        ans = max(ans,righttotal[i]-2*(c-x[n+1-i])+maxlefttotal[n-i]);
    }

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

Measured memory_bytes: 4992
package main

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

func main() {
	sc := NewScanner()

	x := sc.NextInt()
	a := sc.NextInt()
	b := sc.NextInt()

	fmt.Printf("%v\n", (x-a)%b)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		boolean[] arg = null;
		int length=0,out=0;
        int i=0,rou=0,store=1,sc=0;
        int state=0;


		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null ) {
            	i++;
            	String[] tokens=line.split(" ");
            	int[] time=new int[line.length()];
            	int[] result=new int[3];
            	for(int k=0;k<tokens.length;k++){
            		time[k]=Integer.parseInt(tokens[k]);
            	}
            	if(time[2]>time[5]){
            		time[1]++;
            		result[0]=(60-time[2]+time[5]);
            	}else{
            		result[0]=(time[5]-time[2]);
            	}
            	if(time[1]>time[4]){
            		time[0]++;
            		result[1]=(60-time[1]+time[4]);
            	}else{
            		result[1]=(time[4]-time[1]);
            	}
            	result[2]=time[3]-time[0];

            	System.out.println(result[2]+" "+result[1]+" "+result[0]);
            	if(i==3){
            		break;
            	}

            }

		}
	}
}

Measured memory_bytes: 24416
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

void solve(){
  int k, s;
  cin >> k >> s;
  int ans = 0;
  FOR(i,0,k+1){
    FOR(j,0,k+1){
      if(s-i-j<=k && s-i-j>=0) ++ans;
      if(s-i-j < 0) break;
    }
  }
  cout << ans << endl;
}

int main(void){
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {
	static int[][] numbers;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int  n= in.nextInt();
		int[] nums = new int[n];
		for(int i =0; i< n; i++)
			nums[i] = in.nextInt();
		
		 int count = 0;
	        for (int i = 0; i < nums.length - 2; i++) {
	            for (int j = i + 1; j < nums.length - 1; j++) {
	                for (int k = j + 1; k < nums.length; k++) {
	                    if (nums[i] + nums[j] > nums[k] && nums[i] + nums[k] > nums[j]
	                    		&& nums[j] + nums[k] > nums[i]) {
	                    	if(nums[i]!=nums[j] && nums[i]!=nums[k] && nums[j]!=nums[k])
	                    		 count++;
	                    }
	                       
	                }
	            }
	         } 	 
         
         System.out.println(count);     
	}
	
	
}

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

int main(){
	int n;
	cin >> n;
	vector<pair<ll,ll>> in(n);
	rep(i,n){
		int a,b;
		cin >> a >> b;
		in[i] = make_pair(b,a);
	}
	sort(in.begin(),in.end());
	ll now=0;
	bool can = true;
	rep(i,n){
		now+=in[i].second;
		if(in[i].first<now)
			can = false;
	}
	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int max_val(vector<int>&t,int x)
{
	int mval=INT_MIN,mind=0;
	for(int i=0;i<t.size();i++)
	{
		if(i!=x&&mval<t[i])
		{
			mval=t[i];
			mind=i;
		}
	}
	return mval;
}
int main()
{
	int n;
	cin>>n;
	vector<vector<int>>v(n,vector<int>(3,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>v[i][j];
		}
	}
	vector<vector<int>>cache(n,vector<int>(3,0));
	for(int i=0;i<3;i++)
	{
		cache[0][i]=v[0][i];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cache[i][j]=v[i][j]+max_val(cache[i-1],j);
		}
	}
	int res=cache[n-1][max_element(cache[n-1].begin(),cache[n-1].end())-cache[n-1].begin()];
	cout<<res<<endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    int ans=N;
    rep(i,N+1){
        int t=i;
        int u=N-i;
        int c=0;
        while(t>0){
            c+=(t%6);
            t/=6;
        }
        while(u>0){
            c+=(u%9);
            u/=9;
        }
        ans=min(ans,c);
    }
    cout << ans << endl;




    



}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define INF 1000000

int digit(int n) {
  int res = 0;
  while (n) {
    res++;
    n /= 10;
  }
  return res;
}

signed main() {
  int n;
  cin >> n;
  int ans = INF;
  for (int i = 1; i * i <= n; i++) {
    if (n % i) continue;
    int b = n / i;
    ans = min(ans, max(digit(i), digit(b)));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if len(set(a)) <= k:
  print(0)
else:
  count = {}
  for i in a:
    count.setdefault(i, 0)
    count[i] += 1
  m = len(count) - k
  print(sum(sorted(count.values())[:m]))

Measured memory_bytes: 36788
def tax(p,x):
    return p*(100+x)//100

while True:
    x,y,s=map(int,input().split())
    if x==y==s==0: 
        break
    sm=0
    for i in range(1,s):
        for j in range(i,s):
            if tax(i,x)+tax(j,x)==s:
                if sm<tax(i,y)+tax(j,y):
                    sm=tax(i,y)+tax(j,y)
    print(sm)


Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1e18L+5 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << ", ";} cout << "\n";

int main(){
    IOS;
    int n, w;
    cin >> n >> w;
    vector<ll> val(n), wgt(n);
    for(int i = 0; i<n; i++){
        cin >> wgt[i];
        cin >> val[i];
    }

    ll sum = 0;
    for(int i: val){
        sum += i;
    }
 
    vector<ll> dp(sum+1, INF);
    dp[0] = 0;

    for(ll item = 0ll; item<n; item++){
        // pcont(dp);
        for(ll value_already = sum-val[item]; value_already>=0; value_already--){
            dp[value_already+val[item]] = min(dp[value_already+val[item]], dp[value_already] + wgt[item]);
        }
    }

    ll ans = 0;
    for(ll i = 0ll; i<=sum; i++){
        if(dp[i] <= w){
            ans = max(ans, (ll)i);
        }
    }

    cout << ans << "\n";

    return 0;
}

/*
create dp with the weight as dimension
we need to maximum value for a particular weight
*/

Measured memory_bytes: 3920
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	ll ans = 0, l = 0;
	cin >> num;
	vector<ll> d(num);
	rep(i, num)
		cin >> d[i];
	rep(i, num) {
		if (l <= d[i])
			l = d[i];
		else
			ans += l - d[i];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4840
using System;


namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 0;
            int y = 0;
            while (true)
            {
                String s = Console.ReadLine();
                string[] ss = s.Split(' ');
                x = int.Parse(ss[0]);
                y = int.Parse(ss[1]);
                if ((x == 0) && (y == 0))
                {
                    break;
                    
                }
                else if (x > y)
                {
                    int t;
                    t = x;
                    x = y;
                    y = t;
                }
                Console.WriteLine(x + " " + y);
            }
        }
    }
}

Measured memory_bytes: 9244
def main():
    s = input()
    if s=='RRR':
        print(3)
    elif s=='RRS' or s=='SRR':
        print(2)
    elif s=='RSS' or s=='SRS' or s == 'SSR' or s=='RSR':
        print(1)
    else:
        print(0)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9096
n = int(input())
a = list(map(int, input().split()))
list.sort(a, reverse=True)

goukei = 0

if len(a) % 2 == 1:
	a.append(0)

for i in range(0,len(a),2):
	goukei = goukei + (a[i] - a[i + 1])
#	print(a[i],a[i+1])
print(goukei)

Measured memory_bytes: 3064
from math import gcd


MOD = 10**9 + 7

n = int(input())

cnt = {}

zero_cnt = 0
for i in range(n):
    a, b = map(int, input().split())
    if (a,b) == (0,0):
        zero_cnt += 1
        continue
    g = gcd(abs(a), abs(b))
    a //= g
    b //= g
    rotate = 0
    while not (a >= 0 and b > 0):
        a,b = -b,a
        rotate += 1
    if (a,b) not in cnt:
        cnt[(a,b)] = [0,0]

    cnt[(a,b)][rotate % 2] += 1

ans = 1
    
for key in cnt:
    A, B = cnt[key]
    ans *= 1 + pow(2, A, MOD) - 1 + pow(2, B, MOD) - 1
    ans %= MOD

ans += zero_cnt
ans -= 1
print(ans % MOD)

    


Measured memory_bytes: 60452
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int N, K; cin >> N >> K;
    vector<int> p(N); rep(i, N) cin >> p[i];

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

    int ans = 0;
    rep(i, K) {
        ans += p[i];
    }    

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


Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))

p,m = [],[]
p_total = 0
m_total = 0
p_max,p_min = 0,10**10
m_max,m_min = -10**10,0
p_count,p_min_idx,p_max_idx = 0,0,0
m_count,m_min_idx,m_max_idx = 0,0,0
for a in A:
    if a < 0:
        if m_min > a:
            m_min = a
            m_min_idx = m_count
        if m_max < a:
            m_max = a
            m_max_idx = m_count
        m_total += a
        m.append(a)
        m_count += 1
    else:
        if p_min > a:
            p_min = a
            p_min_idx = p_count
        if p_max < a:
            p_max = a
            p_max_idx = p_count
        p_total += a
        p.append(a)
        p_count += 1

if len(m) == 0:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])

elif len(p) == 0:
    print(2*m_max-m_total)
    for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
    print(m[m_max_idx],m[-1])

else:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i]

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<int>s,g;
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		if(a==1)s.emplace_back(b);
		if(b==n)g.emplace_back(a);
	}
	sort(g.begin(),g.end());
	if(g.size())for(auto&&i:s){
		if(*lower_bound(g.begin(),g.end(),i)==i){
			cout<<"POSSIBLE\n"s;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE\n"s;
}


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

int main() {
    ll N, W;
    cin >> N >> W;
    
    ll w[N], v[N];
    REP(i, N) cin >> w[i] >> v[i];
    
    ll dp[N + 1][W + 1];
    REP(i, N + 1) REP(j, W + 1) dp[i][j] = 0;

    for(ll i = 0; i < N; ++i) {
        for(ll sum_w = 0; sum_w <= W; ++sum_w) {
            if(sum_w - w[i] >= 0) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            
            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }
    
    cout << dp[N][W] << endl;

    return 0;
}

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


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

    long long N,A,B;
    cin >> N >> A >> B;
    long long x,y;
    x=N/(A+B);
    y=N%(A+B);
    if(A<y){
        y=A;
    }
    cout << x*A+y << endl;

}

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

//#define DEBUG

using namespace std;

int main(){
    int N, tmpa;
    int ans=0;

    cin >> N;

    for(int i=0; i<N; i++){
        cin >> tmpa;
        ans += tmpa - 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    char cx[30];
    int jhowmany, chowmany, i, j, jemx[20], jemy[20], cy[30], rx, ry, nx, ny, result;
    scanf(" %d", &jhowmany);
    while(jhowmany != 0){
        nx = 10;
        ny = 10;
        //first, get an unit of input.
        for(i=0;i<jhowmany;i++){
            scanf(" %d %d", &jemx[i], &jemy[i]);
        }
        scanf(" %d", &chowmany);
        for(i=0;i<chowmany;i++){
            scanf(" %hhc %d", &cx[i], &cy[i]);
        }
        for(i=0;i<chowmany;i++){
            //culc next place for robot, nx and ny.
            rx = nx;
            ry = ny;
            if(cx[i] == 'N'){
                ny += cy[i];
            }else if(cx[i] == 'S'){
                ny -= cy[i]; 
            }else if(cx[i] == 'E'){
                nx += cy[i];
            }else{
                nx -= cy[i];
            }

            //check if jem is between (nx, ny) and (rx, ry).
            for(j=0;j<jhowmany;j++){
                if(jemx[j] == -1)
                    continue;
                if((rx <= jemx[j] && jemx[j] <= nx && ry <= jemy[j] && jemy[j] <= ny) ||
                (rx >= jemx[j] && jemx[j] >= nx && ry <= jemy[j] && jemy[j] <= ny) ||
                (rx <= jemx[j] && jemx[j] <= nx && ry >= jemy[j] && jemy[j] >= ny) ||
                (rx >= jemx[j] && jemx[j] >= nx && ry >= jemy[j] && jemy[j] >= ny)){
                    jemx[j] = -1;
                }
            }
        }
        //check if all jems are corrected.
        result = 1;
        for(i=0;i<jhowmany;i++){
            if(jemx[i] != -1){
                puts("No");
                result = 0;
                break;
            }
        }
        if(result == 1){
            puts("Yes");
        }
        scanf(" %d", &jhowmany);
    }


}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const double pi=3.1415926;
const int M=2e5+5;
int a[M];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int t;
        scanf("%d",&t);
        a[t]++;
    }
    for(int i=1;i<=n;i++) printf("%d\n",a[i]);
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vector<pair<pair<int,int>,int>> vec;
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        vec.push_back({{a,b},c});
    }
    vvvi dp(n+1,vvi(401,vi(401,5000)));
    rep(i,n+1)dp[i][0][0]=0;
    for (int i=1;i<n+1;i++){
        for (int j=1;j<401;j++){
            for (int k=1;k<401;k++){
                int a=vec[i-1].fi.fi;
                int b=vec[i-1].fi.se;
                if (j>=a && k>=b){
                    dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-a][k-b]+vec[i-1].se);
                }
                else dp[i][j][k]=dp[i-1][j][k];
            }
        }
    }
    int ans=10000;
    for (int j=1;j<401;j++){
        for (int k=1;k<401;k++){
            if (j*mb!=k*ma)continue;
            else if (dp[n][j][k]==5000)continue;
            else ans=min(dp[n][j][k],ans);
        }
    }
    if (ans==10000)cout<<-1<<endl;
    else cout<<ans<<endl;


    return 0;
}

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

int main(){
int A, B;
cin >> A >> B;

if(A <= 5) cout << 0 << endl; 
else if(A >= 6 && A <= 12) cout << B / 2 << endl;
else if(A >= 13) cout << B << endl; 
}

Measured memory_bytes: 256