akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int modPow(long long a, long long n, long long p) {
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

int res[100001];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	if (n == 1) {
		if (a[0] == 0) dunk(1);
		else dunk(0);
      return 0;
	}

	if (n % 2 == 0) {
		rep(i, n) {
			res[a[i]]++;
		}
		bool elf = true;
		rep(i, n) {
			if (res[i] == 2) {
				if (i % 2 == 0) elf = false;
			}
			else if (res[i] != 0) elf = false;
		}
		if (elf) {
			int ans = modPow(2, n / 2, mod);
			dunk(ans);
		}
		else {
			dunk(0);
		}
	}
	else {
		rep(i, n) {
			res[a[i]]++;
		}
		bool elf = true;
		rep(i, n) {
			if (res[i] == 2) {
				if (i % 2 != 0) elf = false;
			}
			else if (res[i] != 0) {
				if (i != 0) elf = false;
			}
		}
		if (elf) {
			int ans = modPow(2, (n - 1) / 2, mod);
			dunk(ans);
		}
		else {
			dunk(0);
		}
	}

	return 0;
}


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

#define Online 1
// #define multitest 1
#define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
	int n, m, k, x;
	cin >> n >> m;
	vector<vector<int>> V(m, vector<int>(n));
	for (int i = 0; i < m; ++i)
	{
		cin >> k;
		while (k--)
		{
			cin >> x;
			V[i][x - 1] = 1;
		}
	}
	vector<int> p(m);
	for (auto &x : p)
		cin >> x;
	ll ans = 0;
	for (int i = 0; i < (1 << n); ++i)
	{
		bool t = true;
		for (int j = 0; j < m; ++j)
		{
			int cnt = 0;
			for (int k = 0; k < n; ++k)
			{
				if (V[j][k])
				{
					if (i & (1 << k))
						cnt++;
				}
			}
			if ((cnt % 2) != p[j])
			{
				t = false;
				break;
			}
		}
		if (t)
			ans++;
	}
	cout << ans;
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
if a**2*b >= 2*x:
    c = (2*x)/(a*b)
    print(math.degrees(math.atan(b/c)))
else:
    d = 2*(b-x/a/a)
    print(math.degrees(math.atan(d/a)))

Measured memory_bytes: 3060
s = input()
alp = [chr(ord('A') + i) for i in range(26)]
alp.remove('A')
alp.remove('C')
alp.remove('G')
alp.remove('T')

ans = 0
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        flg = True
        for k in alp:
            if k in s[i:j]:
                flg = False
                break
        if flg:
            ans = max(ans, j - i)
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[1010000];
char in[100];
int v[300];
int w[300];
int main(){
	bool sec=false;
	while(1){
		int n=0;
		bool last=true;
		int ns=0;
		while(1){
			gets(in);
			if(in[0]==0)break;
			ns++;
			for(int i=0;in[i];i++){
				str[n++]=in[i];
			}
		}
		if(ns==0)break;
		if(sec)printf("\n\n");
		gets(in);
		int m=strlen(in);
		for(int i=0;i<300;i++)v[i]=w[i]=0;
		for(int i=0;i<m;i++)w[in[i]]=1;
		int left=0;
		int right=n;
		int cnt=0;
		int now=0;
		sec=true;
		int R=0;
		for(int i=0;i<n;i++){
			while(R<n&&now<m){
				v[str[R]]++;
				if(v[str[R]]==1&&w[str[R]])now++;
				R++;
			}
			if(now<m)break;
			if(right-left>R-i){
				right=R;left=i;cnt=1;
			}else if(right-left==R-i)cnt++;
			v[str[i]]--;
			if(v[str[i]]==0&&w[str[i]])now--;
		}
		printf("%d",cnt);
		if(cnt){
			printf("\n\n");
			for(int i=0;i<right-left;i++){
				printf("%c",str[left+i]);
				if(i%72==71&&i!=right-left-1)printf("\n");
			}
		}
		gets(in);
	}printf("\n\n");
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <sstream>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", max(a + b, max(a - b, a * b)));
	return 0;
}

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

int main(){
    int n,ans=0;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++) cin >> p[i];
    for(int i=1;i<n-1;i++){
        if(p[i-1]<p[i]&&p[i]<=p[i+1]) ans++;
        else if(p[i-1]>=p[i]&&p[i]>p[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
///****In the name of ALLAH, most Gracious, most Compassionate****//

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e3+5;
const int oo=1e9+7;

ll ans[N][N][4];
int now [N][N];

int32_t main()
{
    FastIO;
    int n,m,k;
    cin>>n>>m>>k;
    while(k--)
    {
        int x,y,v;
        cin>>x>>y>>v;
        now[x][y]+=v;
    }
    for(int i=n; i>=1; i--)
    {
        for(int j=m; j>=1; j--)
        {
            ll mx = 0;
            for(int x= 3;x>=0;x--)
            {
                ans[i][j][x] = max(ans[i+1][j][0] ,ans[i][j+1][x]);

                ans[i][j][x]  = max(ans[i][j][x] , mx);

                if(x != 3)
                    ans[i][j][x] = max(ans[i][j][x] , now[i][j] + max(ans[i+1][j][0] , ans[i][j+1][x+1])  );

                mx = max (ans[i][j][x]  , mx);

            }
        }
    }
//    for(int x = 0;x<=3;x++) {
//            DBG(x);
//    for(int i=1; i<=n; i++)
//    {
//        for(int j=1; j<=m; j++)
//            cout<<ans[i][j][x]<<" ";
//        NL;
//    }
//    }
    cout<<ans[1][1][0]<<"\n";
}


Measured memory_bytes: 320472
#include <iostream>

using namespace std;

int main()
{
    int l,r,d,i,j=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++)
    {
        if(i%d==0&&i>=d)
            j++;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef long long llint;
typedef pair<int, int> pii;

#define mp make_pair
#define pb push_back
#define X first
#define Y second

//#define DEBUG
#ifdef DEBUG
#define TRACE(x) cout<<#x<<" = "<<x<<endl
#else
#define TRACE(x) ;
#endif // DEBUG



int main() {
    llint n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k) {
        cout << n * x << endl;
    }
    else {
        cout << k * x + (n - k) * y << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] X = new int[M];
        int[] Y = new int[M];
        int[] Z = new int[M];
        for (int i=0; i<M; i++) {
            X[i] = sc.nextInt();
            Y[i] = sc.nextInt();
            Z[i] = sc.nextInt();
        }

        System.out.println(solve(N, M, X, Y, Z));
    }

    private static int solve(int N, int M, int[] X, int[] Y, int[] Z) {
        UnionFind uf = new UnionFind(N);
        for (int i=0; i<M; i++) {
            uf.unite(X[i]-1, Y[i]-1);
        }

        Set<Integer> set = new HashSet();
        for (int i=0; i<N; i++) {
            set.add(uf.find(i));
        }

        return set.size();
    }

    public static class UnionFind {
        /**
         * 各要素のrootを示す．対象要素がrootの場合は木の要素数を負の値で表現する
         */
        int[] parent;

        public UnionFind(int N) {
            parent = new int[N+1];
            Arrays.fill(parent, -1);
        }

        /**
         * xとyの木を併合する
         * @param x
         * @param y
         */
        public void unite(int x, int y) {
            int rootx = find(x);
            int rooty = find(y);

            // XとYが同一木なら何もしない
            if (rootx == rooty) return;

            // 小さい木を大きい木に併合したいので
            // Xの方が小さい場合はXとYを入れ替えてYをXに併合する
            if (size(x) < size(y)) {
                unite(y, x);
                return;
            }

            parent[rootx] += parent[rooty];
            parent[rooty] = x;
        }

        /**
         * UnionFind木のルートを求める
         * @param x
         * @return
         */
        public int find(int x){
            if (parent[x] < 0) {
                return x;
            }

            return parent[x] = find(parent[x]);
        }

        /**
         * 2つの要素が同一木に属するか
         * @param x
         * @param y
         * @return
         */
        public boolean isSame(int x, int y) {
            return find(x) == find(y);
        }

        /**
         * 要素xが属する木の要素数を返す
         * @param x
         * @return
         */
        public int size(int x) {
            return -parent[find(x)];
        }
    }
}


Measured memory_bytes: 94808
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys
import math


n,x = map(int, input().split())

cntr = [1]
keta = [1]

for i in range(n):
  cntr.append(cntr[-1]*2+1)
  keta.append(keta[-1]*2+3)

ans = 0
for i in range(n,-1,-1):
  if x >= cntr[i]:
    ans += 2**i
    x -= cntr[i]
  else:
    x -= 1
print(ans)

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

using namespace std ; 

const int N = 1e5 + 7 ; 

long long n ; 
set<long long > s ; 

void doo(long long x){
    long long tmp = n ; 
    while(tmp%x==0 && x > 1){
        tmp/=x ; 
    }
    if(tmp%x==1){
        s.insert(x) ; 
    }
}

void make(long long x){
    for(long long i  = 1ll ; i * i <=x ; i++){
        if(x%i==0){
            long long j = x  / i ; 
           // s.insert(i) ; 
         //   s.insert(j) ; 
            doo(i) ; 
            doo(j) ; 
        }
    }   
}

map<long long , int > dv ; 

int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
    //freopen("in.in" , "r" , stdin) ; 
    cin>> n; 
    make(n) ; 
    make(n-1) ; 
    cout<<s.size() ; 
    return 0 ; 
}

Measured memory_bytes: 256
H,W=[int(i) for i in input().split(" ")]

city=[]
for i in range(H):
    C=input()
    row=[]
    timer=-1000
    for c in C:
        if c=="c":
            timer=0
            row.append(timer)
        else:
            timer+=1
            row.append(timer)
    city.append(row)


for i in range(H):
    for j in range(W):
        if city[i][j]<0:
            city[i][j]="-1"
        else:
            city[i][j]=str(city[i][j])

for c in city:
    print(" ".join(c))



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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    vector<int> a(3);
    for(int i=0;i<3;i++)cin >> a[i];
    sort(a.begin(), a.end());
    rep(i,3){
        cout << a[i];
        if(i == 2)cout << endl;
        else cout << " ";
    }
    return 0;
}



Measured memory_bytes: 3140
A,B=map(int,input().split())
res,B=0,B+1
for j in range(41):
    res+=((((B//(2*(2**j)))*(2**j)+max(0,(B%(2*(2**j)))-2**j))-((A//(2*(2**j)))*(2**j)+max(0,(A%(2*(2**j)))-2**j)))%2)*(2**j)
print(res)

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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  
  set<int> x;
  for(int i=a; i<=min(a+k-1, b); i++) x.insert(i);
  for(int i=b; i>=max(b-k+1, a); i--) x.insert(i);

  for(int y:x) cout << y << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 2;
ll i,k,n,a;
priority_queue<ll,vector<ll> > pq;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    rep(i,1,n + 1){
        cin>>a;
        pq.push(a);
    }
    while(!pq.empty() && k > 0){
        a = pq.top();
        pq.pop();
        a /= 2;
        if(a > 0)
            pq.push(a);
        k -= 1;
    }
    a = 0;
    while(!pq.empty()){
        a += pq.top();
        pq.pop();
    }
    cout<<a;
    return 0;
}

Measured memory_bytes: 1400
N = int(input())
A = list(map(int, input().split()))
m = {}
non_color = 0

for a in A:
    if a < 400:  # 1-399
        m[0] = 1
    elif 400 <= a and a < 800:  # 400-799
        m[1] = 1
    elif 800 <= a and a < 1200:  # 800-1199
        m[2] = 1
    elif 1200 <= a and a < 1600:  # 1200-1599
        m[3] = 1
    elif 1600 <= a and a < 2000:  # 1600-1999
        m[4] = 1
    elif 2000 <= a and a < 2400:  # 2000-2399
        m[5] = 1
    elif 2400 <= a and a < 2800:  # 2400-2799
        m[6] = 1
    elif 2800 <= a and a < 3200:  # 2800-3199
        m[7] = 1
    elif 3200 <= a:  # 3200-
        non_color += 1

if non_color > 0:
    print(max(len(m), 1), len(m)+non_color)
else:
    print(len(m), len(m))


Measured memory_bytes: 3064
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int main() {

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int a;
        cin>>a;
        cout<<a+a*a+a*a*a<<endl;
    }
    return 0;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    multiset<ll> C;
    set<ll> D;
    REP(i,0,N) {
        ll a;
        cin >> a;
        C.insert(a);
        D.insert(a);
    }

    bool f = false;
    if(N % 3 != 0) {
        if(C.count(0) == N) f = true;    
    }
    else {
        if(C.count(0) == N) f = true;
        if(SZ(D) == 2 && C.count(0) == N / 3) f = true;
        if(SZ(D) == 3) {
            bool g = true;
            ll x = 0;
            FORR(d,D) {
                x = x ^ d;
                if(C.count(d) != N / 3) g = false;
            }
            if(x != 0) g = false;
            f = g;
        }
    }

    if(f) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 10708
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	final int maxn = 101001;

	int l, d;
	String[] str = new String[3];
	char[] ans = new char[maxn];
	int[][] sum = new int[maxn][4];
	int[][] val = new int[maxn][3];

	boolean check(int idx, int valA, int valB, int valC) {
		int vala = sum[idx][0];
		int valb = sum[idx][1];
		int valc = sum[idx][2];
		int vald = sum[idx][3];
		if (d - valA < 0)
			return false;
		if (d - valB < 0)
			return false;
		if (d - valC < 0)
			return false;
		if (vala + valA > d) {
			valb += vala + valA - d;
			valc += vala + valA - d;
			vala = d - valA;
		}
		if (valb + valB > d) {
			vala += valb + valB - d;
			valc += valb + valB - d;
			valb = d - valB;
		}
		if (valc + valC > d) {
			vala += valc + valC - d;
			valb += valc + valC - d;
			valc = d - valC;
		}
		if (vala + valA > d || valb + valB > d)
			return false;
		int tmpA = Math.min(vald, d - vala - valA);
		int tmpB = Math.min(vald, d - valb - valB);
		int tmpC = Math.min(vald, d - valc - valC);
		if (tmpA + tmpB + tmpC < vald * 2)
			return false;
		return true;
	}

	void run() {

		Scanner scan = new Scanner(System.in);

		while (scan.hasNext()) {
			l = scan.nextInt();
			d = scan.nextInt();
			if (l == 0 && d == 0)
				break;
			for (int i = 0; i < 3; i++) {
				str[i] = scan.next();
			}
			for (int i = 0; i < maxn; i++)
				for (int j = 0; j < 4; j++)
					sum[i][j] = 0;
			for (int i = l - 1; i >= 0; i--) {
				for (int j = 0; j <= 3; j++) {
					sum[i][j] = sum[i + 1][j];
				}
				if (str[0].charAt(i) == str[1].charAt(i)
						&& str[1].charAt(i) == str[2].charAt(i))
					continue;
				if (str[0].charAt(i) == str[1].charAt(i))
					sum[i][2]++;
				else if (str[0].charAt(i) == str[2].charAt(i))
					sum[i][1]++;
				else if (str[1].charAt(i) == str[2].charAt(i))
					sum[i][0]++;
				else
					sum[i][3]++;
			}
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < l; j++) {
					if (str[i].charAt(j) >= 'A' && str[i].charAt(j) <= 'Z') {
						val[j][i] = (int) (str[i].charAt(j) - 'A');
					} else {
						val[j][i] = (int) (str[i].charAt(j) - 'a' + 26);
					}
				}
			}
			if (check(0, 0, 0, 0) == false) {
				System.out.println("-1");
				continue;
			}

			int valA = 0, valB = 0, valC = 0;
			int ansA = 0, ansB = 0, ansC = 0;
			for (int i = 0; i < l; i++) {
				for (int j = 0; j < 52; j++) {
					int tmpA = 0, tmpB = 0, tmpC = 0;
					if (j != val[i][0])
						tmpA = 1;
					if (j != val[i][1])
						tmpB = 1;
					if (j != val[i][2])
						tmpC = 1;
					valA = ansA + tmpA;
					valB = ansB + tmpB;
					valC = ansC + tmpC;
					if (check(i + 1, valA, valB, valC) == true) {
						if (j < 26) {
							ans[i] = (char) ('A' + j);
						} else {
							ans[i] = (char) ('a' + j - 26);
						}
						// System.out.println("HEHE " + i);
						ansA = valA;
						ansB = valB;
						ansC = valC;
						break;
					}
				}
				// System.out.println("HEHE " + i);
			}
			for (int i = 0; i < l; i++) {
				System.out.print(ans[i]);
			}
			System.out.println();
		}

	}

	public static void main(String arsgs[]) {
		new Main().run();
	}
}

Measured memory_bytes: 86960
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a;
    cin>>a;
    int ans=a+a*a+a*a*a;
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3612
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> diff(n);
	rep(i,n) std::cin >> diff[i];
	std::sort(all(diff));
	print(diff[n/2]-diff[n/2-1]);
	return 0;
}


Measured memory_bytes: 1024
H, W = map(int, input().split())
C = [[int(x) for x in input().split()] for _ in range(10)]
A = [[int(x) for x in input().split()] for _ in range(H)]

import heapq
def dijkstra(adj, n, st=1):
    inf = float('inf')
    dj = [inf] * (n + 1)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = dict((x, []) for x in range(10))
for i in range(10):
    for j in range(10):
        adj[j].append((i, C[i][j]))
costs = dijkstra(adj, 9, 1)

ans = 0
for i in range(H):
    for j in range(W):
        a = A[i][j]
        if a == -1: continue
        ans += costs[a]
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> dp(10007);
  dp[0]=1;
  int n;cin>>n;
  rep(i,n)
  {
    int a;cin>>a;
    auto tdp=dp;

    rep(j,10007-a)
    {
      if(dp[j]==0)continue;
      tdp[j+a]=1;
    }
    dp=tdp;
  }
//  rep(i,100)cout<<dp[i]<<endl;
  rep(i,10007)
  {
    int ti=10006-i;
    if(dp[ti]==1&&ti%10>0)
    {
      cout<<ti<<endl;
      return 0;
    }
  }
  cout<<0<<endl;

  return 0;

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vi a(3);
    rep(i,3) cin>>a[i];
    int k; cin>>k;
    sort(rall(a));
    a[0]*=1<<k;
    cout<<a[0]+a[1]+a[2]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i, H) {
        rep(j, W){
            int A; cin >> A;
            if(A == -1) continue;
            ans += c[A][1];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
int main(int argc,char const* argv[])
{
  int x,y,z;
  int ans=0;
  cin >> x >> y >> z;
  x=x-(2*z)-y;
  ans++;
  while(x>=(y+z))
    {
      x=x-y-z;
      ans++;
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int r, d, x, i=10;
	
	scanf("%d %d %d", &r, &d, &x);
	
	x=r*x-d;
	while(i>0){
		printf("%d\n", x);
		x=r*x-d;
		i--;
	}
	
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int x,y,rem,gcd;

  scanf("%d %d",&x,&y);
  if(x>y){
    while(1){
      rem=x%y;
      if(rem==0){
	gcd=y;
	break;
	  }
      x=y;
      y=rem;
    }
  }
  else{
    while(1){
      rem=y%x;
      if(rem==0){
	gcd=x;
	break;
	  }
      y=x;
      x=rem;
    }
  }
  printf("%d\n",gcd);
  return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());
            var remain = N % 500;
            if (remain <= A)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> table(h);
    rep(i, h) {
        cin >> table[i];
    }


    rep(i, h)rep(j, w) {
        int flag = 0;
        if (i - 1 >= 0 && table[i - 1][j] == '#') flag++;
        if (i + 1 < h && table[i + 1][j] == '#') flag++;
        if (j - 1 >= 0 && table[i][j - 1] == '#') flag++;
        if (j + 1 < w && table[i][j + 1] == '#') flag++;

        if (flag == 0 && table[i][j] == '#') {
            cout << "No" << endl;
            return 0;
        }

    }
    cout << "Yes" << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3588
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

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

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int N=2e5+100;

int a[N],b[N];

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

    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    set<pii,greater<pii>> s;
    for(int i=0;i<n;i++)
        s.insert(mp(b[i],i));
    int ans=0;
    while(!s.empty())
    {
        int i=s.begin()->second;
        s.erase(s.begin());
        if(b[i]<a[i])
            cout<<-1,exit(0);
        if(b[i]==a[i])
            continue;
        int add=b[(i-1+n)%n]+b[(i+1)%n];
        int cnt=(b[i]-a[i])/add;
        if(!cnt)
            cout<<-1,exit(0);
        b[i]-=cnt*add;
        ans+=cnt;
        s.insert(mp(b[i],i));
    }
    cout<<ans;
}


Measured memory_bytes: 15872
#include<iostream>
#include<iomanip>
#include<memory>
#include<array>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int f( int x )
{
  return x * x;
}

int main()
{
  int d;
  while( cin >> d )
    {
      int area = 0;

      for ( int i = 1; i < 600/d; ++i )
        area += d * f( i * d );

      cout << area << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1160
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int x,y;
int main(){
    scanf("%d%d",&x,&y);
    if(abs(x)<abs(y)){
        int o=0;
        if(x<0)++o;
        if(y<0)++o;
        printf("%d\n",o+abs(y)-abs(x));
    }
    else{
        int o=0;
        if(x>0)++o;
        if(y>0)++o;
        printf("%d\n",o+abs(x)-abs(y));
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Xml;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    // メンバ変数---
    // -------------

    void calc()
    {
        const int MAX_A = 1000000+100; 
        var N = cin.nextInt();
        var A = cin.ArrayInt(N).ToList();
        A.Sort();
        var dict = new Dictionary<int, int>();
        foreach(var a in A)
        {
            if (dict.ContainsKey(a)) dict[a]++;
            else dict[a] = 1;
        }
        var dp = new bool[MAX_A+1];
        for (int i = 0; i < MAX_A; i++) dp[i] = true;
        int ans = 0;
        A = A.ToHashSet().ToList();
        for(int i = 0;i < A.Count; i++)
        {
            int a = A[i];
            if (dp[a] && dict[a] == 1) ans++;
            for(int j = a * 2;j < MAX_A; j += a) dp[j] = false;
        }
        Console.WriteLine(ans);
        
    }

    int Pow(int x, int y)
    {
        return (int)Math.Pow(x, (double)y);
    }

    double Pow(double x, double y)
    {
        return Math.Pow(x, y);
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 54060
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int       lint;
typedef vector<int>         vi;
typedef vector<lint>        vl;
typedef pair<int, int>      pii;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
 
#define pb(n)           push_back(n)
#define ALL(n)          (n.begin(), n.end())
#define SORT(n)         (n.begin(), n.end(), greater<lint>())       
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define M               10000000
#define MOD             10000007
#define INF             10000000000000000
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define REPL(i,a,b)     for(lint i = lint(a); i <= lint(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    vi v(n);
    int maxi = INT_MIN, mini = INT_MAX;
    REP(i, 0, n -1){
        cin>>v[i];
        maxi = max(maxi, v[i]);
        mini = min(mini, v[i]);
    }
    if(maxi < mini) mini = maxi;

    int ans = INT_MAX;
    for(int i = mini; i <= maxi; i++){
        int count = 0;
        for(int j = 0; j < v.size(); j++){
            count += (v[j] - i) * (v[j] - i);
        }
        ans = min(ans, count);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::{stdout, Write};
use std::cmp;

fn main() {
    let mut N = String::new();
    let mut A = String::new();
    io::stdin().read_line(&mut N);
    io::stdin().read_line(&mut A);
    let mut n :usize = N.trim().parse().unwrap();
    let mut vecA :Vec<usize> = A.trim().split_whitespace().map(|e| e.parse::<usize>().unwrap()).collect();
    vecA.sort();
    vecA.push(0);
    let mut count = 0;
    let mut ansVec: Vec<bool> = vec![false ; 10_usize.pow(6)+1];
    for &v in &vecA{
        ansVec[v] = true;
    }
    for i in 0..vecA.len()-1{
        if vecA[i] != vecA[i+1] || i == n-1{
            if ansVec[vecA[i]] {
                count += 1;
            }
        }
        if ansVec[vecA[i]] {
            for j in (vecA[i]..=10_usize.pow(6)).step_by(vecA[i]){
                ansVec[j] = false;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 5908
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<double> x(N);
	vector<string> u(N);
	double ans = 0;
	for (int i = 0; i < 2 * N; i++) {
		if (i % 2 == 0) {
			cin >> x[i / 2];
		}
		else if (i % 2 == 1) {
			cin >> u[(i - 1) / 2];
		}
	}
	for (int j = 0; j < N; j++) {
		if (u[j] == "JPY") {
			ans += x[j];
		}
		else {
			ans += 380000.0 * x[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int binary_op(int x,int y,int op)
{
  if(op==0)
    return(x+y);
  else if(op==1)
    return(x-y);
  else
    return(x*y);
}

main()
{
     int num[4]={1,1,1,4};
     char ops[3]="+-*";

     int i,j,k,l;
     int op1,op2,op3;

  while(4 == scanf(" %d %d %d %d",num,num+1,num+2,num+3) && (num[0] || num[1] || num[2] || num[3]))
    {
      for(i=0;i<4;i++)
       {
         for(j=0;j<4;j++)
           {
             if(j==i)continue;
             for(k=0;k<4;k++)
               {
                 if((k==i)||(k==j))continue;
                 {
                   for(l=0;l<4;l++)
                     {
                       if((l==i)||(l==j)||(l==k))continue;
                       
                       for(op1=0;op1<3;op1++)
                         for(op2=0;op2<3;op2++)
                           for(op3=0;op3<3;op3++)
                             { if(10 == binary_op(binary_op(binary_op(num[i],num[j],op1),num[k],op2),num[l],op3))
                               {                    
                                printf("((%d %c %d) %c %d ) %c %d\n"
                                       ,num[i],ops[op1],num[j],ops[op2],num[k],ops[op3],num[l]);
                                goto END;
                               }
                               if(10 == binary_op(binary_op(num[i],num[j],op1),binary_op(num[k],num[l],op2),op3))
                                 {                  
                                printf("((%d %c %d) %c (%d %c %d))\n"
                                       ,num[i],ops[op1],num[j],ops[op3],num[k],ops[op2],num[l]);
                                goto END;
                                 }
                             }
                     }
                 }
               }
           }
       }
         printf("0\n");
       END:
      ;
    }
  return(0);

}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let ans = if a < b {
        2 * b - 1
    } else if a > b {
        2 * a - 1
    } else {
        2 * a
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

typedef pair<int,int>P;

const int INF=100000;
const int di[]={-1,0,1,0},dj[]={0,-1,0,1};

int main()
{
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    int ans=0;
    rep(i,h)
    {
        cin>>s[i];
    }
    queue<P> que;
    auto bfs=[&](int sx,int sy)
    {
        vector< vector<int> >dist(h,vector<int>(w,INF));

        que.push(P(sx,sy));
        dist[sx][sy]=0;
        while(!que.empty())
        {
            P now=que.front();
            que.pop();

            rep(i,4)
            {
                int dx=now.first+di[i];
                int dy=now.second+dj[i];
                if((dx>=0 && dx<h)&&(dy>=0 && dy<w) && s[dx][dy]!='#')
                {
                    if(dist[dx][dy]!=INF)continue;
                    que.push(P(dx,dy));
                    dist[dx][dy]=dist[now.first][now.second]+1;
                    ans=max(ans,dist[dx][dy]);
                }
            }
        }

    };

    rep(i,h)rep(j,w)
    {
        if(s[i][j]!='#')
        {
            bfs(i,j);
        }
    }
    cout<<ans;
}

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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
ll n;
cin>>n;

scan(a,n);

ll XOR = 0; 
for (int i = 0; i < n; i++) XOR ^= a[i]; 
  
    
for (int i = 0; i < n; i++) a[i] = XOR ^ a[i]; 

fo(n)cout<<a[i]<<" ";

}



int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
   // cin >> t;
    t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}

Measured memory_bytes: 5268
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
#define P pair<int,int>
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

int n;
int t[111111];

int main(){
  cin>>n;
  rep(i,n)cin>>t[i];
  int ans=0;
  for(int i=1;i<n-1;i++){
    if(t[i]>t[i+1]&&t[i]>t[i-1])continue;
    if(t[i]<t[i+1]&&t[i]<t[i-1])continue;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256