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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef pair <ll ,ll> pll;
typedef pair <int ,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define prvc(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 2e3;
const double PI = 3.141592653589 , eps = 1e-8;


void solve(){
    int n; cin >> n;
    vector <pii> a(n);
    for (int i = 0; i < n; i ++){
        cin >> a[i].fi >> a[i].se;
    }
    sort(all(a) , [](const pii &a , const pii &b){
        return a.fi + a.se < b.fi + b.se;
    });
    vector <int> r(n);
    for (int i = 0; i < n; i ++){
        r[i] = a[i].fi + a[i].se;
    }

    vector <int> dp(n , 0);
    dp[0] = 1;
    for (int i = 1; i < n; i ++){
        int id = upper_bound(all(r) , a[i].fi - a[i].se) - r.begin() - 1;
        if (id < 0) dp[i] = 1;
        else dp[i] = 1 + dp[id];
        dp[i] = max(dp[i] , dp[i - 1]);
    }
    cout << dp[n - 1] << '\n';
}

int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #endif
    cout.precision(20);

    int t = 1;
    while(t --> 0){
        solve();
    }


    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,k;
    cin >> n >> k;
    map<ll, ll> bukkit;
    for (ll i = 0; i < n;i++){
        ll a, b;
        cin >> a >> b;
        bukkit[a] += b;
    }
    for(auto i:bukkit){
        k -= i.second;
        if(k<=0){
            cout << i.first << endl;
            break;
        }
    }
}

Measured memory_bytes: 4224
n,k,s = map(int,input().split())
if s != 10**9:
  for _ in range(k):
    print(s,end=" ")
  for _ in range(n-k):
    print(10**9,end=" ")
else:
  for _ in range(k):
    print(10**9,end=" ")
  for _ in range(n-k):
    print(1,end=" ")

Measured memory_bytes: 4340
K=int(input())
S=input()
N=len(S)
mod=10**9+7

def cmb(n,r):
  global mod
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod

g1=[1,1]
g2=[1,1]
inv=[0,1]
for i in range(2,3000003):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)
P=0
for i in range(K+1):
  P+=pow(26,i,mod)*pow(25,K-i,mod)*cmb(N+K-i-1,K-i)
print(P%mod)

Measured memory_bytes: 227796
import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
d = [li() for _ in range(n)]

flag = 0
for i in range(n-2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print('Yes')
        exit()
print('No')

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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n, X, Y;
    cin >> n >> X >> Y;
    vector<int> cnt(n + 1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            int cur1 = min(abs(i - j), abs(X - i) + 1 + abs(Y - j));
            int cur = min(cur1, abs(Y - i) + 1 + abs(X - j));
            cnt[cur]++;
        }
    }
    for (int i = 1; i < n; i++)
    {
        cout << cnt[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=1;;i++){
            int x =sc.nextInt();
            if(x!=0){
                System.out.printf("Case %d: %d\n",i,x);
            }else{
                break;
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 66700
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();

            if (IsPrime(N)) return N - 1;

            var sqrt = Math.Sqrt(N);
            for (var i = (long)Math.Floor(sqrt); i > 0; i--)
            {
                if (N % i == 0)
                {
                    return i + N / i - 2;
                }
            }

            throw new Exception();
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion

        public static bool IsPrime(long n)
        {
            if (n == 0 || n == 1) return false;

            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0) return false;
            }

            return true;
        }
    }
}

Measured memory_bytes: 11092
h, w, k = map(int, input().split())
grid = [[0] * w for i in range(h)]
start = 1
empty = []
cnt = [0] * (k + 1)
for i in range(h):
	l = input()
	if '#' in l:
		n = len(empty)
		for j in range(w):
			if l[j] == '.':
				grid[i][j] = start
				if n:
					for u in range(n):
						grid[empty[u]][j] = start
			elif cnt[start] == 0:
				grid[i][j] = start
				cnt[start] += 1
				if n:
					for u in range(n):
						grid[empty[u]][j] = start
			else:
				start += 1
				grid[i][j] = start
				cnt[start] += 1
				if n:
					for u in range(n):
						grid[empty[u]][j] = start
		empty = []
		start += 1
	else:
		empty.append(i)
n = len(empty)
if n:
	for i in range(w):
		for j in range(empty[0], h):
			grid[j][i] = grid[j - 1][i]
for out in grid:
	print(*out)
	

Measured memory_bytes: 8144
#!/usr/bin/env python3
import sys
from itertools import combinations as comb
from itertools import chain
import numpy as np

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(H, W, K, C):
    answer = 0
    for hn in range(H + 1):
        for wn in range(W + 1):
            for h_idxs in comb(range(H), hn):
                for w_idxs in comb(range(W), wn):
                    cs = C.copy()
                    cs[h_idxs, :] = 0
                    cs[:, w_idxs] = 0
                    answer += cs.sum() == K
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    H = int(next(tokens))
    W = int(next(tokens))
    K = int(next(tokens))
    C = np.array(
        [
            list(map(lambda x: {"#": 1, ".": 0}[x], line))
            for line in tokens
        ]
    )
    answer = solve(H, W, K, C)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27300
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string A,B;
    while(cin>>A>>B){
        int ans=0;
        if(A.size()<B.size())swap(A,B);
        for(int i=-(int)(B.size())+1;i<(int)A.size();i++){
            int cou=0;
            for(int j=0;j<B.size();j++){
                if(0<=i+j&&i+j<A.size()){
                    if(A[i+j]==B[j])cou++;
                    else cou=0;
                    ans=max(ans,cou);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class19
    {
        static void Main()
        {
            var abc = Console.ReadLine().Split();
            string a = abc[0], b = abc[1], c = abc[2];
            if (a == b)
            {
                if (a != c)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            if (a == c)
            {
                if (a != b)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                    
            }
            if (b == c)
            {
                if (b != a)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;

int main()
{
  IOS
  ll a;
  cin>>a;
  string s;
  cin>>s;
  if(a>=3200)
  	cout<<s;
  else
  	cout<<"red\n";
  return 0;
}                   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll>a(n);
  ll cur = 0;
  ll tmp;
  rep(i,n) {
    cin >> a[i];
    int cnt = 0;
    tmp = a[i];
    while(tmp % 2 == 0) {
      tmp = tmp / 2;
      cnt ++;
    }
    if(i != 0 && cur != cnt) {
      // cout << "different 2^" << endl;
      cout << 0 << endl;
      return 0;
    }
    cur = cnt;
  }
  ll koyaku = 1;
  rep(i,n) {
    koyaku = lcm(a[i]/2, koyaku);
    if(koyaku > m) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll c  = 0;
  // cout << koyaku << endl;
  cout << (m - koyaku) / (2 * koyaku) + 1 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007
typedef long long ll;


ll modinv(ll a,ll n=MOD){
    ll            q, s, t, u, v, w;
    s = a;
    t = n;
    u = 1;
    v = 0;

    while (s > 0) {
        q = t / s;
        w = t - q * s;
        t = s;
        s = w;
        w = v - q * u;
        v = u;
        u = w;
    }
    return ((v + n) % n);
}

int main(){
    int n; cin >> n;
    vector<int> x(n); rep(i,n) cin >> x[i];
    ll factnm = 1;
    for(long long int i=1;i<n;i++) factnm = (factnm * i) %MOD;
    vector<ll> su(n);
    su[1] = 1*factnm;
    for(int i=2;i<n;i++) su[i] = (su[i-1] + (factnm * modinv(i))) % MOD;

    ll ans = 0;
    for(int i=1;i<=n-1;i++) ans = (ans + (x[i]-x[i-1]) * su[i]) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
my @w;
{
    my $in = <STDIN>;
    @w = split(" ", $in);
}
my $l = 0;
my $l += shift @w;
my $r = 0;
my $r += pop @w;
while (1)
{
    if ($l<$r)
    {
        $l += shift @w;
    }
    else
    {
        $r += pop @w;
    }
    my $c = @w;
    if ($c==0)
    {
        last;
    }
}
my $ans = abs($l-$r);

print "$ans\n";

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

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  vector<double> b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
  	b.at(i) = 1/a.at(i);
  }
 
  double b_sum = 0;
  for(int i=0;i<n;i++){
    b_sum += b.at(i);
  }
  cout << 1/b_sum << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int n, d, x, a[100], result = 0, i, j;

    scanf("%d%d%d", &n, &d, &x);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    for (i = 0; i < n; i++) {
        j = 0;
        while (a[i] * j + 1 <= d) {
            result++;
            j++;
        }
    }

    printf("%d\n", result + x);
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    from collections import Counter
    C = Counter(S)
    for st in ["AC", "WA", "TLE", "RE"]:
        print("{} x {}".format(st, C[st]))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 16540
#include <iostream>
#include <algorithm>
using namespace std ;
int main(int argc, char** argv) {
	int n ;
	long long int cnt = 1 ;
	cin >> n ;
	int arr[n] ;
	int count[100000] = {0} ;
	for ( int i = 0 ; i < n ; i++ ) {
		cin >> arr[i] ;
		count[arr[i]] += 1 ;
		if ( count[arr[i]] > 2 ) {
			cout << 0 ;
			return 0 ;
		}
	}
	if ( count[0] > 1 ) {
		cout << 0 ;
		return 0 ;
	}
	for ( int i = 0 ; i < n / 2 ; i++ ) {
		cnt = cnt * 2 ;
		cnt = cnt % 1000000007 ;
	}
	cout << cnt ;
	return 0;
}

Measured memory_bytes: 1024
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 505;

using namespace std;

int n, m;
string s[N], a[N], b[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> m;
	for (int i = 0; i < n; i++)	
		cin >> s[i];
	//~solve
	for (int i = 0; i < n; i++)
		a[i] = s[i];
	for (int i = 0; i < n; i++)	
		a[i][0] = '#';
	for (int i = 1; i < n; i += 2)
	{
		for (int j = 1; j < m - 1; j++)
			a[i][j] = '#';			
	}
	for (int i = 0; i < n; i++)
		cout << a[i] << endl;
	cout << endl;
	for (int i = 0; i < n; i++)	
		b[i] = s[i];
	for (int i = 0; i < n; i++)
		b[i][m - 1] = '#';
	for (int i = 0; i < n; i += 2)
	{
		for (int j = 1; j < m - 1; j++)
			b[i][j] = '#';
	}
	for (int i = 0; i < n; i++)
		cout << b[i] << endl;

	return 0;
}



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

int main()
{
    std::string hoge;
    std::cin >> hoge;
    int head = -1;
    int ans = 0;
    for (int i = 0; i < hoge.size(); i++) {
        if (hoge.at(i) == 'A' && head == -1) {
            head = i;
        }
        if (hoge.at(i) == 'Z') {
            ans = i;
        }
    }
    std::cout << ans - head + 1 << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n,m;
vector<int> way[maxn];
int vis[maxn];
vector<int> topo;
int par[maxn];
void tsort(int u) {
    vis[u] = 1;
    for(auto v : way[u]) if(!vis[v]) tsort(v);
    topo.push_back(u);
}
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n-1+m;i++) {
        int u,v; scanf("%d%d",&u,&v);
        way[u].push_back(v);
    }
    for(int i=1;i<=n;i++) if(!vis[i]) tsort(i);
    reverse(topo.begin(),topo.end());
    for(auto u : topo) {
        for(auto v : way[u]) par[v] = u;
    }
    for(int i=1;i<=n;i++) printf("%d\n",par[i]);
}

Measured memory_bytes: 10740
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int n; cin >> n;
    int a[110];
    rep(i,n) cin >> a[i];
    
    sort(a, a + n, greater<int>());
    
    int Alice = 0;
    int Bob = 0;
    
    rep(i,n){
        if(i % 2 == 0)Alice += a[i];
        else Bob += a[i];
    }
    print(Alice - Bob);
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	static long[] dp;
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n = Integer.parseInt(br.readLine());
	    long[] arr = new long[n];
	    dp = new long[n];
	    String[] str = br.readLine().split(" ");
	    for(int i=0; i<n; i++) {
	    	arr[i] = Long.parseLong(str[i]);
	    	dp[i] = -1;
	    }
	    for(int i=0; i<n; i++) {
	    	if(i==0) dp[i] = 0;
	    	else if(i==1) dp[i] = Math.abs(arr[1]-arr[0]);
	    	else dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
	    }
	    System.out.println(dp[n-1]);
	}
}


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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}


int main() {
    int n;
    cin >> n;
    int i = n%10;

    switch(i){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            ct("hon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            ct("pon");
            break;
        case 3:
            ct("bon");
            break;

    }

}


/*
for(auto i : a){
    ct(i);
}
*/

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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


const string YES = "Yes";
const string NO = "No";

void func(long long A, long long B, long long C, long long D){

    while(1){
        C-=B;
        if(C<=0){
            cout<<YES<<endl;
            return;
        }
        A-=D;
        if(A<=0){
            cout<<NO<<endl;
            return;
        }
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    func(A, B, C, D);
    return 0;
}


Measured memory_bytes: 3684
import Data.List
import Data.Maybe
import Control.Monad
main = do
  xs <- (return . map (read::String->Int) . words) =<< getLine
  q <- readLn::IO Int
  forM [1..q] $ \i -> do
    uf <- (return . map (read::String->Int) . words) =<< getLine
    print $ xs !! (f3 xs uf)
  
f1 xs x = (fromJust . (elemIndex x)) xs
f2 xs u | f1 xs u == 0 = [1,2,4,3]
f2 xs u | f1 xs u == 1 = [0,3,5,2]
f2 xs u | f1 xs u == 2 = [0,1,5,4]
f2 xs u | f1 xs u == 3 = [0,4,5,1]
f2 xs u | f1 xs u == 4 = [0,2,5,3]
f2 xs u | f1 xs u == 5 = [1,3,4,2]
f3 xs [u,f] = (f2 xs u) !! (((f1 (f2 xs u) (f1 xs f)) + 1) `mod` 4)


Measured memory_bytes: 4080
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int h, n;
    cin >> h >> n;
    while (n--)
    {
        int a;
        cin >> a;
        h -= a;
    }
    cout << (h <= 0 ? "Yes" : "No") << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100001;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        arrin(a,n);
        ll ans=1000,cur=0;
        if(a[0]<a[1]){
            cur+=ans/a[0]; ans%=a[0];
        }
        for(int i=1;i<n-1;i++){
            if(a[i-1]>=a[i] && a[i]<=a[i+1]){
                cur+=ans/a[i]; ans%=a[i];
            }
            if(a[i-1]<=a[i] && a[i]>=a[i+1]){
                ans+=cur*a[i]; cur=0;
            }
        }
        ans+=cur*a[n-1];
        cout<<ans<<nl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int n;
  while(cin >> n){
    int a, b, c, d, cnt = 0;
    for(int a = 0; a < 10; a++){
      for(int b = 0; b < 10; b++){
        for(int c = 0; c < 10; c++){
          for(int d = 0; d < 10; d++){
            if(a + b + c + d == n)
             cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  
}

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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0n(i, n) for (i = 0; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
//*/

//int row, column;
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll n, x, i;
        cin >> n >> x;
        ll arr[n];
        f0n(i, n)cin >> arr[i];
        sort(arr, arr+n);
        ll c = 0;
        f0n(i, n)
        {
            if (c+arr[i] > x)break;
            c += arr[i];
        }
        ll ans = min(i, n);
        ans += (x-c)/arr[0];
        cout << ans << endl;
    }
    return 0;
}
template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}


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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    int A[H][W];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A[i][j];
        }
    }    
    int cnt = 0;
    vector< pair< pair<int, int>, pair<int, int> > > ans;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(i == H-1 && j == W-1) continue;
            if(A[i][j] % 2 == 1){
                if(j < W-1) {
                    ans.push_back({{i+1, j+1}, {i+1, j+2}});
                    A[i][j+1]++;
                }
                else{
                    ans.push_back({{i+1, j+1}, {i+2, j+1}});
                    A[i+1][j]++;
                }
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    for(auto l : ans){
        cout << l.first.first << " " << l.first.second << " " << l.second.first << " " << l.second.second << endl;
    }    
    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
#define peso first
#define beneficio second
int n,m;
vector<pair<int,int> >num(100001);
long long dp[100005];
int main(){
    cin>>n>>m;
    for(int qq=1;qq<=n;qq++){
        cin>>num[qq].peso>>num[qq].beneficio;
    }
    dp[0]=0;
    for(int qq=1;qq<=n;qq++){
        for(int ww=m;ww>=num[qq].peso;ww--){
            dp[ww]=max(dp[ww],dp[ww-num[qq].peso]+num[qq].beneficio);
        }
    }
    cout<<dp[m];
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-08-30 13:56:28 +0900
# LastModified: 2020-08-30 14:22:16 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()
    takahashi = ''
    for t in T:
        if t == 's':
            takahashi += 'r'
        elif t == 'p':
            takahashi += 's'
        else:
            takahashi += 'p'

    for i in range(K, N):
        if takahashi[i-K] == takahashi[i]:
            takahashi = takahashi[:i] + '_' + takahashi[i+1:]
    ans = takahashi.count('r')*R + takahashi.count('s')*S + takahashi.count('p')*P
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 11516
n,l=map(int, input().split())

mi=l
ma=l+n-1

if mi <= 0 and 0 <= ma:
    print(int((mi+ma)*n/2))
elif abs(mi) < abs(ma):
    print(int((mi+ma)*n/2-mi))
else:
    print(int((mi+ma)*n/2-ma))

Measured memory_bytes: 3060
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<int,int> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
	read(t);read(args...);
}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
ll dp[N][5];
int a[N];
char s[N];
int main()
{
	int n;
	read(n);
	read(a[1]);
	char ch;
	for(int i=2;i<=n;++i)
	{
		ch=getchar();
		while(ch!='+'&&ch!='-') ch=getchar();
		s[i]=ch;
		read(a[i]);
	}
	memset(dp,-63,sizeof(dp));
	dp[1][0]=a[1];
	for(int i=2;i<=n;++i)
	{
		for(int j=0;j<5;++j)
		{
			for(int k=j;k<5;++k)
			{
				chmax(dp[i][j],dp[i-1][k]);
			}
		}
		if(s[i]=='-')
		{
			for(int j=3;j>=0;--j)
			{
				dp[i][j+1]=dp[i][j];
			}
			dp[i][0]=-1e18;
		}
		for(int j=0;j<5;++j)
		{
			if(j&1) dp[i][j]-=a[i];
			else dp[i][j]+=a[i];
		}
	}
	ll ans=-1e18;
	for(int i=0;i<5;++i) chmax(ans,dp[n][i]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
 #define rep(i,n) for(int i=1;i<=n;i++)
 using namespace std;
  int main(){
    long long a;
     cin >> a;
     long long ans=0;
     rep(i,a){
         if(i%3!=0 && i%5!=0){
             ans+=i;
         }
     }
     cout << ans << endl;
  }

Measured memory_bytes: 3604
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll target;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string stra,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d,c;
    multiset<int> s;
    cin>>stra>>str2;
    
    if(stra>str2&&stra.length()>=str2.length()) cout<<"GREATER";
    else if(stra.compare(str2)==0) cout<<"EQUAL";
    else cout<<"LESS";


    return 0;
}


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

int main() {
int N;
cin >> N;
vector<int> A(N);
 
  for( int j = 0; j < N; j++){
        cin >> A.at(j);
  }
  
  int i = 0;
  while(i < N){
    int r;
    r = A.at(i) %2;
    if(r == 0){
      int p, q;
      p =  A.at(i) %3;
      q =  A.at(i) %5;
      	if(!(p == 0 || q == 0)){
      		 cout << "DENIED"<<endl;
    		   break;
   		    }
    	}
           i++;
   	       if( i == N){
    	   cout << "APPROVED"<<endl;
 		 }
  	}
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Int = long long;
int main() {
    Int N;
    cin >> N;
    vector<Int> A(N);
    for (auto& i : A) cin >> i;
    sort(A.begin(), A.end());
    Int sum = 0, t = -1;
    for (Int i = 0; i < N - 1; i++) {
        sum += A[i];
        if (2 * sum < A[i + 1]) t = i;
    }
    cout << N - t - 1 << endl;
}


Measured memory_bytes: 1024
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    const x = nextIntArray()
    let a = x.length
    let s = new Set(x)
    let b = s.size
    if(a === b) console.log("YES")
    else console.log("NO")

}
Main()


Measured memory_bytes: 58336
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int N,M;
const int mod=1000000007;
const int MAX_V=1001;
typedef long long ll;

vector<int> G[MAX_V];
vector<int> rG[MAX_V];
bool used[MAX_V];
int cmp[MAX_V];
vector<int> vs;
vector<int> cG[MAX_V];
int in[1001];

void dfs(int s){
  used[s]=true;
  for(int i=0;i<G[s].size();i++){
    int to=G[s][i];
    if(!used[to])dfs(to);
  }
  vs.push_back(s);
}

void rdfs(int s,int k){
  used[s]=true;
  cmp[s]=k;
  for(int i=0;i<rG[s].size();i++){
    int to=rG[s][i];
    if(!used[to])rdfs(to,k);
  }
}

void makeGraph(int s){
  used[s]=true;
  for(int i=0;i<G[s].size();i++){
    int to=G[s][i];
    // 異なる連結成分へ移動
    if(cmp[to]!=cmp[s])
      cG[cmp[to]].push_back(cmp[s]);
    if(!used[to])makeGraph(to);
  }
}

int dp[1001];
int rec(int s){
  if(dp[s]>=0)return dp[s];
  ll res=1;
  for(int i=0;i<cG[s].size();i++){
    int to=cG[s][i];
    res=(res*(1+rec(to)))%mod;
  }
  return dp[s]=res%mod;
}

int main(){
  while(cin>>N>>M&&(N|M)){
    int S,D;
    for(int i=0;i<N;i++){
      G[i].clear();rG[i].clear();
      cG[i].clear();
    }
    for(int i=0;i<M;i++){
      cin>>S>>D;
      S--;D--;
      G[S].push_back(D);
      rG[D].push_back(S);
    }
    memset(used,0,sizeof(used));
    for(int i=0;i<N;i++)
      if(!used[i])dfs(i);
    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--)
      if(!used[vs[i]])rdfs(vs[i],k++);
    // 連結成分を一つのノードとしたグラフを作成
    memset(used,0,sizeof(used));
    for(int i=0;i<N;i++)
      if(!used[i])makeGraph(i);
    memset(in,0,sizeof(in));
    for(int i=0;i<k;i++)
      for(int j=0;j<cG[i].size();j++)
	in[cG[i][j]]++;
    // 入点が存在しないところそれぞれについて計算
    memset(dp,-1,sizeof(dp));
    ll res=1;
    for(int i=0;i<k;i++)
      if(in[i]==0)res=(res*(1+rec(i)))%mod;
    cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
implicit none
integer(8) :: n,m,i,kai,modu,ans
read(5,*) n,m
kai=1
ans=1
modu=10**9+7

do i=1,min(n,m)
  kai=mod(kai*i,modu)
enddo

ans=mod(kai**2,modu)

if (n==m) then
  write(6,"(i0)") mod(ans*2,modu)
else if  (abs(n-m)==1) then
  write(6,"(i0)") mod(ans*max(m,n),modu)
else 
  write(6,"(i0)") 0
endif
end

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

using namespace std;

int main()
{
    int a, b, t;
    scanf("%d %d %d", &a, &b, &t);
    t += 0.5;

    printf("%d\n",(t / a) * b);
    return 0;
}
/*

int main()
{
    int a, b, t;
    scanf("%d %d %d",&a, &b, &t);
    int res = 0, i = 1;;
        t += 0.5;
        while((i * a) <= t){
            res += b;
            i = i + 1;
        };
    printf("%d\n", (res > 0 ? res : 0));
    return 0;
}
*/


Measured memory_bytes: 3788
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vll &a){sort(a.begin(),a.end()) ;}
//void myrev(vll &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n),ans(n,0) ;
	for(auto &i:a) cin >> i ;
	for(int i=n-1;i>=0;i--){
		ll cnt = 0 ;
		for(int j=i;j<n;j+=i+1){
			cnt += ans.at(j) ;
		}
		ans.at(i) = ((cnt&1)!=a.at(i)) ;
	}
	ll m = 0 ;
	for(int i=0;i<n;i++) m += ans.at(i) ;
	cout << m << endl ;
	for(int i=0;i<n;i++) if(ans.at(i)) cout << i+1 << endl ;
}


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

using namespace std;
  
bool checkingAlgo(int koyta, int seq[]) 
{  
    int duplicate[koyta]; 
    for (int i = 0; i < koyta; i++) 
        duplicate[i] = seq[i]; 
    sort(duplicate, duplicate + koyta); 
  
 
    int swap = 0; 
    for (int i = 0; i < koyta; i++) 
        if (seq[i] != duplicate[i]) 
            swap++; 
    if (swap == 0 || swap == 2) 
        return true; 
    else
        return false; 
} 
  

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

    int seq[koyta]; 
    for (int i = 0; i < koyta; i++) 
        cin >> seq[i]; 
     

    if (checkingAlgo(koyta, seq)) 
        cout << "YES"; 
    else
        cout << "NO"; 
    return 0; 
} 


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;

int main(){
  char A;
  cin >> A;

  if('A' <= A && A <= 'Z'){
    cout << 'A' << endl;
  }
  else{
    cout << 'a' << endl;
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int) x.size()
using namespace std;
typedef vector <int> vi;
typedef vector <vector<int>> vii;
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
typedef long double ld;

const long double PI=3.141592653589793238462643383279502884;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main(){
    fast;
    ll n;
    cin>>n;
    cout<<n*(n-1)/2;
    return 0;
}





Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char AsumiKana[2048];
	int SawasiroMiyuki;
	int n=0,w=0,s=0,e=0;
	if (scanf("%2047s", AsumiKana) != 1) return 1;
	for (SawasiroMiyuki = 0; AsumiKana[SawasiroMiyuki] != '\0'; SawasiroMiyuki++) {
		switch(AsumiKana[SawasiroMiyuki]) {
		case 'N': n=1; break;
		case 'W': w=1; break;
		case 'S': s=1; break;
		case 'E': e=1; break;
		}
	}
	puts((n ^ s) == 0 && (w ^ e) == 0 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	vector<int> y(m);
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}

	int nm = n - 1;
	int mm = m - 1;

	vector<int> xc(nm), yc(mm);

	xc[0] = xc[nm-1] = nm;
	int xp = nm - 2;
	for (int i = 1; i < (nm + 1) / 2; i++) {
		xc[i] = (xc[i - 1] + xp) % mod;
		xc[nm - i - 1] = xc[i];
		xp -= 2;
	}

	yc[0] = yc[mm-1] = mm;
	int yp = mm - 2;
	for (int i = 1; i < (mm + 1) / 2; i++) {
		yc[i] = (yc[i - 1] + yp) % mod;
		yc[mm - i - 1] = yc[i];
		yp -= 2;
	}

	int xsum = 0;
	rep(i, nm) {
		xsum += (xc[i] * ((x[i + 1] - x[i]) % mod)) % mod;
		xsum %= mod;
	}
	int ans = 0;
	rep(i, mm) {
		ans += (((xsum * yc[i]) % mod) * ((y[i + 1] - y[i]) % mod)) % mod;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

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

#define MAX 10000
#define INFTY (1<<29)

class DisjointSet{
    public:
        vector<int> rank, p;
        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i=0; i<size; i++) makeSet(i);
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }
        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }
        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }
            else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};
class Edge{
    public:
        int source, target, cost;
        Edge(int source=0, int target=0, int cost=0):
        source(source), target(target), cost(cost){}
        bool operator < (const Edge &e) const{
            return cost < e.cost;
        }
};

int kruskal(int N, vector<Edge> edges){
    int totalCost = 0;
    sort(edges.begin(), edges.end());

    DisjointSet dset = DisjointSet(N+1);

    for(int i=0; i<N; i++) dset.makeSet(i);

    int source, target;
    for(int i=0; i<edges.size(); i++){
        Edge e = edges[i];
        if(!dset.same(e.source, e.target)){
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;
}

int main(int argc, char const *argv[])
{
    int N, M, cost;
    int source, target;

    cin >> N >> M;

    vector<Edge> edges;
    for(int i=0; i<M; i++){
        cin >> source >> target >> cost;
        edges.push_back(Edge(source, target, cost));
    }

    cout << kruskal(N, edges) << endl;

    return 0;
}



Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H - h) * (W - w) << endl;

  return 0;
}


Measured memory_bytes: 256
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    writeln(a < 9 && b < 9 ? "Yay!" : ":(");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    ll power = 1;
    for (int i = 1; i <= N; i++)
    {
        if (i == N)
        {
            cerr  <<"beforePower=" << power<< endl;
        }
        
        power *= i;
        power %= MOD;
    }
    

    cout << power << endl;
    
    return 0;
}

Measured memory_bytes: 256