akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str = scn.next();
		int []arr=new int[str.length()];
		for(int i=0,j=str.length()-1;i<str.length()&&j>=0;i++,j--) {
			if( str.charAt(i)=='R') {
				if(i>0&&str.charAt(i-1)=='R') {
					arr[i]=arr[i-1]+1;
					arr[i-1]=0;
				}else {
					arr[i]=1;
				}
			}
			if(str.charAt(j)=='L') {
				if(j<str.length()-1&&str.charAt(j+1)=='L') {
					arr[j]=arr[j+1]+1;
					arr[j+1]=0;
				}else {
					arr[j]=1;
				}
			}
		}
//		for(int i=0;i<str.length();i++) {
//			System.out.print(arr[i]+" ");
//		}
//		System.out.println();
		int flag=0;
		for(int i=0;i<str.length();i++) {
			flag=0;
			if(i+1<str.length()&&str.charAt(i)=='R'&&str.charAt(i+1)=='L') {
				int x=Integer.max(arr[i], arr[i+1])-Integer.min(arr[i], arr[i+1]);
				if((Integer.max(arr[i], arr[i+1])-1)%2!=0) {
					flag=1;
					
				}
				if(arr[i]<arr[i+1]) {
					arr[i]+=x/2;
					arr[i+1]-=x/2;
				}else {
					arr[i+1]+=x/2;
					arr[i]-=x/2;
				}
				if(flag==1) {
					int temp=arr[i];
					arr[i]=arr[i+1];
					arr[i+1]=temp;
				}
				
			}
		}
		for(int i=0;i<str.length();i++) {
			System.out.print(arr[i]+" ");
		}
	}

}


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

namespace diverta2019ProgrammingContest
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            long numai = 0;
            long beginb = 0;
            long enda = 0;
            long both = 0;
            for (int i = 0; i < N; ++i)
            {
                var si = Console.ReadLine();
                var ai = CountOf(si);
                numai += ai;
                var begin = si[0];
                var end = si[si.Length - 1];
                if ('B' == begin & 'A' == end)
                { ++both; }
                else if ('B' == begin)
                { ++beginb; }
                else if ('A' == end)
                { ++enda; }
            }
            var hosei = 0;
            if (0 != both)
            {
                --both;
                if (0 != enda) { --enda; ++hosei; }
                if (0 != beginb) { --beginb; ++hosei; }
            }
            var cnt = numai + hosei + both + Math.Min(beginb, enda);
            Console.WriteLine($"{cnt}");
        }

        public static int CountOf(string target)
        {
            int count = 0;
            string str = "AB";
            int index = target.IndexOf(str, 0);
            while (index != -1)
            {
                count++;
                index = target.IndexOf(str, index + str.Length);
            }
            return count;
        }
    }
}


Measured memory_bytes: 13408
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vP fstl;
  vP sndl;
  rep(i, n) {
    string s;
    cin >> s;
    ll lc = 0, rc = 0;
    for (char c : s) {
      if (c == '(')
        lc++;
      else {
        if (lc == 0)
          rc++;
        else
          lc--;
      }
    }
    if (lc >= rc)
      fstl.emplace_back(rc, lc);
    else
      sndl.emplace_back(lc, rc);
  }
  Sort(fstl);
  Sort(sndl);
  Reverse(sndl);
  ll tmp = 0;
  rep(i, n) {
    ll rc, lc;
    if (i < (ll)fstl.size()) {
      rc = fstl[i].first;
      lc = fstl[i].second;
    } else {
      ll ii = i - fstl.size();
      rc = sndl[ii].second;
      lc = sndl[ii].first;
    }
    tmp -= rc;
    if (tmp < 0) {
      puts("No");
      return 0;
    }
    tmp += lc;
  }
  string ans = tmp == 0 ? "Yes" : "No";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18976
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int in[55];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);

	vector <pii> Va;
	int mx = 1;
	for (i = 2; i <= N; i++) if (abs(in[i]) > abs(in[mx])) mx = i;

	for (i = 1; i <= N; i++) if (i != mx) Va.emplace_back(mx, i);

	if (in[mx] >= 0) {
		for (i = 1; i < N; i++) Va.emplace_back(i, i + 1);
	}
	else {
		for (i = N; i >= 2; i--) Va.emplace_back(i, i - 1);
	}

	printf("%d\n", (int)Va.size());
	for (auto it : Va) printf("%d %d\n", it.first, it.second);
	return 0;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    string s[10010];
    std::cin >> n;
    ll result = 0;
    ll right_a = 0;
    ll left_b = 0;
    ll a_b_both = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
        for (int j = 0; j < s[i].length()-1; j++) {
            if(s[i][j] == 'A' && s[i][j+1] == 'B'){
                result++;
            }
        }
        if(s[i][0] == 'B' && s[i][s[i].length()-1] == 'A'){
            a_b_both++;
        }else if(s[i][0] == 'B'){
            left_b++;
        }else if(s[i][s[i].length()-1] ==  'A'){
            right_a++;
        }
    }
    
    if(a_b_both>0){
        result += a_b_both-1;
        if(right_a>0){
            result++;
            right_a--;
        }
        if(left_b>0){
            result++;
            left_b--;
        }
        result += min(right_a,left_b);
    }else{
        result += min(right_a,left_b);
    }
    
    std::cout << result << std::endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f(string s){
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ans = f(s);
  ans &= f(s.substr(0, n / 2));
  ans &= f(s.substr((n+1) / 2));
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!
    val alist = readLine()!!.split(" ").map { it.toInt() }

    val count = alist.filter { it % 2 == 0 }.filter { !(it % 3 == 0 || it % 5 == 0) }.count()

    if (count > 0) {
        print("DENIED")
    } else {
        print("APPROVED")
    }
}

Measured memory_bytes: 38028
#include<cstdio>
using namespace std;
const int TT=1e9+7;
int n,cnt[26];char s[100005];
long long ans=1;
int main(){
	scanf("%d%s",&n,s);
	for (int i=0;s[i];i++) cnt[s[i]-'a']++;
	for (int i=0;i<26;i++) ans=ans*(cnt[i]+1)%TT;
	printf("%lld\n",ans?--ans:TT-1);
	return 0;
}

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

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg bool check = false;
    string s; cin >> s;
    for (reg int i = 0; i < (int)s.size(); i++) {
        if ((i + 1) % 2) {
            if (s[i] == 'L') { check = true; break; }
        }
        else {
            if (s[i] == 'R') { check = true; break; }
        }
    }
    if (check) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 3e6 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, a[25][25], dp[25][N];
vector<int>bt[25];

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

//	srand(time(NULL));

	scanf("%d", &n);

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < n; j++)
			scanf("%d", &a[i][j]);
   
	for(int i = 0; i < (1<<n); i++) {
		int bi = bit(i);
		bt[bi].pb(i);
	}

	dp[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < n; j++) {
			if(!a[i][j]) continue;
			int bi = i - 1;
			for(auto x : bt[bi]) {
				if(x & (1<<j)) continue;
				dp[i][x|(1<<j)] = (dp[i][x|(1<<j)] + dp[i - 1][x]) % mod;
			}
		}

	cout << dp[n][(1<<n)-1];

    return 0;                                        
}

Measured memory_bytes: 202812
use std::io::{self, BufRead};
use std::mem::swap;
use std::collections::BTreeSet;

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let (n, m) = (xs[0], xs[1]);
  let mut es: Vec<Vec<usize>> = vec![vec![]; n];
  for _ in 0..m {
    let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
    let (u, v) = (xs[0] - 1, xs[1] - 1);
    es[u].push(v);
  }
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let (s, t) = (xs[0] - 1, xs[1] - 1);
  let mut dss: Vec<Vec<usize>> = vec![vec![usize::max_value(); 3]; n];
  dss[s][0] = 0;
  let mut nexts: BTreeSet<usize> = BTreeSet::new();
  nexts.insert(s);
  let mut step: usize = 1;
  while !nexts.is_empty() {
    let mut temp: BTreeSet<usize> =BTreeSet::new();
    let round = (step - 1) / 3 + 1;
    let phase = step % 3;
    for &u in &nexts {
      for &v in &es[u] {
        if round < dss[v][phase] {
          dss[v][phase] = round;
          temp.insert(v);
        }
      }
    }
    swap(&mut nexts, &mut temp);
    step += 1;
  }
  println!("{}", if dss[t][0] < usize::max_value() { dss[t][0] as i32 } else { -1 });
}

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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
  int k; cin>>k;
  int odd,even,ans;
  Rep(i,1,k+1){
    if(i%2==0) even++;
  }
  odd = k-even;
  ans = odd*even;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	ll a,b,v,w,t;
	cin>>a>>v;
	cin>>b>>w;
	cin>>t;
	if(b<a)
	{
		ll distA = a - t*v;
		ll distB = b - t*w;
		if(distA<=distB)
		{
			cout<<"YES\n";
		}
		else
		{
			cout<<"NO\n";
		}
	}
	else
	{
		ll distA = a + t*v;
		ll distB = b + t*w;
		if(distA>=distB)
		{
			cout<<"YES\n";
		}
		else
		{
			cout<<"NO\n";
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    cout << (N > K ? 0 : 1) << endl;
}


Measured memory_bytes: 3168
import math

N, K = map(int, input().split())

prob = 0
for n in range(1, N+1):
    i = int(math.log2(K/n))
    if n > K:
        i = 0
    elif not n * 2**i == K:
        i += 1
    prob += 1 / N / (2**i)

print(prob)

Measured memory_bytes: 3060
#include<iostream>
#include<numeric>
#include<cmath>
#include<vector>

using namespace std;
/*
int main() {
	int A, N,answer;
	cout << "N,Aを入力。" << endl;
	cin >> N >> A;
	answer = N % 500;
	if (A>=1)
	{
		answer %= 1;
		if (answer==0)
		{
			cout << "Yes" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}
*/
int main() {
	int N ,n,tmp=0;
	vector<int> A;
	
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> n;
		A.push_back(n);
	}

	for ( int  t= 0; t <N; t++)
	{
		for (int r = 0; r < N; r++)
		{
			if (tmp < abs(A[t] - A[r]))
			{
				tmp = abs(A[t] - A[r]);
			}
		}
	}

	cout << tmp;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    N = int(input())
    adjL = [[] for _ in range(N)]
    edges = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        adjL[a].append(b)
        adjL[b].append(a)
        edges.append((a, b))
    M = int(input())
    uvs = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

    e2Roots = [set() for _ in range(N)]
    def dfs(vNow, vPar):
        for v2 in adjL[vNow]:
            if v2 == vPar: continue
            e2Roots[v2] |= e2Roots[vNow]
            e2Roots[v2].add((vNow, v2))
            dfs(v2, vNow)

    dfs(0, -1)

    ePaths = [set() for _ in range(M)]
    for i, (u, v) in enumerate(uvs):
        ePaths[i] = e2Roots[u] ^ e2Roots[v]

    numEs = [0] * (1<<M)
    for a, b in edges:
        ptn = 0
        for iC, ePath in enumerate(ePaths):
            if (a, b) in ePath or (b, a) in ePath:
                ptn |= 1<<iC
        for S in range(1<<M):
            if S & ptn:
                numEs[S] += 1

    def getPows(base, n):
        pows = [1] * (n+1)
        for x in range(1, n+1):
            pows[x] = (pows[x-1] * base)
        return pows
    pows = getPows(2, N)

    def getNum1s(N):
        num1s = [0]
        for _ in range(N):
            num12s = [num1+1 for num1 in num1s]
            num1s += num12s
        return num1s
    num1s = getNum1s(M)

    ans = pows[N-1]
    for S in range(1, 1<<M):
        num = pows[N-1-numEs[S]]
        if num1s[S] % 2:
            ans -= num
        else:
            ans += num

    print(ans)


solve()


Measured memory_bytes: 151120
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int k;
	cin >> k;
	int a,b;
	cin >> a >> b;
	int maxi = a/k;
	if((maxi+1)*k<=b||a%k==0){
		cout << "OK" << endl;
	}
	else
		cout << "NG" << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>

int r[100005];
using namespace std;
int main() {
	
	string p;
	cin >> p;
	string ans;
	for (int i = 0; i < min(4, (int)p.size()); i++) {
		ans += p[i];
	}
	if (ans == "YAKI")cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
int N;
cin >> N;
if(N/100==7){
  cout << "Yes" <<endl;
}
else if(N%100/10==7){
  cout << "Yes" <<endl;
}
else if(N%100%10==7){
  cout << "Yes" <<endl;
}
else{
  cout << "No" <<endl;
}
}

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

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

    int a = s.size();
    if (a <= k) {
        cout << s << endl;
    }
    else {
        for (int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;

#define int long long

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s).begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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


signed main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int t=0;
    queue<pair<int, string> > s;
    int n,q;
    cin>>n>>q;
    rep(i,n) {
        string ss;
        int k;cin>>ss;cin>>k;
        s.push(mp(k,ss));
    }
    while(!s.empty()) {
        auto p = s.front();s.pop();
        if (p.FST > q) {
            s.push(mp(p.FST-q, p.SEC));
            t+=q;
        } else {
            t += p.FST;
            cout << p.SEC << " " << t << endl;
        }
    }

	return 0;
}


Measured memory_bytes: 6308
#include <iostream>
#include <fstream>
#include <utility>
#include <queue>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define bs(n) (1ull<<(n))

int main() {
	ll n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	ll r = 0;
	n /= 2;
	while (n) {
		r += n / 5;
		n /= 5;
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <utility> // std::swap

using namespace std;
using ll = long long;
using pii=pair<int,int>;
//  << std::setprecision(15)

template<typename T> // 0th<1st<2nd<3rd<4th pop
using pq_asc=priority_queue<T, vector<T>, greater<T>>;
template<typename T> // 0>1>2>3>4
using pq_dsc=priority_queue<T>;

int main(int argc, char const* argv[])
{
  int r ;
  cin >> r;
  cout << r* r << endl;



  return 0;
}


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

#define ll long long int
#define MOD 1000000007
#define sc(a) scanf("%lld",&a)
#define f0(n) for(ll i=0;i<n;i++)
#define f1(n) for(ll i=1;i<=n;i++)
#define pb(v,a) v.push_back(a)
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end());


int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	for(ll i=1;i<=i;i++)
	{
		if(i%2==1)
		{
			c=c-b;
			if(c<=0)
			{
				cout<<"Yes"<<endl;
				break;
			}
		}
		else
		{
			a=a-d;
			if(a<=0)
			{
				cout<<"No"<<endl;
				break;
			}
		}

	}
}


Measured memory_bytes: 3632
import collections

def main():
    n = int(input())
    str_list = [input() for _ in range(n)]

    if len(str_list) == len(set(str_list)):
        str_list.sort()
        print(*str_list,sep='\n')
        exit()

    count_list = collections.Counter(str_list)

    max_num = max(count_list.values())

    output_list = []

    for k, v in count_list.items():
        if max_num == v:
            output_list.append(k)

    output_list.sort()

    print(*output_list,sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 95832
#include <stdio.h>

int main(void){
  int x[3000], y[3000], i, n, tmp;

  n = 0;
  while (1) {
    scanf("%d%d", &x[n], &y[n]);
    if (x[n] == 0 && y[n] == 0) {
      break;
    }
    n++;
  }

  for (i = 0; i < n; i++) {
    if (x[i] > y[i]) {
      tmp = x[i];
      x[i] = y[i];
      y[i] = tmp;
    }
    printf("%d %d\n", x[i], y[i]);
  }

  return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,h;
    cin>>h>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
    {
        h-=a[i];
        if(h<=0)
        {
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);

	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}

	long double sum = 0;

	for (int i = 0; i < k; ++i) {
		sum += (p[i] + 1);
	}

	long double ans = sum;

	for (int i = k; i < n; ++i) {
		sum -= p[i - k] + 1;
		sum += p[i] + 1;

		ans = max(ans, sum);
	}

	printf("%Lf\n", ans/2);

	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int ans_a = 0, ans_b = 0, ans_c = 0;
    for (int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        int new_ans_a = max(ans_b, ans_c) + a;
        int new_ans_b = max(ans_c, ans_a) + b;
        int new_ans_c = max(ans_a, ans_b) + c;
        swap(ans_a, new_ans_a);
        swap(ans_b, new_ans_b);
        swap(ans_c, new_ans_c);
    }
    cout << max({ans_a, ans_b, ans_c}) << '\n';
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <numeric>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#include <iterator>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
    long long int n,l,ans=0, sum=0, min_num=200;
    int j;
    cin >> n >> l;
    vector<int> v(n);
    rep(i,n) {
        v[i] = l + (i+1) -1;
    }
    sum = accumulate(v.begin(), v.end(), 0);
    //sort(v.begin(), v.end());
    rep(i,n) {
        if(abs(v[i]) < min_num) {
            min_num = abs(v[i]);
            j = i;
        }
    }
    v.erase(v.begin() + j); 
    rep(i,n-1) {
        ans += v[i];
    } 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    k=int(input())
    a,b=map(int,input().split())
    if b//k-(a-1)//k!=0:
        print('OK')
    else:
        print('NG')

resolve()

Measured memory_bytes: 61656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>

using namespace std;

int main() {

	int i;
	double no[6] = { 0 }, a, b;

	while (cin >> no[0]) {
	
	for (i = 1; i < 6; i++) {
			cin >> no[i];
		}
		
		a = ((no[2] * no[4]) - (no[1] * no[5])) / ((no[0] * no[4]) - (no[1] * no[3]));
		b = ((no[3] * no[2]) - (no[0] * no[5])) / ((no[1] * no[3]) - (no[0] * no[4]));
		if (a == 0)
			a = 0;
		if (b == 0)
			b = 0;
		
		printf("%.3f %.3f\n", a, b);
	} 

	return 0;
}

Measured memory_bytes: 1236
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    Array.Sort(nums);//ソート
    long[] sums = new long[n];//iまでの和
    long answer = 1;

    sums[0] = nums[0];
    for(long i = 1; i < n; i++)
    {
      sums[i] = sums[i-1] + nums[i];
    }

    for(long i = n-2; i >= 0; i--)
    {
      if(sums[i]*2 >= nums[i+1]) answer++;
      else break;
    }
    
		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 28508
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

class UnionFind {
private:
	Vec< int > data;
	int num_of_g;
	
public:
	UnionFind(int n) : data(n, -1), num_of_g(n) {}
	
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		
		if (x == y) return 0;
		
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y]; data[y] = x;
		--num_of_g;
		
		return 1;
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
	int getNumOfG() { return num_of_g; }
};

const int MAX_X = 100005;

int main() {
	int N;
	cin >> N;
	
	Vec< int > x(N), y(N);
	Vec< Vec< int > > px(MAX_X, Vec< int >());
	Vec< Vec< int > > py(MAX_X, Vec< int >());
	
	for_(i,0,N) {
		cin >> x[i] >> y[i];
		px[x[i]].push_back(i);
		py[y[i]].push_back(i);
	}
	
	UnionFind uf(N);
	for (int i=0; i<MAX_X; ++i) {
		int m = px[i].size();
		for (int j=0; j<m-1; ++j) uf.unionSet(px[i][j], px[i][j+1]);
		m = py[i].size();
		for (int j=0; j<m-1; ++j) uf.unionSet(py[i][j], py[i][j+1]);
	}
	
	Vec< Vec< int > > group(N, Vec< int >());
	for (int i=0; i<N; ++i) group[uf.root(i)].push_back(i);
	
	lint ans = 0;
	for (int g=0; g<N; ++g) {
		if (group[g].empty()) continue;
		bool flag = false;
		for (int i : group[g]) flag |= (px[x[i]].size() > 1 && py[y[i]].size() > 1);
		if (flag) {
			set< int > x_set, y_set;
			for (int i : group[g]) {
				x_set.insert(x[i]);
				y_set.insert(y[i]);
			}
			ans += (x_set.size() * y_set.size()) - group[g].size();
		}
	}
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 16632
#include <iostream>
#include <string>
#include <cctype>
#define MAXSIZE 101
#define PI 3.141592653589
using namespace std;
int main(){
  string x;
  int N=0;
  while (std::cin >> x) {
    if(x=="0")break;
    for(int i=0;i<x.size();i++){
      N+=x[i]-'0';
    }
    std::cout << N << '\n';
    N=0;
  }
}

Measured memory_bytes: 3140
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a = l()

b = l()


if a[0] + 1  == b[0] and  b[1] == 1:
    print(1)
else:
    print(0)



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

// int prime[1000001];
// vector<ll> primes;

// void soe() {
//     int i,j;
//     for(i=2;i<1000001;i++) prime[i] = 1;
//     for(i=2;i<=sqrt(1000001);i++) {
//         if(prime[i] == 1) {
//             for(j=i*i;j<1000001;j+=i) {
//                 prime[j] = 0;
//             }
//         }
//     }
//     for(i=2;i<1000001;i++) {
//         if(prime[i]) primes.pb(i);
//     }
// }


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

    int a,b,c,f5 = 0,f7 = 0;
    cin >> a >> b >> c;
    if(a == 5) f5++;
    else if(a == 7) f7++;
    if(b == 5) f5++;
    else if(b == 7) f7++;
    if(c == 5) f5++;
    else if(c == 7) f7++;
    if((f5 == 2) && (f7 == 1)) cout << "YES";
    else cout << "NO";
    cout << "\n";
    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
AC
*/

int main(void){
	ll n,a[100010],ans=0,c=1;
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(i==0){
			ans+=a[0]-1;
			c=2;
		}else{
			if(a[i]==c){//ちょうどなら値段cを上げざるを得ない
				c++;
				continue;
			}else if(a[i]<c){
				continue;
			}else{
				if(a[i]%c==0){
					a[i]-=c+1;
					ans++;
				}
				ans+=a[i]/c;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int T = cin.nextint;
        for (int i = 0; i < T; i++)
        {
            var A = cin.nextlong;
            var B = cin.nextlong;
            var C = cin.nextlong;
            var D = cin.nextlong;
            WriteLine(calc(A, B, C, D));
        }
    }

    string calc(long A, long B, long C, long D)
    {
        if (A < B || D < B) return "No";
        if (C >= B - 1) return "Yes";

        //朝に1からB-1だとだめ
        //夜に何だとだめか
        //夜にC+1からB-1だとだめ

        var N = A % B;
        var M = D % B;


        var L = C + 1 - N;
        while (L < 0) L += B;
        var R = B - 1 - N;
        while (R < L) R += B;
        if (M == 0)
        {
            if (C + 1 <= N && N <= B - 1)
            {
                return "No";
            }
            else
            {
                return "Yes";
            }
        }
        if (R - L + 1 >= M) return "No";


        var K = M;
        long r = N;
        var H = new HashSet<long>();
        H.Add(r);
        while (true)
        {
            var X = (C + 1 - r + M - 1) / M;
            var Z = M * X + r;
            if (C + 1 <= Z && Z <= B - 1) return "No";
            var Y = (B - r + M - 1) / M;
            var W = M * Y + r;
            r = W % B;
            if (H.Contains(r)) return "Yes";
            H.Add(r);
        }


    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11348
#include <iostream>
#include <cmath>

int main(void){
    long long D, N, ans=0;
    std::cin >> D >> N;

    ans = std::pow(100, D) * N;

    if (N == 100) ans += std::pow(100, D);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3792
#include<cmath>
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;



int main() {
	int n, m, l;
	long long c[100][100] = {};
	int a[100][100];
	int b[100][100];
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
			cout << c[i][j];
			if (0 <= j&&j < l - 1)cout << ' ';
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1320
#include<iostream>
#define ll long long int
using namespace std;
ll n, cap;
ll berat[110], val[110];
ll m[110][110000];

ll dp(ll taken, ll sisaCap){
//	cout<<taken<<" "<<sisaCap<<"\n";
	if(sisaCap == 0) return 0;
	if(taken == n+1){
		return 0;
	}
	if(m[taken][sisaCap]!=-1) return m[taken][sisaCap];
	
	// punya pilihan pake atau ga
	ll ans = 0;
	ans = dp(taken+1, sisaCap);
	if(berat[taken-1] <= sisaCap){
		ans = max(ans , (dp(taken+1,sisaCap - berat[taken-1]) + val[taken-1]));
	}
	return m[taken][sisaCap] = ans;
}

int main(){
	cin>>n>>cap;
	for(ll i = 0;i<n;i++){
		cin>>berat[i]>>val[i];
	}
	for(int i = 0;i<=n;i++){
		for(int j = 0;j<=cap;j++){
			m[i][j] = -1;
		}
	}
	cout<<dp(0,cap)<<"\n";
	return 0;
}

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

int main() {
  char s;
  deque<char> dq;
  while (cin >> s) {
    //cout << s << endl;
    if (s == '0') {
      dq.push_back('0');
      continue;
    }
    if (s == '1') {
      dq.push_back('1');
      continue;
    }
    if (s == 'B' && (!dq.empty())) {
      dq.pop_back();
      continue;
    }
  }
  while(!dq.empty()) {
    cout << dq.front();
    dq.pop_front();
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3600
#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 ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
    dcl(n);
    vi a(n);
    geti(a);
    sort(all(a));

    bool ok;
    if(n%2){
        ok=a[0]==0;
        for(int i=1;i<n;i+=2){
            ok&=(a[i]==a[i+1]&&a[i]==i+1);
        }
    }else{
        ok=a[0]==1;
        for(int i=0;i<n;i+=2){
//            cout<<a[i]<<","<<a[i+1]<<","<<i+1<<endl;
            ok&=(a[i]==a[i+1]&&a[i]==i+1);
        }
    }
    if(ok){
        ll ans=1;
        rep(i,(a.back()+1)/2){
            ans=ans*2%MOD;
        }
        cout<<ans<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      int N = int.Parse(Console.ReadLine());
      List<int> xs = new List<int>();
      List<int> ys = new List<int>();
      //int minX = 0, maxX = 0, minY = 0, maxY = 0;
      for(int i = 0; i < N; i++)
      {
        string[] ss = Console.ReadLine().Split(' ');
        int x = int.Parse(ss[0]);
        int y = int.Parse(ss[1]);
        //minX = Math.Min(minX, x);
        //maxX = Math.Max(maxX, x);
        //minY = Math.Min(minY, y);
        //maxY = Math.Max(maxY, y);
        xs.Add(x);
        ys.Add(y);
      }
      //int xo = minX + maxX / 2;
      //int yo = minY + maxY / 2;
      int[] maxs = new int[4];
      int[] maxIndexes = new int[4];
      int baseX = 1, baseY = 1;
      //List<int> ts = new List<int>();
      maxIndexes[0] = GetMaxTIndex(N, xs, ys, baseX, baseY);
      baseX = 1000000000;
      baseY = 1;
      maxIndexes[1] = GetMaxTIndex(N, xs, ys, baseX, baseY);
      baseX = 1;
      baseY = 1000000000;
      maxIndexes[2] = GetMaxTIndex(N, xs, ys, baseX, baseY);
      baseX = 1000000000;
      baseY = 1000000000;
      maxIndexes[3] = GetMaxTIndex(N, xs, ys, baseX, baseY);

      for(int i = 0; i < 4; i++)
      {
        baseX = xs[maxIndexes[i]];
        baseY = ys[maxIndexes[i]];
        maxs[i] = GetMaxT(N, xs, ys, baseX, baseY);
      }

      int max = 0;
      foreach(int m in maxs)
      {
        max = Math.Max(max, m);
      }

      Console.WriteLine(max);
      Console.ReadLine();
    }

    private static int GetMaxTIndex(int N, List<int> xs, List<int> ys, int baseX, int baseY)
    {
      int result = 0;
      int max = 0;
      for(int i = 0; i < N; i++)
      {
        int t = Math.Abs(xs[i] - baseX) + Math.Abs(ys[i] - baseY);
        if(max < t)
        {
          max = t;
          result = i;
        }
      }

      return result;
    }
    private static int GetMaxT(int N, List<int> xs, List<int> ys, int baseX, int baseY)
    {
      int max = 0;
      for(int i = 0; i < N; i++)
      {
        max =Math.Max(max, Math.Abs(xs[i] - baseX) + Math.Abs(ys[i] - baseY));
      }

      return max;
    }
  }
}

Measured memory_bytes: 44344
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;

void solve()
{
  int n;
  cin>>n;
  ll happy=0;
  happy=(n/500);
  n=n-500*happy;
  happy*=1000;
  happy+=((n/5)*5);
  cout<<happy;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A,B,C,D;

    scanf("%d %d %d %d",&A,&B,&C,&D);

    if((A+B)>(C+D)){
        printf("Left\n");
    }else if((A+B)<(C+D)){
        printf("Right\n");
    }else{
        printf("Balanced\n");
    }

    return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 10**20

# どのビルを見るかをbit全探索
for i in range(1 << n):
    li = []
    for j in range(n):
        if (i >> j)&1:
            li.append(j)
    if len(li) < k:
        continue
    point = 0
    now = a[0]
    for l in range(1,n):
        if l in li and a[l] <= now:
            point += now+1-a[l]
            now += 1
        now = max(now,a[l])
    ans = min(ans,point)
    
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3010;
const ll INF=1e18;
int a[N];
ll dp[N][N];
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch&15),ch=getchar();
	return x*f;
}
int main()
{
	int n=read();
	for (register int i=1;i<=n;++i) a[i]=read();
	for (register int i=1;i<=n;++i) dp[i][i]=a[i];
	for (register int i=n;i>=1;--i)
	  for (register int j=i+1;j<=n;++j)
	    dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 70016
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
)

func main() {
        sc := bufio.NewScanner(os.Stdin)
        sc.Split(bufio.ScanWords)

        var evenNum, max int
        vals := make([]int, 3)
        for i := range vals {
                sc.Scan()
                a, _ := strconv.Atoi(sc.Text())
                vals[i] = a
                if a%2 == 0 {
                        evenNum++
                }
                if max < a {
                        max = a
                }
        }
        const (
                even = 0 + iota
                odd
        )
        var lifted, ops int
        if evenNum%2 == 0 {
                lifted = even
                ops += evenNum / 2
        } else {
                lifted = odd
                ops += (len(vals) - evenNum) / 2
        }
        for _, v := range vals {
                ops += (max - v) / 2
                if (max+v)%2 == 1 {
                        if max%2 == lifted {
                                ops++
                        }
                }
        }
        fmt.Printf("%d\n", ops)
}

Measured memory_bytes: 640
S = input()
ans = 'AC'

if S[0] != 'A':
    ans = 'WA'

cnt = 0

for i in range(1, len(S)):
    s = S[i]
    if s.isupper():
        if i == 1 or i == len(S) - 1 or s != 'C':
            ans = 'WA'
        cnt += 1

if cnt != 1:
    ans = 'WA'

print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

bool isCompare(tuple<int, string, int> a, tuple<int, string, int> b)
{
  string sa = get<string>(a), sb = get<string>(b);
  int pa = get<2>(a), pb = get<2>(b);

  bool isFlg = false;
  if (sa < sb) {
    isFlg = true;
  } else if (sa > sb) {
    isFlg = false;
  } else if (pa > pb) {
    isFlg = true;
  }
  return isFlg;
}

int main(int argc, char* argv[])
{
  int N; cin >> N;

  vector<tuple<int, string, int>> v;
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    v.push_back(make_tuple(i, s, p));
  }

  sort(v.begin(), v.end(), isCompare);

  vector<pair<int, int>> order;
  for (int i = 0; i < N; i++) {
    cout << get<0>(v[i]) + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256