akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}
ll pow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}
ll divi(ll x,ll y){return mul(x,pow(y,mod-2));}

ll fuc[300000];

ll nCr(ll n,ll r){
  return divi( fuc[n] , mul( fuc[n-r] , fuc[r] ) );
}

int main(){
  fuc[0]=1;
  for(int i=1;i<300000;i++)    fuc[i]=mul(i,fuc[i-1]);
  
  ll H,W,A,B;
  cin>>H>>W>>A>>B;

  if(A==H || W==B){
    cout<<0<<endl;
    return 0;
  }
  
  ll ans=0;
  for(ll i=1;i<=H-A;i++){
    ll dy=i-1;
    ll dx=B-1;
    ll dy2=H-i;
    ll dx2=W-B-1;

    ans= add(ans,    mul( nCr(dy+dx,dx) , nCr(dy2+dx2,dx2) ) );
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		print();
	}

	public static void print() {
		try {
			long answer = 1;
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			int num = Integer.parseInt(str);

			for (int i = 0; i < num; i++) {
				answer = answer * (i + 1);
			}

			System.out.println(answer);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

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

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    unordered_map<int, ll> m(n);

    vector<int> arr(n);
    for (int i = 0; i < n; ++i) {
        int v; cin >> v;
        arr[i] = v;
        m[arr[i]]+= 1;
    }
    ll sum = 0;

    for (auto it : m) if (it.second > 1) sum += (it.second) * (it.second-1) / 2;
    for (int i = 0; i < n; ++i) {
        auto v = m[arr[i]];
        cout << sum - (v * (v-1) / 2) + ((v-1)*(v-2)/2) << endl;
    }

    
    return 0;
}



Measured memory_bytes: 7936
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define MAXNUM 300000

int main(void){
	int n, p, i, j, count1, count2, flag[MAXNUM + 1], tmp[MAXNUM + 1];
	for(i = 0;i <= MAXNUM;i++)
		flag[i] = 1;
	flag[0] = flag[1] = 0;
	for(i = 2;i <= sqrt((double)MAXNUM);i++){
		for(j = 2 * i;j <= MAXNUM;j += i)
			flag[j] = 0;
	}
	while(1){
		scanf("%d%d",&n,&p);
		if(n == -1 && p == -1)
			break;
		count1 = 0;
		memset(tmp,0,sizeof(tmp));
		for(i = n + 1;count1 < p;i++){
			if(flag[i]){
				count1++;
				count2 = 0;
				for(j = i;count2 < p;j++){
					if(flag[j]){
						count2++;
						tmp[i + j]++;
					}
				}
			}
		}
		count1 = 0;
		for(i = n + 1;count1 < p;i++){
			if(tmp[i])
				count1 += tmp[i];
		}
		printf("%d\n",i - 1);
	}
	return 0;
}

Measured memory_bytes: 3372
use proconio::input;
fn main() {
    input! {
        x:i64,
    }

    for i in -3000i64..3000i64 {
        for j in -3000i64..3000i64 {
            if i.pow(5) - j.pow(5) == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}


Measured memory_bytes: 2136
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	//int INF = 1 << 28;
	long INF = 1L << 60;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for (;;) {
			//input
			int n = sc.nextInt(), m = sc.nextInt();
			if ((n|m) == 0) break;
			
			long[][] s = new long[n][n], l = new long[n][n];
			for (int i=0;i<n;i++) {
				fill(s[i], INF);
				fill(l[i], INF);
				s[i][i] = l[i][i] = 0;
			}
			
			for (int i=0;i<m;i++) {
				int x = sc.nextInt()-1, y = sc.nextInt()-1, t = sc.nextInt();
				char sl = sc.next().charAt(0);
				if (sl == 'S')	s[x][y] = s[y][x] = min(s[x][y], t);
				else 			l[x][y] = l[y][x] = min(l[x][y], t);
			}

			int r = sc.nextInt();
			int[] ps = new int[r];
			for (int i=0;i<r;i++) ps[i] = sc.nextInt()-1;
			
			// WF
			for (int k=0;k<n;k++) for (int i=0;i<n;i++) for (int j=0;j<n;j++) {
				s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
				l[i][j] = min(l[i][j], l[i][k] + l[k][j]);
			}

			long[][] dp = new long[r][n];
			for (long[] a : dp) fill(a, INF); dp[0][ps[0]] = 0;
			
			for (int i=1;i<r;i++) for (int j=0;j<n;j++) {
				dp[i][j] = min(dp[i][j], dp[i-1][j] + l[ps[i-1]][ps[i]]);
				for (int k=0;k<n;k++) 
					dp[i][j] = min(dp[i][j], dp[i-1][k] + l[ps[i-1]][k] + s[k][j] + l[j][ps[i]]);
			}

			long ans = INF;
			for (int i=0;i<n;i++) ans = min(ans, dp[r-1][i]);
			
			System.out.println(ans);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 63944
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 100005;
const LL inf = 1ll<<50;

LL f[maxn][3];
char c[maxn][5];int n,a[maxn];

int main()
{
	#ifdef Amberframe
		freopen("arc066c.in","r",stdin);
		freopen("arc066c.out","w",stdout);
	#endif
	scanf("%d %d",&n,&a[0]);
	for (int i=1;i<n;i++)
		scanf("%s %d",c[i],&a[i]);
	f[0][0]=a[0];f[0][1]=f[0][2]=-inf;
	
	for (int i=1;i<n;i++)
	if (*c[i]=='-') {
		f[i][0]=-inf;
		f[i][1]=f[i-1][0]-a[i];
		f[i][2]=f[i-1][1]+a[i];
		f[i][1]=max(f[i][1],f[i][2]);
		f[i][0]=max(f[i][0],f[i][1]);
	}
	else {
		f[i][0]=f[i-1][0]+a[i];
		f[i][1]=f[i-1][1]-a[i];
		f[i][2]=f[i-1][2]+a[i];
		f[i][1]=max(f[i][1],f[i][2]);
		f[i][0]=max(f[i][0],f[i][1]);
	}
	printf("%lld",f[n-1][0]);
	return 0;
}

Measured memory_bytes: 3456
<?php
while (true) {
    $line = trim(fgets(STDIN));
    list($H, $W) = explode(' ', $line);
    if ($W == 0 && $H == 0) {
        break;
    }
    $rooms = array();
    for ($i = 0; $i < $H; $i++) {
        $room[$i] = trim(fgets(STDIN));
    }
    $visited = array();
    for ($i = 0; $i < $H; $i++) {
        for ($j = 0; $j < $W; $j++) {
            $visited[$i][$j] = false;
        }
    }
    $x = 0; $y = 0;
    $isLoop = false;
    while (true) {
        $line = $room[$y];
        $dir = $line[$x];
        if ($dir == '.') {
            break;
        }
        $visited[$y][$x] = true;
        switch ($dir) {
            case '>':
                $x++;
                break;
            case '<':
                $x--;
                break;
            case 'v':
                $y++;
                break;
            case '^':
                $y--;
                break;
        }
        if ($visited[$y][$x]) {
            $isLoop = true;
            break;
        }
    }
    if ($isLoop) {
        echo "LOOP\n";
    } else {
        echo "$x $y\n"; 
    }
}

 

Measured memory_bytes: 16636
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

void solve(){
	int n;
	cin>>n;
	fill(int,h,n);

	vector<int> dp(n);

	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	rep(i,2,n){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}

	cout<<dp[n-1];
}
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 4768
N ,Y = map(int, input().split())
total = 0
flag1 = False
ans = [-1,-1,-1]
for i in range(N + 1):
    for j in range(N - i + 1):
        total = (10000 * i) + (5000 * j) + (1000 * (N - i - j))
        if total == Y:
            ans[0] = i
            ans[1] = j
            ans[2] = N - i - j
            flag1 = True
            break
        if total > Y:
            break

    if flag1:
        break

print(ans[0],ans[1],ans[2])



Measured memory_bytes: 3064
//THE DOC

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w,m;
    cin>>h>>w>>m;
    map<pair<ll,ll>,ll> mm;
    vector<ll> hh(h+1,0);
    ll max1=0;
    ll max2=0;
    vector<ll> ww(w+1,0);
    ll x,y;
    for (int i = 0; i <m ; ++i) {
        cin>>x>>y;
        mm[{x,y}]=1;
        hh[x]++;
        if(hh[x]>max1){
            max1=hh[x];
        }
        ww[y]++;
        if(ww[y]>max2){
            max2=ww[y];
        }
    }
    vector<ll> indx1;
    vector<ll> indx2;
    for (int i = 1; i <h+1 ; ++i) {
        if(hh[i]==max1) {
            indx1.pb(i);
            //cout<<i<<" ";
        }
    }
    //cout<<"\n";
    for (int i = 1; i <w+1 ; ++i) {
        if(ww[i]==max2) {
            indx2.pb(i);
           // cout<<i<<" ";
        }
    }
    //cout<<"\n";
    //cout<<max1<<" "<<max2<<"\n";
    ll z=0;
    for (int j = 0; j <indx1.size() ; ++j) {
        for (int i = 0; i <indx2.size() ; ++i) {
            if(mm[{indx1[j],indx2[i]}]==0){
                z=1;
                break;
            }
        }
    }
    if(z==1){
        cout<<max1+max2<<"\n";
    }
    else{
        cout<<max1+max2-1<<"\n";
    }
    return 0;
}


Measured memory_bytes: 50028
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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 T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int N; cin >> N;
	vector<pair<ll, ll> > v;
	v.push_back({0, 0});
	rep(i, N){
		ll a; cin >> a;
		v.push_back({a, i+1});
	}

	vector<ll> ans(N, 0);
	sort(ALL(v));
	ll ridx = LLINF;
	ll ma = LLINF;
	ll sum = 0;
	ll k = 0;
	rrep(i, N+1){
		sum += v[i].first;
		k++;
		if(v[i].second < ridx && v[i].first <= ma){
			ll tmp = ridx;
			ridx = v[i].second;
			ma = v[i].first;
			if(tmp == LLINF) continue;

			ans[tmp-1] = sum - k * ma;
			sum = k * ma;
		}
	}

	rep(i, ans.size()){
		if(i) cout << " ";
		cout << ans[i];
	}
	cout << endl;



	return 0;
}


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

int main()
{
  double x;
  double money = 100;

  cin >> x;

  int year = 0;
  while (money < x)
  {
    money = money * 1.01;
    money = floor(money);
    year++;
  }

  cout << year << endl;
}

Measured memory_bytes: 3700
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;

bool ban[2005] ;
int N , K , Q , a[2005] , rk[2005] , sa[2005] ;
int pre[2005] , nxt[2005] ;
struct Node{
	short sum ;
	Node *ch[2] ;
} *root , w[4005] , *tw = w ;

template< typename T > void smin( T &x , T y ){ if( x > y ) x = y ; }
bool cmp( const int &A , const int &B ){ return a[A] < a[B] ; }

Node *build( short lf , short rg ){
	Node *nd = ++tw ;
	if( lf != rg ){
		short mid = ( lf + rg ) >> 1 ;
		nd->ch[0] = build( lf , mid ) ;
		nd->ch[1] = build( mid+1,rg ) ;
	} return nd ;
}

void reset( Node *nd , short lf , short rg ){
	if( lf != rg ){
		short mid = ( lf + rg ) >> 1 ;
		reset( nd->ch[0] , lf , mid ) ;
		reset( nd->ch[1] , mid+1,rg ) ;
		nd->sum = nd->ch[0]->sum + nd->ch[1]->sum ;
	} else nd->sum = !ban[lf] ;
}

short Query( Node *nd , short lf , short rg , short L , short R ){
	if( L <= lf && rg <= R ) return nd->sum ;
	short mid = ( lf + rg ) >> 1 , rt = 0 ;
	if( L <= mid ) rt += Query( nd->ch[0] , lf , mid , L , R ) ;
	if( R >  mid ) rt += Query( nd->ch[1] , mid+1,rg , L , R ) ;
	return rt ;
}

void set_zero( Node *nd , short lf , short rg , short pos ){
	if( !nd ) return ; nd->sum -- ;
	short mid = ( lf + rg ) >> 1 ;
	if( pos <= mid ) set_zero( nd->ch[0] , lf , mid , pos ) ;
	else set_zero( nd->ch[1] , mid+1,rg , pos ) ;
}

void preWork(){
	sort( sa + 1 , sa + N + 1 , cmp ) ;
	for( int i = 1 ; i <= N ; i ++ ) rk[ sa[i] ] = i ;
	root = build( 1 , N ) ;
}

void solve(){
	int ans = 0x3b9aca00 ; nxt[N+1] = N + 1 ;
	for( int i = 0 , cnt , st , ed ; ; i ++ ){

		for( int j = 1 ; j <= i ; j ++ ) ban[ sa[j] ] = true ;
		for( int j = 1 ; j <= N ; j ++ ) pre[j] = ban[j] ? j : pre[j-1] ;
		for( int j = N ; j >= 1 ; j -- ) nxt[j] = ban[j] ? j : nxt[j+1] ;

		cnt = st = 0 , reset( root , 1 , N ) ;

		for( int j = i + 1 ; j <= N && cnt < Q ; j ++ ){
			if( nxt[ sa[j] ] - pre[ sa[j] ] - 1 < K ) continue ;
			if( Query( root , 1 , N , pre[ sa[j] ] + 1 , nxt[ sa[j] ] - 1 ) >= K ){
				if( !st ) st = j ;
				if( ++cnt == Q ) ed = j ;
				else set_zero( root , 1 , N , sa[j] ) ;
			}
		} if( cnt != Q ) break ;

		smin( ans , a[ sa[ed] ] - a[ sa[st] ] ) ;
		for( int j = 1 ; j <= i ; j ++ ) ban[ sa[j] ] = false ;

	} printf( "%d" , ans ) ;
}

int main(){
	scanf( "%d%d%d" , &N , &K , &Q ) ;
	for( int i = 1 ; i <= N ; i ++ )
		scanf( "%d" , &a[i] ) , sa[i] = i ;
	preWork() ; solve() ;
}


Measured memory_bytes: 256
x, k, d = map(int,input().split())
if x < 0:
    x = (-1)*x
if x >= k*d:
    print(x-k*d)
else:
    deg = int(x/d)
    r = k-deg
    if r % 2 == 0:
        print(x-deg*d)
    else:
        print((x-(deg+1)*d)*(-1))

Measured memory_bytes: 9208
N,L,T = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

xs = []
for x,w in src:
    dx = T if w==1 else -T
    xs.append((x+dx) % L)
xs.sort()

if N == 1:
    print(xs[0])
    exit()

x0,w0 = src[0]
k0 = 0
for x,w in src:
    if x == x0: continue
    if w == w0: continue
    if w0 == 1:
        dist = (x-x0) % L
    else:
        dist = (x0-x) % L
    if 2*T >= dist:
        k0 += 1 + (2*T-dist)//L

newx0 = (x0+T)%L if w0==1 else (x0-T)%L
i0 = xs.index(newx0)
if w0 == 1 and i0+1 < N and xs[i0] == xs[i0+1]:
    i0 += 1
i0 += (k0 if w0==2 else -k0)
i0 %= N

for i in range(i0,i0+N):
    print(xs[i%N])

Measured memory_bytes: 18464
#include <iostream>
#include <string>
#include <vector>
using namespace std;

const string DOW[] = {
    "Saturday",
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday"
};

string getDOW(int y, int m, int d) {
    if (m <= 2) {
        --y;
        m += 12;
    }
    int c = y / 100;
    y %= 100;
    int h = d + (26 * (m + 1)) / 10 + y + y / 4 + 5 * c + c / 4;
    return DOW[h % 7];
}

int main() {
    int m, d;
    while (cin >> m >> d, m) {
        cout << getDOW(2004, m, d) << endl;
    }
    return 0;
}

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

int main(void) {
    int S[14],H[14],C[14],D[14];
    for (int i = 0; i < 14; i++) S[i] = 0;
    for (int i = 0; i < 14; i++) H[i] = 0;
    for (int i = 0; i < 14; i++) C[i] = 0;
    for (int i = 0; i < 14; i++) D[i] = 0;
    int n;cin>>n;
    for (int i = 0; i < n; i++) {
        char egara;
        int num;
        cin>>egara>>num;
        if (egara == 'S') S[num] = 1;
        if (egara == 'H') H[num] = 1;
        if (egara == 'C') C[num] = 1;
        if (egara == 'D') D[num] = 1;
    }
    for (int i = 1; i <= 13; i++) {
        if (S[i] == 0) cout << "S " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (H[i] == 0) cout << "H " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (C[i] == 0) cout << "C " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (D[i] == 0) cout << "D " << i << endl;
    }
    return 0;
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    int m = n % 100;
    int cnt = m / 5 + !!(m%5);
    if(100*cnt + m > n)cout << 0;
    else cout << 1;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}

//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}

int32_t main(void){
	IOS;
	
	in1(n);
	int r = n%10;
	if(r == 2 || r == 4 || r == 5 || r == 7 || r == 9) cout<<"hon";
	else if(r <2 || r == 6 || r == 8) cout<<"pon";
	else cout<<"bon";
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  long a,b,c;
  cin >> a >> b >> c;
  long ans;
  if(a+b>c){
    ans = b+c;
  }else {
    ans = a+b*2;
    if(a+b<c) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    As = list(map(int, input().split()))

    res_count = 0
    while(1):
        for i, a in enumerate(As):
            if a % 2 == 1:
                break
        if i != (N-1):
            break

        res_count += 1
        for i, a in enumerate(As):
            As[i] = a // 2

    print(res_count)

            
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vvec<char> S(H,vec<char>(W));
    vec<int> dx = {-1,1,0,0},dy = {0,0,-1,1};
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> S[i][j];
    auto in = [&](int x,int y){
        return 0<=x && x<H && 0<=y && y<W;
    };

    const int inf = 1e9;
    auto bfs = [&](int x,int y){
        queue<P<int,int>> Q;
        vvec<int> dist(H,vec<int>(W,inf));
        dist[x][y] = 0;
        int ma = -1;
        Q.push({x,y});
        while(!Q.empty()){
            P<int,int> now = Q.front(); Q.pop();
            for(int k=0;k<4;k++){
                int nx = now.first+dx[k],ny = now.second+dy[k];
                if(in(nx,ny) && S[nx][ny]!='#' && dist[nx][ny]==inf){
                    dist[nx][ny] = dist[now.first][now.second]+1;
                    ma = max(dist[nx][ny],ma);
                    Q.push({nx,ny});
                }
            }
        }
        return ma;
    };

    int ans = 0;
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(S[i][j]!='#') ans = max(ans,bfs(i,j));
    cout << ans << endl;
}

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

int main() {
  int a,b;cin>>a>>b;
  int ans = (a%3)*(b%3)*((a+b)%3)==0;
  cout << (ans ? "Possible":"Impossible") << endl;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
t = S()
ans = len(t)
for i in range(len(s) - len(t)+1):
    x = len(t)
    for j in range(len(t)):
        if s[i+j] == t[j]:
            x -= 1
    ans = min(ans, x)
print(ans)

Measured memory_bytes: 74868
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();

		if(n%2==1)
			System.out.println("No");
		else
		{
			if(s.substring(0,(n/2)).equals(s.substring(n/2)))
				System.out.println("Yes");
			else
				System.out.println("No");
		}


	}
}

Measured memory_bytes: 22996
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <string>

typedef long long ll;

using namespace std;
int main()
{

	int a, b , c;

	
	cin >> a >> b >> c;

	if (a == b && b == c)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//
// https://atcoder.jp/contests/abc131/tasks/abc131_e

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
    int N, K;
    cin >> N >> K;
    if (K > (N-1)*(N-2)/2) {
        cout << "-1" << endl;
        return 0;
    }
    int bypassed = (N-1)*(N-2)/2 - K;
    int M = (N-1) + bypassed;
    cout << M << endl;
    for (int i = 0; i < N-1; i++) {
        cout << "1 " << (i+2) << endl;
    }
    for (int i = 2; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            if (bypassed > 0) {
                cout << i << " " << j << endl;
                bypassed--;
                if (bypassed == 0) {
                    return 0;
                }
            }
        }
    }
}



Measured memory_bytes: 256
from collections import deque

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

P = N+2
es = [[] for i in range(P)] # [[to1,cap1,rev1], ...]

def add_edge(fr,to,cap):
    es[fr].append([to,cap,len(es[to])])
    es[to].append([fr,0,len(es[fr])-1])

INF = float('inf')
score = 0
for i,a in enumerate(A):
    if a < 0:
        add_edge(0,i+1,-a)
    elif a > 0:
        add_edge(i+1,N+1,a)
        score += a
for n in range(1,N//2+1):
    for m in range(2*n,N+1,n):
        add_edge(n,m,INF)

level = [0] * P
iters = [0] * P

def dinic_max_flow(s,t):
    global iters

    def _bfs(s):
        global level
        level = [-1] * P
        level[s] = 0
        q = deque([s])
        while q:
            v = q.popleft()
            for to,cap,rev in es[v]:
                if cap > 0 and level[to] < 0:
                    level[to] = level[v] + 1
                    q.append(to)

    def _dfs(v,t,f):
        if v == t: return f
        for i in range(iters[v],len(es[v])):
            iters[v] += 1
            to,cap,rev = es[v][i]
            if es[v][i][1] > 0 and level[v] < level[to]:
                d = _dfs(to,t,min(f,es[v][i][1]))
                if d > 0:
                    es[v][i][1] -= d #cap
                    es[to][rev][1] += d
                    return d
        return 0

    flow = 0
    while True:
        _bfs(s)
        if level[t] < 0: return flow
        iters = [0] * P
        f = 0
        while True:
            f = _dfs(s,t,INF)
            if f <= 0: break
            flow += f

print(score - dinic_max_flow(0,N+1))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n;
  int sum=0;
  cin>>h>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    sum+=a;
  }
  if(sum>=h){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return(0);
}


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

int main() {
    int n, x;
    cin >> n >> x;
    int l[100];
    for (int i = 1; i <= n; i++) cin >> l[i];

    int d[10000];
    d[0] = 0;
    for (int i = 1; i <= n; i++) {
        d[i] = d[i-1]+l[i];
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (d[i] <= x) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def minkowski_dist(x, y, n, p):
    d = 0
    for i in range(n):
        d += abs(x[i] - y[i])**p
    d = d**(1/p)
    return d

n = int(input())
x = list(map(float,input().split()))
y = list(map(float,input().split()))

for p in range(1,4):
    print(minkowski_dist(x,y,n,p))

d = abs(x[0]-y[0])
for i in range(n):
    el = abs(x[i]-y[i])
    d = max(d,el)
print(d)



Measured memory_bytes: 5664
use std::io;


fn main() {
    let s = read_one::<String>();

    if s.len() >= 4 && &s[0..4] == "YAKI" { println!("Yes"); }
    else { println!("No"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b <= d) && abs(b - c) <= d)) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
int a[1000];
int main()
{
	int n;
	cin >> n;
	int t = 0;
	for (int i = 1; i <= n; i++)
	{
		int t1;
		scanf("%d", &t1);
		t = t ^ t1;
	}
	if (t == 0)printf("Yes");
	else printf("No");
}

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

int n;

typedef unsigned long long ll;

const ll p=353;
const ll p1=19260817;
const ll p2=212370440130137957;
const ll p3=998244353;

ll pow(ll x,ll y){
    ll ans=1;
    while(y){
	    if(y&1) ans=ans*x%p2;
	    y>>=1; x=x*x%p2;
	}
	return ans;
}

ll work(string s){
    ll ans=0;
    for(int i=0;i<s.size();i++){
	    ans+=(pow((ll)(s[i]),p)*p1+p3)%p2;
	}
	return ans*(s.size()+p)%p2;
}

map<ll,ll> mp;

int main(){
    ios::sync_with_stdio(0);
    cin>>n;
    long long ans=0;
	for(int i=1;i<=n;i++){
		string s;
	    cin>>s;
	    sort(s.begin(),s.end());
	    
	    ll x=work(s);
	    
	    ans+=mp[x];
	    mp[x]++;
	}
	cout<<ans<<"\n";
    return 0;
}


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

int n, pa[100001];
map<int, int> tr[100001];

int P(int v){
    if (pa[v])return pa[v] = P(pa[v]);
    return v;
}

int main(){
    scanf("%d", &n);
    f(i, 2, n << 1){
        int a, b;
        scanf("%d%d", &a, &b);
        ++tr[a][b];
        ++tr[b][a];
    }
    stack<pair<int, int> > st;
    f(i, 1, n + 1)for (map<int, int>::iterator it = tr[i].lower_bound(i); it != tr[i].end(); ++it)if (it->second >= 2)st.push(make_pair(i, it->first));
    while (!st.empty()){
        int a = P(st.top().first), b = P(st.top().second);
        st.pop();
        if (a == b)continue;
        if (tr[a].size() > tr[b].size())swap(a, b);
        for (map<int, int>::iterator it = tr[a].begin(); it != tr[a].end(); tr[a].erase(it++)){
            if (it->first == b){
                tr[b].erase(a);
                continue;
            }
            map<int, int>::iterator it0 = tr[b].insert(make_pair(it->first, 0)).first;
            int t = it0->second;
            it0->second += it->second;
            tr[it->first][b] += it->second;
            if (t < 2 && it0->second >= 2)st.push(make_pair(it->first, b));
            tr[it->first].erase(a);
        }
        pa[a] = b;
        --n;
    }
    if (n == 1)printf("YES\n");
    else printf("NO\n");
}

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

typedef long long ll;

int N, M, Q;
int a[50], b[50], c[50], d[50];
int A[11] = {1};

int check() {
	int sum = 0;
	for (int i=0; i<Q; i++)
		if (A[b[i]]-A[a[i]]==c[i])
			sum += d[i];
	return sum;
}

int f (int n) {
	if (n>N)
		return 0;
	if (n==N)
		return check ();
	int tmp = 0;
	for (A[n+1]=A[n]; A[n+1]<=M; A[n+1]++) {
		int tmp2 = f (n+1);
		if (tmp2 > tmp)
			tmp = tmp2;
	}
	return tmp;
}

int main () {
	cin >> N >> M >> Q;
	for (int i=0; i<Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	
	cout << f(0) << endl;
	return 0;
}

Measured memory_bytes: 3596
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    i64 a, b, n;
    std::cin >> a >> b >> n;
    i64 x = std::min(b - 1, n);
    std::cout << (a * x / b) - a * (x / b) << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N; cin >> N ;
  vector<int64_t> a(N+1);
  vector<int64_t> b(N);
  rep(i,N+1) cin >> a.at(i);
  rep(i,N) cin >> b.at(i);
  int64_t ans =0;
  rep(i,N){
    if(a[i]>=b[i]) ans += b[i];
    else{
      b[i]-=a[i];
      if(a[i+1]>b[i]){
        ans += a[i] + b[i];
        a[i+1] -= b[i];
      }else{
        ans += a[i] + a[i+1];
        a[i+1] =0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(M)]
edges = [(i - 1, j - 1, c) for i, j, c in edges]

INF = int(10000)

dp = [[INF for _ in range(N)] for _ in range(N)]
for i, j, cost in edges:
    dp[i][j] = cost
    dp[j][i] = cost

for i in range(N):
    dp[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            if dp[i][k] != INF and dp[k][j] != INF:
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

count = 0
for i, j, cost in edges:
    if dp[i][j] < cost:
        count += 1

print(count)

Measured memory_bytes: 9396
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

using T=tuple<int,int,char>;
const int math=200001;

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<T> a(n);
    int x,y;
    char z;
    rep(i,n){
        cin>>x>>y>>z;
        a[i]=T(x,y,z);
    }
    vector<set<int>> U(math),D(math),R(math),L(math);
    using T2=tuple<int,int,int>;
    set<T2> uplus,umin,dplus,dmin;
    rep(i,n){
        tie(x,y,z)=a[i];
        if(z=='U') {U[x].insert(y);uplus.insert(T2(x+y,x,y));umin.insert(T2(x-y,x,y));}
        if(z=='D') {D[x].insert(y);dplus.insert(T2(y+x,x,y));dmin.insert(T2(x-y,x,y));}
        if(z=='R') R[y].insert(x);
        if(z=='L') L[y].insert(x);
    }

    int ans2=inf;
    int ans3=inf;
    rep(i,n){
        tie(x,y,z)=a[i];
        if(z=='U'||z=='D') continue;
        if(z=='R'){
            int pl=x+y,mi=x-y;
            auto itr=dmin.lower_bound(T2(mi,x,0));
            if(itr!=dmin.end() && get<0>(*itr)==mi){
                int ans=get<1>(*itr)-x;
                ans3=min(ans,ans3);
            }
            itr=uplus.lower_bound(T2(pl,x,0));
            if(itr!=uplus.end() && get<0>(*itr)==pl){
                int ans=get<1>(*itr)-x;
                ans3=min(ans,ans3);
            }
        }
        if(z=='L'){
            int pl=x+y,mi=x-y;
            auto itr=umin.lower_bound(T2(mi,x,0));
            if(itr!=umin.begin()){
                itr --;
                if(get<0>(*itr)==mi){
                    int ans=get<1>(*itr)-x;
                    if(ans<0)ans3=min(-ans,ans3);
                }
            }
            itr=dplus.lower_bound(T2(pl,x,0));
            if(itr!=dplus.begin()){
                itr --;
                if(get<0>(*itr)==pl){
                    int ans=get<1>(*itr)-x;
                    if(ans<0) ans3=min(-ans,ans3);
                }
            }
        }
    }
    rep(i,n){
        tie(x,y,z)=a[i];
        if(z=='D' || z=='L') continue;
        if(z=='U'){
            if(D[x].upper_bound(y)!=D[x].end()){
                int dist=*D[x].upper_bound(y);
                dist -=y;
                ans2 =min(ans2,dist);
            }
        }
        if(z=='R'){
            if(L[y].upper_bound(x)!=L[y].end()){
                int dist=*L[y].upper_bound(x);
                dist -=x;
                ans2 =min(ans2,dist);
            }
        }
    }
    if(ans2==inf && ans3==inf){
        cout<<"SAFE"<<endl;
        return 0;
    }
    if(ans2<inf)ans2 *=5;
    if(ans3<inf)ans3 *=10;
    cout<<min(ans2,ans3)<<endl;
}/*
./problem.exe
*/

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

using ll = long long;

int main() {
    ll X;
    cin >> X;
    cout << X / 500 * 1000 + X % 500 / 5 * 5 << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#define eMax 100000000
#define existing 1234567
#define true 1
#define false 0
#define nil -1
#define Qsize 50000
#define Psize 9
#define N 3
typedef struct{
  int state[Psize];
  int space;
  int path;
} puzzule;
int bfs(puzzule);
int isTarget(puzzule);
int exist(puzzule);
int hashu(int *); //ハッシュ値を生成する関数
void enqueue(puzzule);
puzzule dequeue(void);
int goal[Psize] = {1, 2, 3, 4, 5, 6, 7, 8, Psize};
int dx[N+1] = {-1, 0, 1, 0}, dy[N+1] = {0, -1, 0, 1};
int head = 0, tail = 0;
int e[eMax];
puzzule queue[Qsize];

int main()
{
  puzzule in;
  int i;

  for(i = 0 ; i < Psize ; i++){
    scanf("%d",&in.state[i]);
    if(in.state[i] == 0){
      in.state[i] = Psize;
      in.space = i; }
  }
  
  printf("%d\n",bfs(in));

  return 0;
}

void enqueue(puzzule p)
{
  int next;

  next = (tail + 1) % Qsize;

  if(next != head){
    queue[tail] = p;
    tail = next; }

}

puzzule dequeue(void)
{
  puzzule p;

  if(head != tail){
    p = queue[head];
    head = (head + 1) % Qsize;
    return p; }
  
  }

int bfs(puzzule p)
{
  puzzule u, v;
  int sx, sy, tx, ty;
  int i, ForChange;
  
  p.path = 0;
  e[hashu(p.state)] = existing;
  enqueue(p);

  while(head != tail){
    u = dequeue(); 
    if(isTarget(u) == true) return u.path;
    sx = u.space / N;
    sy = u.space % N;
    for(i = 0 ; i <= N ; i++){
      tx = sx + dx[i];      
      ty = sy + dy[i];
      if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      v = u;
      ForChange = v.state[u.space];
      v.state[u.space] = v.state[tx * N + ty];
      v.state[tx * N + ty] = ForChange;
      v.space = tx * N + ty;
      if(exist(v) != true){
	v.path += 1;
	enqueue(v); }
    }  
  }
  
  return nil;
}

int exist(puzzule p)
{
  if(e[hashu(p.state)] == existing) return true;
  e[hashu(p.state)] = existing;

  return false;
}

int isTarget(puzzule p)
{
  int i;
  
  for(i = 0 ; i < Psize ; i++){ 
    if(p.state[i] != goal[i]) return false; }
  
  return true;
}

int hashu(int *table)
{
  int  i, j, hash = 0, work[Psize];
  int FACTOR[Psize] = {40320,5040,720,120,24,6,2,1,1}; // i!の並びになっている。
  
  for (i=0; i < Psize; i++) work[i] = table[i];
    for (i=0; i < Psize; i++) {
    hash += work[i] * FACTOR[i];
    for (j=i+1; j < Psize; j++)
      if (work[i] < work[j]) work[j]--;
  }
    
    return hash;
}


Measured memory_bytes: 5372
#include <iostream>
#include <iomanip>

int main() {
	std::cout << std::setprecision(3);
	std::cout.setf(std::ios::fixed, std::ios::floatfield);
	double a, b, c, d, e, f;
	while( std::cin >> a >> b >> c >> d >> e >> f ) {
		const double x = (b*f-c*e) / (b*d-a*e);
		const double y = (c-a*x) / b;
		std::cout << ((-0.0005<=x && x<0.0005)?0.0:x) << " " << ((-0.0005<=y && y<0.0005)?0.0:y) << std::endl; 
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846
int main() {
    int a, b, x3;
    cin >> a >> b >> x3;
    int capa = a * b;
    double x2 = x3 / (double)a;
    double capa_h = capa / (double)2;

    double c;
    double d;
    if(capa_h < x2) {
        x2 = capa - x2;
        c = x2 * 2 / a;
        d = atan2(c, a) * 180.0 / PI;

    } else {
        c = x2 * 2 / b;
        d = atan2(c, b) * 180.0 / PI;
        d = 90 - d;
    }
    printf("%.10f\n", d);
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int d, t, s;
    cin >> d >> t >> s;

    bool ans = d <= t * s;
    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++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<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int compress(vector<int> &x,int w){
    vector<int> sx;
    for(int i=0;i<(int)x.size();++i){
        for(int d=-2;d<=2;++d){
            int t=x[i]+d;
            if(t>=0&&t<w) sx.push_back(t);
        }
    }
    sort(sx.begin(),sx.end());
    sx.erase(unique(sx.begin(),sx.end()),sx.end());
    for(int i=0;i<(int)x.size();++i){
        x[i]=lower_bound(x.begin(),x.end(),x[i])-x.begin();
    }
    return (int)sx.size();
}
int main(){
    int n,m;cin>>n>>m;
    vector<ll> x(n),y(m);
    for(int i=0;i<n;++i) cin>>x[i];
    for(int i=0;i<m;++i) cin>>y[i];
    ll sx=0,sy=0;
    for(int k=1;k<=n;++k){
        sx+=(2*k-n-1)*x[k-1]%MOD;
        sx%=MOD;
    }
    for(int k=1;k<=m;++k){
        sy+=(2*k-m-1)*y[k-1]%MOD;
        sy%=MOD;
    }
    cout<<sx*sy%MOD<<endl;
    return 0;
}

Measured memory_bytes: 28312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  char op;
  cin >> A >> op >> B;
  
  if(op == '+'){
  	cout << A+B << endl;
  }else if(op == '-'){
  	cout << A-B << endl;
  }
}

Measured memory_bytes: 256
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let arr:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ans = 0;
    let mut tmp = 0;
    for i in 0..n-1 {
        if arr[i] >= arr[i+1] {
            tmp += 1;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    println!("{}", ans);
}


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

typedef long long ll;
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;

    ll n = s.length(), m = t.length();
    ll dp[n + 1][m + 1];
    string b = "";
    ll i = -1, j = -1;
    for (ll x = 0; x <= n; x++)
    {
        for (ll y = 0; y <= m; y++)
        {
            if (x == 0 || y == 0)
                dp[x][y] = 0;
            else if (s[x - 1] == t[y - 1])
            {
                dp[x][y] = 1 + dp[x - 1][y - 1];
            }
            else
                dp[x][y] = max(dp[x - 1][y], dp[x][y - 1]);
        }
    }
    //cout << i << " " << j << "\n";
    i = n, j = m;
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            b = s[i - 1] + b, i--, j--;
        }
        else
        {
            if (dp[i - 1][j] > dp[i][j - 1])
                i--;
            else
                j--;
        }
    }
    cout << b << "\n";
}

Measured memory_bytes: 73984
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> poin(n, k);
    vector<int> a(q);
    for (int i = 0; i < q; i++) {
        cin >> a.at(i);
    }
    for (int j = 0; j < n; j++) {
    poin.at(j) -= q;
    }
    for (int i = 0; i < q; i++) {
        poin.at(a.at(i) - 1)++;
    }
    for (int i = 0; i < n; i++) {
        if (poin.at(i) < 1) {
            cout << "No" << endl;
        }
        else cout << "Yes" << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    cout<<max(a+b, max(a-b,a*b))<<endl;
    return 0;
}


Measured memory_bytes: 256