akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	vector<ll> v;
	rep(i, n) {
		ll a; cin >> a;
		v.push_back(a);
	}
	queue<int> out;
	ll osum = 0; ll esum = 0;
	for (int i = 0; i < n; i += 2) {
		esum += max((ll)0, v[i]);
	}
	for (int i = 1; i < n; i += 2) {
		osum += max((ll)0, v[i]);
	}
	if (osum == 0 && esum == 0) {
		ll ma = -INF; int chk;
		rep(i, n) {
			if (ma < v[i]) {
				ma = v[i]; chk = i;
			}
		}
		cout << ma << endl;
		cout << n - 1 << endl;
		rep(i, chk) {
			cout << 1 << endl;
		}
		rep(i, n - chk - 1) {
			cout << n - chk - i << endl;
		}
	}
	else {
		if (esum >= osum) {
			for (int i = 0; i < n; i += 2) {
				if (v[i] <= 0) {
					if (i == 0) {
						out.push(1); out.push(1);
						v.erase(v.begin()); v.erase(v.begin());
						n -= 2; i -= 2;
					}
					else if (i == n - 1) {
						out.push(n); out.push(n - 1);
						v.erase(v.begin() + n - 1); v.erase(v.begin() + n - 2);
						n -= 2; i -= 2;
					}
					else {
						out.push(i+1);
						v.erase(v.begin() + i); v.erase(v.begin() + i);
						n -= 2; i -= 2;
					}
				}
			}
			if ((n - 1) % 2) {
				out.push(n); v.erase(v.begin() + n - 1); n--;
			}
			rep(i, n/2) {
				out.push(2);
			}
			cout << esum << endl;
		}
		else {
			for (int i = 1; i < n; i += 2) {
				if (v[i] <= 0) {
					if (i == 0) {
						out.push(1); out.push(1);
						v.erase(v.begin()); v.erase(v.begin());
						n -= 2; i -= 2;
					}
					else if (i == n - 1) {
						out.push(n); out.push(n - 1);
						v.erase(v.begin() + n - 1); v.erase(v.begin() + n - 2);
						n -= 2; i -= 2;
					}
					else {
						out.push(i+1);
						v.erase(v.begin() + i); v.erase(v.begin() + i);
						n -= 2; i -= 2;
					}
				}
			}
			if (n % 2) {
				out.push(n); v.erase(v.begin() + n - 1); n--;
			}
			rep(i, n/2) {
				if (i == 0)out.push(1);
				else out.push(2);
			}
			cout << osum << endl;
		}
		int len = out.size();
		cout << len << endl;
		rep(i, len) {
			int x = out.front(); out.pop();
			cout << x << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;
const int INF = 1e9;
#define rep(i,n)for(int i=0;i<n;++i)
#define p pair<int,int>
int main() {
	int N, A;
	cin >> N >> A;
	int x[50];
	ll dp[60][60][3000];
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	for (int i = 0; i < 60; ++i) {
		for (int j = 0; j < 60; ++j) {
			for (int k = 0; k < 3000; ++k) {
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			for (int k = 0; k < 3000; ++k) {
				if (dp[i][j][k] == 0)continue;
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i < N + 1; ++i) {
		ans += dp[N][i][i*A];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 84608
#include <bits/stdc++.h>
using namespace std;
	
int main() {
 
  double L;
  int64_t A,B;
  cin >> L;
  A = L;
  //L = L-(double)A;
  A = A*A*A/27;
  L = L*L*L/27;
  B = L;
  L = L-(double)B;
  

  cout << fixed << setprecision(10);
  cout << A+(double)L <<endl;
  
}

Measured memory_bytes: 256
MOD = 10**9 + 7


def main():
    N = int(input())
    S1 = input()
    _ = input()
    skip = False
    ans = 0
    pre = True  # X if pre else Y
    for i in range(N):
        if i == 0:
            if i != N-1 and S1[i] == S1[i+1]:
                pre = False
                ans = 6
                skip = True
            else:
                pre = True
                ans = 3
            continue
        if skip:
            skip = False
            continue
        if i != N-1 and S1[i] == S1[i+1]:
            if pre:
                ans *= 2
            else:
                ans *= 3
            pre = False
            skip = True
        else:
            if pre:
                ans *= 2
            else:
                ans *= 1
            pre = True
        ans %= MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int n, m[3];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> m[0] >> m[1] >> m[2];
		sort(m, m + 3);
		if(pow(m[0], 2) + pow(m[1], 2) == pow(m[2], 2))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def boxify(image, w):
    new = ['#' * (w + 2)]
    for row in image:
        new.append('#' + row + '#')
    new.append('#' * (w + 2))
    return new


if __name__ == '__main__':
    h, w = map(int, input().split())
    image = [input() for _ in range(h)]
    for row in boxify(image, w):
        print(row)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  double x[4],y[4],ax,ay,bx,by;
  int i,f;
  while(scanf("%lf,%lf",&x[0],&y[0])!=EOF){
    for(i=1;i<4;i++)scanf(",%lf,%lf",&x[i],&y[i]);
    for(i=f=0;i<4;i++){
      ax=x[(i+1)%4]-x[i];
      ay=y[(i+1)%4]-y[i];
      bx=x[(i+2)%4]-x[i];
      by=y[(i+2)%4]-y[i];
      if(ax*by-ay*bx>0)f++;
    }
    if(f%4)printf("NO\n");
    else   printf("YES\n");
  }
  return 0;
}

Measured memory_bytes: 608
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int ceilDiv(int a, int b) {
    return (a + b - 1) / b;
}

int main() {
    string s;
    cin >> s;
    vector<int> ans(s.size());
    vector<int> rl;
    for (int i = 0; i < s.size() - 1; ++i) {
        if (s[i] == 'R' && s[i + 1] == 'L') {
            rl.push_back(i);
        }
    }

    for (int i = 0; i < rl.size(); ++i) {
        ans[rl[i]] = ans[rl[i] + 1] = 1;

        int cntr = 0, cntl = 0;
        for (int j = rl[i] - 1; j >= 0; --j) {
            if (s[j] == 'R')
                ++cntr;
            else
                break;
        }

        for (int j = rl[i] + 2; j < s.size(); ++j) {
            if (s[j] == 'L')
                ++cntl;
            else
                break;
        }

        ans[rl[i]] += cntr / 2 + ceilDiv(cntl, 2);
        ans[rl[i] + 1] += cntl / 2 + ceilDiv(cntr, 2);
    }

    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i];
        if (i == ans.size() - 1) {
            cout << endl;
        } else
            cout << " ";
    }
    return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int t[5], miss[5];
    int max_miss = 0;
    int sum = 0;
    for (int i = 0; i < 5; i++) {
        cin >> t[i];
        miss[i] = t[i] % 10 == 0 ? 0 : 10 - (t[i] % 10); 
        max_miss = max(max_miss, miss[i]);
        sum += t[i] + miss[i];
    }
    cout << sum - max_miss << endl;



    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) { cin >> a[i]; }
	vector<ll> l(n, 0);
	vector<ll> r(n, 0);
	REP(i, n) {
		if(i + a[i] < n) {
			r[i + a[i]]++;
		}
		if(i - a[i] > 0) {
			l[i - a[i]]++;
		}
	}
	ll result = 0;
	REP(i, n) { result += r[i] * l[i]; }
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 8008
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)

using namespace std;
int main() {
    int N;
    cin >> N;
    int tmp = 1;
    int max_ans = 0;
    int ans = 0;
    int j;
    FOR(i, 1, N+1) {
        j = i;
        while(j != 0) {
            if(j%2 == 0) {
                j /= 2;
                if(j != 0) tmp++;
            } else {
                break;
            }
        }
        if(tmp > max_ans) {
            max_ans = tmp;
            ans = i;
        }
        tmp = 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();

        int nc = c*2;
        long price = Long.MAX_VALUE;
        long tmpPrice = 0;
        for(int i=0; i<=100000; i++) {
            tmpPrice = i*nc + a*Math.max(0,x-i) + b*Math.max(0,y-i);
            if(price > tmpPrice) {
                price = tmpPrice;
            }
        }
        System.out.println(price);
    }
}


Measured memory_bytes: 35844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
string s;
llint cnt[26];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	for(int i = 0; i< s.size(); i++) cnt[s[i]-'a']++;
	llint ans = 1;
	for(int i =0; i < 26; i++) ans *= (cnt[i]+1), ans %= mod;
	cout << (ans + mod-1) % mod << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<string.h>
#include <iostream>

using namespace std;


int f[501][501];

int main() {

	while (true) {
		int jk = 0;
		int n = 0, m = 0, sum = 0;
		int i = 0, j = 0, l = 0;

		int a = 0, b = 0, ans[10001] = { 0 }, p[10001] = { 0 };

		cin >> n >> m;

		if (n == 0 || m == 0) return 0;

		memset(f, 0, sizeof f);

		for (i = 0; i < n; i++) {

			p[i] = 0;
			ans[i] = 0;

			for (j = 0; j < 510; j++) f[i][j];

		}

		for (i = 0; i < m; i++) {
			cin >> a >> b;

			f[a - 1][b - 1] = 1;
			if (a == 1) {
				p[b - 1] = 1;
				ans[b - 1] = 1;
			}
		}

		for (i = 1; i < n; i++) {
			for (j = 1; j < n; j++) {
				if ((p[i] == 1) && (f[i][j] == 1 || f[j][i] == 1)) ans[j] = 1; 
			}
		}

		for (i = 0; i < n; i++) {
			sum += ans[i];
		}

		cout << sum << endl;
		sum = 0;
	}
}


Measured memory_bytes: 4076
#include <stdio.h>

int main(void){

  int n,k,q,i,j,s[100000],c;
  scanf("%d %d %d",&n,&k,&q);
  for(i=0;i<n;i++){
    s[i]=k;
  }
  for(i=0;i<q;i++){
    scanf("%d", &c);
    s[c-1]++;
  }
  for(i=0;i<n;i++){
    s[i]-= q;
    if(s[i]>0){
      printf("Yes\n");
    }else{
      printf("No\n" );
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;
int ans;

int main()
{
	in>>S;
	rep(i,S.length())
	{
		ans+=(S[i]=='1'?1:0);
	}
	out<<ans<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_geneous = 0; ngtkana_is_geneous < n; ngtkana_is_geneous++)
#define rep(i, begin, end) for(int i = begin; i < end; i++)

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::priority_queue<double, std::vector<double>,
    std::greater<double>> que;
  loop(n)
  {
    double v; std::cin >> v;
    que.emplace(v);
  }
  while (true)
  {
    auto x = que.top(); que.pop();
    if (que.empty()) break;
    auto y = que.top(); que.pop();
    que.emplace((x + y) / 2);
  }
  std::cout << que.top() << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for(int i=0; i<M; i++)
    cin >> L[i] >> R[i];

  int max = 0;
  for(int i=0; i<M; i++)
    if(max < L[i])
      max = L[i];
  
  int min = 200000;
  for(int i=0; i<M; i++)
    if(min > R[i])
      min = R[i];

  if(max <= min)
    cout << min - max + 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1024
"""
"""


def int_as_array(num): return list(map(int, [y for y in str(num)]))


def array_as_int(arr): return int(''.join(map(str, arr)))


def read_int(): return int(input())


def read_array(): return list(map(int, input().split(' ')))


def array_to_string(arr, sep=' '): return sep.join(map(str, arr))


def matrix_to_string(arr, sep=' '): return '[\n' + '\n'.join(
    [sep.join(map(str, row)) for row in arr]) + '\n]'


coins = {
    500: 1000,
    100: 0,
    50: 0,
    10: 0,
    5: 5,
    1: 0
}


def solve(number):
    points = 0
    points += (number // 500) * 1000
    number = number % 500
    points += (number // 5) * 5
    number = number % 5
    return points


T = read_int()

print(solve(T))


Measured memory_bytes: 3064
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=0
if a[0]+a[1]>x:
    ans+=a[0]+a[1]-x
    a[1]=max(a[1]-ans,0)
for i in xrange(1,n-1):
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        tmp=a[i]+a[i+1]-x
        a[i+1]=max(a[i+1]-tmp,0)

print(ans)

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

int main()
{
    int n, ans;
    cin >> n;
    vector<pair<int, int>> red, blue;
    for(int i = 0; i<n; i++){
        int a,b;
        cin >> a >> b;
        red.push_back({a, b});
    }
    for(int i = 0; i<n; i++){
        int c,d;
        cin >> c >> d;
        blue.push_back({c, d});
    }
    sort(blue.begin(), blue.end());
    sort(red.begin(), red.end(), [](const pair<int, int> l, const pair<int, int> r){return l.second > r.second;});
    ans = 0;
    for(auto b: blue){
        for(auto r = red.begin(); r!=red.end(); r++){
            if(b.first > r->first && b.second > r->second){
                ans++;
                red.erase(r);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    int n;
    cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);
    vector<int> t(n-1);
    int max = 0;

    REP(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }

    REP(i,t.size()){
        int time = s[i] + c[i];
        for(int j = i + 1;j<s.size();j++){
            if(time <= s[j]){
                time = s[j] + c[j];
            }
            else{
                int dif = time - s[j];
                int lossc = ceil((double)dif/f[j]);
                int losstime = lossc * f[j];
                time = s[j] + losstime + c[j];
            }
        }
        t[i] = time;
    }

    REP(i,n-1){
        cout << t[i] << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = {
        let mut s = String::new(); // バッファを確保
        std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
        s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
    };
    let (x, a) = {
        let mut ws = s.split_whitespace(); // 空白区切りの単語に分解する
        let n: i32 = ws.next().unwrap().parse().unwrap(); // イテレータから値を取り出して整数に
        let m: i32 = ws.next().unwrap().parse().unwrap();
        (n, m)
    };
    if x >= a {
        println!("10");
    } else {
        println!("0");
    }
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

void work()
{
    int n, x, y;
    cin >>n >>x >>y;

    if(x > y) swap(x, y);

    for(int k = 1; k < n; k++)
    {
        int ans = 0;
        for(int i = 1; i <= n; i++)
        {
            int c = i - k;
            if(abs(i - y) <= k - 1)
            {
                int d = k - abs(i - y) - 1;
                int a = x - d;
                int b = x + d;

                if(c < a)
                {
                    if(c > 0) ans++;
                }
                else if(a <= c && c <= b)
                {
                    if(a > 0) ans++;
                    if(b > 0 && c == b && a != b) ans++;
                }
                else if(b < c)
                {
                    if(a > 0) ans++;
                    if(b > 0 && a != b) ans++;
                    if(c > 0) ans++;
                }
            }
            else
            {
                if(c > 0) ans++;
            }
        }
        cout <<ans <<endl;
    }
}



int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		
		string s = Console.ReadLine();
		string t = Console.ReadLine();
		
		if(s==t.Substring(0,s.Length)){
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
		
	}
}

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

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

	int digit = N / 100;

	if (N > digit * 100 + digit * 10 + digit)
		cout << (digit+1) * 100 + (digit+1) * 10 + (digit+1) << endl;
	else
		cout << digit * 100 + digit * 10 + digit << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<ll> v(87);
    v[0]=2,v[1]=1;
    FOR(i,2,87){
        v[i]=v[i-1]+v[i-2];
    }
    cout<<v[n]<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    int ans = 1;
    ll prev_diff = a[1] - a[0];
    REP(i, n - 1) {
        ll diff = a[i + 1] - a[i];
        if(prev_diff * diff < 0) {
            ans++;
            i++;
            prev_diff = a[i + 1] - a[i];
            continue;    
        }
        if(diff != 0) prev_diff = diff;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
int n,m,ind[N][2],vis[N];
vector<int> G[N];
char s[N];
queue<int> q;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>m>>s+1;
	//cout<<s+1<<endl;
	for(int i=1;i<=m;i++){
		int u,v; cin>>u>>v;
		G[u].push_back(v); G[v].push_back(u);
		ind[u][s[v]-'A']++; ind[v][s[u]-'A']++;
	}
	int tot=0;
	for(int i=1;i<=n;i++){
		if(!ind[i][0]||!ind[i][1]) q.push(i),vis[i]=1;
	}
	while(!q.empty()){
		int u=q.front(); q.pop(); tot++;
		for(int i=0;i<G[u].size();i++){
			int v=G[u][i];
			if(!(--ind[v][s[u]-'A'])&&!vis[v]) q.push(v),vis[v]=1;
		}
	}
	if(tot<n) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }

    return 0;
}

Measured memory_bytes: 3168
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    map<string, LL> count;
    LL max_count = 1;
    REP(i,n){
        string s;
        cin>>s;
        if(EXIST(count,s)){
            LL c = count[s] + 1;
            count[s] = c;
            max_count = max(max_count, c);
        }
        else {
            count[s] = 1;
        }
    }
    
    vector<string> ans;
    EACH(itr, count){
        if(itr->second == max_count){
            ans.PB(itr->first);
        }
    }
    SORT(ans);
    REP(i,ans.size()){
        PUTS(ans[i]);
    }
}

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

int main() {
  int n;
  int a[100];
  int max = 0;
  int min = 1000000000;
  cin >> n;
  for(int i = 0;i < n;i++){
  	cin >> a[i];
  }
  for(int i = 0;i < n;i++){
  	if(a[i] > max){
    	max = a[i];
    }
    if(a[i] < min){
    	min = a[i];
    }
  }
  int ans = max - min;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
  int n,counter=0;
  std::cin >> n;
  rep(i,n){
    int a,b;
    std::cin >> a>>b;
    counter+=b-a+1;
  }
  std::cout << counter << std::endl;
}

Measured memory_bytes: 256
#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  
#include <climits>

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

ll GCD(ll a, ll b)  
{  
    return b ? GCD(b, a % b) : a;  
}  
const int PRIMERANGE = 1000000;  
int prime[PRIMERANGE + 1];  
int getPrime()  
{  
    memset (prime, 0, sizeof (int) * (PRIMERANGE + 1));  
    for (int i = 2; i <= PRIMERANGE; i++)  
    {  
        if (!prime[i]) prime[++prime[0]] = i;  
        for (int j = 1; j <= prime[0] && prime[j] <= PRIMERANGE / i; j++)  
        {  
            prime[prime[j]*i] = 1;  
            if (i % prime[j] == 0) break;  
        }  
    }  
    return prime[0];  
}  
/*************************************** 
get factor of n 
O(sqrt(n)) 
factor[][0] is prime factor 
factor[][1] is factor generated by this prime 
factor[][2] is factor counter 

need: Prime Table 
***************************************/  
///you should init the prime table before  
int factor[100][3], facCnt;  
int getFactors(int x)  
{  
    facCnt = 0;  
    int tmp = x;  
    for(int i = 1; prime[i] <= tmp / prime[i]; i++)  
    {  
        factor[facCnt][1] = 1, factor[facCnt][2] = 0;  
        if(tmp % prime[i] == 0)  
            factor[facCnt][0] = prime[i];  
        while(tmp % prime[i] == 0)  
            factor[facCnt][2]++, factor[facCnt][1] *= prime[i], tmp /= prime[i];  
        if(factor[facCnt][1] > 1) facCnt++;  
    }  
    if(tmp != 1)  
        factor[facCnt][0] = tmp, factor[facCnt][1] = tmp, factor[facCnt++][2] = 1;  
    return facCnt;  
}  

bool test(ll v) {
    
}

void dfs(int fac, int v, int flag) {
    if(flag) {
        cout << v << endl;
        test(v);
    }
    if (fac >= facCnt) {
        return;
    }
    for (int i = 0; i <= factor[fac][2]; ++i) {
        dfs(fac+1, v*qpow(factor[fac][0], i), i==0?0:1);
    }
}

ll a[100005], b, x, n;
int main()
{
    cin >> n;
    ll cnt = 0, ans = 0;
    map<ll, int> s;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        ans += s[a[i]-cnt];
        // if (s[a[i]-cnt] > 0) cout << i << ' ' <<a[i] << endl;
        s[-(a[i]+cnt)]++;
        ++cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27828
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int[] n = new int[31];
			for(int i=0;i<28;i++){
				n[sc.nextInt()]++;
			}
			
			for(int i=1;i<31;i++){
				if(n[i]==0)System.out.println(i);
			}
						
		}
	}
}

Measured memory_bytes: 17180
#include <bits/stdc++.h>
using namespace std;
int n,a[200005];
long long X,Y,ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	for (int l=1,r=0;l<=n;X^=a[l],Y-=a[l],++l){
		while (r<=n&&X==Y) ++r,X^=a[r],Y+=a[r];
		ans+=r-l;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


def main():
    N,M = map(int,input().split())
    S=input()
    T=input()

    L=int(lcm(N,M))

    N_ = int(L/N)
    M_ = int(L/M)

    L_ = int(lcm(N_,M_))

    for i in range(0,L,L_):
        if(S[int(i/N_)] != T[int(i/M_)]):
            print(-1)
            return 0;

    print(L)
    return 0;

main()

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;
using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int N = 1e5+5;

const int INF = 1e9+5;
void solve(){

    int n;
    cin >> n;
    vector<int>dp(3);
    for(int i = 0;i < n;++i) {
        vector<int>new_dp(3, 0);
        vector<int>cost(3);
        for(int i=0;i < 3;i++) {
            cin >> cost[i];
        }
        for(int i=0;i < 3;i++) {
            for(int j=0;j < 3;j++) {
                if(i!=j) {
                    new_dp[j] = max(new_dp[j], dp[i]+cost[j]);
                }
            }
        }
        dp = new_dp;
    }
    cout << max(dp[0], max(dp[1], dp[2]));








}
int main() {
    fast;
    solve();

}


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

int main()
{
    int n, m ;
    cin>>n>>m;
    char arr1[n][n];
    char arr2[m][m];
    for( int  i = 0 ; i < n ; i++)
    {
        for ( int  j = 0 ; j < n ; j++)
        {
            cin>>arr1[i][j];
        }
    }
    for( int  i = 0 ; i < m ; i ++)
    {
        for ( int  j = 0 ; j < m ; j++)
        {
            cin>>arr2[i][j];
        }
    }
    for( int  k = 0 ; k <= n-m ; k ++)
    {
        for ( int  l = 0 ; l <= n-m ; l++)
        {
            int f = 0;
            if( arr1[k][l] == arr2[0][0])
            {
                for( int  i = 0 ; i < m ; i ++)
                {
                    for ( int  j = 0 ; j < m ; j++)
                    {
                        if ( arr2 [i][j] != arr1[k+i][l+j])
                        {
                            f = 1;
                            break;
                        }
                    }
                    if ( f ==1 )
                        break;
                }
                if ( f == 0)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
  int x;
  cin >> x;
  int m = 2 * x;
  
  bool prime = true;
  int j = x;
  int memo = 0;
  
  while(prime){
    int cnt = j - 1;
    
    for(int i = 2; i < j; i++){
      if(j % i == 0){
        break;
      }
      cnt--;
    }
    
    if(cnt == 1){
      prime = false;
      memo = j;
      break;
    }
    
    j++;
    if(j > m){
      break;
    }
  }
  
  cout << memo << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
 string s;ll k;cin>>s>>k;
  ll n=s.size();
  char x=s.at(0);
  bool b=true;
  rep(i,n){
    if(x!=s.at(i))b=false;
  }
  if(b){
    cout<<(n*k)/2<<endl;
    return 0;
  }
  
  int j=1;
  int count=0;
  for(int i=1;i<n;i++){
    if(s.at(i)==s.at(i-1)){
     j++;
    }
    else {
      count+=j/2;
      j=1;
    }
  }
  count+=j/2;
  if(s.at(0)!=s.at(n-1)){
    cout<<count*k<<endl;
  }
  else{
    ll a=1;
    for(int i=1;i<n;i++){
      if(s.at(i)==s.at(i-1)){
        a++;
      }
      else break;    
  }
  ll b=1;
  for(int i=n-2;i>=0;i--){
      if(s.at(i)==s.at(i+1)){
        b++;
      }
      else break;    
  }
  cout<<(count)*k+((a+b)/2-(a/2)-(b/2))*(k-1)<<endl;
  
}

}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,W,N;
  cin>>H>>W>>N;
  vector<int> A(H*W);
  int j=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    for(int k=0;k<a;k++)
      A[j+k]=i+1;
    j+=a;
  }
  vector<vector<int>> B(H,vector<int>(W));
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      if(i%2==0)
        B[i][j]=A[i*W+j];
      else
        B[i][W-j-1]=A[i*W+j];
    }
  for(vector<int> i:B){
    for(int j:i)
      cout<<j<<' ';
    cout<<endl;
  }
}

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

using namespace std;

int mod(int a, int b){
  if(a>b)
    return a-b;
  return b-a;
}

int minimum(int a, int b)
{
  if(a<b)
    return a;
  return b;
}

int main(){
  int n;
  cin >> n;
  int h[n];
  for(int i=0;i<n;i++)
    cin >> h[i];
  int dp[n];
  dp[n-1]=0;
  dp[n-2]=mod(h[n-1],h[n-2]);
  for(int i=n-3;i>=0;i--){
    dp[i] = minimum(dp[i+1]+mod(h[i],h[i+1]), dp[i+2]+mod(h[i],h[i+2]));
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 4288
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> l(N);
    rep(0, i, N)
    {
        cin >> l.at(i);
    }
    sort(all(l));
    reverse(all(l));
    ll ans = 0;
    rep(0, i, K)
    {
        ans += l.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var orgArry = cin.ReadIntArray(n);
            var sortedArry = orgArry.OrderBy(o => o).ToArray();
            var count = 0;
            for (var i = 0; i < orgArry.Length - 1; i++)
            {
                if (orgArry[i] == sortedArry[i]) continue;
                if (++count > 2) {
                    WriteLine("NO");
                    return;
                }
            }
            WriteLine("YES");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13524
N = input()
K = int(input())

L = len(N)

# dp[i][j][k]
# i: 決定した桁数(上から)
# j: 0の個数
# k: N未満確定フラグ
dp = [[[0] * 2 for _ in range(5)] for _ in range(110)]

dp[0][0][0] = 1

# 配るDP
for i in range(L):
    S = int(N[i])
    for j in range(K+1):
        for k in range(2):
            # d: 次の桁
            for d in range((9 if k else S) + 1):
                dp[i+1][j + (d != 0)][k | (d < S)] += dp[i][j][k]

ans = dp[L][K][0] + dp[L][K][1]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  char s[30];
  gets(s);
  int n,i,j,x=0;
  n = strlen(s);
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(s[i]==s[j] && x==0){
        printf("no\n");
        x += 1;
        break ;
      }
    }
  }
  if(x==0){
    printf("yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(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)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int A, B; cin >> A >> B;
    int r = A+B;
    r = max(r, A-B);
    r = max(r, A*B);
    cout << r << endl;
}                              


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	int a[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	sort(a,a+4);
	if (a[0] == 1&&a[1] == 4&&a[2] == 7&&a[3]==9) {
		cout << "YES" << endl;
	} else {
		cout << "NO" <<endl;
	}
}

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

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<long long> A(N,0);
  for(int i=0; i<N; i++){
    long long a; cin>>a;
    A[i]=a;
  }
  sort(A.begin(),A.end(),greater<int>());
  long long mid=(A[0]/2);
  long long min=1000000001,m,ans;
  for(int i=1; i<N; i++){
    long long t=A[0]-A[i];
    m=abs(mid-t);
    //cout<<t<<endl;
    if(m<min){
      min=m;
      ans=A[i];
      //cout<<A[i]<<endl;
  }
  }
  cout<<A[0]<<" "<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int i,n;
    cin>>n;
    for(i=1; i<=9; i++)
    {
        int k = n/i;
        if(k<=9&&k*i==n)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n, cnt = 1, a, b;
  cin>>n;
  vector<ll>p(n);
  vector<ll>q(n);
  vector<ll>v(n);
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  rep(i,n) v[i] = i+1;
  
  do{
    bool okp = 1, okq = 1;
    rep(i,n){
      if(p[i] != v[i]){
        okp = 0;
        break;
      }
    }
    rep(i,n){
      if(q[i] != v[i]){
        okq = 0;
        break;
      }
    }
    if(okp) a = cnt;
    if(okq) b = cnt;
    cnt++;
  }while(next_permutation(all(v)));
  
  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
import heapq
def topologicalsort(N,E):
    V = [0]*N
    for i in range(N):
        for y in E[i]:
            V[y] += 1
    S = [ i for i in range(N) if V[i] == 0]
    SORTED = []
    while S:
        s = S.pop(0)
        SORTED.append(s)
        for t in E[s]:
            V[t] -= 1
            if V[t] == 0:
                S.append(t)
    return SORTED
    
N, M = map( int, input().split())
E = [ [] for _ in range(N)]
for _ in range(M):
    x, y = map( int, input().split())
    # x, y = x-1, y-1
    E[x].append(y)
ANS = topologicalsort(N, E)
for i in range(N):
    print(ANS[i])


Measured memory_bytes: 8736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;


typedef long long LL;
int main(){
	LL a , b , c, d;
	cin >> a >> b >> c >> d;
	LL sum1 , sum2;
	sum1 = a * b;
	sum2 = c * d;
	LL ans = max(sum1 , sum2);
	cout << ans << endl;
	return 0;
	}

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

int main()
{
    string S;
    cin >> S;
    int count = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'o') {
            count += 1;
        }
    }
    if(((15-S.size()) + count) >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
w, a, b = map(int, input().split())

if a <= a + w <= b <= b + w:
    print(b - a - w)
elif a <= b <= a + w <= b + w:
    print(0)
elif b <= a <= a + w <= b + w:
    print(0)
elif b <= b + w <= a <= a + w:
    print(a - b - w)


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

using namespace std;

int w, h;
vector<string> feeld;

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

int add, id;
void rec(int x, int y) {
	if (feeld[y][x] == 'B') {
		id |= 1;
		return;
	}
	
	if (feeld[y][x] == 'W') {
		id |= 2;
		return;
	}
	
	feeld[y][x] = '-';
	add++;
	
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (!(0 <= nx && nx < w && 0 <= ny && ny < h)) continue;
		if (feeld[ny][nx] == '-') continue;
		rec(nx, ny);
	}
}

void solve() {
	int ansb = 0, answ = 0;
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (feeld[i][j] == '.') {
				add = 0; id = 0;
				rec(j, i);
				if (id == 1) ansb += add;
				if (id == 2) answ += add;
			}
		}
	}
	
	cout << ansb << " " << answ << endl;
}

int main() {
	while (1) {
		cin >> w >> h; if (w == 0 && h == 0) break;
		feeld.assign(h, "");
		for (int i = 0; i < h; i++) cin >> feeld[i];
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1424