akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1000010;

int a[N],n;
int b[N],m;
int len;

int main(){
	len=get();n=get();
	fo(i,1,n)a[i]=get();
	fo(i,2,n-1)
		if (a[i]%2){
			if (a[n]%2)swap(a[i],a[1]);
			else swap(a[n],a[i]);
		}
	if (a[1]%2&&a[n]%2==0)swap(a[1],a[n]);
	int cnt=0;
	fo(i,1,n)cnt+=a[i]%2;
	if (cnt>2){
		printf("Impossible\n");
		return 0;
	}
	if (n==1){
		if (a[1]>1)printf("%d\n2\n1 %d\n",a[1],a[1]-1);
		else printf("1\n1\n1\n");
		return 0;
	}
	b[1]=a[1]+1;
	fo(i,2,n-1)b[i]=a[i];
	b[n]=a[n]-1;
	fo(i,1,n)printf("%d ",a[i]);putchar('\n');
	if (!b[n])n--;
	printf("%d\n",n);
	fo(i,1,n)printf("%d ",b[i]);putchar('\n');
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>

#define N 100
#define L 5120000
#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define MN(A,B) \
  ( MIN( A, B ) - 1 )
#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )
#define MX(A,B) \
  ( MAX( A, B ) - 1 )

static int c[ N ][ N ];
static int t[ N ][ N ];
static int m;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j, k;

  for ( ; ; )
  {
    int n;

    scanf ( "%d%d", &n, &m );
    if ( !( n | m ) ) break ;

    for ( i = 0; i < m; ++i )
    for ( j = 0; j <= i; ++j )
    {
      c[ i ][ j ] =
      t[ i ][ j ] = ( i == j ? 0 : L );
    }
    while ( n-- )
    {
      int a, b;

      scanf ( "%d%d", &a, &b );
      scanf ( "%d", &c[ MX( a, b ) ][ MN( a, b ) ] );
      scanf ( "%d", &t[ MX( a, b ) ][ MN( a, b ) ] );
    }

    for ( k = 0; k < m; ++k )
    for ( i = 0; i < m; ++i )
    for ( j = 0; j < i; ++j )
    {
      c[ i ][ j ] = MIN( c[ i ][ j ]
                       , c[ MAX( i, k ) ][ MIN( i, k ) ]
                       + c[ MAX( k, j ) ][ MIN( k, j ) ] );
      t[ i ][ j ] = MIN( t[ i ][ j ]
                       , t[ MAX( i, k ) ][ MIN( i, k ) ]
                       + t[ MAX( k, j ) ][ MIN( k, j ) ] );
    }

    scanf ( "%d", &n );
    while ( n-- )
    {
      int p, q, r;

      scanf ( "%d%d%d", &p, &q, &r );
      printf ( "%d\n", ( r ? t : c )[ MX( p, q ) ][ MN( p, q ) ] );
    }
  }

  return ( 0 );
}

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

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    
    ll N; cin >> N;
    vector<ll> result{};
    result = divisor(N);
    int len = result.size()/2;
    if(result.size() %2 ==0) cout << result[len] - 1 + result[len-1] -1 << endl;
    else cout << result[len] - 1 + result[len] -1 << endl;
} 

Measured memory_bytes: 3452
package main

import "fmt"

func main(){
    var a, b, c int
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Scan(&c)
    if a > b {
       a, b = b, a
    }
    if b > c {
       b, c = c, b
    }
    if a > b {
       a, b = b, a
    }
    fmt.Println(a, b, c)
}


Measured memory_bytes: 1172
use List::Util 'sum';
while(<>){
	chomp;
	($h, $n) = split(/ /, $_) if($. == 1);
	@a = split(/ /, $_) if($. == 2);
}

if($h <= sum(@a)){
	print "Yes\n";
}else{
	print "No\n";
}

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

const long long INF = 1e18;

struct BellmanFord {
    struct edge {
        int from, to; long long cost;
        edge(int a, int b, long long c) : from(a), to(b), cost(c) {}
    };

    int V, E; vector<long long> d; vector<edge> es;
    BellmanFord(int v, int e) : V(v), E(e) {d = vector<long long>(V);}
    void add_edge(int from, int to, long long cost) {es.emplace_back(from, to, cost);}
    vector<long long>& shortest_path(int s) {
        for (long long& i : d) i = INF;
        d[s] = 0;
        while (1) {
            bool update = 0;
            for (const edge& e : es) {
                if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    update = 1;
                }
            }
            if (!update) break;
        }
        return d;
    }

    bool find_negative_loop() {
        for (long long& i : d) i = 0;
        for (int i = 0; i < V; ++i) {
            for (const edge& e : es) {
                if (d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    if (i == V - 1) return true;
                }
            }
        }
        return false;
    }

    bool find_negative_loop_start_with(int s) {
        for (long long& i : d) i = INF;
        d[s] = 0;
        for (int i = 0; i < V; ++i) {
            for (const edge& e : es) {
                if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    if (i == V - 1) return true;
                }
            }
        }
        return false;
    }
};


/**
 * AOJ Single Source Shortest Path (Negative Edges)
 * url:https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_1_B
 */
int main(){
    int v, e, r;
    cin >> v >> e >> r;

    BellmanFord bf(v,e);
    for (int i = 0; i < e; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        bf.add_edge(s, t, d);
    }

    if (bf.find_negative_loop_start_with(r)) {
        puts("NEGATIVE CYCLE");
        return 0;
    }

    auto &ans = bf.shortest_path(r);
    for (auto &i : ans) {
        if (i != INF) cout << i << endl;
        else cout << "INF" << endl;
    }
}


Measured memory_bytes: 3140
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<climits>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<utility>

using namespace std;
typedef long long int lld;

template<typename T>
void input_vector(vector<T>& v, lld n, lld start=0) {
	for(lld i=start; i<n; ++i) 
		cin>>v[i];
}

template<typename T>
void display_vector(vector<T> v, lld start=0, string sep=" ") {
	for(lld i=start; i<v.size(); ++i)
		cout<<v[i]<<sep;
	cout<<"\n";
}

void solve(lld n) {
	
}

int main() {
	lld t;
	t=1;
	
	for (lld cs=1; cs<=t; ++cs) {
		string s;
		lld k;
		cin>>k;
		cin>>s;
		if(s.length()<=k)
			cout<<s<<"\n";
		else
			cout<<s.substr(0, k)<<"...\n";
	}
	
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

int main(){
	int n;
	std::vector<int> a;
	std::cin >> n;
	for(int i = 0; i < n; i++){
		int t;
		std::cin >> t;
		a.push_back(t);
		std::cout << t;
		if(i == n - 1){
			std::cout << std::endl;
		} else {
			std::cout << ' ';
		}
	}
	for(int j = 1; j < n; j++){
		int key = a[j], i = j - 1;
		for(; i >= 0 && a[i] > key; i--){
			a[i+1] = a[i];
		}
		a[i+1] = key;
		for(int k = 0; k < n; k++){
			std::cout << a[k];
			if(k == n - 1){
				std::cout << std::endl;
			} else {
				std::cout << ' ';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;
int main(){
        int W,H,N;
        int x[100],y[100],a[100];

        cin >> W >> H >> N;
        rep(i,N) cin >> x[i] >> y[i] >> a[i];
        int line[5] = {-1,0,W,0,H};
        rep(i,N) switch(a[i]) {
        case 1: line[a[i]] = max(line[a[i]], x[i]); break;
        case 2: line[a[i]] = min(line[a[i]], x[i]); break;
        case 3: line[a[i]] = max(line[a[i]], y[i]); break;
        case 4: line[a[i]] = min(line[a[i]], y[i]); break;
        }
        int width = line[2]-line[1];
        int height = line[4]-line[3];

        if(width <= 0 || height <= 0) cout << 0 << endl;
        else cout << width * height << endl;

        return 0;
}


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

int main(){
  long N, M;
  std::cin>>N>>M;
  std::vector<long> L(M);
  std::vector<long> R(M);
  for(long i = 0 ; i < M ; i++ ){
    std::cin>>L[i]>>R[i];
  }
  long min = L[0];
  long max = R[0];

  for(long i = 0 ; i < M ; i++ ){
    if(min<=L[i]) min = L[i];
    if(max>=R[i]) max = R[i];
  }
  if(min <= max){
    std::cout<<max - min + 1 << std::endl;
  }else{
    std::cout<<0<<std::endl;
  }
  
  return 0;
}


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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



int main(){
    int N;
    cin >> N;
    rep(i,10){
        rep(j,10){
            if(i*j == N){
                cout <<"Yes" << endl;
                return 0;
            }
        }
    }
    cout <<"No" << endl;




}


Measured memory_bytes: 3624
H,W,A,B = map(int,input().split())

U = 2*(10**5)
MOD = 10**9 + 7

fact = [1]*(U+1)
fact_inv = [1]*(U+1)
for i in range(1, U+1) :
    fact[i] = (fact[i-1] * i) % MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
for i in range(U,0,-1) :
    fact_inv[i-1] = (fact_inv[i] * i) % MOD

def comb(n, k) :
    if k < 0 or k > n :
        return 0
    x = fact[n]
    x *= fact_inv[k]
    x %= MOD
    x *= fact_inv[n-k]
    x %= MOD
    return x

ans = 0
for x in range(B,W) :
    if x == B :
        ans += comb(H-A-1+x, x) * comb(A+W-1-x, W-1-x)
    else :
        ans += (comb(H-A-1+x, x) - comb(H-A-1+x-1, x-1)) * comb(A+W-1-x, W-1-x)
    ans %= MOD
print(ans)


Measured memory_bytes: 43504
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<long long>h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  bool judge=true;
  for(int i=0;i<n-1;i++){
    if(h.at(i)<h.at(i+1)){
      h.at(i+1)--;
    }
    else if(h.at(i)==h.at(i+1)){
      continue;
    }
    else{
      judge=false;
      break;
    }
  }
  if(judge){
    cout<< "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int cnt=0;
  int i;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    while(a%2==0){
      a/=2;
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return;
}

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


Measured memory_bytes: 128
def main():
    a = [input().split() for _ in range(3)]
    ans = [[0] * 3 for _ in range(3)]
    n = int(input())
    b = [input() for _ in range(n)]

    for bi in b:
        for y in range(3):
            for x in range(3):
                if bi == a[y][x]:
                    ans[y][x] = 1

    if ans[0][0] == ans[0][1] == ans[0][2] == 1:
        print('Yes')
    elif ans[1][0] == ans[1][1] == ans[1][2] == 1:
        print('Yes')
    elif ans[2][0] == ans[2][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][0] == ans[2][0] == 1:
        print('Yes')
    elif ans[0][1] == ans[1][1] == ans[2][1] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][2] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][1] == ans[2][0] == 1:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mmax=1000009;

//解説
int main(void){
    int n;
    cin>>n;
    vector<int> X(n),Y(n);
    rep(i,n) cin>>X[i]>>Y[i];
    vector<int> from00(n);//(0,0)からのマンハッタン距離
    rep(i,n) from00[i]=abs(X[i]-0)+abs(Y[i]-0);
    sort(from00.begin(),from00.end());
    vector<int> from1e90(n);//(1e9,0)からのマンハッタン距離
    rep(i,n) from1e90[i]=abs(X[i]-1e9)+abs(Y[i]-0);
    sort(from1e90.begin(),from1e90.end());
    cout<<max(from00[n-1]-from00[0],from1e90[n-1]-from1e90[0])<<endl;
    return 0;
}


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

std::string s;
int res = 1000;

int main() {
    std::cin >> s;
    for (int i=0; i<s.size()-2; ++i) {
        int tmp = (s[i] - '0')*100 + (s[i+1] - '0')*10 + (s[i+2]-'0');
        res = std::min( res, std::abs( tmp - 753 ) );
    }
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]

for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

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

char H[101][101];
int h,w;
int dx[]{1,-1,0,0},dy[]{0,0,1,-1};
void dfs(int x,int y){
	char c=H[x][y];
	H[x][y]=0;
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<h&&0<=ny&&ny<w&&c==H[nx][ny])dfs(nx,ny);
	}
}
int main(){
	while(cin>>h>>w,h){
		rep(i,h)scanf("%s",H[i]);
		int cnt=0;
		rep(i,h){
			rep(j,w){
				if(H[i][j]){
					dfs(i,j);cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s1 = sc.next();
		String s2 = sc.next();
		int ans = 2*n;
		for(int i = 0; i < n; i++) {
			if(s2.startsWith(s1.substring(i))) {
				ans -= (n-i);
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn


int main()
{
	IO;
	ll w{},h{};
	cin>>w>>h;
	if(w==1 || h==1)cout<<"1\n";
	else cout<<(ll)((h*w)/2)+(ll)((h*w)%2)<<'\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
vector<int> num, p, q, used;
int N, p1, count, res;
int dfs(int i, vector<int> p){
    if(i == N){
        if(num == p)p1 = count;
        else count++;
        return p1;
    }
    for(int j = 0; j < N; j++){
        if(used[j] == 1){
            num[i] = j + 1;
            used[j] = 0;
            res = max(res, dfs(i + 1, p));
            used[j] = 1;
        }
    }
    return res;
}
int main(){
    cin >> N;
    p.resize(N);
    q.resize(N);
    num.resize(N);
    count = 0;
    p1 = 0;
    res = 0;
    used.resize(N, 1);
    for(int i = 0; i < N; i++)cin >> p[i];
    for(int i = 0; i < N; i++)cin >> q[i];
    int a = dfs(0, p);
    count = 0;
    used.resize(N, 1);
    res = 0;
    p1 = 0;
    int b = dfs(0, q);
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
l,r=map(int,input().split())
mod=2019
if r-l>=2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%mod)
    print(res)

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

int main(){
    using namespace std;
    size_t Q;
    cin >> Q;
    priority_queue<long, vector<long>, less<>> pq1;
    priority_queue<long, vector<long>, greater<>> pq2;
    long C{0};
    for(unsigned long i = 0, a, b; i < Q; ++i){
        char c;
        cin >> c;
        if(c == '1'){
            cin >> a >> b;
            C += b;
            pq1.push(a);
            C -= a;
            auto t = pq1.top();
            pq1.pop();
            C += 2 * t;
            pq2.push(t);
            if(pq1.size() < pq2.size()){
                auto k = pq2.top();
                pq2.pop();
                C -= 2 * k;
                pq1.push(k);
            }
        }else cout << pq1.top() << " " << C + (pq1.size() != pq2.size()) * pq1.top() << endl;
    }
    return 0;
}

Measured memory_bytes: 3828
// abc046_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string s;
    cin >> s;

    int g = count(ALL(s), 'g');
    int p = count(ALL(s), 'p');

    int ans = (g - p) / 2;
    print(ans);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3632
import Control.Applicative

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine
getIntArray :: IO [Integer]
getIntArray = ((map (\a -> read a :: Integer)) . words) <$> getLine

main = do
    [a, b, x] <- getIntArray
    putStrLn $ if ((x < a) || (a + b < x)) then "NO" else "YES"


Measured memory_bytes: 508
def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    ans = 0
    for i in range(N - 1, -1, -1):
        tmp = min(A[i + 1], B[i])
        ans += tmp
        B[i] -= tmp
        if B[i] > 0:
            tmp = min(A[i], B[i])
            ans += tmp
            A[i] -= tmp
    print(ans)


resolve()


Measured memory_bytes: 18468
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n>>m;
    vector<int> height(n);
    vector<int> max_height(n,0);
    for(int i=0; i< n; i++){
        int h;
        cin >> h;
        height.at(i) = h;
    }
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        max_height.at(a-1) = max(max_height.at(a-1), height.at(b-1));
        max_height.at(b-1) = max(max_height.at(b-1), height.at(a-1));
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(height.at(i) > max_height.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4008
#include <stdio.h>
int main(void) {
  int n, i, max, min, tmp;
  scanf("%d", &n);
  scanf("%d", &max);
  min = max;
  for (i = 1; i < n; i++) {
    scanf("%d", &tmp);
    if (tmp < min) min = tmp;
    if (tmp > max) max = tmp;
  }
  printf("%d\n", max - min);
  return 0;
}

Measured memory_bytes: 128
def edit_dist(s,t):
    n = len(s)
    m = len(t)
    pre = [i for i in range(m+1)]
    for i in range(n):
        nxt = list(range(m+1))
        nxt[0] = i+1
        for j in range(m):
            cost = 0 if s[i] == t[j] else 1
            nxt[j+1] = min(pre[j+1] + 1, nxt[j] + 1, pre[j] + cost)
            # ?????\??????????????????
        pre, nxt = nxt, pre
    return pre[m]

s = input()
t = input()

print(edit_dist(s,t))

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

using namespace std;
typedef long long ll;

// #define DEBUG


main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    ll n, w, c, ans;
    cin >> n >> w;
    vector<ll> coin[4];
    map<ll, int> coin_set;
    for (int k = 0; k < 4; k++)
        for (int i = 0; i < n; i++){
            cin >> c;
            coin[k].push_back(c);
        }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            // cout << coin[0][i] * coin[1][j] << endl;
            if (coin[0][i] + coin[1][j] <= w)
                coin_set[coin[0][i] + coin[1][j]]++;
        }
    }

    ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            // cout << coin[0][i] * coin[1][j] << endl;
            ans += coin_set[w - coin[2][i] - coin[3][j]];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 128156
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[200000001];
string com;
void maxHeapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(1);
    }
}
int main(){
    while(1){
        cin>>com;
        int k;
        if(com=="end") break;
        if(com=="insert"){cin>>k; insert(k);}
        else extract();
    }
    return 0;
}


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

typedef long long ll;
#define OO 1e9
using namespace std;

int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int W;
  cin >> W;
  int w[n], v[n];
  for(int i = 0;i < n;i++)
    scanf("%d %d", w + i, v + i);
  ll dp[n][W + 1];
  for(int i = 0;i <= W;i++){
    if(i + w[n - 1] <= W){
      dp[n - 1][i] = v[n - 1];
    }else{
      dp[n - 1][i] = 0;
    }
  }
  for(int i = n - 2;i >= 0;i--){
    for(int j = 0;j <= W;j++){
      dp[i][j] = dp[i + 1][j];
      if(j + w[i] <= W)
        dp[i][j] = max(dp[i][j], dp[i + 1][j + w[i]] + v[i]);
    }
  }

  cout << dp[0][0];
}


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

int main() {
    string s;
    ll k;
    cin >> s;
    cin >> k;
    if (s.size() >= k) {
        for (ll i = 0; i < k; i++) {
            if (s.at(i) - '0' != 1) {
                cout << s.at(i) << endl;
                return 0;
            }
        }
        cout << 1 << endl;
        return 0;
    } else {
        for (int i = 0; i < s.size(); i++) {
            if (s.at(i) - '0' != 1) {
                cout << s.at(i) << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
ll const mod = 998244353;
const ll MAX = 300000;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;


int getmx(ll n) {
    ll res = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0)res = i;
    }
    return res;
}


int main() {
    ll n;
    cin >> n;
    ll a = getmx(n);
    ll b = n / a;
    cout << a + b - 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1E5+7;
ll arr[N];
const int MOD=998244353;
ll ksm(ll x, ll y){
	ll res=1;
	while(y){
		if(y&1) res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return res%MOD;
}

int main(){
	ll n;
	cin>>n;
	ll sum=1;
	ll x;
	ll s=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i==1&&x!=0) sum=0;
		arr[x]++;
		s=max(s,x);
	}
	for(int i=s;i>=0;i--){
		if(arr[i]==0) sum=0;
		if(i>1)	sum=sum*ksm(arr[i-1],arr[i])%MOD;
	}
	if(arr[0]>1) sum=0;
	printf("%lld\n",sum);
	
	return 0;
}

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

// MY TOOLS
#define let long long int
#define async ios_base::sync_with_stdio(false);cin.tie(NULL);
#define i_upto( n ) for( int i = 0 ; i < n ; i++ )
#define ij_upto( n, m ) for( int i = 0 ; i < n ; i++ ) for( int j = 0 ; j < m ; j++ )
template<class T>
T ** array2D( let R , let C ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
	return t ;
}
template<class T>
T ** array2D( let R , let C, T value ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
    ij_upto( R, C ) t[i][j] = value ;
	return t ;
}
template<class T>
T * array1D( let N, T value ){
    T * t = new T[N] ;
    i_upto(N) t[i] = value ;
    return t ;
}
template<class T>
T * array1D( let N ){
    T * t = new T[N] ;
    return t ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M ){
	return vector<vector<T>>(N,vector<T>(M)) ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M, T Value ){
	return vector<vector<T>>(N,vector<T>(M,Value)) ;
}
#define then ;
#define vector2D( t ) vector<vector<t>>
template<class T>
class matrix{
	T ** v ;
	let rows, cols ;
	public :
		matrix( let n, let m ){
			v = array2D<T>( n, m ) ;
			rows = n ;
			cols = m ;
		}
		void input(){
			ij_upto( rows, cols ) cin >> v[i][j] ;
		}
		T at( let i, let j ){
			return v[i][j] ;
		}
		void set( let i, let j, T value ){
			v[i][j] = value ;
		}
		void output(){
			for( let i = 0 ; i < rows ; i++ ){
				for( let j = 0 ; j < cols ; j++ ){
					cout << v[i][j] << " " ;
				}
				cout << endl ;
			}
		}
		void fill( T value ){
			ij_upto( rows, cols ) v[i][j] = value ;
		}
		
};
//
let setBits( let x ){
    return __builtin_popcount( x ) ;
}
bool isSet( let x, let i ){
    return !( x & (1LL<<i) ) ;
}
let toggle( let x, let i ){
    return ( x ^ (1LL<<i) ) ;       
}
// main
// write your code here
int main(){
	async ;
    int mod = 1e9 + 7 ;
    int N then cin >> N ;
    matrix<int> mat( N, N ) then mat.input() ;
    let Max = 1 << N ;
    vector<int> dp( Max ) ;
    dp[0] = 1 ;
    for( int mask = 0 ; mask <  Max - 1LL ; mask++ ){
        int x = setBits( mask ) ;
        for( int ref = 0 ; ref < N ; ref++ ){
            if( isSet( mask, ref ) && mat.at( x, ref ) == 1LL ){
                dp[toggle( mask, ref )] = (dp[toggle( mask, ref )] +  dp[mask])%mod ;
            }
        }
    }
    cout << dp[ Max-1 ] ;
    return 0 ;
}

Measured memory_bytes: 11360
use std::io::*;
use std::str::FromStr;
use std::vec::Vec;
use std::i32;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed 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 calc_fib(max: i32) -> Vec<i64> {
    let mut ret = Vec::with_capacity(max as usize);
    ret.push(1 as i64);
    ret.push(1 as i64);
    let max2 = max as usize;
    let mod_num = 10i64.pow(9) + 7;
    let mut i: usize = 2;
    while i < max2 {
        let v1 = ret[i - 1];
        let v2 = ret[i - 2];
        ret.push((v1 + v2) % mod_num);
        i += 1;
    }
    return ret
}

fn solve(n: i32, a: Vec<i32>) -> i64 {
    let fib = calc_fib(100001);
    let count = a.len();
    if count == 0 {
        return fib[n as usize];
    }
    let mod_num = 10i64.pow(9) + 7;
    let mut total = fib[(a[0] - 1) as usize];

    for i in 0..count-1 {
        let diff = a[i + 1] - a[i];

        if diff <= 1 {
            return 0
        }
        total = total * fib[(diff - 2) as usize] % mod_num;
    }
    let diff = n - a[count - 1] - 1;
    if diff > 0 {
        total = total * fib[diff as usize] % mod_num;
    }
    return total
}

fn main() {
    let n: i32 = read();
    let m: i32 = read();
    let a = (0..m).map(|_| read::<i32>()).collect::<Vec<_>>();
    let ans = solve(n, a);
    println!("{}", ans);
}


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

int main() {
  long long x, y;

  cin >> x >> y;

  for (long long i = x * 2; i <= 1e18; i += x) {
    if (i % y != 0) {
      cout << i;
      return 0;
    }
    if (x < i && x % y == 0) break;
  }

  cout << -1;

  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

vector<int> p;
vector<int> cnt;
int size = 0;

int f(int n, int ans) {
    //cout << n << " " << ans << endl;
    if(n == size){
        if(ans == 75){
            return 1;
        }else{
            return 0;
        }
    }

    //int res = f(n+1, ans);
    if(ans > 75) return 0;
    int res = 0;
    for(int i=0;i<=cnt[n];i++){
        res += f(n+1, ans*(i+1));
    }
    return res;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    map<int, int> mp;
    for(int i=1;i<=n;i++){
        int m = i;
        while(m != 1){
            for(int j=2;j<=m;j++){
                if(m%j == 0){
                    mp[j]++;
                    m /= j;
                    break;
                }
            }
        }
    }
    for(auto kv : mp){
        //cout << kv.first << " " << kv.second << endl;
        p.pb(kv.first);
        cnt.pb(kv.second);
    }
    size = cnt.size();

    cout << f(0, 1) << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
G=[["@"]*(w+2) for i in range(h+2)]
for i in range(1,h+1):
  G[i]=["@"]+list(input())+["@"]
V=[[0]*(w+2) for i in range(h+2)]
X=deque([])
Y=deque([])
XX=[-1,0,0,1]
YY=[0,-1,1,0]
ans=0
for i in range(h+2):
  for j in range(w+2):
    if V[i][j]==0 and G[i][j]=="#":
      X.append(i)
      Y.append(j)
      V[i][j]=1
      C=[1,0]
      while len(X)>0:
        x=X[0]
        y=Y[0]
        X.popleft()
        Y.popleft()
        if G[x][y]=="#":
          for k in range(4):
            if V[x+XX[k]][y+YY[k]]==0 and G[x+XX[k]][y+YY[k]]==".":
              X.append(x+XX[k])
              Y.append(y+YY[k])
              V[x+XX[k]][y+YY[k]]=1
              C[1]+=1
        else:
          for k in range(4):
            if V[x+XX[k]][y+YY[k]]==0 and G[x+XX[k]][y+YY[k]]=="#":
              X.append(x+XX[k])
              Y.append(y+YY[k])
              V[x+XX[k]][y+YY[k]]=1
              C[0]+=1
      ans=ans+C[0]*C[1]
print(ans)

Measured memory_bytes: 11752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, x, t;
int main() {
	cin >> x >> n;
  	for (int i=0; i<n; i++) {
      cin >> t; x-=t;
    }
  	cout << (x<0 ? -1 : x); 
}

Measured memory_bytes: 3608
package main

import (
	"fmt"
	"math"
)

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

func main() {
	var n, v int
	fmt.Scan(&n)
	nmax, nmin, sum := math.MinInt64, math.MaxInt64, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&v)
		nmin = min(v, nmin)
		nmax = max(v, nmax)
		sum += v
	}
	fmt.Println(nmin, nmax, sum)
}



Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  ll A, B, C, K;
  
  I(A);
  I(B);
  I(C);
  I(K);

  ll k = 0;
  while(A >= B) {
    k++;
    B *= 2;
  }
  while(B >= C) {
    k++;
    C *= 2;
  }

  P((k <= K)?"Yes":"No");

}


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

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

    int n; cin >> n;
    int C0 = 0, C1 = 0, C2 = 0, C3 = 0;
    while(n--)
    {
        string s; cin >> s;

       if(s == "AC") C0++;
        else if (s == "WA") C1++;
        else if(s == "TLE") C2++;
        else if(s == "RE") C3++;
    }

    cout <<"AC x "<<C0<<endl;
    cout <<"WA x "<<C1<<endl;
    cout <<"TLE x "<<C2<<endl;
    cout <<"RE x "<<C3<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

const int MAX_L = 1000001;
const int MAX_SQRT_B = 1000001;
bool is_prime_array[MAX_L];
bool is_prime_small[MAX_SQRT_B];

bool is_prime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return n != 1;
}

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int eratosthenes(int n) {
	bool is_prime[n + 1];
	memset(is_prime, true, sizeof(is_prime));
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return ans;
}

// [a, b)の整数に対して篩を行う
ll segment_eratosthenes(ll a, ll b) {
	for(int i = 0; (ll)i * i < b; i++) is_prime_small[i] = true;
	for(int i = 0; i < b - a; i++) is_prime_array[i] = true;

	for(int i = 2; (ll)i * i < b; i++) {
		if(is_prime_small[i]) {
			for(int j = 2 * i; (ll)j * j < b; j += i) is_prime_small[j] = false; // [2, sqrt(b))の篩
			for(ll j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) is_prime_array[j - a] = false; // [a, b)の篩
		}
	}
	ll rsl = 0;
	rep(i, 0, sqrt(b)) {
		if(is_prime_array[i]) rsl++;
	}
	return rsl;
}

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

    int N, M;
    cin >> N >> M;

    vector<int> div = divisor(M);
    vsort(div);
    rep(i, 0, div.size()) {
        if(div[i] >= N) {
            int rsl = M / div[i];
            cout << rsl << endl;
            return 0;
        }
    }
    cout << 1 << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main() {
  int A,B;

sleep(6); 

  while(cin>>A>>B, A|B) {
    int rem = B-A;
    int th = 0, fi = 0, hu = 0;
    while(rem >= 1000) {
      rem -= 1000;
      th++;
    }
    while(rem >= 500) {
      rem -= 500;
      fi++;
    }
    while(rem >= 100) {
      rem -= 100;
      hu++;
    }
    cout<<hu<<" "<<fi<<" "<<th<<endl;
  }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int n,k;

bool f(int mid, vector<int> &v){
	bitset<5005> bi(1);
	REP(i,v.size()){
		if(i == mid)continue;
		bi |= (bi << v[i]);
	}
	for(int i = k - v[mid];i < k;i++){
		if(bi[i] == 1)return false;
	}
	return true;
}

int main(){
	
	cin >> n >> k;
	vector<int> v;
	
	REP(i,n){
		int tmp;cin >> tmp;
		if(tmp < k)v.EB(tmp);
	}
	
	sort(ALL(v));
	
	int l = -1;
	int r = v.size();
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(f(mid, v))l = mid;
		else r = mid;
	}
	
	cout << l+1 << endl;
	
	return 0;
}


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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;

int main(){
  IO; string s, t, u; int a, b;
  cin >> s >> t >> a >> b >> u;
  (s == u ? a : b) --;
  cout << a << " " << b;
}


Measured memory_bytes: 256
main :: IO ()
main = do
    str <- getContents
    let n:m:_ = map read $ words str
    putStrLn $ show $ solveC n m

solveC :: Int -> Int -> Int
solveC n m = factor (n - m) *% modfrac n *% modfrac m
    where factor 0 = 2
          factor 1 = 1
          factor (-1) = 1
          factor _ = 0

(?%) :: Integral a => (a -> a -> a) -> a -> (a -> a -> a)
(?%) f m = \a b -> (f a b `mod` m)
(*%) :: Int -> Int -> Int
(*%) = (*) ?% modnumber
(+%) :: Int -> Int -> Int
(+%) = (+) ?% modnumber
modfrac :: Int -> Int
modfrac n = foldr (*%) 1 [1..n]
modnumber :: Int
modnumber = 10^9 + 7

Measured memory_bytes: 3964
x, k , d = map(int, input().split())
if abs(x) > k * d:
    print(abs(abs(x) - k * d))
    exit()

else:
    x = abs(x)
    q = x // d
    r = x % d
    if (q - k) % 2 == 0:
        print(r)
    else:
        print(abs(r-d))
    

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

int main(){
	int n ,x;
	int c;
	
	for(;;){
		c = 0;
		cin >> n >> x;
		if(n == 0 && x == 0) break;
		for(int i = 1; i <= n; i++){
			for(int j = i+1; j <= n; j++){
				for(int k = j+1; k <= n; k++){
					if(i + j + k == x){
						c++;
					}
				}
			}
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  int x = 0;
  for(char c : s) {
    if (c == 'x') ++x;
  }
  if (x >= 8) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T inv[N+1];
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i = 0; i < N; i++)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i = N-1; i >= 0; i--)
            ifact[i] = (ifact[i+1]*(i+1))%M;
        inv[0] = 0;
        for (int i = 0; i < N; i++)
            inv[i+1] = (fact[i]*ifact[i+1])%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

ll N;

int main() {
    fastio();
    ll N, ans = 0, prev, now;
    cin >> N;
    cin >> prev;
    ll a = 0;
    REP(i, N-1) {
        cin >> now;
        a = (a + fact.inv[i+1]) % MOD;
        ans = (ans + a * (now - prev)) % MOD;
        prev = now;
    }
    cout << (ans * fact.fact[N-1])%MOD << "\n";
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair

using namespace std;

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	int r = 0, b = 0;
	int n; cin >> n;	
	string s; cin >> s;
	for (int i = 0; i < n; ++i) {

		if (s[i] == 'R')
			r++;
		else
			b++; 
	}
	cout << (r > b ? "Yes":"No");
}

Measured memory_bytes: 256
h,w = map(int,input().split())
s = []
ans = 0
for _ in range(h):
  si = str(input())
  s.append(si)
for i in range(h):
  for j in range(w):
    if s[i][j] == ".":
      t = [[-1 for _ in range(w)] for _ in range(h)]
      t[i][j] = 0
      stack = [[i,j]]
      while stack:
        ni,nj = stack.pop(0)
        tn = t[ni][nj]
        for p,q in [[-1,0],[1,0],[0,-1],[0,1]]:
          x = ni+p
          y = nj+q
          if 0 <= x and x <= h-1 and 0 <= y and y <= w-1:
            if t[x][y] == -1:
              if s[x][y] == ".":
                t[x][y] = tn+1
                stack.append([x,y])
      mx = max(max(t[xx]) for xx in range(h))
      if mx > ans:
        ans = mx
print(ans)
                
              
          
      
  

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

#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define ll  long long
#define ld	long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"

const ll MOD2 = 998244353;
const ll MOD = 1000*1000*1000 + 7;	
const ll N  = 1000*1000+5;
const double PI  = 3.14159265;
ll countDivisibles(ll A, ll B,ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll dum = __gcd(c,d);
	ll dum2 = c*d;
	dum2/=dum;
	ll ans = b-a+1;
	ans-=(countDivisibles(a,b,c));
	ans-=(countDivisibles(a,b,d));
	ans+=(countDivisibles(a,b,dum2));
	cout<<ans;

	
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <set>
#define MAXN 222222
#define ll long long
using namespace std;

// 01, 32
// 00, 22


int ans[MAXN+2];


int main() {
    int N;
    cin>>N;
    
    vector<pair<int,int> > vals;
    for(int i=0;i<N;i++) {
        int x;
        cin>>x;
        vals.push_back({x,i});
    }
    
    
    
    sort(vals.begin(),vals.end());
    
    for(int i=0;i<vals.size();i++) {
        if (i <= N/2-1)
            ans[vals[i].second] = vals[N/2].first;
        else
            ans[vals[i].second] = vals[N/2-1].first;
    }
    
    
    for(int i=0;i<N;i++)
        printf("%d\n",ans[i]);
    
    
}

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

using namespace std;

typedef long long ll;

ll N, M, P, Q, R, S, A, B, C, D, E, F, X, Y, Z;
ll arr[200005];

vector<int> AdjList[2005];
ll dist[2005][2005];
ll ans[2005];

void bfs(int x){
	queue<int> q;
	for (int i = 1; i <= N; ++i){
		dist[x][i] = 1e9;
	}
	q.push(x);
	dist[x][x] = 0;
	while (!q.empty()){
		int v = q.front();
		q.pop();
		for (auto it : AdjList[v]){
			if (dist[x][it] > dist[x][v] + 1){
				dist[x][it] = dist[x][v] + 1;
				q.push(it);
			}
		}
	}
	for (int i = 1; i <= N; ++i){
		ans[dist[x][i]]++;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> X >> Y;
	for (int i = 1; i < N; ++i){
		AdjList[i].push_back(i+1);
		AdjList[i+1].push_back(i);
	}
	AdjList[X].push_back(Y);
	AdjList[Y].push_back(X);
	for (int i = 1; i <= N; ++i) bfs(i);
	for (int i = 1; i < N; ++i){
		cout << ans[i] / 2 << '\n';
	}
	return 0;
}

Measured memory_bytes: 33024