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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;
const ll MOD = 998244353;
const int MX = 3005;

int a, b, c, d;

ll dp[MX][MX];
bool vis[MX][MX];

int parents[MX][MX];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	
	queue<pair<int, int>> q;
	q.push({a, b});
	vis[a][b] = true;
	
	while (!q.empty()) {
		pair<int, int> v = q.front();
		q.pop();
		int h = v.first, w = v.second;
		
		if (!dp[h][w]) {
			ll lp = dp[h][w - 1], bp = dp[h - 1][w];
			lp = (lp * h) % MOD;
			bp = (bp * w) % MOD;
			dp[h][w] = (lp + bp) % MOD;
		
			if (parents[h][w] == 2) {
				dp[h][w] = dp[h][w] - (((h - 1) % MOD * (w - 1) % MOD) % MOD * dp[h - 1][w - 1] % MOD) + MOD;
				dp[h][w] %= MOD;
			}
			
		}
		
		++parents[h + 1][w];
		++parents[h][w + 1];
		if (h + 1 <= c && !vis[h + 1][w]) {
			q.push({h + 1, w});
			vis[h + 1][w] = true;
		}
		if (w + 1 <= d && !vis[h][w + 1]) {
			q.push({h, w + 1});
			vis[h][w + 1] = true;
		}
	}
	
	cout << dp[c][d];
}


Measured memory_bytes: 117996
#include "bits/stdc++.h"
using namespace std;

#define S second
#define F first
#define all(a) a.begin() , a.end()
#define pb push_back 
#define DBG cout<<"debug\n";

typedef long long ll;

const int N = 2 * 1e5 + 10;
const ll inf = 9e18 + 9; 

ll res;
ll a[N];


void solve(){
    ll n;
    cin>>n;
    vector<ll> v(n);

    double xm = 0;

    for(auto &i : v) {
        cin>>i;
    }

    sort(all(v));
    xm = v[0];
    for(int i = 1 ; i < v.size() ;i++) {
        xm = (xm + v[i])/2;
    }

    cout<<xm<<"\n";
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main(){
    string a;
    int b = 0;
    cin >> a;
    for(int i =0; i<4; i++){
        if(a[i] == '+'){
            ++b;
        }else{
            --b;
        }
    }
    cout << b << endl;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	int A[100010];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	for (int i = 0; i < N; i++) {
		int cover = (K - 1) * i + 1; 
		if (cover >= N) {
			cout << i << endl;
			break;
		}
	}
    return 0;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
//--
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstdio>
#include<cstring>
#include<sstream>
#define X first
#define Y second
#define pb push_back

using namespace std;
priority_queue<int> hoge;

int aa=3,num,maxN,minN,dig
,powT[]={1,10,100,1000,10000,100000,10000000};
map<int,int> mark;

int main(){
  int i,j,t;
  while(1){
    scanf("%d %d",&num,&dig);
    mark.clear();
    t=1;
    mark[num]=t;
    if(num==0 && dig==0)
      break;
    while(1){
      t++;
      int temp=num;
      maxN=0;
      minN=0;
      for(i=0;i<dig;i++){
        hoge.push(temp%10);
        temp/=10;
      }
      for(i=0;i<dig;i++){
        maxN+=powT[dig-i-1]*hoge.top();
        minN+=powT[i]*hoge.top();
        hoge.pop();
      }
      num=maxN-minN;
      //cout<<maxN<<"-"<<minN<<"="<<num<<endl;
      if(mark[num]>0){
        printf("%d %d %d\n",mark[num]-1,num,t-mark[num]);
        break;
      }else{
        mark[num]=t;
      }
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int s1 = N / 1000;
  int s2 = N / 100 - 10 * s1;
  int s3 = N / 10 - 100 * s1 - 10 *  s2;
  int s4 = N - (1000 * s1 + 100 * s2 + 10 * s3);
  
  if ((s1 == s2 && s2 == s3) || (s2 == s3 && s3 == s4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60) {
    ll x = 0;
    rep(j, n) if (a[j] >> i & 1) x++;  // i桁目が1の数
    ll now = x * (n - x) % mod;
    rep(j, i) now = now * 2 % mod;
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    long long int N, a, sum =0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> a;
        while(a % 2 ==0){
            sum ++;
            a /= 2;
        }
    }

    cout << sum;

    return 0;

}



Measured memory_bytes: 256
// ref: https://img.atcoder.jp/abc089/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int H, W, D; cin >> H >> W >> D;
    vector<pair<int,int>> idx2ij(H*W);
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            int idx; cin >> idx; --idx;
            idx2ij[ idx ].first  = i;
            idx2ij[ idx ].second = j;
        }
    }
    
    vector<int> vSum(H*W, 0);
    for(int idx=D; idx<H*W; ++idx){
        int i = idx2ij[ idx-D ].first;
        int j = idx2ij[ idx-D ].second;
        int x = idx2ij[ idx   ].first;
        int y = idx2ij[ idx   ].second;
        int tmp = abs( x-i ) + abs( y-j );
        
        vSum[idx] = vSum[idx-D] + tmp;
    }
    
    int Q; cin >> Q;
    for(int i=0; i<Q; ++i){
        int L, R; cin >> L >> R; --L; --R;
        cout << vSum[R] - vSum[L] << endl;
    }
    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> c(n);
    for(int i=0; i<n; i++){
        cin >> x.at(i);
        c.at(i) = x.at(i);
    }
    sort(c.begin(),c.end());
    int a,b;
    a=c.at(n/2-1);
    b=c.at(n/2);
    for(int i=0; i<n; i++){
        if(x.at(i) <= a) cout << b << endl;
        else cout << a << endl;
    }
}

Measured memory_bytes: 4840
#include <iostream>

using namespace std;

typedef long long   ll;
typedef long double ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(ll N, ll X, ll T) {
  ll res;
  res = (N/X)*T;
  if (N % X)
    res += T;

  return (res);
}

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

  ll N, X, T;
  cin >> N >> X >> T;

  auto ans = solve(N, X, T);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

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

    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();

    ll dp[n+1][m+1];
    for(ll i=0;i<=n;++i){dp[i][0]=0;}
    for(ll j=0;j<=m;++j){dp[0][j]=0;}

    for(ll i=1;i<=n;++i){
        for(ll j=1;j<=m;++j){
            if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    string ans="";
    ll i=n,j=m;
    while(ans.length()<dp[n][m])
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i-=1;
            j-=1;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1]){
                i-=1;
            }
            else{
                j-=1;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;

    return (0);
}


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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif

const int MOD = 1000000007;

int main(){
    IOS;
    int n;
    cin >> n;
    int a[n];

    for (int i = 0; i< n; i++){
        cin >> a[i];
    }

    int count = 0;
    for (int i = 1; i < n - 1; i++){
        if ((a[i] > a[i-1] && a[i] < a[i+1]) || (a[i] < a[i-1] && a[i] > a[i+1])){
            count++;
        }
    }
    cout << count << endl;

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a[3], count=0;
  for(int i=0; i<3; i++) cin >> a[i];
  if (a[0]!=a[1]) count++;
  if (a[0]!=a[2]) count++;
  if (a[1]!=a[2]) count++;
  if (count==0) count++;
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()


def pow_mod(x,n):
    if n==0:
        return 1
    
    K = 1
    while n>1:
        if n%2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

def factorial(n,mod):
    factorial = 1
    for i in range(1,n+1):
        factorial *= i
        factorial %= mod
    return factorial

def n_C_k(n,k,mod):
    factorial_n = factorial(n,mod)
    factorial_k = factorial(k,mod)
    factorial_nk = factorial(n-k,mod)
    conbi=factorial_n*pow_mod(factorial_nk,mod-2)*pow_mod(factorial_k,mod-2)
    return conbi%mod

ans=0
mod = 10**9+7
factorial_N = factorial(N,mod)

for i in range(N-K+1):
    if i==0:
        conbi = n_C_k(N-1,K-1,mod)
    else:
        conbi *= (N-K-i+1)*pow_mod(N-i,mod-2)
        conbi %= mod
    ans += (A[N-1-i]-A[i])*conbi
    ans %= mod

print(ans)



Measured memory_bytes: 63344
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;

int main()
{
  std::cin >> S;

  ll cnt = 0;

  rep( i, S.size() ) if( S[i] == 'o' )
    ++cnt;

  puts( cnt+(15-S.size()) >= 8 ? "YES" : "NO" );

  return 0;
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

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

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    cini(m);
    vector<pii> a(n);

    fori(n) {
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(), a.end());

    multiset<int> bees;
    int idx=0;
    ll ans=0;
    for(int i=1; i<=m; i++) {
        while(idx<n && a[idx].first<=i) {
            bees.insert(a[idx].second);
            idx++;
        }
        if(bees.size()>0) {
            auto it=bees.end();
            it--;
            int val=*it;
//cout<<"days "<<i<<" job worth="<<val<<endl;
            ans+=val;
            bees.erase(it);
        }
    }

    cout<<ans<<endl;
}



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

N = int(input())
As = list(mapint())
s = set()
for i in range(N+1):
    a = As[i]
    if a in s:
        r = N-i
        l = As.index(a)
        break
    s.add(a)
mod = 10**9+7
rest = l+r

pos = {}
neg = {}
pos[0] = 1
neg[0] = 1
c = 1
for i in range(1, 10**5+5):
    c *= i
    c %= mod
    pos[i] = c
    neg[i] = pow(c, mod-2, mod)

for i in range(1, N+2):
    All = pos[N+1]*neg[i]*neg[N+1-i]%mod
    if rest-i+1>=0:
        kaburi = pos[rest]*neg[i-1]*neg[rest-i+1]%mod
    else:
        kaburi = 0
    print((All-kaburi)%mod)

Measured memory_bytes: 130092
import heapq

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

B_pool = 0
deck = []
for i in range(N):
	heapq.heappush(deck, A[i]-B[i])

while deck:
	diff = heapq.heappop(deck)
	if diff <= 0:
		B_pool += (-diff) // 2
	else:
		B_pool -= diff

if B_pool >= 0:
	print('Yes')
else:
	print('No')

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

int main()
{
	int A, B, C, X, a , b , c, x, n;
	cin >> A >> B >> C >> X;
	
	a = 0; n = 0;
	
	while(X - 500*a >= 0 && a <= A)
	{
		b = 0;
		while(X - 500*a  - 100 * b >=0 && b <= B)
		{
			x =  X - 500 * a - 100 * b;
			c = x / 50;
			
			if(c <= C)
			{
				n += 1;
			}
			b++;
		}
		a++;
	}
	
	cout << n << endl;
}

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

using namespace std;

#define debug(x) cout << "\n" << __LINE__ << " " <<  (#x) << " is " << (x) << endl

#define MAXN 200001
int N;
int distaL[MAXN];
int distaR[MAXN];
string S;

int findL(int i){
	if(S[i] == 'L')return 0;
	if(distaL[i] != -1)return distaL[i];
	return distaL[i] = 1 + findL(i + 1);
}

int findR(int i){
	if(S[i] == 'R')return 0;
	if(distaR[i] != -1)return distaR[i];
	return distaR[i] = 1 + findR(i - 1);
}

int main(){
	#ifdef EVAL	
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	cin >> S;
	N = S.size();
	vector<int> v(N,0);
	memset(distaL,-1,sizeof(distaL));
	memset(distaR,-1,sizeof(distaR));
	for(int i = 0; i < N; i++){
		if(S[i] == 'R'){
			int len = findL(i);
			//cout << "la posizione " << i << " dista da L " << len << endl; 
			if(len % 2 == 0){
				v[i + len]++;
			}else{
				v[i + len - 1]++;
			}
		}else{
			int len = findR(i);
			//cout << "la posizione " << i << " dista da R " << len << endl; 
			if(len % 2 == 1){
				v[i - len + 1]++;
			}else{
				v[i - len]++;
			}
		}
	}
	for(int i = 0; i < N; i++){
		cout << v[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 5760
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var K = int.Parse(inputs[1]);
        inputs = Console.ReadLine().Split(' ');
        var x = new long[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = long.Parse(inputs[i]);
        }

        long ans = 1000000000;
        for (int i = 0; i < N; i++)
        {
            if (i + K - 1 == N)
            {
                break;
            }
            var xl = x[i];
            var xr = x[i + K - 1];

            var leftToRight = Math.Abs(xl) + Math.Abs(xl - xr);
            var rightToLeft = Math.Abs(xr) + Math.Abs(xr - xl);
            var min = Math.Min(leftToRight, rightToLeft);
            ans = Math.Min(min, ans);
        }

        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 20448
#include<stdio.h>
int main()
{
    int n,a[1001],b[1001],i,c=0,j,temp=0;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]),b[i]=a[i];
    for(i=0; i<n; i++)
    {
        for(j=0; j<n-1; j++)
        {
            if(a[j]>a[j+1])
            {
                temp =a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
   // for(i=0; i<n; i++)
        //printf("%d ",a[i]);

    for(i=0; i<n; i++)
    {
        if(a[i]!=b[i])
            c++;
    }
    if(c>2)
        printf("NO");
    else
        printf("YES");
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
typedef long long ll;
ll ans=0;
int cur=0;
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for(auto c:s){
		if(c=='B') cur++;
		else ans+=cur;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:> 
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
    string S;

    
    int dx = tx - sx;
    int dy = ty - sy;
    
    for (int i = 0; i < dy;i++) {
        S += "U";
    }
    for (int i = 0; i < dx; i++) {
        S += "R";
    }
    for (int i = 0; i < dy;i++) {
        S += "D";
    }
    for (int i = 0; i <= dx; i++) {
        S += "L";
    }
    for (int i = 0; i <= dy;i++) {
        S += "U";
    }
    for (int i = 0; i <= dx; i++) {
        S += "R";
    }
    S += "D";
    S += "R";
    for (int i = 0; i <= dy;i++) {
        S += "D";
    }
    for (int i = 0; i <= dx; i++) {
        S += "L";
    }
    S += "U";
    
    cout << S << endl;
    return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

struct UF
{
	vector<int> par; // 親
	vector<int> sz; // 数
	// 初期化
	UF(int n):par(n),sz(n) {
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;
		}
	}
	// 木の根を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		par[x] = y;
		sz[y] += sz[x];
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int n){return sz[find(n)];}
};

vector<pair<ll,pair<ll,ll>>> v;
vector<pair<ll,ll>> h;
ll n,m;

int main(){
	while(cin >> n >> m,n|m){
		h.clear();
		v.clear();
		REP(i,n){
			ll tmp;cin >> tmp;
			h.PB(MP(tmp,i));
		}
		REP(i,m){
			ll a,b,c;cin >> a >> b >> c;
			a--;b--;
			v.PB(MP(c,MP(a,b)));
		}
				
		sort(ALL(h));
		sort(ALL(v));
		vector<int> jun(n);
		REP(i,n)jun[h[i].SE] = i;

		UF seica(n);
		REP(i,m){
			int A = v[i].SE.FI;
			int B = v[i].SE.SE;
			if(!seica.same(A,B)){
				seica.unite(A,B);
			}
		}
		if(seica.size(0) != n){
			cout << 0 << endl;
		}
		else{
			vector<bool> sink(n);
			
			int cou = 0;
			while(1){
				int tmp = cou;
				while(cou < n-1 && h[cou].FI == h[cou+1].FI){
					cou++;
				}
				DBG(cout << "before cou " << cou << endl;)
				if(cou == n-1){
					cou = tmp - 1;
					break;
				}
				
				UF uf(n);
				REP(i,m){
					int A = v[i].SE.FI;
					int B = v[i].SE.SE;
					if(jun[A] > cou && jun[B] > cou && !uf.same(A,B)){
						uf.unite(A,B);
					}
				}
				int ma = 0;
				REP(i,n)ma = max(ma,uf.size(i));
				if(ma != n - cou -1){
					cou = tmp - 1;
					break;
				}
				DBG(cout << "after cou " << cou << endl;)
				cou++;
			}
			DBG(cout << "OUT CHECK " << cou << endl;);
			ll ans = 0;
			UF uf(n);
			while(1){
				REP(i,m){
					int A = v[i].SE.FI;
					int B = v[i].SE.SE;
					if(jun[A] > cou && jun[B] > cou && !uf.same(A,B)){
						uf.unite(A,B);
						ans += v[i].FI;
					}
				}
				DBG(cout << "cou " << cou << endl;)
				if(cou < 0)break;
				while(cou > 0 && h[cou].FI == h[cou-1].FI)cou--;
				cou--;
			}
			
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3808
loop {
    w, h = gets.split.map &:to_i
    break if w == 0
    max = (1..h).map{ gets.split("").map{|s| s =~ /\d/ ? s.to_i : -1} }
    
    opt = 0 
    (0..h-1).each{|i|
        (0..w-1).each{|j|
            next if max[i][j] < 0 
            m = 0 
            m = max[i-1][j] if i > 0 && max[i-1][j] > m 
            m = max[i][j-1] if j > 0 && max[i][j-1] > m 
            max[i][j] += 10 * m 
            opt = max[i][j] if max[i][j] > opt 
        }
    }   
    p opt 
}

Measured memory_bytes: 6160
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include<bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  int A[2000];
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A,A+N);
  int ret = 0;
  for(int a = 0; a < N; a++) {
    for(int b = a + 1; b < N; b++) {
      for(int c = b + 1; c < N; c++) {
        ret += A[a] + A[b] > A[c];
      }
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
   var (
        grid [52][52]bool // t=>black, f=>white
        row, col int
    )
    
    fmt.Scan(&row, &col)
    
    for i := 1; i <= row; i++ {
        var line string
        fmt.Scan(&line)
        for j := 1; j <= col; j++ {
            if line[j-1] == '#' {
                grid[i][j] = true
            }
        }
    }
    
    for i := 1; i <= row; i++ {
        for j := 1; j <= col; j++ {
            if grid[i][j] == true {
                if !(grid[i-1][j] || grid[i][j-1] || grid[i+1][j] || grid[i][j+1]) {
                    fmt.Println("No")
                    return
                }
            }
        }
    }
    
    fmt.Println("Yes")
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int maxn = 2012;
int a[maxn],ord[maxn];
vector<int> t;
int n,k,q;
bool vis[maxn],era[maxn];
bool cmp(const int A,const int B)
{
	return a[A]<a[B];
}
void erase_t()
{
	sort(t.begin(),t.end(),cmp);
	reverse(t.begin(),t.end());
//	for(int i=0;i<t.size();i++)
//	cout<<a[t[i]]<<" ";cout<<endl;
	for(int i=0;i<min((int)t.size(),k);i++)
	{
		era[t[i]] = 1;
//		cout<<"ERA: "<<t[i]<<endl;
	}
	return ;
}
void work()
{
	memset(era,0,sizeof(era));
	int i=1,j=0;
	while(i!=n+2)
	{
//		cout<<"->"<<i<<" "<<j<<endl;
		t.clear();
		while(!vis[j+1])
		{
			j++;
			t.push_back(j);
		}
//		cout<<"<-"<<i<<" "<<j<<endl;
		erase_t();
		i = j+2;
		j = i-1;
	}
	return ;
}
int main()
{
	cin>>n>>k>>q;k--;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ord[i] = i;
	}
	sort(ord+1,ord+1+n,cmp);
	int ans = 1<<30;
	memset(vis,0,sizeof(vis));
	vis[0] = vis[n+1] = 1;
	for(int i=1;i<=n;i++)
	{
		work();
//		cout<<"work ok"<<endl;
		int cnt = 0;
		for(int j=i;j<=n;j++)
		if(!era[ord[j]])
		{
			cnt++;
			if(cnt==q)
			{
//				cout<<"Find: "<<j<<endl;
				ans = min(ans,a[ord[j]]-a[ord[i]]);
				break;
			}
		}
		if(cnt<q)break;
		vis[ord[i]] = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int q;
    scanf("%d", &q);
    lint L = 0, R = 0;
    while(q--){
        int p;
        lint n;
        char c;
        scanf("%d %c %lld", &p, &c, &n);
        if(c == '(') L += n;
        else R += n;
        puts(L==R ? "Yes" : "No");
    }
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x+mo_num)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;

int32_t main()
{
    IOS
    cin>>n>>m;
    cout<<max({m+n,n-m,n*m});
    return 0;
}

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

int a[1001];

int main() {

  int n;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import  Counter

n,p=map(int,input().split())

def fctr1(n):
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

tmp=fctr1(p)

ans=1
for i in range(len(tmp)):
    if tmp[i][1]>=n:
        ans*=(tmp[i][0]**(tmp[i][1]//n))


print(ans)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
pair<long long,long long>a[N],temp;
long long c[N];
long long dp[N];

bool mycmp(pair<long long ,long long> x,pair<long long,long long> y)
{
	return x.first*(y.second+1)>y.first*(x.second+1);
}
int main()
{
	long long n,t;
	scanf("%lld%lld",&n,&t);
	int cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
	 {
	 		scanf("%lld%lld",&temp.first,&temp.second);
	 	if(temp.first==0)c[cnt2++]=temp.second+1;
	 	else a[cnt1++]=temp;
	 }
	sort(c,c+cnt2);
	sort(a,a+cnt1,mycmp);
	for(int i=1;i<=30;i++)
	dp[i]=t+1;
	dp[0]=0;
	for(int i=1;i<cnt2;i++)c[i]+=c[i-1];
	for(int i=0;i<cnt1;i++)
	 {
	 	for(int j=30;j>=1;j--)
	 	dp[j]=min(dp[j],(a[i].first+1)*(dp[j-1]+1)+a[i].second);
	 }
	int ans=0;
	for(int i=0;i<=30;i++)
	{
		if(dp[i]>t)continue;
		int add=0;
		if(cnt2)add=upper_bound(c,c+cnt2,t-dp[i])-c;
		ans=max(ans,i+add);
	}
	printf("%d\n",ans);
}

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

signed main() {
  int N;
  cin >> N;
  
  string S = "";
  if( N == 0 ){
    S = "0";
  }
  while( N != 0 ){
    if( N%2 != 0 ){
      N--;
      S = '1' + S;
    }
    else S = '0' + S;
    N /= -2;
  }
  cout << S << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

//右下左上
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll n, a;
    cin >> n;
    vll b, ans;
    rep(i, 0, n)
    {
        cin >> a;
        b.push_back(a);
    }
    rep(i, 0, n)
    {
        repm(j, b.size() - 1, 0)
        {
            if (b[j] == j + 1)
            {
                ans.push_back(b[j]);
                b.erase(b.begin() + j);
                break;
            }
            else if (b[j] >= j + 1)
                return cout << -1 << endl, 0;
        }
    }
    reverse_v(ans);
    rep(i, 0, n) cout << ans[i] << endl;
}


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

const int N = 648;

int n, D1, D2;
int a[N][N];

void coloring(int dist, int bit) {
	int i, j, L = ctz(dist) / 2; dist >>= 2 * L;
	switch (dist & 3) {
		case 0: throw "gg"; break;
		case 1: for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) a[i][j] |= ((i ^ j) >> L & 1) << bit; break;
		case 2: for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) a[i][j] |= (i >> L & 1) << bit; break;
	}
}

int main() {
	int i, j, c, d, col[4] = {0};
	scanf("%d%d%d", &n, &D1, &D2), d = n * n, n *= 2, coloring(D1, 0), coloring(D2, 1);
	for (i = 0; i < n; ++i)
		for (j = 0; j < n; ++j) ++col[ a[i][j] ];
	c = std::max_element(col, col + 4) - col;
	for (i = 0; i < n && d; ++i)
		for (j = 0; j < n && d; ++j)
			if (a[i][j] == c) --d, printf("%d %d\n", i, j);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include<stdio.h>

using namespace std;

int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int sum=0;
    if(n*a<=b)
        printf("%d\n",n*a);
    else printf("%d\n",b);

    return 0;
}


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

int main(){
	int n;
	scanf("%d",&n);
	int x=-1,y=-1;
	if(n%2==0){
		for(int i=2;i<=n-1;i++){
			int c=(n^i^1);
			if(c>=1&&c<=n-1&&c!=i){
				x=i;
				y=c;
				break;
			}
		}
	}
	if(n<=2||(n%2==0&&x==-1)){
		puts("No");
	}
	else{
		puts("Yes");
		printf("%d %d\n",n+1,n+2);
		for(int i=2;i+1<=n;i+=2){
			printf("%d %d\n",n+i,i+1);
			printf("%d %d\n",i+1,1);
			printf("%d %d\n",1,i);
			printf("%d %d\n",i,n+i+1);
		}
		if(x!=-1){
			printf("%d %d\n",x,n);
			printf("%d %d\n",y,n+n);
		}
	}
	return 0;
}

// 1 2 3 4 5

Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<ll, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<ldouble, ldouble> pdd;

void solve() {
	int x, y; scanf("%d%d", &x, &y);
	if(x % y == 0) {
		puts("-1");
	}
	else {
		for(ll i=x;;i+=x) {
			if(i % y) {
				printf("%lld\n", i);
				return;
			}
		}
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define mod 1e9+7
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

int main(void){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(b/n>=a)printf("%d",n*a);
	else		printf("%d",b);
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int last = X;
		last = last - A;
		last = last % B;
		System.out.println(last);
	}
}

Measured memory_bytes: 22100
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

signed main(){
	ll a,b;
	cin >> a >> b;
	
	cout << max((ll)0,a-2*b) << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    from itertools import accumulate
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n//i != i:
                    # i が平方数でない
                    divs.append(n//i)
        return divs

    divs = enum_divisors(sumA)
    divs.sort(reverse=True)

    for d in divs:
        if d == 1:
            print(d)
            return
        diff_n = []
        for a in A:
            if a % d != 0:
                diff_n.append(a % d)
        diff_n.sort()
        diff_p = []
        for dn in diff_n:
            diff_p.append(d - dn)
        S_n = list(accumulate([0] + diff_n))
        S_p = list(accumulate([0] + diff_p))
        M = len(S_n) - 1
        if min(S_n[i] for i in range(1, M)
               if (S_n[i] - (S_p[M] - S_p[i])) == 0) <= K:
            print(d)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 73984
from heapq import heappush, heappop
INF = float("inf")


def dijkstra(v, st, g):
    dist = [INF] * v
    dist[st] = 0
    hq = [(st, 0)]  # (頂点，重み)
    while hq:
        u, d = heappop(hq)
        if dist[u] < d:
            continue
        for nu, w in g[u]:  # (隣接頂点，重み)
            nw = d + w
            if dist[nu] > nw:
                dist[nu] = nw
                heappush(hq, (nu, nw))
    return dist


def main():
    v, e, st = map(int, input().split())
    g = [[] for _ in range(v)]
    for _ in range(e):
        s, t, d = map(int, input().split())
        g[s].append((t, d))  # s->tの有向グラフ
    for ans in dijkstra(v, st, g):
        if ans == INF:
            print('INF')
        else:
            print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 136932
#include <iostream>


double func(double input) {
    return input * input;
}

double integral(double h, double min_x = 0, double max_x = 600) {
    double sum = 0;
    for (double x = min_x; x < max_x; x+= h) {
        sum += func(x) * h;
    }
    return sum;
}

int main()
{
    int input;
    while(std::cin >> input) {
        std::cout << (int)integral(input) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, T = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))

cummin = list(itertools.accumulate(A, min))
rcummax = list(reversed(list(itertools.accumulate(reversed(A), max))))

max_profit = 0
for mi, ma in zip(cummin, rcummax):
    max_profit = max(max_profit, ma - mi)

mic = 0
mac = 0
for a, mi, ma in zip(A, cummin, rcummax):
    if a == mi and ma - mi == max_profit:
        mic += 1
    if a == ma and ma - mi == max_profit:
        mac += 1
print(min(mic, mac))


Measured memory_bytes: 24432
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll a,b,c,k;
string result="No";
cin >>a >>b>>c;
cin>>k;
  for(int i=0;i<=k&&result=="No";i++){
   for(int n=0;n<=k-i&&result=="No";n++){
    if(a*pow(2,i+1)<b*pow(2,n+1)&&b*pow(2,n+1)<c*pow(2,k-n-i+1))result="Yes"; 
   }
  }
cout <<result;
return 0;
}






ll gcd(ll a, ll b){

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

}


Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>

long long q, h, s, d;
long long n;
int main() {
	std::cin >> q >> h >> s >> d;
	std::cin >> n;

	long long one = std::min({ 4 * q,2 * h,s });
	long long two = std::min(one * 2, d);
	std::cout << two * (n / 2) + one * (n % 2) << std::endl;
	return 0;
}


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

int main()
{
    int m,t,p,j;
    while(cin>>m>>t>>p>>j,m||t||p||j){
        vector<pair<pair<int,int>,int> >team(t);
        REP(i,t)team[i].second=-i-1;
        vector<vector<int> >pro(t,vector<int>(p,0));
        int a,b,c,d;
        REP(i,j){
            cin>>a>>b>>c>>d;b--;c--;
            if(d) pro[b][c]++;
            else {
                team[b].first.first--;
                team[b].first.second+=a+pro[b][c]*20;
            }
            
        }
        sort(team.begin(),team.end());
        cout<<-team[0].second;
        rep(i,1,t) cout<<(team[i].first==team[i-1].first?"=":",")<<-team[i].second;cout<<endl;
    }
}


Measured memory_bytes: 3048
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;

int main() {

  int N, M, P;
  cin >> N >> M >> P;
  vector<ll> dist(N,LINF);
  dist[0] = 0;

  vector<ll> a(M);
  vector<ll> b(M);
  vector<ll> c(M);

  REP(m,M){
    ll atmp, btmp, ctmp;
    vector<ll> vtmp(2);
    cin >> atmp >> btmp >> ctmp;
    atmp-=1, btmp-=1;
    ctmp = - ctmp + P;
    a[m] = atmp;
    b[m] = btmp;
    c[m] = ctmp;
  }


  REP(n,N){
    REP(m,M){
      ll atmp, btmp, ctmp;
      atmp = a[m];
      btmp = b[m];
      ctmp = c[m];
      if(dist[atmp] == LINF) continue;
      if (dist[btmp] > dist[atmp] + ctmp) dist[btmp] = dist[atmp] + ctmp;
    }
    
  }


  ll ans = dist[N-1];
  vector<bool> negative(N,false);

REP(n,N){
  REP(m,M){
    ll atmp, btmp, ctmp;
    atmp = a[m];
    btmp = b[m];
    ctmp = c[m];
    if (dist[atmp] == LINF) continue;

    if (dist[btmp] > dist[atmp] + ctmp){
      dist[btmp] = dist[atmp] + ctmp;
      negative[btmp] = true;
    }

    if (negative[atmp] == true) negative[btmp] = true;
  }
}

  if (negative[N-1]){
    cout << -1 << endl;
  }else{
    ans = - ans;
    if (ans < 0) ans = 0;
    cout << ans << endl;
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    int P,Q,R; cin>>P>>Q>>R;
    vector<int> S(3);
    S[0]=P;S[1]=Q;S[2]=R;
    sort(S.begin(),S.end());
    cout<<S[0]+S[1];

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int M, T, P, R;

int main() {
	struct team {
		int number, point, time;
		bool operator<(const team& right) const {
			// ポイントは大きい方が↑、同じなら時間小さい方が↑；さらに番号大きい順だった。。。（ｙｋｙｍ）
			if (point == right.point && time == right.time) return number < right.number;
			return point == right.point ? time > right.time : point < right.point;
		}
	};
	while (1) {
		cin >> M >> T >> P >> R;
		if (M == 0 && T == 0 && P == 0 && R == 0) break;
		vector<team> teams;
		team ttemp;
		repi(i, 0, T) {
			team t;
			t.number = i, t.point = 0, t.time = 0;
			teams.push_back(t);
		}
		int mi, ti, pi, ji;//経過時間、チーム番号、問題番号、ジャッジの種類
		int timetemps[51][11] = {};//[チーム番号][問題番号]
		repi(i, 0, R) {
			cin >> mi >> ti >> pi >> ji;
			if (ji == 0) {
				//正解
				teams[ti - 1].point++;
				teams[ti - 1].time += (timetemps[ti - 1][pi] + mi);
			}
			else {
				//不正解
				timetemps[ti-1][pi] += 20;
			}
		}
		sort(teams.begin(), teams.end());
		reverse(teams.begin(), teams.end());
		repi(i, 0, teams.size()) {
			if (i > 0) {
				if (teams[i].point == teams[i - 1].point && teams[i].time == teams[i - 1].time) {
					wr("=");
				}
				else {
					wr(",");
				}
			}
			wr(teams[i].number + 1);
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>

int main(void){
  int h[100];
  int w[100];
  int i = 0;
  int j = 0;
  int k = 0;
  int n,m;

  while(1){
    scanf("%d %d", &h[i], &w[i]);
    if(h[i] == 0 && w[i] == 0)
      break;
    i++;
  }
  while(j < i-1){
    for(n = 0; n < h[j]; n++){
      for(m = 0; m < w[j]; m++){
	putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
  j++;
  }
  
for(n = 0; n < h[j]; n++){
      for(m = 0; m < w[j]; m++){
	putchar('#');
      }
      putchar('\n');
    }
 putchar('\n');

  return 0;
}

Measured memory_bytes: 572