akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
    int n,b,S[14],H[14],C[14],D[14];
    char a[2];
    for(int i=0;i<14;i++)S[i]=H[i]=C[i]=D[i]=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %d",a,&b);
        if(a[0]=='S')S[b]=1;
        if(a[0]=='H')H[b]=1;
        if(a[0]=='C')C[b]=1;
        if(a[0]=='D')D[b]=1;
    }
    for(int i=1;i<=13;i++)if(S[i]==0)printf("S %d\n",i);
    for(int i=1;i<=13;i++)if(H[i]==0)printf("H %d\n",i);
    for(int i=1;i<=13;i++)if(C[i]==0)printf("C %d\n",i);
    for(int i=1;i<=13;i++)if(D[i]==0)printf("D %d\n",i);
}


Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i] >> B[i];
    }

    vector<long long> dp(H+1,0);
    for ( int h = H; h >= 1; h-- ) {
        if ( h != H && dp[h] == 0 ) { continue; }
        for ( int i = 0; i < N; i++ ) {
            int a = max( 0, h-A[i] );
            
            if ( dp[a] == 0 ) { dp[a] = dp[h]+B[i]; }
            else { dp[a] = min( dp[a], dp[h]+B[i] ); }
        }
    }
    cout << dp[0] << endl;
    return 0;
}

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

int main() {
	double h,N,T,A,M=999999; cin >> N >> T >> A;
	int i = 1,ans = 0;
	while( i < N+1 ){
		cin >> h;
		if(M > fabs(T -A - h*0.006)){
			M = fabs(T - A - h*0.006);
			ans = i;
		}
		i++;
	}
	cout << ans << endl;
}

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

using namespace std;

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

    for (int i = 1; i <= 9; ++i)
        if(n % i == 0 and n / i <= 9) return puts("Yes"),0;

    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long yaku(long,long);
int main(void){
  long A,B;
  scanf("%ld %ld",&A,&B);
  long s=yaku(A,B);
  long a=A/s;
  long b=B/s;
  long ans=a*b*s;
  printf("%ld",ans);
  return 0;
}
  
  long yaku(long C,long D){
   if(C<D){
     long w=C;
     C=D;
     D=w;
   }
    long r=C%D;
    if(r==0){
      return D;}
    else {yaku(D,r);}
 
    }

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "B" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
class Union:
  def __init__(s, num):
    s.T = [-1 for i in range(num)]
 
  def root(s, x):
    if s.T[x] < 0: return x, -s.T[x]
    t, k = s.root(s.T[x])
    s.T[x] = t
    return t, k
 
  def merge(s, x, y):
    an, am = s.root(x)
    bn, bm = s.root(y)
    if an == bn: return False
    if am < bm: an, bn  = bn, an
    s.T[an] += s.T[bn]
    s.T[bn] = an
    return True
 
  def size(s, x):
    return s.root(x)[1]

  def same(s, x, y):
    return s.root(x)[0] == s.root(y)[0]

import heapq
pop = heapq.heappop
push = heapq.heappush
q  = []

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

uni = Union(N)

xyn = [[0] * 3 for _ in range(N)]
for i in range(N):
  x, y = xy[i]
  xyn[i] = [x, y, i]

xyn.sort()
x, y, n = xyn[0]
push(q, (y << 20) + n)
for i in range(1, N):
  x, y, n = xyn[i]
  m = pop(q)
  yy, nn = m >> 20, m % (1 << 20)
  if yy < y:
    uni.merge(nn, n)
    while q:
      p = pop(q)
      yy, nn = p >> 20, p % (1 << 20)
      if yy < y:
        uni.merge(nn, n)
      else:
        push(q, (yy << 20) + nn)
        break
  else:
    push(q, (y << 20) + n)
  push(q, m)

for i in range(N):
  print(uni.root(i)[1])


Measured memory_bytes: 154232
macro scan(x...)
    quote
        input = split(chomp(readline()))
        for (vari, item) in zip($x, input)
            eval(parse("$vari = $item"))
        end
    end
end

stoi(s) = parse(Int, s)

function solve()
    @scan N K
    println(N - K + 1)

    return nothing
end

solve()

Measured memory_bytes: 121608
#![allow(dead_code, unused_variables)]
use proconio::{fastout, input};
use std::cmp::min;

#[fastout]
fn main() {
    input! {
        n: usize,
        k:usize,
        h:[i32;n],
    }

    let mut dp = vec![1000000000;n+10];
    dp[0] = 0;

    for i in 0..n{
        for j in 1..k+1{
            if i < j{
                continue;
            }
            dp[i] = min(dp[i],dp[i-j] + (h[i] - h[i-j]).abs());
        }
    }

    println!("{}",dp[n-1]);
}


Measured memory_bytes: 3372
#include<iostream>
using namespace std;
int main() {
	while(1) {
		int h,w; cin>>h>>w;
		if(h==0&&w==0) break;
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(i==0||j==0||i==h-1||j==w-1) cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
n=int(input())
c=input()

W=0
R=0

for i in range(n):
    if c[i]=="W":
        W+=1
    if c[i]=="R":
        R+=1

leftW=0
for i in range(R):
    if c[i]=="W":
        leftW+=1

print(leftW)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;

    int q;
    cin >> q;

    int rev = 0;

    vector<char> fr, en;

    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            rev++;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            f--;
            f += rev;
            f %= 2;
            if (f == 0) {
                fr.push_back(c);
            }
            else {
                en.push_back(c);
            }
        }
    }

    if (rev % 2) {
        reverse(all(s));

        for (int v = en.size(), i = v-1; i >= 0; i--) {
            cout << en[i];
        }
        cout << s;
        for (int i = 0, v = fr.size(); i < v; i++) {
            char c = fr[i];
            cout << c;
        }
    }
    else {
        for (int v = fr.size(), i = v-1; i >= 0; i--) {
            char c = fr[i];
            cout << c;
        }
        cout << s;
        for (int i = 0, v = en.size(); i < v; i++) {
            char c = en[i];
            cout << c;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 1;
    for (int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            if (m / i >= n) {
                ans = max(ans, i);
            }
            if (i >= n) {
                ans = max(ans, m / i);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph=vector<vector<int>>;

int main(){
    int n,m;
    cin>>n>>m;
    cout<<n*m<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int dx[] = {-1,0,0,1};
int dy[] = {0,-1,1,0};

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> A(H);
    rep(i,H) cin >> A[i];
    vector<vector<int>> dist(H,vector<int>(W,-1));
    deque<pair<int,int>> dq;
    rep(i,H)rep(j,W){
        if(A[i][j]=='#'){
            dist[i][j]=0;
            dq.push_back(make_pair(i,j));
        }
    }
    while(!dq.empty()){
        int now_x = dq.front().second;
        int now_y = dq.front().first;
        dq.pop_front();
        for(int i=0;i<4;i++){
            int nx = now_x + dx[i];
            int ny = now_y + dy[i];
            if(nx<0||nx>=W||ny<0||ny>=H){
                continue;
            }
            if(dist[ny][nx]==-1){
                dist[ny][nx] = dist[now_y][now_x] + 1;
                dq.push_back(make_pair(ny,nx));
            }
        }
    }
    int ans = 0;
    rep(i,H)rep(j,W){
        ans = max(ans,dist[i][j]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(a+b>c+d) cout<<"Left"<<endl;
    else if(a+b==c+d) cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;







    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

long long N,A,B;
int main(){
 
  cin>>N>>A>>B;
  if(A>B){
    cout<<0<<endl;
    return 0;
  }
  if(N==1 && A!=B){
    cout<<0<<endl;
    return 0;
  }
  long long a=A*(N-1)+B;
  long long b=B*(N-1)+A;
  long long ans=b-a+1;
  cout<<ans<<endl;
 
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, A[101];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];
  sort(A, A+N);
  cout << A[N-1]-A[0] << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;

vector<int> od,ev;
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		int a;
		scanf("%d",&a);
		if(a&1) od.pb(a);
		else ev.pb(a); 
	} 
	if(od.size()>2){
		puts("Impossible");
	}else if(!od.size()){
		rep0(i,ev.size()) printf("%d ",ev[i]);puts("");
		printf("%d\n%d ",m+1,ev[0]-1);
		rep(i,1,ev.size()-1) printf("%d ",ev[i]);puts("1");
	}else if(od.size()==1){
		printf("%d ",od[0]);
		rep0(i,ev.size()) printf("%d ",ev[i]);puts("");
		printf("%d\n",m+(od[0]>1));
		if(od[0]>1) printf("%d ",od[0]-1);
		rep0(i,ev.size()) printf("%d ",ev[i]);puts("1");
	}else{
		printf("%d ",od[0]);
		rep0(i,ev.size()) printf("%d ",ev[i]);
		printf("%d\n",od[1]);
		printf("%d\n",m-(od[0]==1));
		if(od[0]>1) printf("%d ",od[0]-1);
		rep0(i,ev.size()) printf("%d ",ev[i]);
		printf("%d\n",od[1]+1);
	}
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define int long long
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (ll i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((ll)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <ll, ll> pii ;
typedef vector <ll> vi ;
typedef vector <pii> vii ;
typedef queue <ll> qi ;
typedef queue <pii> qii ;
typedef set <ll> si ;
typedef map <ll, ll> mii ;
typedef map <string, ll> msi ;
const ll maxn = 2e6 + 100 ;
const ll inf = 0x3f3f3f3f ;
const ll iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T = ll> T chmin(T &a, T b) { return a = min(a, b);}
template <class T = ll> T chmax(T &a, T b) { return a = max(a, b);}
template <class T = ll> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

ll n, m;

ll edge[20][20];

ll f[1 << 15], g[16][1 << 15], bit[1 << 15];

ll power(ll a, ll b)
{
	ll ret = 1;
	for(; b; b >>= 1, (a *= a) %= mod) if(b & 1) (ret *= a) %= mod;
	return ret;
}

signed main()
{
	n = read(), m = read();
	rep(i, 1, m)
	{
		ll u = read(), v = read();
		edge[u][v] = 1;
	}
	rep(i, 1, n) bit[1 << (i - 1)] = i;
	ll lim = (1 << n) - 1;
	rep(i, 1, n) rep(j, 1, lim) g[i][j] = g[i][j - lowbit(j)] + edge[i][bit[lowbit(j)]];//, printf("%lld %lld : %lld\n", i, j, g[i][j]);
	f[0] = 1;
	rep(i, 1, lim)
	{
		if(((i & 1) ^ ((i >> 1) & 1)) == 1) continue;
		// printf("now : %lld\n", i);
		for(ll j = i; j; j = (j - 1) & i)
		{
			ll coef = 1, mask = i - j;
			rep(k, 1, n)
			{
				if((mask >> (k - 1)) & 1) (coef *= (1 << g[k][j]) - 1) %= mod;
				if((j >> (k - 1)) & 1) (coef *= 1 << g[k][mask]) %= mod;
			}
			// printf("%lld %lld : %lld %lld\n", mask, j, f[mask], coef);
			(f[i] += f[mask] * coef % mod) %= mod;
		}
		// printf("val : %lld\n", f[i]);
	}
	// printf("%lld\n", f[lim]);
	printf("%lld\n", (power(2ll, m) + mod - f[lim]) % mod);
	return 0;
}

Measured memory_bytes: 7892
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

x = INT()
n = ceil(sqrt(2 * x))
k = inf
ans = 0
for i in range(max(0, n - 100), n + 100):
    tmp = x - i * (i + 1) // 2
    if k > tmp >= 0:
        ans = i
        k = tmp
if k > ans:
    ans += k * 2
elif k != 0:
    ans += 1
print(ans)

Measured memory_bytes: 5840
#include <iostream>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

#define int long long
#define LL long long
#define ULL unsigned long long

const LL LL_INF = ~(ULL)0 >> 1;

int day[105] = {0}, n, k, mem[101][4][4][4];

int f(int d, int src, int presrc, int num) {
    if (d == n) {
        return (num + 1) % 10000;
    }

    if (day[d + 1] != 0) {
        return f(d + 1, day[d + 1], src, num);
    }

    int result = num;
    for (int i = 1; i <= 3; ++i) {
        int ptemp[] = {presrc, src, i, day[d + 2], day[d + 3]}, pre = 0, isoverlap = false;
        for (int j = 0, count = 0; j < 5; ++j) {
            if (pre == ptemp[j]) {
                count++;
                if (count == 3) {
                    isoverlap = true;
                    break;
                }
            } else {
                pre = ptemp[j];
                count = 1;
            }
        }
        if (isoverlap) continue;

        int temp = (mem[d + 1][i][src][presrc] == LL_INF) ? f(d + 1, i, src, 0) : mem[d + 1][i][src][presrc];
        mem[d + 1][i][src][presrc] = temp;
        result = (result + temp) % 10000;
    }

    return result;
}

signed main() {
    for (int i = 0; i < 101; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                fill(mem[i][j][k], mem[i][j][k] + 4, LL_INF);
            }
        }
    }
    cin >> n >> k;

    for (int i = 0; i < k; ++i) {
        int a, b;
        cin >> a >> b;
        day[a] = b;
    }

    int result = 0;

    if (day[1] == 0) {
        for (int i = 1; i <= 3; ++i) {
            result = (result + f(1, i, 0, 0)) % 10000;
        }
    } else {
        result = (result + f(1, day[1], 0, 0)) % 10000;
    }

    cout << result << endl;

    return 0;
}

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

int main() {   
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r; // 5 4 2 2 1

    string t = "No";

    if (x >= (0+r) && x <= (w-r)) {
        if (y >= (0+r) && y <= (h-r)) {
            t = "Yes";
        }
    }

    cout << t << endl;
}


Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

long long n,m,a,b;
long long f[N] , rf[N];

long long binpow(long long a,long long b){
    if(b == 0)return 1ll;
    if(b % 2)return (a * binpow(a , b - 1)) % mod;
    long long t = binpow(a , b / 2ll);
    return (t * t) % mod;
}

long long C(long long n,long long k){
    long long answ = f[n];
    answ *= rf[k];
    answ %= mod;
    answ *= rf[n - k];
    answ %= mod;
    return answ;
}

int main(){
    cin>>n>>m>>a>>b;
    f[0] = rf[0] = 1ll;
    for(int i=1;i<=200000;i++){
        f[i] = 1ll * f[i-1] * i;
        f[i] %= mod;
        rf[i] = binpow(f[i] , mod - 2);
    }
    long long k1 = n - a - 1 , k2 = m - b - 1;
    long long n1 = n - a + b - 1 , n2 = m - b + a - 1;
    long long answ = 0;
    int tm = min(m - b , n - a);
    while(tm--){
        answ += (C(n1 , k1) * C(n2 , k2)) % mod;
        answ %= mod;
        k1--;
        k2--;
    }
    cout<<answ<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
set<int>used;
void solve()
{

}
int main()
{
  //flash;
  ll yo;
  cin>>yo;
  cout<<((yo)*(yo-1))/2;
  return 0;
}
//code the AC sol !
// BS/queue/map


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define ull unsigned long long
#define ALL(v) ((v).begin()), ((v).end())
#define INCREASING(v) sort(ALL(v))
#define DECREASING(v) INCREASING(v), reverse(ALL(v))
#define SZ(v)   ((int)((v).size()))
#define LP(c,x,n)  for(int c=x;c<n;c++)
#define LO(c,n,x)  for(int c=n;c>=x;c--)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define PB push_back
#define F first
#define S second
#define STP(x) setprecision(x)
#define MP make_pair
#define PI ( 2 * acos(0.0))
#define EPS 1e-8
#define INF 1.0/0.0
#define Yala_Besor3a ios_base::sync_with_stdio(0),ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ReadFile freopen("coins.in","r",stdin);
#define WriteFile freopen("output.txt","w",stdout)
using namespace std;
const int OO = 0x3f3f3f3f,NegOO= -1*OO,N =1050,mod =1e9+7 ;
int num[13];
int main() {

    num[4]=2,num[6]=2,num[9]=2,num[11]=2,num[2]=3;
    int x,y;
    cin>>x>>y;
    if(num[x]==num[y])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
// RAM RAM
    #include <bits/stdc++.h>
    #define int long long
    #define pb push_back
    #define ppb pop_back
    #define vi vector<int>
    #define mp make_pair
    #define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
    #define N 55
    const int MOD=1000000007;
    using namespace std;
     
    int32_t main()
    {
    	ios_base::sync_with_stdio(false);cin.tie(0);
    	

        int n;cin>>n;
        int pow=1;
        for(int i=1;i<=n;i++){
        	pow=pow*i;
        	pow%=MOD;
        }

        cout<<pow<<endl;
    	return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main(){
  int sx,sy,tx,ty;
  int i,j,k;
  cin >> sx >> sy >> tx >> ty;
  for(i=0;i<tx-sx;i++)cout << 'R';
  for(i=0;i<ty-sy;i++)cout << 'U';
  for(i=0;i<tx-sx;i++)cout << 'L';
  for(i=0;i<ty-sy;i++)cout << 'D';
  cout << 'D';
  for(i=0;i<tx-sx+1;i++)cout << 'R';
  for(i=0;i<ty-sy+1;i++)cout << 'U';
  cout << 'L';
  cout << 'U';
  for(i=0;i<tx-sx+1;i++)cout << 'L';
  for(i=0;i<ty-sy+1;i++)cout << 'D';
  cout << 'R' << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using process = pair<string, int>;

queue<process> que;

int main()
{
	int n, q; cin >> n >> q;
	while (n--)
	{
		process p; cin >> p.first >> p.second;
		que.push(p);
	}
	
	int stamp = 0;
	while (!que.empty())
	{
		process cur = que.front(); que.pop();
		
		int diff = min(cur.second, q);
		cur.second -= diff, stamp += diff;
		if (cur.second == 0)
		{
			cout << cur.first << ' ' << stamp << endl;
		}
		else que.push(cur);
	}
}



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

using namespace std;

bool isPrime(int n)
{
	if(n == 2)
		return true;
	if(n == 1 || n % 2 == 0)
		return false;
	
	int t = sqrt(n);
	
	for(int i = 3; i <= t; i+=2)
	{
		if(n % i == 0)
			return false;
	}
	
	return true;
}

int main()
{
	int n, m, count = 0;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		
		if(isPrime(m))
			count++;
	}
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        if(a<=b) ans = a;
        else ans = a-1;

        System.out.println(ans);
    }
}

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

int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e; 
	
	if(a==0)
		cout << 1;
	else if(b==0)
		cout << 2;
	else if(c==0)
		cout << 3;
	else if(d==0)
		cout << 4;
	else if(e==0)
		cout << 5;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main(){
  int N, K;
  cin >> N >> K;
  REP(i,40){
    if (pow(K,i) <= N && N < pow(K,i+1)){
      cout << i+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
    exit()
if h % 2 == 0 or w % 2 == 0:
    print(h * w // 2)
    exit()
print(h * w // 2 + 1)
exit()

Measured memory_bytes: 2940
from itertools import permutations
n,m=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(m):
  u,v=map(int,input().split())
  g[u-1].append(v-1)
  g[v-1].append(u-1)
ans=0
for v in permutations([int(i) for i in range(n)],n):
  if v[0]!=0:
    continue
  for i in range(n-1):
    if not v[i+1] in g[v[i]]:
      break
  else:
    ans+=1
print(ans)

Measured memory_bytes: 3064
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

X,Y = map(int,input().split())
if(X>Y): x,y = Y,X
else: x,y = X,Y
  
#1 : →↑↑ , 2 :→↑→
#1をi回使う ∧ 2をN-i回使う
ans = -1
for i in range(y+1):
  #i回 1を使い、N-i回 2を使う
  tmp_x,tmp_y = 2*i,1*i 
  res_x,res_y = x-tmp_x,y-tmp_y
  if(res_x > 0):
    if((res_y%res_x == 0)and(res_y//res_x == 2)):
     n1 = i
     n2 = res_x
     break
  elif(res_x == 0):
     if(res_y == 0):
       n1 = i
       n2 = i
     else: ans = 0
     break
  elif(res_x < 0):
    ans = 0
    break
    
if(ans != 0):
 mod = 10**9+7 #出力の制限
 N = n1+n2
 g1 = [1, 1] # 元テーブル
 g2 = [1, 1] #逆元テーブル
 inverse = [0, 1] #逆元テーブル計算用テーブル
 for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 r = min(n1,n2)
 ans = cmb(N, r, mod)

  
if((x+y)%3 != 0): ans = 0
ans = ans%(10**9 + 7)
print(ans)

Measured memory_bytes: 82488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3)if (s[i] == t[i])ans++;
	cout << ans;

	return 0;
}

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

double lng(int a, int b){
    double res = sqrt(a*a+b*b);
    return res;
}

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

    double d,w,h;
    int n;
    while(cin >> d >> w >> h){
        if(!d && !w && !h) break;
        cin >> n;
        double l1 = lng(d,w);
        double l2 = lng(w,h);
        double l3 = lng(h,d);
        double l = min( min(l1,l2), l3 );
        rep(i,n){
            double r;
            cin >> r;
            cout << (2.0*r > l ? "OK" : "NA") << endl;
        }
    }
      
    return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int h, w;
	while (cin >> h >> w && h > 0) {
		cout << string(w, '#') << endl;
		for (int i = 0; i < h - 2; ++i)
			cout << '#' << string(w - 2, '.') << '#' << endl;
		cout << string(w, '#') << endl << endl;
	}

	return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;


const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
    return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n)-1;
    //cout << ans << endl;
    mint temp = 1;
    for(int i = n;i>n-a;i--){
        temp*=i;
    }
    for(int i = 1;i<=a;i++){
        temp*=mint(i).inv();
    }
    ans-=temp;
    //cout << ans << endl;

    temp = 1;
    for(int i = n;i>n-b;i--){
        temp*=i;
    }
    for(int i = 1;i<=b;i++){
        temp*=mint(i).inv();
    }
    ans-=temp;
    cout << ans << endl;
    
 }

Measured memory_bytes: 3644
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

sn = N.to_s.split('').map(&:to_i).sum

if N % sn == 0
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14440
#include <stdio.h>
#define MAX 15

int main(void){
	int n, i, j, nx, ny, sum;
	int magic[MAX][MAX];

	while(1){
		for(i = 0; i < MAX; i++){
			for(j = 0; j < MAX; j++){
				magic[i][j] = 0;
			}
		}

		scanf("%d", &n);
		
		if(n == 0){
			break;
		}

		magic[n / 2 + 1][n / 2] = 1;
		nx = n / 2 + 1;
		ny = n / 2;

		for(i = 2; i <= n * n; i++){
			nx++;
			ny++;
			while(1){
				nx = (nx + n) % n;
				ny = (ny + n) % n;
				if(magic[nx][ny] == 0){
					magic[nx][ny] = i;
					break;
				}
				nx++;
				ny--;
			}
		}

		for(i = 0; i < n; i++){
			for(j = 0; j < n; j++){
				printf("%4d", magic[i][j]);
			}
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 616
import java.util.*;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		
		int a ,b;
		int count = 0;
		while(true){
			a = scanner.nextInt();
			b = scanner.nextInt();
			if(a == 0 && b == 0){break;}
			if(a > b){
				System.out.println(b + " " + a);
			}
			else{
				System.out.println(a + " " + b);
			}
				
		}
		scanner.close();
		
		
	}

}

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

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

const long long int m = 1000000007;

long long int eval(vector<vector<long long int>> &dp,int i,int j)
{
  if(dp[i][j]!=-1)return dp[i][j];

  dp[i][j] = ( eval(dp,i+1,j) + eval(dp,i,j+1) )%m;
  return dp[i][j];
}
int main()
{
  int h,w;
  cin>>h>>w;
  vector<vector<char>> input(h,vector<char>(w));
  vector<vector<long long int>> dp(h+1,vector<long long int>(w+1,-1));
  rep(i,h)
  {
    rep(j,w)
    {
      cin>>input[i][j];
      if(input[i][j]=='#')dp[i][j]=0;
    }
    dp[i][w]=0;
  }
  dp[h-1][w-1]=1;
  rep(i,w+1)dp[h][i]=0;

  cout<<eval(dp,0,0)<<"\n";
  return 0;
}


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

ll f(ll n){
  ll ans;
  if(n%2 == 0)ans = n;
  ans ^= ((n+1)/2)%2;
  return ans; 
}

int main(void){
  ll A,B,X,Y;
  cin >> A >> B;
  cout << (f(A-1) ^ f(B)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<iostream>
 
int main(){
  int j, k;
  
  std::cin>>j>>k;
 
  if(k%2 != 0){
  	std::cout<<"No";
  }else{
  
    if(j*4 < k || j*2 >k){
    std::cout<<"No";
    }
    else{
    std::cout<<"Yes";
    }
    
  }
 
}

Measured memory_bytes: 3128
#include<stdio.h>

int main(int argc, char **argv){
  int a,b;
  int sum;

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

  sum = a + b;

  if(sum % 2 == 0)
    printf("%d", sum / 2);
  else
    printf("%d", (sum / 2) + 1);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int p[200010];
    rep(i, N) cin >> p[i];
    rep(i, N) sum[i + 1] = sum[i] + p[i];
    double ans = 0.0;
    rep(i, N - K + 1) {
        double score = sum[K + i] - sum[i] + K;
        //cout << score << endl;
        ans = max(ans, score / 2.0);
    }
    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 5324
c,gx,gy;
char map[20][20];
check(x,y)
{
  map[x][y]=35;
  c++;
  if(x+1<gy&&map[x+1][y]==46)
    check(x+1,y);
  if(x>0&&map[x-1][y]==46)
    check(x-1,y);
  if(y+1<gx&&map[x][y+1]==46)
    check(x,y+1);
  if(y>0&&map[x][y-1]==46)
    check(x,y-1);
}

int main()
{
  int n,m,x,y;
  for(;scanf("%d%d",&gx,&gy),gx;)
    {
      for(x=0;x<20;x++)
	for(y=0;y<20;)
	  map[x][y++]=35;
      for(c=n=0;n<gy;n++)
	{
	  scanf("%s",map[n]);
	  for(m=0;m<gx;m++)
	    if(map[n][m]==64)
	      x=n,y=m;
	}
      check(x,y);
      printf("%d\n",c);
    }
  exit(0);
}

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

using namespace std;

const int N = 1e5 + 5, mod = 1e9 + 7;
int n, dp[N], r[N], prefSum[N], lst[N][3], Lst[3], ans;
string s;

void add (int &_a, int _b) {
    _a += _b;
    if (_a >= mod) _a -= mod;
}

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

    cin >> s; n = s.size(); s = '!' + s;

    bool diff = 1;
    for (int i = 1; i < n; ++i) if (s[i] == s[i + 1]) diff = 0;
    if (diff) return cout << 1, 0;

    int R = n + 1;
    for (int i = n; i >= 0; --i) {
        r[i] = R;
        if (s[i] == s[i + 1]) R = i + 1;
    }

    for (int i = 1; i <= n; ++i) prefSum[i] = (prefSum[i - 1] + (s[i] == 'a' ? 1 : 2) ) % 3;

    Lst[0] = Lst[1] = Lst[2] = n + 1;
    for (int i = n; i > 0; --i) {
        Lst[ prefSum[i] ] = i;
        for (int j = 0; j < 3; ++j) lst[i][j] = Lst[j];
    }

    dp[0] = 1;
    for (int i = 0; i <= n; ++i) {
        add(dp[i + 1], dp[i]);
        if (r[i] <= n) {
            for (int j = 0; j < 3; ++j) {
                int tmp = (prefSum[ lst[ r[i] ][j] ] - prefSum[i] + 3) % 3;
                if (s[i + 1] == 'a' && tmp == 2) add(dp[ lst[ r[i] ][j] ], dp[i]);
                if (s[i + 1] == 'b' && tmp == 1) add(dp[ lst[ r[i] ][j] ], dp[i]);
            }
        }
    }

    for (int i = n; i > 0; --i) if (prefSum[i] == prefSum[n]) add(ans, dp[i]);

    cout << ans;

    return 0;
}


Measured memory_bytes: 2816
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------
signed main(){
    int n;
    cin>>n;

    pair<i64, i64> itv[n];
    vector<i64> x(n), l(n);
    vector< vector<i64> > p(n, vector<i64>(2));
    
    REP(i,n){
        cin>>x[i]>>l[i];
        itv[i].second = x[i]-l[i]; //hajime
        itv[i].first = x[i]+l[i]-1; //owari
    }

    sort(itv, itv+n);

    i64 ans=0, t=-INF;
    REP(i,n){
        if(t<itv[i].second){
            ans++;
            t = itv[i].first;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 12160
def max_profit(prices):
    """returns max(prices[j] - prices[i]) while j > i


    >>> max_profit([5, 3, 1, 3, 4, 3])
    3
    >>> max_profit([4, 3, 2])
    -1
    """
    minprice = prices[0]
    maxprofit = -prices[0]

    for p in prices[1:]:
        if maxprofit < p - minprice:
            maxprofit = p - minprice
        if minprice > p:
            minprice = p

    return maxprofit


def run():
    count = int(input())
    prices = []

    for i in range(count):
        prices.append(int(input()))

    print(max_profit(prices))


if __name__ == '__main__':
    run()



Measured memory_bytes: 15096
# B
W, H, N = [int(i) for i in input().split()]
xya = [input().split() for i in range(N)]
ld, ru = [0, 0], [W, H]
for i in range(len(xya)):
    id = int(xya[i][2])
    if id == 1 or id == 3:
        ld[id//2] = max(ld[id//2], int(xya[i][id//2]))
    elif id == 2 or id == 4:
        ru[id//3] = min(ru[id//3], int(xya[i][id//3]))
        
if (ru[0]-ld[0]) > 0 and (ru[1]-ld[1])>0:
    print((ru[0]-ld[0])*(ru[1]-ld[1]))
else: print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

lint lcm(lint x, lint y) {
  return x * y / __gcd(x, y);
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n, m; cin >> n >> m;
  string s, t; cin >> s >> t;
  lint l = lcm(n, m);
  lint k = lcm(l / n, l / m);
  for (lint i = 0; i < l; i += k) {
    if (s[i / (l / n)] != t[i / (l / m)]) return cout << -1 << '\n', 0;
  }
  cout << l << '\n';
}

Measured memory_bytes: 640
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    #LIS
    N=I()
    h=LI()
    a=LI()
    
    #####segfunc######

    #評価関数（という言い方であっている？）
    def segfunc(x,y):
        return max(x,y)


    #初期化
    def init(init_val):
        #init_valは操作する数列
        for i in range(N):
            seg[i+num-1]=init_val[i]    
        #built
        for i in range(num-2,-1,-1) :
            seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
            

    #k番目の値をxに更新
    def update(k,x):
        k += num-1
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

            
    #[p,q)の区間に対するクエリへの応答
    def query(p,q):
        if q<=p:
            return ide_ele
        p += num-1
        q += num-2
        res=ide_ele
        while q-p>1:
            if p&1 == 0:
                res = segfunc(res,seg[p])
            if q&1 == 1:
                res = segfunc(res,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = segfunc(res,seg[p])
        else:
            res = segfunc(segfunc(res,seg[p]),seg[q])
        return res


    #####単位元######
    ide_ele = 0

    #num:N以上の最小の2のべき乗
    num =2**(N-1).bit_length()
    seg=[ide_ele]*2*num
    
    ans=0
    for i in range(N):
        score=query(0,h[i]-1)+a[i]
        update(h[i]-1,score)
        ans=max(ans,score)
        
    print(ans)
    
    

main()


Measured memory_bytes: 123900
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

const int H_MAX = 101;
int main() {
	int n;
	int h[H_MAX];
	int h_maxHeight = 0;
	cin >> n;
	REP(i, n) {
		cin >> h[i];
	}
	int ret = 0;
	REP(i, n) {
		if (h_maxHeight <= h[i]) {
			ret++;
		}
		h_maxHeight = max(h[i], h_maxHeight);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
def solve(n, k):
    MOD = 998244353

    if n > k:
        return 0
    if n == 1:
        return pow(2, k - 1, MOD)

    pf, kf = 1, 1
    for m in range(2, k + 1):
        pf = kf
        kf *= m
        kf %= MOD
    inv = pow(kf, MOD - 2, MOD)
    invs = [1] * (k + 1)
    invs[k] = inv
    for m in range(k, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    ans = 0
    if k & 1 == 0:
        r = k >> 1
        s = k - n + 1
        ans = pf * (invs[r] * invs[r - 1] - invs[s] * invs[k - s - 1]) % MOD

    for r in range(k // 2 + 1, k + 1):
        if r * 2 >= n + k:
            ans += kf * invs[r] * invs[k - r]
        else:
            s = r * 2 - n + 1
            ans += kf * (invs[r] * invs[k - r] - invs[s] * invs[k - s])
        ans %= MOD

    return ans


print(solve(*map(int, input().split())))


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

using namespace std;

int main(void) {
  string S_1, S_2; cin >> S_1 >> S_2;
  
  reverse(S_2.begin(), S_2.end());
  if (S_1 == S_2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(M):
    x,y,c=map(int,input().split())
    ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

Measured memory_bytes: 18608
#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,b,c;
int main()
{
cin>>a>>b>>c;
cout<<(a+b)*c/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    long ans = 0;
    for(int b=k+1;b<=n;b++){
        int a=max(k,1);
        while(a<=n){
            ans += min(b-(a%b),n-a+1);
            a = (a/b + 1) * b + k; 
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    k, n = map(int, input().split())
    dp = [0] * (k+1)
    dq = [0] * (k+1)
    pen = 0
    for i in range(n):
        p,q = input().split()
        p = int(p)
        if dp[p] == 0:
            if q == 'WA':
                dq[p] += 1
            elif q == 'AC':
                dp[p] = 1
                pen += dq[p]
    print(sum(dp), pen)

if __name__ == '__main__':
    main()

Measured memory_bytes: 48856