akhauriyash/Code-Regression huggingface dataset:
x, k, d = map(int, input().split())
x = abs(x)
p_n = x % d
p_n_num = x//d

m_n = p_n - d
ans = ""
if x == 0:
    if k % 2 == 0:
        ans = 0
    else:
        ans = k
else:
    if k <= p_n_num:
        ans = x - (k*d)
    else:
        if (p_n_num - k) % 2 == 0:
            ans = p_n
        else:
            ans = m_n
print(abs(ans))

Measured memory_bytes: 9216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int main() {
    // source
    int a, b;
    cin >> a >> b;
    if (a > 8 | b > 8) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def print_ans(N, H):
    """Test Case
    >>> print_ans(5, [1, 2, 1, 1, 3])
    Yes
    >>> print_ans(4, [1, 3, 2, 1])
    No
    >>> print_ans(5, [1, 2, 3, 4, 5])
    Yes
    >>> print_ans(1, [1000000000])
    Yes
    """
    if N == 1 :
        print("Yes")
    else:
        tmp_max = 0
        for i in range(N - 1):
            if (H[i] > H[i + 1] and H[i] - 1 > H[i + 1] ) or tmp_max > H[i + 1]  :
                print("No")
                break
            else:
                if H[i] < H[i + 1]:
                    H[i + 1] -= 1
                    tmp_max = H[i + 1]
            if i == N -2:
                print("Yes")



if __name__ == '__main__':
    N = int(input().rstrip())
    H = list(map(int,input().rstrip().split()))
    print_ans(N, H)


Measured memory_bytes: 14704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int x = sc.NextInt();
        int y = sc.NextInt();

        int answer = x + y / 2;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main(){
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

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

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
///

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    double W, H, x, y; cin >> W >> H >> x >> y;
    double ans = W * H / 2.0;
    if(2 * x == W && 2 * y == H){
        cout << ans << " " << 1 << endl;
    }
    else{
        cout << ans << " " << 0 << endl;
    }
    return 0;
}


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

int main(){

  long long n;
  int a, d, m;
  map<int, int> mp;
  

  cin>>n>>a>>d>>m;
  for(int i=0;i<m;i++){
    int x, y, z;
    cin>>x>>y>>z;
    if(mp[y]==0) mp[y]=a+(y-1)*d;
    if(mp[z]==0) mp[z]=a+(z-1)*d;
    if(x){
      mp[y]=mp[z];
    }else{
      swap(mp[y], mp[z]);
    }
  }

  int k;
  cin>>k;
  if(mp[k]!=0) cout<<mp[k]<<endl;
  else cout<<a+(k-1)*d<<endl;

  
  return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << ((sizeof...(tail)!=0)?" ":""); print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a << ((&a!=&vec.back())?" ":""); } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }

struct UnionFind {
	vector<int> data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}

	int find(int k) {
		if(data[k] < 0) return(k);
		return data[k] = find(data[k]);
	}

	bool same(int x, int y)	{
		return find(x) == find(y);
	}

	int size(int k)	{
		return -data[find(k)];
	}

    ll size2(int k)	{
		ll num = -data[find(k)];
        return num * (num-1ll) / 2ll;
	}
};

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

    int n, m; cin >> n >> m;
    vector<P> edges(m);
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        edges[i] = P(x, y);
    }

    UnionFind uf(n);

    reverse(all(edges));
    vector<ll> cnt(m+1);
    cnt[0] = 0;
    rep(i, m) {
        P p = edges[i];
        if (uf.same(p.fi, p.se)) cnt[i+1]=cnt[i];
        else {
            ll tmp = cnt[i];
            tmp -= uf.size2(p.fi);
            tmp -= uf.size2(p.se);
            uf.unite(p.fi, p.se);
            tmp += uf.size2(p.fi);
            cnt[i+1] = tmp;
        }
    }

    reverse(all(cnt));
    ll total = n * (n-1ll) / 2ll;
    FOR(i, 1, m+1) {
        cout << total-cnt[i] << endl;
    }
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline
 
s = input().rstrip()
k = int(input())
    
def check_count(s):
    cnt_list = [1]
    cnt = 1
    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            cnt_list[-1] += 1
        else:
            cnt_list.append(1)
    return cnt_list

def calc_ans(cnt_list, k):
    _ans = 0
    for c in cnt_list:
        _ans += c//2
    return(_ans * k)

if len(s)==1:
    ans = k//2
else:
    cnt_list = check_count(s)
    if len(cnt_list)==1:
        ans = (len(s)*k)//2
    else:
        ans = calc_ans(cnt_list, k)
        if s[0]==s[-1]:
            if cnt_list[0]%2==1 and cnt_list[-1]%2==1:
                ans += k - 1

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

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


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

void solve(long long A, long long B){
	
	int ans = 0;

	for(long long n = A; n <= B; n++)
	{
		if ((int)(n/10000) != n%10) continue;
		if ((int)(n%10000/1000) != (int)(n%100/10)) continue;
		ans++;
	}
		
	cout << ans << endl;
}

int main(){	
	long long A;
	long long B;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<c&&c<b){cout<<"Yes";return 0;}
  else if(b<c&&c<a){cout<<"Yes";return 0;}
  else{cout<<"No";return 0;}
}

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

using namespace std;

int main(){
  double n,k,c,e = 0,i = 1;
  int a = 0;
  cin >> n >> k;
  double b = k;
  for(; i <= n; ++i){
    for(;b > i; ++a){
      b /= 2;
    }
    c = 1 / n;
    for(int d = 1; d <= a; ++d){
      c /= 2;
    }
    e += c;
    a = 0;
    b = k;
  }
  cout << fixed << setprecision(12) << e << endl;
  return 0;
}  

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

int n;
int s;
int t;
int ans;
int a[3001];
int b[3001];
int dp[3001][3001];

int main() {
    scanf("%d %d %d", &n, &t, &s);
    for (int i=1; i<=n; i++) {
        scanf("%d %d", &a[i], &b[i]);
    }

    for (int i=1; i<=n; i++) {
        for (int j=0; j<=s; j++) {
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            if (j-b[i] < 0) continue;
            dp[i][j] = max(dp[i][j], dp[i-1][j-b[i]] + a[i]);
            //dp[i][j+b[i]] = max(dp[i][j+b[i]], dp[i-1][j] + a[i]);
        }
    }

    /*for (int i=0; i<=n; i++) {
        for (int j=0; j<s; j++) {
            dp[i][s] = max(dp[i][s], dp[i][j]);
        }
    }*/

    for (int i=1; i<=n; i++) {
        for (int j=s; j<=t; j++) {
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            if (j-b[i] < s) continue;
            dp[i][j] = max(dp[i][j], dp[i-1][j-b[i]] + a[i]);
        }
    }

    /*for (int i=1; i<=n; i++) {
        for (int j=0; j<=t; j++) {
            printf("%2d ", dp[i][j]);
        }
        puts("");
    }*/

    ans = 0;
    for (int i=1; i<=n; i++) {
        for (int j=0; j<=t; j++) ans = max(ans, dp[i][j]);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 36220
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        try{
            String buf = br.readLine();
            String str[] = buf.split(" ", 0);

            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            try{
                String s = br.readLine();
                String tmp[] = s.split(" ", 0);
                int k = Integer.parseInt(tmp[0]);

                if(b <= a && c <= a){
                    for(int i=0; i<k; i++){
                        a = a * 2;
                    }
                }
                else if(a <= b && c <= b){
                    for(int i=0; i<k; i++){
                        b = b * 2;
                    }
                }
                else{
                    for(int i=0; i<k; i++){
                        c = c * 2;
                    }
                }
                System.out.println(a+b+c);
            }
            catch(IOException e){
                System.out.println(e);
            }
        }
        catch(IOException e){
            System.out.println(e);
        }
    }
}


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


void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
    vector<vector<long long> > HH(N+1, vector<long long>(1));
    for(int i = 0; i < M; ++i){
        HH[A[i]].push_back(B[i]);
        HH[B[i]].push_back(A[i]);
    }
    /*
    for(int i = 1; i <= N; ++i){
        cout << i << ":" << H[i] << endl;
        for(auto j : HH[i]){
            cout << H[j] << " ";
        }
        cout << endl;
    }
    */
    long long ans = 0;
    for(int i = 1; i <= N; ++i){
        long long maxval = 0;
        for(auto j : HH[i]){
            maxval = max(maxval, H[j]);
        }
        //cout << H[i] << " " << maxval << endl;
        if(H[i] > maxval) ans++;
    }
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N+1);
    H[0] = 0;
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int n;
	cin >> n;
	if(n % 2){
		// 奇数だったら、N - iとの辺を繋がない。
		int m = (n-1) * n / 2; m -= (n - 1) / 2;
		cout << m << endl;
		for(int i = 0; i < n; i++){
			int a = i + 1;
			for(int j = a; j <= n; j++){
				if(a + j == n) continue;
				if(a == j) continue;
				cout << a << " " << j << endl;
			}
		}
	}
	else {
		int m = (n-1) * n / 2; m -= n / 2;
		cout << m << endl;
		for(int i = 0; i < n; i++){
			int a = i + 1;
			for(int j = a + 1; j <= n; j++){
				if(a + j == n + 1) continue;
				cout << a << " " << j << endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 1e9;
const ll kLInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N, K;
int a[105];
bool dp[100010];

int main()
{
   cin >> N >> K;
   REP(i, N) cin >> a[i];
   REP(i, K+1) {
      REP(j, N) {
         if (i-a[j]>=0) {
            if (!dp[i-a[j]]) dp[i] = 1;
         }
      }
   }
   if (dp[K]) cout << "First" << endl;
   else cout << "Second" << endl;
   return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cmath>
#define rep(i,s,t) for(int i=s;i<=t;++i)
using namespace std;
typedef long long ll;
ll s;
inline bool check(ll x){
	ll y=s/x;
	if(y*x<s)++x;
	ll b=y-(y*x-s);
	printf("%lld 0 0 %lld %lld %lld\n",x-1,b,x,y);
	return 0;
}
int main(){
	scanf("%lld",&s);
	ll x=sqrt(s);
	check(x);
	return 0;
}

Measured memory_bytes: 128
import itertools

# input
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int, input().split()))
    C.append(l[0])
    A.append(l[1:])

# process
ans = 1300000
idx = [i for i in range(N)]
for i in range(1, N+1):
    combs = list(itertools.combinations(idx, i))
    for comb in combs:
        c = 0
        a = [0]*M
        for j in comb:
            c += C[j]
            for k in range(M):
                a[k] += A[j][k]
        if len([x for x in a if x<X]) == 0 and c < ans:
            ans = c

# output
print(-1 if ans == 1300000 else ans)


Measured memory_bytes: 9392
import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

solve :: [Int] -> Double    
solve [n, m, d] = fromIntegral (m - 1) * avg
  where
    avg = (if d==0 then 1.0 else 2.0) * (1.0 - fromIntegral d / fromIntegral n) / fromIntegral n

main = map read . words <$> getLine >>= putStrLn . printf "%.15f" . solve

Measured memory_bytes: 508
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int N;
	sci(N);
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		int tmp;
		sci(tmp);
		if ((i & 1) && (tmp & 1)) {
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n;
    cin>>n;
    string s[n];
    int t[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i]>>t[i];
    }
    string x;
    cin>>x;

    bool f = 0;
    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        if( f )
            ans += t[i];
        if( s[i] == x )
            f = 1;
    }
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let ps = reads int
    let qs = List.sort ps
    let count = List.fold2 (fun s p q -> if p <> q then s + 1 else s) 0 ps qs
    match count with
    | 0 | 2 -> "YES"
    | _ -> "NO"
    |> printfn "%s"
    0

Measured memory_bytes: 14940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define reps(i,s,n) for (int i = (s); i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    
    int N;
    int K;
    cin >> N >> K;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    cout << ((N-1) + (K-1) - 1) / (K-1) << endl;

    return 0;
}
    

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

int main(){
    int n;
    cin >> n;
    vector<int> top(n+1), bot(n+1);
    for(int i=1; i<=n; i++){
        cin >> top[i];
        top[i] += top[i-1];
    }
    for(int i=n;i>0; i--) cin >> bot[i];
    for(int i=1; i<=n; i++) bot[i] += bot[i-1];
    reverse(bot.begin(), bot.end());
    
    int ans = 0;
    for(int i=0; i<n; i++) ans = max(ans, top[i+1] + bot[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    vector<int> A(N), B(N);
    REP(i, 0, N) cin >> A[i] >> B[i];
    sort(ALL(A), greater<int>());
    sort(ALL(B), greater<int>());

    int i = 0;
    while (i < N && H > 0 && B[i] > A[0]) {
        H -= B[i++];
    }

    cout << i + (max(0, H) + A[0] - 1) / A[0] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 100009
#define nan 1000000000
using namespace std;

int n,m,tot,fst[N],pnt[N<<1],nxt[N<<1],fa[N],ans[N],lf[N],rg[N];
void gg(){
	puts("No"); exit(0);
}
void add(int x,int y){
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
void dfs(int x){
	int i,y;
	for (i=fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (y!=fa[x]){
			fa[y]=x; dfs(y);
			if (lf[y]!=nan){
				if (lf[x]==nan){
					lf[x]=lf[y]-1; rg[x]=rg[y]+1;
				} else if ((lf[x]^lf[y])&1){
					lf[x]=max(lf[x],lf[y]-1);
					rg[x]=min(rg[x],rg[y]+1);
				} else gg();
			}
		}
	}
	if (lf[x]!=nan && lf[x]>rg[x]) gg();
}
void solve(int x,int t){
	int i,y; ans[x]=t;
	for (i=fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (y!=fa[x])
			solve(y,(lf[y]==nan || lf[y]<=t+1 && t+1<=rg[y])?t+1:t-1);
	}
}
int main(){
	scanf("%d",&n);
	int i,x,y;
	for (i=1; i<n; i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	for (i=1; i<=n; i++) lf[i]=nan;
	scanf("%d",&m);
	for (i=1; i<=m; i++){
		scanf("%d%d",&x,&y);
		assert(lf[x]==nan);
		lf[x]=rg[x]=y;
	}
	dfs(1);
	puts("Yes");
	solve(1,lf[1]==nan?0:lf[1]);
	for (i=1; i<=n; i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
ll pow(ll a,ll b){
  if(b==0){
    return 1;
  }else if(b%2==0){
    return(pow(a*a,b/2));
  }else{
    return(a*pow(a,b-1));
  }
}
int main(){
  ll N,ingn=1,countp=0,countq=0;
  cin>>N;
  vector<ll> p(N);
  vector<ll> q(N);
  string sp,sq;
  for(ll i=0;i<N;i++){
    cin>>p.at(i);
    ingn=ingn*(i+1);
    string a=std::to_string(p.at(i));
    sp+=a;
  }
  for(ll i=0;i<N;i++){
    cin>>q.at(i);
    string a=std::to_string(q.at(i));
    sq+=a;
  }
  //cout<<sp<<" "<<sq<<endl;
  vector<ll> v(N);
  iota(v.begin(), v.end(), 1);  
  ll number=1;
  do{
    for(auto x:v){
      ll check=0;
      for(ll i=0;i<N;i++){if(v.at(i)==p.at(i))check++;}
      if(check==N){countp=number/N;}
      check=0;
      for(ll i=0;i<N;i++){if(v.at(i)==q.at(i))check++;}
      if(check==N){countq=number/N;}
      number++;
    }
  }while( next_permutation(v.begin(), v.end()) );
  cout<<max(countq-countp,countp-countq)<<endl;
}

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

int main(){
   int n;
   cin>>n;
   vector<ll> a(n);

   rep(i,n) cin>>a[i];
   ll ans=0;
   for(int i=1;i<n;i++){
       if(a[i-1]>a[i]){
           ans+=a[i-1]-a[i];
           a[i]=a[i-1];
       }
   }

   cout<<ans<<endl;
}


Measured memory_bytes: 4836
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int x[1000][1000][2], n, m, a, b, c, d, q, e;

int path(int n, int s, int g) {
	int p[1000];
	memset(p, 127, sizeof(p));
	p[s] = 0;
	e = min(n, 9);
	for (int i = 0; i < e; i++){
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				if (x[j][k][1] < 10000000) {
					p[k] = min(p[k], p[j] + x[j][k][1]);
				}
			}
		}
	}
	return p[g];
}

int score(int n, int s, int g) {
	int p[1000];
	memset(p, 127, sizeof(p));
	p[s] = 0;
	e = min(n, 9);
	for (int i = 0; i < e; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				if (x[j][k][0] < 10000000) {
					p[k] = min(p[k], p[j] + x[j][k][0]);
				}
			}
		}
	}
	return p[g];
}

int main() {
	while (true) {
		memset(x, 127, sizeof(x));
		cin >> m >> n;
		if (m == 0 && n == 0) { break; }
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> c >> d;
			x[a][b][0] = c;
			x[b][a][0] = c;
			x[a][b][1] = d;
			x[b][a][1] = d;
		}
		cin >> q;
		for (int i = 0; i < q; i++) {
			cin >> a >> b >> c;
			if (c == 0) { cout << score(n, a, b) << endl; }
			else { cout << path(n, a, b) << endl; }
		}
	}
}

Measured memory_bytes: 10880
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        int[] c = new int[n - 1];
        int[] s = new int[n - 1];
        int[] f = new int[n - 1];
        for (int i = 0; i < n - 1; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            c[i] = tmp[0];
            s[i] = tmp[1];
            f[i] = tmp[2];
        }

        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
        {
            if (i != n - 1)
            {
                for (int k = i; k < n - 1; k++)
                {
                    //s秒経過したかを確認
                    if (ans[i] < s[k])
                    {
                        if (ans[i] == 0)
                        {
                            ans[i] += c[k] + s[k];
                        }
                        else
                        {
                            ans[i] += c[k] + s[k] - ans[i];
                        }
                    }
                    else
                    {
                        ans[i] += c[k] + ((f[k] - (ans[i] % f[k])) + (s[k] % f[k])) % f[k];;
                    }
                }
            }
        }

        // 出力
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }
}

Measured memory_bytes: 13268
N=int(input())
T,A=map(float,input().split())
Areal=0.0
Areal=(T-A)//0.006
x=list(map(float,input().split()))
point=0
for i in range(N):
        if abs(x[point]-Areal) > abs(x[i]-Areal):
                point=i
print(point+1)

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


void solve(std::string T){
    replace(T.begin(), T.end(), '?', 'D');
    int ans = 0;
    // for (int i = 0; i < T.size(); i++) {
    //     if (T[i] == 'D') {
    //         ans++;
    //     }
    //     if (i + 1 < T.size() && T[i] == 'P' && T[i+1] == 'D') {
    //         ans++;
    //     }
    // }
    // cout << ans << endl;
    cout << T << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string T;
    std::cin >> T;
    solve(T);
    return 0;
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ull, ull> P; //ペア　タイプでふ
constexpr ll bigNum = 1000000007;

int main(void)
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    //ここから本体
    int l, r;
    cin >> l >> r;
    int a = 2019;
    int ans = 2019;
    if (l + 2019 <= r)
    {
        ans = 0;
    }
    l = l % 2019;
    r = r % 2019;
    if (r < l)
    {
        swap(r, l);
    }
    for (int i = l; i <= r - 1; i++)
    {
        for (int j = l + 1; j <= r; j++)
        {
            ans = min((i * j) % 2019, ans);
        }
    }
    cout << ans;
}


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

using namespace std;

int main() {
    int n, k; cin >> n >> k;
    int result = 1;
    for(int i = 0; i < n; ++i) {
        int a = result*2;
        int b = result+k;
        result = a > b ? b : a; 
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,a;
LL d;
struct data{
	LL h,x;
}w[200005];
LL ans;
queue<data>Q;
bool cmp(data a,data b){
	return a.x<b.x;
}
int main(){
	int h,n;
	scanf("%d%d",&h,&n);
	int s=0,P=1e9;
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		s+=a;
		P=min(P,a);
	}
	puts(s>=h?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,i,c=0;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>a;
        if(a>=k)
            c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3548
s=input()

def check(s):
    if not s[0] == 'A':
        return False
    if not s[2:-1].count('C') == 1:
        return False
    
    count=0
    
    for i in s[1:]:
        if not i.lower() == i:
            count+=1
            if count>1:
                return False
        
    return True
print("AC" if check(s) else "WA")

Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B = map(int, readline().split())
    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        print('Possible')
    else:
        print('Impossible')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

signed main()
{
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int val=0;
	for(int i=0;i<s.size();i++){
		val+=s[i]-'0';
	}
	if(val%9==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 3712
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	int a[110];
	cin >> n;
	REP(i, n) cin >> a[i];
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 256
arr = gets.chomp.split(" ").map(&:to_i)

count = 0

arr.sort!
count += (arr[2] - arr[0])/2
arr[0] += (arr[2] - arr[0])/2 * 2

count += (arr[2] - arr[1])/2
arr[1] += (arr[2] - arr[1])/2 * 2

arr.sort!

min_count = arr.count(arr.min)

if min_count == 1
  count += 2
elsif min_count == 2
  count += 1
end

puts count


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

int main() {
	int N;
	cin >> N;
	if (N % 2 == 0) {
		cout << 0.5 << endl;
	}else {
		float d = (float)((N+1)/2)/N;
		cout << d << endl;
	}
}

Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.09 18:14:44
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;


long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }
    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}
int main() {
    int t;cin >> t;
    while(t--) {
        int n,m,a,b;cin >> n >> m >> a >> b;
        cout << floor_sum(n,m,a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
    map<string,int> msi;
    int n,m;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        msi[s]++;
    }
    cin>>m;
    rep(i,m){
        string s;
        cin>>s;
        msi[s]--;
    }
    int max=0;
    for(auto u:msi){
        if(u.second>max) max=u.second;
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 384
def main(input = STDIN)
  while (cheese = input.gets.split(" ").map(&:to_i)) != [0, 0, 0]
    r = (cheese.sort[0] ** 2 + cheese.sort[1] ** 2) ** 0.5 / 2
    input.gets.to_i.times do
      if r < input.gets.to_i
        puts "OK"
      else
        puts "NA"
      end
    end
  end
end
main

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

int main () {
  string S;
  cin >> S;
  if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
    cout << "Bad";
  } else {
    cout << "Good";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  ++n;
  vector<int> t(n), x(n), y(n);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d", &t[i], &x[i], &y[i]);
  }
  bool found = false;
  for (int i = 1; i < n; ++i) {
    int T = t[i] - t[i - 1];
    int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (dis % 2 != T % 2 || dis > T) {
      found = true;
      break;
    }
  }
  puts(found ? "No" : "Yes");
  return 0;
}


Measured memory_bytes: 1408
#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 MOD 1000000007
#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())

signed main(){

	lli n;
	cin>>n;

	if(n%2==1){
		cout<<0<<endl;
		return 0;
	}

	vector<lli> v;
	vector<lli> data;
	lli now=2*5;

	while(now<1e18){
		if(DEBUG)cout<<now<<endl;
		v.push_back(now);
		now*=5;
	}

	lli sum=0;
	REP(i,0,v.size()){
		if(n/v[i]==0)break;
		sum += n/v[i];
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n,in;
	cin >> n;
	queue<int> pre;
	stack<int> tree;
	vector<int> pos;
	vector<bool> visited(n+1,false);
	rep(i, n) {
		cin >> in;
		pre.push(in);
	}
	rep(i, n) {
		cin >> in;
		if (!visited[in]) {
			while (1) {
				int t = pre.front(); pre.pop();
				visited[t] = true;
				tree.push(t);
				if (t == in)break;
			}
		}
		else {
			while (1) {
				int t = tree.top();
				if (t == in)break;
				pos.push_back(t);
				tree.pop();
			}
		}
	}
	while (!tree.empty()) {
		int t = tree.top(); tree.pop();
		pos.push_back(t);
	}
	cout << pos << endl;
}


Measured memory_bytes: 3292
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

int main() {

    string S;
    cin >> S;

    bool good = true;
    for (int i = 0; i < 3; i++) {
        if(S[i] == S[i + 1]){
            good = false;
        }
    }

    if(good) cout << "Good" << endl;
    else cout << "Bad" << endl;

}

































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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll x; cin >> x;
  ll result = 1-x;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int s[100],b,m,n;
  while(cin>>n>>m&&n+m){
    for(i=0;i<m;i++)
      cin>>s[i];
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	cin>>b;
	s[j]-=b;
      }
    }
    for(i=0;i<m;i++){
      if(s[i]<0)
	break;
    }
    if(i==m)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define NIL -1

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define rep_cs(i, l, n) for (int i = (l); i <= (n); i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool binary_search(int a[], int n, int key)
{
    int l = 0;
    int r = n;
    int middle;
    while (l < r)
    {
        middle = (l + r) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            l = middle + 1;
        }
        else if (key < a[middle])
        {
            r = middle;
        }
    }
    return false;
}

int main()
{
    float c;
    cin >> c;

    cout << c * 2 * 3.14 << endl;
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;


int main(){
	int N,A,B;
	cin >> N >> A >> B;

	if((B-A)%2 == 0){
		puts("Alice");
	}else{
		puts("Borys");
	}

	return 0;

}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> B(N-1), A(N);
    REP(i, N-1) cin >> B[i];

    int ans = 0;
    ans += B[0];
    ans += B[B.size()-1];
    for (int i = 0; i < N-2; i++) {
        ans += min(B[i], B[i+1]);
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n;
vi x, y;

double fx(double xx) {

	double yl = 0, yr = 1000;
	double re = 0;
	while (yr - yl > pow(10, -10)) {

		double c1 = (2 * yl + yr) / 3;
		double c2 = (2 * yr + yl) / 3;

		double r1 = 0, r2 = 0;
		rep(i, n)r1 = max(r1, sqrt(pow(x[i] - xx, 2) + pow(y[i] - c1, 2)));
		rep(i, n)r2 = max(r2, sqrt(pow(x[i] - xx, 2) + pow(y[i] - c2, 2)));
		re = (r1 + r2) / 2;
		if (r1 < r2)yr = c2;
		else yl = c1;
	}

	return re;

}

int main() {

	cin >> n;
	x.resize(n);
	y.resize(n);
	rep(i, n)cin >> x[i] >> y[i];

	double xl = 0, xr = 1000;
	while (xr - xl > pow(10, -10)) {

		double xc1 = (2 * xl + xr) / 3;
		double xc2 = (2 * xr + xl) / 3;

		if (fx(xc1) < fx(xc2))xr = xc2;
		else xl = xc1;
	}

	cout << fixed << setprecision(8);
	cout << fx(xl) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N; cin >> N;
  vector<ll> A(N), B(N), C(N), BA(N), BC(N);
  rep(i, 0, N) {
  	cin >> A[i];
  }
  rep(i, 0, N) {
  	cin >> B[i];
  }
  rep(i, 0, N) {
  	cin >> C[i];
  }
  vsort(A); vsort(B); vsort(C);
  ll j = 0; BA[0] = 0;
  rep(i, 0, N) {
  	while (j < N && B[i] > A[j]) {
    	BA[i]++; j++;
    } if (i < N - 1) {
    	BA[i + 1] = BA[i];
    }
  }
  j = N - 1; BC[N - 1] = 0;
  for (ll i = N - 1; i >= 0; i--) {
  	while(j >= 0 && B[i] < C[j]) {
    	BC[i]++; j--;
    } if (i > 0) {
    	BC[i - 1] = BC[i];
    }
  }
  ll sum = 0;
  rep(i, 0, N) {
  	sum += BA[i] * BC[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

double maximum_spanning_tree(int n, vector< vector< pair<double,int> > > &G){
  priority_queue< pair<double, int> > wait;
  vector<bool> connected(n);
  double ret = 0;
  for(int i = 0; i < n; ++i){
    wait.emplace(0,i);
    while(!wait.empty()){
      double cost = wait.top().first;
      int v = wait.top().second;
      wait.pop();
      if(connected[v]) continue;
      connected[v] = true;
      ret += cost;
      for(int i = 0; i < G[v].size(); ++i){
        int t = G[v][i].second;
        if(!connected[t]){
          wait.push(G[v][i]);
        }
      }
    }
  }
  return ret;
}

double dist(double x1, double y1, double x2, double y2){
  return hypot((x1-x2),(y1-y2));
}

int main(){
  int N, M;
  cin >> N >> M;
  double X[N], Y[N];
  for(int i = 0; i < N; ++i){
    cin >> X[i] >> Y[i];
  }

  vector< vector< pair<double,int> > > G(N);
  int p, q;
  double s = 0;
  for(int i = 0; i < M; ++i){
    cin >> p >> q;
    --p;
    --q;
    double d = dist(X[p],Y[p],X[q],Y[q]);
    s += d;
    G[p].emplace_back(d,q);
    G[q].emplace_back(d,p);
  }
  printf("%.12f\n",s - maximum_spanning_tree(N,G));
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";

int main(){
 char s;
 cin >> s;
 int sum = 0;
 for(int i = 0; i < 26; i++){
     sum++;
     if(s == alphabet[i])break;
 }
 if(sum <= 25)cout << alphabet[sum] << endl;
 else cout << 'a' << endl;
}


Measured memory_bytes: 256