akhauriyash/Code-Regression huggingface dataset:
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXM = 200005;
const int MAXN = 1005;
int used[MAXN], condition[MAXM], vis[MAXN][MAXN], a[MAXM], b[MAXM] ;
vi adj[MAXN];
int N,M;
int r[MAXN],cond[MAXM];

void dfs(int s, int base){
	if(vis[base][s])return;
	vis[base][s]=1;
	for(auto t:adj[s]){
		dfs(t, base);
	}
}

void bfs(int s){
	memset(used,0,sizeof(used));
	memset(r,-1,sizeof(r));
	for(auto t:adj[s]){
		if(r[t]!=-1){
			used[t]=1;
			continue;
		}
		queue<int> q;
		q.push(t);
		r[t] = t;
		while(!q.empty()){
			int v = q.front();q.pop();
			for(auto u:adj[v]){
				if(u==s)continue;
				if(r[u]!=-1){
					if(r[u]!=t)used[u]=1;
					continue;
				}
				r[u]=t;
				q.push(u);
			}
		}
	}
	queue<int> q;
	for(int i=1;i<=N;i++)if(used[i])q.push(i);
	while(!q.empty()){
		int v = q.front();q.pop();
		for(auto t:adj[v]){
			if(t==s)continue;
			if(used[t])continue;
			used[t]=1;
			q.push(t);
		}
	}
	for(int i=1;i<=M;i++){
		if(a[i]==s){
			condition[i] = used[b[i]];
		}
		if(b[i]==s){
			cond[i] = (r[a[i]]!=-1);
		}
	}

}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	cin >> N >> M;
  for(int i=1;i<=M;i++){
  	cin >> a[i] >> b[i];
  	adj[a[i]].pb(b[i]);
  }  
  // for(int i=1;i<=N;i++){
  // 	dfs(i, i);
  // }
  for(int i=1;i<=N;i++){
  	bfs(i);
  }
  for(int i=1;i<=M;i++){
  	if(condition[i]==cond[i]){
  		cout << "same" << endl;
  	}
  	else cout << "diff" << endl;
  }

return 0;
}
///....


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int A, B;
    cin >> A >> B;
    string s;
    cin >> s;

    bool ispostal = true;
    if (s[A] == '-')
    {
        rep(i, A)
        {
            if (!isdigit(s[i]))
            {
                ispostal = false;
                break;
            }
        }
        repm(i, A + 1, s.size())
        {
            if (!isdigit(s[i]))
            {
                ispostal = false;
                break;
            }
        }
    }
    else
        ispostal = false;

    if (ispostal)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	long INF = (long) (1e19);

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long k = sc.nextLong();
		INF = k + 1;
		long[] f = new long[m + 1];
		f[0] = 1;
		char[][] s = new char[n][];
		for (int i = 0; i < n; ++i) {
			s[i] = sc.next().toCharArray();
		}
		for (int j = 0; j < m; ++j) {
			for (int i = 0; i < n; ++i) {
				if (j + s[i].length > m)
					continue;
				f[j + s[i].length] = add(f[j + s[i].length], f[j]);
			}
		}
		if (f[m] < k) {
			System.out.println("-");
			return;
		}
		StringBuilder ans = new StringBuilder();
		long[] g = new long[m + 1];
		g[0] = 1;
		boolean[][] h = new boolean[n][];
		for (int i = 0; i < n; ++i) {
			h[i] = new boolean[s[i].length + 1];
			if (s[i].length <= m) {
				h[i][0] = true;
			}
		}
		for (int T = 0; T < m; ++T) {
			char c = '*';
			long sum = 0;
			boolean flag = false;
			for (int i = 0; i < 26; ++i) {
				c = (char) ('a' + i);
				long tmp = 0;
				for (int u = 0; u < n; ++u) {
					for (int v = 1; v <= Math.min(s[u].length, T + 1); ++v) {
						if (h[u][v - 1] && s[u][v - 1] == c) {
							tmp = add(tmp, mul(g[T + 1 - v], f[m - (T + 1) - (s[u].length - v)]));
						}
					}
				}
				if (add(tmp, sum) >= k) {
					k -= sum;
					flag = true;
					break;
				}
				sum = add(sum, tmp);
			}
			if (!flag)
				throw new AssertionError();
			ans.append(c);
			if (k == 0)
				break;
			for (int i = 0; i < n; ++i) {
				for (int j = h[i].length - 1; j >= 1; --j) {
					h[i][j] = s[i][j - 1] == c && h[i][j - 1];
				}
			}
			for (int i = 0; i < n; ++i) {
				h[i][0] = T + s[i].length + 1 <= m;
			}
			for (int i = 0; i < n; ++i) {
				if (h[i][s[i].length]) {
					g[T + 1] = add(g[T + 1], g[T + 1 - s[i].length]);
				}
			}
		}
		System.out.println(ans);
	}

	long add(long a, long b) {
		if (a + b < 0 || a + b >= INF) {
			return INF;
		} else {
			return a + b;
		}
	}

	long mul(long a, long b) {
		if (a * b < 0 || a * b >= INF) {
			return INF;
		} else {
			return a * b;
		}
	}


	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 34052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N,A;
  cin >> N >> A;
  cout << N*N-A << endl;
  return 0;

}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  
  sort(a,a+n,greater<int>());
  
  int ans=1;
  for(int i=1; i<n; i++) {
    if(a[i]!=a[i-1]) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------

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

  char c; cin >> c;
  cout << (char)(c + ('b'-'a')) << endl;

  return 0;
}



Measured memory_bytes: 256
from sys import stdin

input = stdin.readline
from collections import defaultdict


class BIT:
    def __init__(self, N):
        self.N = N
        self.arr = [0] * (N + 1)

    def add(self, ind, x=1):
        ind += 1
        while ind <= self.N:
            self.arr[ind] += x
            ind += (ind & -ind)

    def get_sum(self, ind):
        ind += 1
        res = 0
        while ind > 0:
            res += self.arr[ind]
            ind -= (ind & -ind)
        return res


def solve():
    N, Q = map(int, input().split())
    c = list(map(int, input().split()))
    query = [tuple(map(int, inp.split())) for inp in stdin.read().splitlines()]
    prev = [-1] * (N+1)
    nxt = [-1] * (N+1)
    for i, v in enumerate(c):
        if prev[v] != -1:
            nxt[prev[v]] = i
        prev[v] = i
    q = defaultdict(list)
    for i, (l, r) in enumerate(query):
        q[l - 1].append((r - 1, i))
    bit = BIT(N)
    ans = [0] * Q
    for l in range(N - 1, -1, -1):
        if nxt[l] != -1:
            bit.add(nxt[l], 1)
        for r, i in q[l]:
            ans[i] = r - l + 1 - bit.get_sum(r)
    for a in ans:
        print(a)

if __name__ == '__main__':
    solve()


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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  long long n, m;
  scanf("%lld %lld", &n, &m);

  if(n == 1 && m == 1){
    printf("1\n");
  }else if(n == 1 || m == 1){
    int hoge = max(n, m);
    printf("%d\n", hoge - 2);
  }else if(n == 2 || m == 2){
    printf("0\n");
  }else{
    long long ans = n * m - (n + m) * 2 + 4;
    printf("%lld\n", ans);
  }
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int>  S(n + 1, 0);
    rep(i, q) {
        int a;
        cin >> a;
        S[a]++;
    }
    rrep(i, n) {
        if(k - (q- S[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    S = [input() for i in range(N)]
    M = int(input())
    T = [input() for i in range(M)]
    ans = 0
    from collections import Counter
    c = Counter(S)
    cT = Counter(T)
    for k, v in c.items():
        ans = max(ans, v - cT[k])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const double eps = 1e-9;
ll a, b, n;
ll calc(ll x){
    return a*x/b - a*(x/b);
}
int main(void){
    IOS;
    cin >> a >> b >> n;
    if (n <= b){
        cout << calc(min(n, b-1)) << endl; return 0;
    }
    ll l = b+1, r = n, ans = b;
    while (l < r-50){
        ll m1 = (l+r) >> 1;
        ll m2 = (m1+r) >> 1;
        if (calc(m1) > calc(m2)){
            ans = m1;
            r = m2-1;
        }else{
            l = m1+1;
        }
    }
    for (ll i = l; i <= r; ++i){
        if (calc(i) > calc(ans)) ans = i;
    }
    cout << max(calc(ans), calc(b-1)) << endl;
    return 0;
}

Measured memory_bytes: 3604
/*
 © 2020-09-26 07:00:12 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const lli N = 1e5 + 5;
struct dsu{
  vector<lli> rank, pr;
  lli tot;
  dsu(int n){
    tot = n;
    rank.resize(n + 1, 1);
    pr.resize(n + 1);
    iota(all(pr), 0);
  }
  lli find(lli u){
    return u == pr[u] ? u : pr[u] = find(pr[u]);
  }
  void unite(lli u, lli v){
    u = find(u), v = find(v);
    if(u != v){
      if(rank[v] > rank[u]) swap(u, v);
      pr[v] = u;
      rank[u] += rank[v];
      tot--;
    }
  }
};
int main(){ _
  lli n, m; cin >> n >> m;
  dsu dd(n);
  fore(i, 0, m){
    lli x, y; cin >> x >> y;
    dd.unite(x, y);
  }
  cout << dd.tot - 1 << ENDL;
  return 0;
}


Measured memory_bytes: 4788
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cnt = 0;
    while(n--){
        int d,c;
        cin >> d >> c;
        if(d == c) cnt++;
        else cnt = 0;
        if(cnt == 3){
            cout << "Yes" << endl;
            return 0;
        };
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(void){

    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    if((A==1&&B==2)||(A==2&&B==1)){
        printf("3");
    }else if((A==2&&B==3)||(A==3&&B==2)){
        printf("1");
    }else if((A==3&&B==1)||(A==1&&B==3)){
        printf("2");
    }
    return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


int main(){fastio
    string s;cin>>s;
    if(0<=s[0]-'a'&&s[0]-'a'<=25){
        cout<<'a';
    }else{
        cout<<'A';
    }
    
    return 0;
}






Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

long long gcd(long long x, long long y){
  if(y == 0) return x;
  return gcd(y,x%y);
}

long long lcm(long long x, long long y){
  long long g = gcd(x,y);
  return x / g * y;
}

int main(int argc, char const *argv[])
{
	ll n, m;
	string s, t;
	cin >> n >> m;
	cin >> s >> t;
	map<ll, char> x;
	map<ll, int> mp;
	ll l = lcm(n,m);
	ll ans = l;
	for (ll i = 0; i < n; ++i)
	{
		mp[i*(l/n)]++;
		x[i*(l/n)] = s[i];
	}

	for (int i = 0; i < m; ++i)
	{
		if (mp[i*(l/m)]==0)
		{
			mp[i*(l/m)]++;
			x[i*(l/m)] = t[i];
		}
		else {
			if (x[i*(l/m)] == t[i]) continue;
			else {
				ans = -1;
				break;
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 21248
from sys import stdin, setrecursionlimit


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))

    for ai in a:
        if ai % 2 == 0 and ai % 3 != 0 and ai % 5 != 0:
            print('DENIED')
            exit()
    print('APPROVED')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Measured memory_bytes: 38384
n = int(input())
l = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(l[1] - l[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(l[i] - l[i-1]), dp[i-2] + abs(l[i] - l[i-2]))

print(dp[-1])

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

int ans;
int gcd(int a, int b) {
	ans++;
	return a % b == 0 ? b : gcd(b, a % b);
}

int main() {
	int a, b;
	while(cin >> a >> b, a || b) {
		ans = 0;
		if(a < b)
			swap(a, b);
		int c;
		c = gcd(a,b);
		cout << c << " " << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <iostream>
#include <random>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int64_t INF64 = int64_t(2e18) + 5;

int64_t N, A, B, C, D;
unordered_map<int64_t, int64_t> save;
set<int64_t> divisions;

int64_t evaluate(int a, int b, int c) {
    int64_t n = N;
    while (a-- > 0) n /= 2;
    while (b-- > 0) n /= 3;
    while (c-- > 0) n /= 5;
    return n;
}

int64_t closest(int64_t n) {
    int64_t dist = INF64;
    auto it = divisions.lower_bound(n);

    if (it != divisions.end())
        dist = min(dist, *it - n);

    if (it != divisions.begin()) {
        it--;
        dist = min(dist, n - *it);
    }

    return dist;
}

const int CUTOFF = 1;

int64_t solve(int64_t n) {
    if (n == 0)
        return 0;

    if (n == 1)
        return D;

    if (closest(n) > CUTOFF)
        return INF64;

    if (save.find(n) != save.end())
        return save[n];

    int64_t ans = (long double) D * n < INF64 ? D * n : INF64;

    ans = min(ans, n % 2 * D + A + solve(n / 2));
    ans = min(ans, n % 3 * D + B + solve(n / 3));
    ans = min(ans, n % 5 * D + C + solve(n / 5));

    if (n > 2) ans = min(ans, (2 - n % 2) * D + A + solve(n / 2 + 1));
    ans = min(ans, (3 - n % 3) * D + B + solve(n / 3 + 1));
    ans = min(ans, (5 - n % 5) * D + C + solve(n / 5 + 1));

    return save[n] = ans;
}

void run_case() {
    cin >> N >> A >> B >> C >> D;
    save.clear();
    divisions.clear();

    for (int a = 0; a <= 60; a++)
        for (int b = 0; b <= 40; b++)
            for (int c = 0; c <= 30; c++)
                divisions.insert(evaluate(a, b, c));

    cout << solve(N) << '\n';
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int tests;
    cin >> tests;

    while (tests-- > 0)
        run_case();
}


Measured memory_bytes: 4488
import sys
b = list(map(int,input().split()))

N = b[0]
K = b[1]

if N < K:
    print(0)
    sys.exit()

H = list(map(int,input().split()))

H.sort(reverse = True)

H = [H[i] for i in range(K,N)]

sum_attack = sum(H)
print(sum_attack)

Measured memory_bytes: 26024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int min_cost = INF;
    rep(i,3)
        rep(j,3)
            rep(k,3)
            {
                if(j==i || k==i || j==k) continue;
                min_cost = min(min_cost, abs(a[i]-a[j])+abs(a[j]-a[k]));
            }
    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
int main(){
  int n,k,ans=0,tmp;
  scanf("%d %d",&n,&k);
  int a[n],d[k],s[101];
  for(int i=0;i<n;i++){
    a[i]=0;
  }
  for(int i=0;i<k;i++){
    scanf("%d",&d[i]);
    for(int j=0;j<d[i];j++){
      scanf("%d",&tmp);
      a[tmp-1]=1;
  }
  }
  for(int i=0;i<n;i++){
    if(a[i]==0){
      ans+=1;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1732
n,x=gets.split.map(&:to_i)
if x>n/2
	x=n-x
end
sum=0

def func(a,b,sum)
	sum+=3*a*(b/a)
	if b%a == 0
		return sum
	else
		func(b%a,a,sum)
	end
end

puts func(x,n-x,sum)

Measured memory_bytes: 1788
N, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
P = [1] * (N + 1)
for i in range(N):
    P[i + 1] = (P[i] * (i + 1)) % mod


def inv(n):
    return pow(n, mod - 2, mod)


def C(i, j):
    return (P[i] * inv(P[j]) * inv(P[i - j])) % mod


for i in range(1, K + 1):
    if i - 1 > N - K:
        print(0)
    else:
        print((C(K - 1, i - 1) * P[N - K + 1] * inv(P[N - K - i + 1]) * inv(P[i])) % mod)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int l=a.size();
	cout<<a;
	if(a[l-1]!='s'){
		cout<<'s';
	}
	else{
		cout<<"es";
	}
	return 0;
} 

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define LL  long long

int main(void)
{
    IOS
    LL n;
    cin >> n;
    LL ans = 0;

    for(LL i = 1; i*i <= n ; i++){
        if (n % i == 0) {
            LL m = i-1;
            if ((m != 0) && (n % m == n / m )) ans += m;
        }
        if (i * i != n) {
            LL m = n/i -1;
            if ((m != 0) && (n % m == n / m )) ans += m;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp
{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enque(P x)
{
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P deque()
{
  P x =Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b)
{
 return a<b ? a :b;
}

int main()
{
  int num = 0, c;
  int i, q;
  P u;
  scanf("%d %d",&n,&q);
  for (i=1; i<=n; i++)
  {
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while( head != tail)
  {
    u = deque();
    c = min(q , u.t);
    u.t -= c;
    num += c;
    if(u.t > 0)enque(u);
    else printf("%s %d\n",u.name,num);
  }
  return 0;
}



Measured memory_bytes: 11868
//start:
//finish:
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int f[4305][4305];
int x[200005],y[200005];
int fac[10005],inv[10005];
int n;
int C(int x,int y){
	return 1ll*fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int ksm(int x,int y){
	if(y==0)return 1;
	int t=ksm(x,y/2);
	t=1ll*t*t%MOD;
	if(y&1)t=1ll*t*x%MOD;
	return t;
}
int main(){
	scanf("%d",&n);
	fac[0]=1;inv[0]=1;
	for(int i=1;i<=8000;i++){
		fac[i]=1ll*fac[i-1]*i%MOD;
		inv[i]=ksm(fac[i],MOD-2);
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		f[-x[i]+2100][-y[i]+2100]++;
	}
	for(int i=1;i<=4300;i++){
		for(int j=1;j<=4300;j++){
			f[i][j]=(f[i][j]+f[i-1][j])%MOD;
			f[i][j]=(f[i][j]+f[i][j-1])%MOD;
		}
	}
	int res=0;
	for(int i=1;i<=n;i++){
		res=(res+f[x[i]+2100][y[i]+2100])%MOD;
		res=(res-C(x[i]+x[i]+y[i]+y[i],x[i]+x[i])+MOD)%MOD;
	}
//	cout<<res<<endl;
	res=1ll*res*ksm(2,MOD-2)%MOD;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 74240
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a;
    int b;
    int c[5]={0};
    
    for(int i=0;i<3;i++){
        cin>>a>>b;
        c[a]++;
        c[b]++;        
    }
    
    for(int i=1;i<=4;i++){
        if(c[i]>=3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  cpp
//
//  Created by Hao He on 8/13/17.
//  Copyright © 2017 Hao He. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
#include <unordered_map>

using namespace std;
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define mp make_pair
#define maxn 300
const int mod = 1000000000 + 7;
const long long inf = 1ll * 1000000000 * 300;

int n, m, k;
int a[maxn][maxn], f[maxn];
vector<pair<int, pair<int,int>>> e;
long long w[maxn][maxn];

int get(int x){
    if(f[x]==x) return x;
    f[x] = get(f[x]);
    return f[x];
}

void solve(){
    cin >> n;
    e.clear();
    rep(i,n)rep(j,n){
        cin >> a[i][j];
        if(i < j) e.push_back(mp(a[i][j], mp(i,j)));
        w[i][j] = (i==j)? 0: inf;
    }
    rep(i,n) f[i] = i;
    
    long long ans = 0;
    
    sort(e.begin(), e.end());
    bool ok = 1;
    for(auto p: e){
        int u = p.second.first;
        int v = p.second.second;
        if(w[u][v] == p.first){
            continue;
        }
        if(w[u][v] > p.first){
            ans += p.first;
            w[u][v] = w[v][u] = p.first;
            rep(i,n)rep(j,n){
                w[i][j] = min(w[i][j], w[i][u] + w[u][v] + w[v][j]);
                w[i][j] = min(w[i][j], w[i][v] + w[v][u] + w[u][j]);
            }
        }
        if(w[u][v] < p.first){
            ok = 0;
        }
    }
    
//    rep(i,n)rep(j,n)rep(k,n){
//        w[i][j] = min(w[i][k] + w[k][j], w[i][j]);
//    }
    
    rep(i,n)rep(j,n){
        ok &= (w[i][j] == a[i][j]);
    }
    
    cout << (ok? ans: -1);
    
}

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*
 8
 1 1 1 3 4 5 5
 4 1 6 2 2 1 3 3
 
*/


Measured memory_bytes: 1912
#include <stdio.h>
int main(void){
    char S[100];
    int sum=0,k;
    scanf("%s",S);
    for(int i=0;S[i]!='\0';i++){
        k=i;
    }
    for(int j=0;j<=(k-j);j++){
        if(S[j]!=S[k-j]){
            sum=sum+1;
        }
        else{
            sum=sum+0;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
int N;
int Count[9],A[101];
int Ansa,Ansb;
int main()
{
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        scanf("%d",&A[i]);
        if(A[i]<400)Count[0]++;
        else if(A[i]<800)Count[1]++;
        else if(A[i]<1200)Count[2]++;
        else if(A[i]<1600)Count[3]++;
        else if(A[i]<2000)Count[4]++;
        else if(A[i]<2400)Count[5]++;
        else if(A[i]<2800)Count[6]++;
        else if(A[i]<3200)Count[7]++;
        else Count[8]++;
    }
    for(int i=0;i<=7;i++)
    {
        if(Count[i])
        {
            Ansa++;
            Ansb++;
        }
    }
    printf("%d %d\n",max(Ansa,1),Ansb+Count[8]);
    return 0;
}

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

using namespace std;

int main()
{
    int i;
    int n = 0;
    int ans = 0;

    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    string x;

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

    for (i = 0; i < n; i++) {
        if (s[i] == x) {
            i++;
            break;
        }
    }
    for (; i < n; i++) {
        ans += t[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0;i < n;i++)

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

  ll n, y;
  cin >> n >> y;
  rep(i, n+1) {
    rep(j, n+1) {
      ll k = n-i-j;
      if (k >= 0 and 10000*i+5000*j+1000*k == y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


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


int main() {
    ios_base::sync_with_stdio(false);;
    cin.tie(0);
    cout.tie(0);
ll a[3][3]; 
for (int i = 0; i<3; ++i)
{
    for(int j=0;j<3;j++) 
    {
        cin>>a[i][j]; 
    }
}
ll n; 
cin>>n;
map<ll,ll> m; 
for (int i = 0; i<n; ++i)
{
    ll x; 
    cin>>x; 
    m[x]++; 
}
ll flag=0;
for (int i = 0; i<3; ++i)
{
    ll x=0,y=0;
    for(int j=0;j<3;j++) 
    {
    if(m.find(a[i][j])==m.end()) 
    x=1; 
    if(m.find(a[j][i])==m.end()) 
      y=1;
    }
    if((x==0)||(y==0)) 
    {
        flag=1; 
        break;
    }
}
if(m.find(a[1][1])!=m.end()) 
{

if((m.find(a[0][0])!=m.end())&&(m.find(a[2][2])!=m.end()))
    flag=1;

if((m.find(a[0][2])!=m.end())&&(m.find(a[2][0])!=m.end()))
    flag=1;
}
if(flag==1) 
    cout<<"Yes"; 
else 
    cout<<"No";
}

Measured memory_bytes: 256
S=input()
oddLst=['R','U','D']
evenLst=['L','U','D']

ret='Yes'
cnt=0
for s in S:
    cnt+=1
    if(cnt%2):
        if s in oddLst:
            continue
        else:
            ret='No'
    else:
        if s in evenLst:
            continue
        else:
            ret='No'

print(ret)


Measured memory_bytes: 2940
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int
main()
{
  int N, K;
  cin >> N >> K;
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    int h;
    cin >> h;
    if (K <= h)
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
a=input().strip().split()
d,e={},{}
for w in a:d.setdefault(w,0);d[w]+=1
for w in d:
 if d[w]==max(d.values()):print(w,end='')
 e.setdefault(len(w),[]).append(w)
print('',*e[max(e)])


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

int main(){
  int i,n;
  scanf("%d",&n);
  int f[n+1][11];
  int p[n+1][11];

  for(i=0;i<n;i++){
    for(int j=0;j<10;j++){
      scanf(" %d",&f[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(int j=0;j<=10;j++){
      scanf(" %d",&p[i][j]);
    }
  }

  int res=-(1<<30);
  for(i=1;i<(1<<10);i++){
    int tmp=0;
    for(int j=0;j<n;j++){
      int c=0;
      for(int k=0;k<10;k++){
        if((i>>k&1)&&f[j][k]) c++;
      }
      tmp+=p[j][c];
    }
    if(res<tmp) res=tmp;
  }
  printf("%d",res);
  return 0;
}


Measured memory_bytes: 256
require "prime"

PrimeArray = (2..50000).select(&:prime?)

while input = $stdin.gets
  target = input.to_i
  break if target == 0
  
  source = PrimeArray.clone
  c = 0
  pl = 0
  pr = source.size - 1 
  while pl <= pr
    s = source[pl].to_i + source[pr].to_i
    if s > target
      pr -= 1
    elsif s == target
      c += 1
      pl += 1
    else
      pl += 1
    end 
  end
  
  puts c
end

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

long long a[200000];
int main()
{
	long long  N,K;
	cin >> N >> K;
	
	for ( long long i=0 ; i<N ; i++ )
	{
		cin >> a[i];
	}

	for( long long i=0 , j=K ; i<N-K ; i++ , j++ ){
		if( a[i]<a[j] )
			cout << "Yes" << endl;
		else 
			cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 5196
#include <iostream>//約数だけ考えればよいですね。O(sqrt(n))で解けます。
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#define MX 100000
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
vector<int>par;
vector<int>fac;
vector<int>ran;
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	return find(par[x]);
}
void unit (int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
		fac[y] += fac[x];
	}
	else {
		par[y] = x;
		fac[x] += fac[y];
	}
	if (ran[x] == ran[y])ran[x]++;
}
int main() {
	int n, m, k;
	cin >> n >> m >> k;

	rep(i, n) {
		par.push_back(i);
		fac.push_back(1);
		ran.push_back(1);
	}
	
	vector<vector<int>>dt(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		unit(a, b);
		dt[a].push_back(b);
		dt[b].push_back(a);
	}
	vector<int>ans(n,0);
	rep(i, k) {
		int c, d;
		cin >> c >> d;
		--c;
		--d;
		if (find(c) == find(d)) {
			ans[c]--;
			ans[d]--;
		}
	}
	
	rep(i, n) {
		int tmp = find(i);
		ans[i] += fac[tmp] - dt[i].size()-1;
		cout << ans[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 8300
#B問題
N = int(input())
P = list(map(int,input().split()))
A = []
B = []
for i in range(N):
    P[i]-=1
    A.append(40000*(i+1))
    B.append(40000*(N-i))
    
add = 0
C = []
for p in P:
    if len(C) == 0:
        C.append(A[p]+B[p])
    else:
        c = C[-1]
        if c < A[p]+B[p]+add:
            C.append(A[p]+B[p]+add)
        else:
            add+=c-(A[p]+B[p]+add)+1
            C.append(A[p]+B[p]+add)
    A[p]+=add
    
for a in A:
    print(a+add,end=" ")
print()
for b in B:
    print(b,end=" ")

Measured memory_bytes: 6864
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> d(N);
  FOR(i, N) cin >> d[i];
  int ans = 0;
  FOR(i, N) {
    for (int j = i + 1; j < N; ++j) {
      ans += d[i] * d[j];
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int ans=0;
		
		for(int i=1; i<=a; i++){
		    ans+=i;
		}
		
		System.out.println(ans);
    }
}

Measured memory_bytes: 35600
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, m) = readIntegerList()
    val aSet = mutableSetOf<Int>()
    val nSet = mutableSetOf<Int>()
    repeat(m) {
        val (a, b) = readIntegerList()
        if (a == 1) { aSet += b }
        if (b == n) { nSet += a }
    }

    val ans = if (aSet.intersect(nSet).isEmpty()) "IMPOSSIBLE" else "POSSIBLE"
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

int A[3][3];

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}

	int N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;
		for (int l = 0; l < 3; l++) {
			for (int m = 0; m < 3; m++) {
				if (A[l][m] == b) A[l][m] = 0;
			}
		}
	}

	if (A[0][0] == 0 && A[0][1] == 0 && A[0][2] == 0) cout << "Yes" << endl;
	else if (A[1][0] == 0 && A[1][1] == 0 && A[1][2] == 0) cout << "Yes" << endl;
	else if (A[2][0] == 0 && A[2][1] == 0 && A[2][2] == 0) cout << "Yes" << endl;
	else if (A[0][0] == 0 && A[1][0] == 0 && A[2][0] == 0)cout << "Yes" << endl;
	else if (A[0][1] == 0 && A[1][1] == 0 && A[2][1] == 0)cout << "Yes" << endl;
	else if (A[0][2] == 0 && A[1][2] == 0 && A[2][2] == 0)cout << "Yes" << endl;
	else if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) cout << "Yes" << endl;
	else if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = 2 * a - 1;
    int d = 2 * b - 1;
    int e = a + b;
    int ans = Math.max(c, Math.max(d, e));
    System.out.println(ans);
  }
}


Measured memory_bytes: 21972
import sys, math
input = sys.stdin.readline

A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0, A+1):
    for j in range(0, B+1):
        for k in range(0, C+1):
            calc = (500 * i) + (100 * j) + (50 * k)
            if calc == X:
                ans += 1

print(ans)


Measured memory_bytes: 40176
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int cnt = Integer.parseInt(scan.next());
        String slimes = scan.next();

        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        List<String> result = new ArrayList<>();
        for (int i = 0; i <cnt; i++) {
            if(i==0) {
                result.add(slimes.substring(0, 1));
            } else if(!slimes.substring(i-1,i).equals(slimes.substring(i, i+1))) {
                result.add(slimes.substring(i, i + 1));
            }
        }
        System.out.println(result.size());
        //result(sum>=power);
    }

    public static void result(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 44376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <iomanip>
#include <list>

using namespace std;
#define GETINT(x) int (x); cin >> (x);
#define FOR(i, N) for(int i = 0; i < (N); (i)++)
#define RET cout << endl;
constexpr int _10e(int n) { return n == 0 ? 1 : 10 * _10e(n - 1); }

int main() {
    GETINT(N); GETINT(K);

    map<int, int> map;
    FOR(i, N) {
        GETINT(h);
        map[h]++;
    }

    int arr[N];
    int mindh = _10e(9);
    int i = 0;
    auto end = map.end();
    for (auto it = map.begin(); it != end; ++it) {
        int num = it->first;
        int times = it->second;
        for (int k = 0; k < times; k++) {
            arr[i++] = num;
        }
    }

    for (int j = K - 1; j < N; j++) {
        int dh = arr[j] - arr[j - (K - 1)];
        if (dh < mindh) mindh = dh;
    }
    
    cout << mindh;
    return 0;
}

Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.Linq;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int[] K = S2Iarray(Console.ReadLine().Split(' '));
            swap(0,1,ref K);
            swap(0, 2, ref K);
            RESULT(K[0] + " " + K[1] + " "+K[2]);

        }
        public static bool swap(int x, int y, ref int[] array)
        {

            // check for out of range
            if (array.Length <= y || array.Length <= x) return false;


            // swap index x and y
            var buffer = array[x];
            array[x] = array[y];
            array[y] = buffer;


            return true;
        }
        static int arser(int[] ar ,int search, int[] except)
        {
            for(int i  = 0;i < ar.Length;i++)
            {
                if(ar[i] == search)
                {
                    if (Array.IndexOf(except, i) >= 0) continue;
                    return i;
                }
            }
            return -1;
        }

        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] S2Iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 11220
require 'pp'
#IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

s,d=gets.chomp.split(' ').map{|n| n}
t,d=gets.chomp.split(' ').map{|n| n}

# matching
def match(s,t)
	ret = true
	0.upto(t.length-1){|i|
		ret = ret && (s[i]=="?"||s[i]==t[i])
	}
	ret
end
len = t.length
match_i = nil
0.upto(s.length-len){|i|
	s_cut = s[i..(i+t.length-1)]
	dputs "s_cut = #{s_cut}"
	if(match(s_cut,t))
		dputs "match!"
		match_i = i
	end
}
if(match_i.nil?)
	puts "UNRESTORABLE"
else
	s[match_i..(match_i+len-1)]=t
	puts s.gsub(/\?/,"a")
end


Measured memory_bytes: 2044
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
	N4RUTO;
	int t;
	t=1;
	// cin>>t;
	while(t--){
	   int n;
	   cin>>n;
	   int a[n];
	   int x = 0;
	   loop(i,0,n-1) cin>>a[i], x^=a[i];
	   loop(i,0,n-1){
		   cout<<(x^a[i])<<" ";
	   }
	}
	return 0;
}

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

int min_cost(int height[], int n) {
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(height[i] - height[i - 1]), dp[i-2] + abs(height[i] - height[i - 2]));
    }
    return dp[n - 1];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int height[n];
    for (int i = 0; i < n; ++i) {
        cin >> height[i];
    }
    cout << min_cost(height, n) << endl;
    return 0;
}

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

vector<int> a,b;
int n,ans=0,u,v,nn;
int main()
{
    cin>>n;
    ref(i,n) {
        cin>>u>>v;
        a.push_back(u);b.push_back(v);
    }
    sort(a.begin(),a.begin()+n);
    sort(b.begin(),b.begin()+n);
    if(n%2) {
        nn=(n+1)/2-1;
        cout<<b[nn]-a[nn]+1;
        return 0;
    }
    else{
        nn=n/2-1;
        cout<<(b[nn]+b[nn+1]-a[nn]-a[nn+1])+1;
        return 0;
    }


    return 0;
}


Measured memory_bytes: 4996
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long

using namespace std;

int main(void){
    string s1,s2;

    cin >> s1 >> s2;
    // s1.size - s2.size = 1 or 0
    for(int i = 0;i < s2.size();i++){
        cout << s1[i] << s2[i];
    }

    if(s1.size() != s2.size()){
        cout << s1.back();
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int C[][] = new int[3][3];
		
		int sum = 0;
		
		for(int i = 0 ; i < 3 ; i ++){
			for(int j = 0 ; j < 3 ; j ++){
				C[i][j] = sc.nextInt();
				sum = sum + C[i][j] ;
			}
		}
		
		boolean result = false;
		
//		System.out.println(sum);
		
		if(sum % 3 == 0){
			
			int D = sum / 3;
			if(D == C[0][0] + C[1][1] + C[2][2] &&
			   D == C[0][1] + C[1][2] + C[2][0] &&
			   D == C[0][2] + C[1][0] + C[2][1] &&
			   D == C[0][2] + C[1][1] + C[2][0] &&
			   D == C[0][1] + C[1][0] + C[2][2] &&
			   D == C[0][0] + C[1][2] + C[2][1] ){
			   	result = true;
			   }
		}
		
		System.out.println( result ? "Yes" : "No");
	}
}




Measured memory_bytes: 23124