akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,k,sum,n2,n1;
    cin>>a>>b>>c>>k;
    if(k>=a){
        n1=k-a;
    }
    if(n1==0)
        sum=k;
    else if(n1>0){
        n2=n1-b;
        if(n2>=0)
        sum=a-n2;
        else
            sum=a;
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
x,y= [int(i) for i in input().split()]
a1 = [1,3,5,7,8,10,12]
a2 = [4,6,9,11]
a3 = [2]
if x in a1 :
    if y in a1 :
        print("Yes")
    else :
        print("No")
elif x in a2 :
    if y in a2 :
        print("Yes")
    else :
        print("No")
elif x == 2 :
    if y == 2:
        print("Yes")
    else :
        print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        while(true){
        int x = input.nextInt();
        String n = input.next();
        int y = input.nextInt();
        if(n.equals("+")){
            System.out.println(x+y);
        }else if(n.equals("-")){
            System.out.println(x-y);
        }else if(n.equals("*")){
            System.out.println(x*y);
        }else if(n.equals("/")){
            System.out.println(x/y);
        }else if(n.equals("?")){
            break;
        }
        }
    }
}

Measured memory_bytes: 26316
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

    int mx = (B + 1) * 10;
    for (int i = 0; i <= mx; i++) {
        int a = i * 0.08;
        int b = i * 0.1;

        if (a == A && b == B) {
            cout << i << endl;

            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
favs = [ 0 for _ in range(m) ]
for i in range(n):
    line = input().split()
    k = int(line[0])
    for j in range(k):
        a = int(line[j + 1])
        favs[a - 1] += 1
sum = 0
for i in range(m):
    if favs[i] == n:
        sum += 1
print(sum)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>

const int MaxN = 200 + 5;

int N;
char Ans[MaxN];

inline char query(int l, int r, int x = 0) {
//  printf("query(%d, %d, %d)\n", l, r, x);
  printf("?");
  for (int i = l; i != r % (2 * N) + 1; i = i % (2 * N) + 1)
    printf(" %d", i);
  if (x != 0) printf(" %d", x);
  putchar('\n');
  fflush(stdout);
  static char s[10];
  scanf("%s", s + 1);
  return s[1];
}

int main() {
  scanf("%d", &N);
  char base = query(1, N);
  int lbound = 2, rbound = N + 1, ans = 0;
  while (lbound <= rbound) {
    int mid = (lbound + rbound) >> 1;
    if (query(mid, mid + N - 1) == base) lbound = mid + 1;
    else {
      rbound = mid - 1;
      ans = mid;
    }
  }
  for (int i = 1; i <= 2 * N; ++i) {
    if (ans <= i && i < ans + N - 1)
      Ans[i] = query((ans + N - 1) % (2 * N) + 1, ans - 2 == 0 ? 2 * N : ans - 2, i);
    else
      Ans[i] = query((ans - 1) % (2 * N) + 1, (ans + N - 3) % (2 * N) + 1, i);
  }
  printf("! %s\n", Ans + 1);
  fflush(stdout);
  return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,ans=0;
    cin >> n;
    ll a[n],b[n];
    for (ll i=0;i<n+1;i++){
        cin >> a[i];
    }
    for (ll i=0;i<n;i++){
        cin >> b[i];
    }
    for (ll i=0;i<n;i++){
        ans+=min(a[i],b[i]);
        b[i]=max(b[i]-a[i],0LL);
        ans+=min(a[i+1],b[i]);
        a[i+1]=max(a[i+1]-b[i],0LL);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        //ArrayList<Integer> A = new ArrayList<Integer>();
        int[] A = new int[26];
        Arrays.fill(A, 0);
        String str;

        while (sc.hasNext()) {
            str = sc.nextLine();

            str = str.toLowerCase();
            char[] c = str.toCharArray();

            for (int i=0; i<c.length; i++) {
                if ((int)c[i] >= 97 && (int)c[i] <= 122) {
                    A[(int) c[i] - 97] += 1;
                }
            }



        }

        for (int j = 0; j < 26; j++) {
            System.out.printf("%c : %d\n", (char)(j + 97), A[j]);
        }

/*
        while (true) {
            String str = sc.nextLine();


            str = str.toLowerCase();
            char[] c = str.toCharArray();

            if ((int)c[c.length-1] == 46) {
                for (int i=0; i<c.length; i++) {
                    if ((int)c[i] >= 97 && (int)c[i] <= 122) {
                        A[(int) c[i] - 97] += 1;
                    }
                }
                for (int j = 0; j < 26; j++) {
                    System.out.printf("%c : %d\n", (char)(j + 97), A[j]);
                }
                break;
            }
            else {
                for (int i=0; i<c.length; i++) {
                    if ((int)c[i] >= 97 && (int)c[i] <= 122) {
                        A[(int) c[i] - 97] += 1;
                    }
                }
            }
        }

 */
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  for(int i = 2; i < n; i++){
    if(a[i].first == a[i].second && a[i-1].first == a[i-1].second && a[i-2].first == a[i-2].second){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" <<endl;
}

Measured memory_bytes: 3544
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
l = list()
for i in range(1, n+1):
    l.append(i)
a = list(itertools.permutations(l))
print(abs(a.index(p)-a.index(q)))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
ll fact[1000007]={0}; // returns factorial of that number
bool sv[maxx]={0};    // returns if a num is prime or not
int sp[maxx]={0};     // gives smallest prime factor of the number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void Sieve() {for(int i= 2; i< maxx; i+= 2)sp[i] = 2;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    unordered_map<string,int> s,t;
    string x,y,u;
    cin>>x>>y;
    int a,b;
    cin>>a>>b;
    cin>>u;
    s[x]=a;
    s[y]=b;
    if(u==x)
      s[x]--;
    else
    {
      s[y]--;
    }
    cout<<s[x]<<" "<<s[y]<<endl;
    
  }
  //time("");
  return 0;
}

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

int main(){
  int x,n;
  cin >>x>>n;
  if(n==0){
    cout << x <<endl;
    return 0;
  }
  vector<int> p(n);
  vector<int> q(n);
  rep(i,n){
    cin >> p[i];
  }
  sort(p.begin(),p.end());

  int num;
  rep(i,n){
    if(p[i]<x){
      continue;
    }
    if(x==p[i]){
      num = i;
      break;
    }
    else cout << x<<endl;
    return 0;
  }

  int small=p[0]-1,big=p[n-1]+1;
  q[0]=p[0];
  for(int i=1;i<n;i++){
    q[i]= p[i]-p[i-1];
  }



  for(int i=num;i>=0;i--){
    if(q[i]>1){
      small = p[i]-1;
      break;
    }
  }
  for(int i=num;i<n-1;i++){
    if(q[i+1]>1){
      big = p[i]+1;
      break;
    }
  }
  //cout << "small: "<<small <<endl;
  //cout << "big: "<<big<<endl;
  if(x-small<=big-x){
    cout << small<<endl;
  }
  else cout << big << endl;

  return 0;
  }


Measured memory_bytes: 3628
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
const int MAXN=3e3+10;
const int MOD=998244353;
int a[MAXN];
ll dp[MAXN];
int main(void)
{
    sync;
    int n,s;
    cin>>n>>s;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    int res=0;
    for(int i=1;i<=n;++i)
    {
        for(int j=s;j>a[i];--j)
            dp[j]=(dp[j]+dp[j-a[i]])%MOD;
        dp[a[i]]=(dp[a[i]]+i)%MOD;
        res=(res+(n-i+1)*dp[s]%MOD)%MOD;
        dp[s]=0;
    }
    cout<<res<<endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>i;
	if(i<1000) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int MAX = 2e5 + 5;
vector <int> adj[MAX];
bool vis[MAX];
ll val[MAX];
void init()
{
	for(int i = 0; i < MAX; i++)
	{
		vis[i] = false;
		val[i] = 0;
	}
}
void dfs(int x)
{
	int i;
	vis[x] = true;
	fo(i, 0, adj[x].size())
	{
		if(!vis[adj[x][i]])
		{
			val[adj[x][i]] += val[x];
			dfs(adj[x][i]);
		}
	}
}
int main()
{
	boost;
	int n, q, i, j, a, b, r, x;
	cin >> n >> q;
	init();
	fo(i, 0, n - 1)
	{
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	while(q--)
	{
		cin >> x >> r;
		val[x] += r;
	}
	dfs(1);
	foe(i, 1, n)
	cout << val[i] << ' ';
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    string s;
    cin >> s;

    int b = 0, w = 0;
    for (auto x: s)if (x == '#')b++; else w++;
    int ans = min(w, b);
    int cura = 0, curb = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '#')curb++; else cura++;
        ans = min(ans, curb + (w - cura));
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 720
class Vector
  attr_accessor :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end

  def length()
    Math.sqrt(@x**2 + @y**2)
  end

  def self.minus(v1, v2)
    return Vector.new(v1.x - v2.x, v1.y - v2.y)
  end
end


if __FILE__ == $0
  n = gets.to_i
  n.times do 
    xa, ya, ra, xb, yb, rb = gets.split.map{|i| i.to_f}
    v1 = Vector.new(xa, ya)
    v2 = Vector.new(xb, yb)
    dist = Vector.minus(v1, v2).length()
    if (dist + rb) < ra
      puts "2"
    elsif (dist + ra) < rb
      puts "-2"
    elsif dist <= (ra + rb)
      puts "1"
    else
      puts "0"
    end
  end
end

Measured memory_bytes: 6148
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main _argv =
  
    let ab = stdin.ReadLine().Split(' ') |> Array.map int
    let a = ab.[0]
    let b = ab.[1]
    
    if (a + b) % 2  = 0 then
        printfn "%d" ((a + b) / 2)
    else
        printfn "IMPOSSIBLE"
    0 // return an integer exit code


Measured memory_bytes: 11992
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int N,H,W;
    int h,w,ans;

    cin>>N;
    cin>>H;
    cin>>W;

    h=N-(H-1);
    w=N-(W-1);
    ans=h*w;

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

Measured memory_bytes: 256
import math

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

sqrt_m = math.sqrt(m)
sqrt_m = int(sqrt_m) + 1

mod = 10**9 + 7
fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n + 31):
    fac.append(fac[i-1] * i % mod)
    inv.append(mod - inv[mod%i] * (mod//i) % mod)
    finv.append(finv[i-1] * inv[i] % mod)

def nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod


prime = []
for i in range(2, sqrt_m + 1):
    count = 0
    while m % i == 0:
        m = m // i
        count += 1
    if count > 0:
        prime.append(count)
if m > 1:
    prime.append(1)

ans = 1
for i in prime:
    ans *= nck(n-1+i, i)
    ans %= mod

print(ans)


Measured memory_bytes: 15040
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#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>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int main()
{
	int a, b, N;
	int now_a=1, now_b=1;
	int move_a, move_b;
	int move_length = 0;
	cin >> a >> b >> N;
	cin >> now_a >> now_b;
	for (size_t i = 0; i < N-1; i++)
	{
		cin >> a >> b;
		move_a = a - now_a;
		move_b = b - now_b;
		if ((move_a == abs(move_a)) == (move_b == abs(move_b)))
		{
			move_length += max(abs(move_a), abs(move_b));
		} else
		{
			move_length += abs(move_a) + abs(move_b);
		}
		now_a = a;
		now_b = b;
	}
	cout << move_length << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/29/2018
 
 15:47-
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
//const int MAX_N=1e5+1;
string S;
//LL A[MAX_N];
void solve() {
  int N=SZ(S);
  int cnt=0,res=0;
  REP(i,N) {
    if(S[i]=='S') ++cnt;
    else {
      res+=cnt==0?1:0;
      if(cnt)--cnt;
    }
  }
  cout<<2*res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>S;
  solve();
  return 0;
}


Measured memory_bytes: 1464
a = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
K = int(input())
print(a.split(',')[K-1].strip())

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

int main() {
  int r, n;
  while (cin >> r >> n, r) {
    vector<int> mh(41, 0);
    for (int i = 0; i < n; i++) {
      int xl, xr, h;
      cin >> xl >> xr >> h;
      xl += 20;
      xr += 20;
      for (int x = xl; x < xr; x++) {
        mh[x] = max(mh[x], h);
      }
    }
    double ans = 1e2;
    for (int x = 20 - r + 1; x < 20 + r; x++) {
      int l = abs(20 - x);
      int h = min(mh[x - 1], mh[x]);
      double d = r - sqrt(r * r - l * l);
      ans = min(ans, d + h);
    }
    cout << ans << endl;
  }
}



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

int main(){
    int x, y;
    cin >> x >> y;
    if(x==1 && y==1){
        cout << 1000000 << endl;
        return 0;
    }
    int ans = 0;
    if(x==1) ans += 300000;
    else if(x==2) ans += 200000;
    else if(x==3) ans += 100000;
    if(y==1) ans += 300000;
    else if(y==2) ans += 200000;
    else if(y==3) ans += 100000;

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

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[200100];
int main()
{
	int n;cin>>n;
	lint x=0,y=0,out=123456789012345678LL;
	rep(i,n){
		cin>>a[i];x+=a[i];
	}
	rep(i,n-1){
		y+=a[i];
		out=min(out,abs(y-(x-y)));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


ll n;
ll a[200005];
ll mi[2000005];
ll sign[2000005];
bool prime[1000055];
const ll mod = 998244353;
ll ME(ll x,ll nn,ll M)
{
    ll result=1;
    while(nn>0)
    {
        if(nn % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        nn=nn/2;
    }
    return result;
}
ll inv(ll x)
{
        return ME(x,mod-2,mod);
}
void sieve()
{
        memset(prime, true , sizeof prime);
        for(ll i=0;i<=1000002;i++) sign[i] = 1;
        prime[1] = prime[0] = false;
        for(ll i=2;i<=1000002;i++)
        {
                if(prime[i]){

                        for(ll j=i;j<=1000002;j+=i){
                                ll x = j/i;
                                if(x%i == 0) sign[j] = 0;
                                else sign[j] = sign[j]*-1;
                                prime[j] = false;
                        }
                }
        }

        mi[1]=1;
        for(ll i=2;i<=1000000;i++) {
                mi[i] = inv(i);
        }
}
ll cnt[2000005], dp[1000005];
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cin >> n;
        for(ll i=1;i <= n;i++) {
                cin >> a[i];
                cnt[a[i]]++;
        }
        sieve();
        ll ans = 0;

        for(ll i = 1000000 ; i>=1;i--) {
                ll sum = 0;
                ll sus = 0;
                for(ll j = i ; j <= 1000000; j += i) {
                        sum = (sum + (cnt[j]*j)%mod)%mod;
                        sus = (sus + (cnt[j]*j*j)%mod)%mod;
                }
                dp[i] = (sum*sum)%mod;
                dp[i] = (dp[i] - sus + mod)%mod;
                dp[i] = (dp[i] * mi[2])%mod;

                for(ll j=i+i; j<=1000000;j+=i) dp[i] = (dp[i] - dp[j] + mod)%mod;

                //cout << i << " --- " << dp[i] << endl;
                ans = (ans + (dp[i] * inv(i))%mod)%mod;
                //cout << ans << endl;
                //cout << dp[i] * inv(i) << endl;
        }
        cout <<ans << endl;
        return 0;
}


Measured memory_bytes: 38656
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		System.out.println(a.charAt(a.length() - 1) == b.charAt(0)
			&& b.charAt(b.length() - 1) == c.charAt(0) ? "YES" : "NO");
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if(a<=b){
		for(int i=1;i<=b;i++){
			cout<<a;
		}
		cout<<endl;
	}
	if(a>b){
		for(int i=1;i<=a;i++){
			cout<<b;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int left[26] = { 0 }, last[26] = { 0 };
    for (int i = 0; i < 26; i++) {
        left[i] = last[i] = -1;
    }
    for (int i = 0; i < s.size(); i++) {
        if (left[s[i] - 'a'] == -1) {
            left[s[i] - 'a'] = i;
            last[s[i] - 'a'] = i;
        } else {
            left[s[i] - 'a'] = max(left[s[i] - 'a'], i - last[s[i] - 'a'] - 1);
            last[s[i] - 'a'] = i;
        }
    }
    int ans = s.size();
    for (int i = 0; i < 26; i++) {
        if (last[i] != -1) {
            left[i] = max(left[i], (int)s.size() - last[i] - 1);
            ans = min(ans, left[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MOD = 1000000007;
int main() {
    int n;
    cin >> n;
    vector s(2,string());
    cin >> s[0] >> s[1];

    long ans = (s[0][0] == s[1][0] ? 3 : 6);
    for (int i=1 + (s[0][0]!=s[1][0]); i<n; i++) {
        if (s[0][i] == s[1][i]) {
            if (s[0][i-1] == s[1][i-1]) {
                ans *= 2;
            }
        } else {
            if (s[0][i-1] == s[1][i-1]) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            i++;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__() for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); debug("Time:%.4fs\n",(double)(clock()-blockTime)/CLOCKS_PER_SEC))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 1000000000
#define MOD 998244353
#define MAXN 111111
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;

int n,m,ans=0;
int memo[MAXN];
vi adj[MAXN];

int dp(int v){
	if(memo[v]!=-1)	return memo[v];
	int tmp=0;
	for(auto i:adj[v])	tmp=max(tmp,dp(i)+1);
	memo[v]=tmp;
	return tmp;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n>>m;
	
	fore(i,1,n)	memo[i]=-1;
	
	forn(i,0,m){
		int x,y;	cin>>x>>y;
		adj[y].pb(x);
	}
	
	fore(i,1,n){
		ans=max(ans,dp(i));
	}
	
	cout<<ans;
	return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t a, b, x;
  std::cin >> a >> b >> x;
  if (a != 0) {
    std::cout << b / x - (a - 1) / x << std::endl;
  } else {
    std::cout << b / x + 1 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
          

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    set <char> u;
    for(int i = 0; i < sz(s); ++i){
        u.insert(s[i]);
    }
    if(sz(u) == sz(s)){
        cout <<"yes";
    }else{
        cout << "no";
    }
}


Measured memory_bytes: 256
//topic9c
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int tarous=0,hanakos=0;
  for(int i=0;i<n;i++){
    string tarou,hanako;
    cin>>tarou>>hanako;
    if(tarou>hanako){
      tarous+=3;
    }else if(tarou<hanako){
      hanakos+=3;
    }else{
      tarous++;
      hanakos++;
    }
  }
  cout<<tarous<<' '<<hanakos<<endl;
  return 0;
}


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

public class Main {


    boolean equals (String s, String t) {
//        debug(s, t);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != '?' && s.charAt(i) != t.charAt(i)) {
                return false;
            }
        }
        return true;
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int index = -1;
        for (int i = s.length() - t.length(); i >= 0; i--) {
            if (equals(s.substring(i, i + t.length()), t)) {
                index = i;
                break;
            }
        }
//        debug(index);
        if (index == -1) {
            System.out.println("UNRESTORABLE");
            return;
        }

        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < index; i++) {
            char c = s.charAt(i);
            sb.append(c == '?' ? 'a' : c);
        }

        sb.append(t);

        for (int i = index + t.length(); i < s.length(); i++) {
            char c = s.charAt(i);
            sb.append(c == '?' ? 'a' : c);
        }

        System.out.println(sb.toString());

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, M;
  cin>>N>>M;
  int x[M], y[M];
  REP(i, M) {
    cin>>x[i]>>y[i];
    --x[i]; --y[i];
  }
  bool red[N]={};
  red[0]=true;
  int num[N];
  REP(i, N) num[i]=1;

  REP(i, M){
    --num[x[i]];
    ++num[y[i]];
    if(red[x[i]]) red[y[i]]=true;
    if(!num[x[i]]) red[x[i]]=false;
  }
  int ans=0;
  REP(i, N){
    if(red[i]) ++ans;
  }
  cout<<ans<<endl;


  return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 998244353;
const ll INF = 1001001001001001000;


int main() {
    int n, k; cin >> n >> k;
    vector<pair<int, int>> LR;
    rep(i,k) {
        int l, r; cin >> l >> r;
        LR.push_back({l,r});
    }
    ll dp[n+5]; rep(i,n+5) dp[i] = 0;
    ll imos[n+5]; rep(i,n+5) imos[i] = 0;
    dp[0] = 1;
    rep(i,n) {
        if (i > 0) {
            imos[i] = (imos[i]+imos[i-1])%mod;
        }
        dp[i] = (dp[i]+imos[i])%mod;
        for (auto pp : LR) {
            int l = pp.first;
            int r = pp.second;
            if (i+l > n) continue;
            imos[i+l] = (imos[i+l]+dp[i])%mod;
            if (i+r+1 > n) continue;
            imos[i+r+1] = (imos[i+r+1]+mod-dp[i])%mod;
        }
    }
    //rep(i,n) {printf("%lld ", dp[i]);}printf("\n");
    //rep(i,n) {printf("%lld ", imos[i]);}printf("\n");
    cout << dp[n-1] << endl;


    return 0;
}


Measured memory_bytes: 6724
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

c = a[0] + (k - a[n - 1])

d = max([a[i] - a[i - 1] for i in range(1, n)])

c = max(c,d)

print(k - c)


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

struct tree{
    int parent;
    int left;
    int right;
    int degree;
    int depth;
    int height;
    tree(){
        parent = -1;
        left   = -1;
        right  = -1;
        degree = -1;
        depth  = -1;
        height = -1;
    }
};

int find_root(const vector<tree>& T){
    for (int i = 0; i < T.size(); i++) {
        if (T[i].parent == -1) {
            return i;
        }
    }
}

void calc_depth(int id, int depth, vector<tree>& T){
    if (id == -1) return;
    T[id].depth = depth;
    calc_depth(T[id].left , depth + 1, T);
    calc_depth(T[id].right, depth + 1, T);
}

int calc_height(int id, vector<tree>& T){
    if (id == -1) return -1;
    int left_height = calc_height(T[id].left, T) + 1;
    int right_height = calc_height(T[id].right, T) + 1;
    return T[id].height = max(left_height, right_height);
}

int main(){
    int n;
    cin >> n;
    vector<tree> T(n);

    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        T[id].left      = left;
        T[id].right     = right;
        T[left].parent  = id;
        T[right].parent = id;
    }
    int root = find_root(T);
    calc_depth(root, 0, T);
    calc_height(root, T);

    for (int i = 0; i < n; i++) {
        cout << "node " << i << ": parent = " << T[i].parent;
        cout << ", sibling = ";
        if (T[i].parent == -1) {
            cout << "-1";
        } else {
            if (T[T[i].parent].left == i) {
                cout << T[T[i].parent].right;
            } else {
                cout << T[T[i].parent].left;
            }
        }
        cout << ", degree = ";
        cout << (T[i].left != -1) + (T[i].right != -1);
        cout << ", depth = " << T[i].depth;
        cout << ", height = " << T[i].height;
        cout << ", ";
        if (T[i].parent == -1) {
            cout << "root";
        } else if (T[i].left != -1 || T[i].right != -1){
            cout << "internal node";
        } else {
            cout << "leaf";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  int r; cin >> r;
  cout << r * r << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define max_n 2000
#define INF 2147483647
using namespace std;
int a[max_n+1],t[max_n+1],b[max_n+1],c[max_n+1];
template<typename T1,typename T2>void minify(T1&x,const T2&y){
	y<x&&(x=y);
}
void cal(int mn,int n,int k,int q,int&ans){
	int bcnt=0;
	for(int l,r=1,cnt=0; r<=n; cnt=0){
		for(l=r-1; a[++l]<mn&&l<=n; );
		for(r=l-1; a[++r]>=mn&&r<=n; );
    	for(int i=l-1; ++i<r; c[++cnt]=a[i]);
    	if(cnt>=k){
    		nth_element(c+1,c+cnt-k+1,c+cnt+1);
    		for(int i=0; ++i<=cnt-k+1; b[++bcnt]=c[i]);
		}
	}
	nth_element(b+1,b+q,b+bcnt+1);
    bcnt>=q&&(minify(ans,b[q]-*min_element(b+1,b+q+1)),1);
}
int main(){
	int n,k,q,ans=INF;
	scanf("%d%d%d",&n,&k,&q);
	for(int i=0; ++i<=n; t[i]=a[i])
		scanf("%d",a+i);
	stable_sort(t+1,t+n+1);
	for(int i=0; ++i<=n; cal(t[i],n,k,q,ans));
    printf("%d\n",ans);
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner input = new Scanner(System.in);
		
		int n = input.nextInt();
		
		int[] arr = new int[n];
		
		int[] b = new int[n];
		
		for(int i=0;i<n;i++) {
			arr[i] = input.nextInt();
			b[i] = arr[i];
		}
		
		Arrays.sort(b);
		
		int token = 0;
		
		for(int i=0;i<n;i++) {
			if(b[i]!=arr[i])
				token++;
		}
		
		if(token==0 || token==2)
			System.out.println("YES");
		else
			System.out.println("NO");
		
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    int N; cin >> N;
    int A[N]; rep(i,N) cin >> A[i];
    sort(A,A+N);
    int ans=0,sum=0;
    rep(i,N-1){
        sum+=A[i];
        if(sum*2>=A[i+1]) ans++;
        else ans=0;
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
typedef unsigned u;
u *G[111111],Ga[111111],Gi[111111];
u *N[111111],Gu[111111];
void add(u i,u j)
{
	if(Ga[i]==Gi[i])
	{
		if(!Ga[i])
		{
			Ga[i]=1;
			G[i]=(u*)calloc(Ga[i],sizeof(u));
			N[i]=(u*)calloc(Ga[i],sizeof(u));
		}
		else
		{
			Ga[i]<<=1;
			G[i]=(u*)realloc(G[i],Ga[i]*sizeof(u));
			N[i]=(u*)realloc(N[i],Ga[i]*sizeof(u));
		}
	}
	N[i][Gi[i]]=Gi[i];
	G[i][Gi[i]++]=j;
	return;
}
u X[111111],Y[111111],z;
int F(const void*x,const void*y){return G[z][*(u*)x]-G[z][*(u*)y];}
int main()
{
	u n,m,i,x,y;
	scanf("%u%u",&n,&m);
	for(i=-1;++i<m;)
	{
		scanf("%u%u",&x,&y);
		X[i]=x;Y[i]=y;
		add(x,y);
	}
	for(z=0;z++<n;)
	{
		qsort(N[z],Gi[z],sizeof(u),F);
		for(i=-1;++i<Gi[z];)G[z][N[z][i]]=i+1;
	}
	for(i=-1;++i<m;)
	{
		x=X[i];y=G[x][Gu[x]++];
		printf("%.6u%.6u\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 11136
import java.util.*;
import java.math.*;

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

        int keta = sc.nextInt();

        int sum = 0;
        int starcount_odd = 0;
        int starcount_even = 0;
        int nnn;

        String id = sc.next();
        if(keta%2!=0){
            keta++;
            id = "0" + id;
        }

        /*

        if(keta%2!=0){
        	ch = sc.nextchar();
        	if(ch == '*'){
        		starcount_odd++;
        	}else{
        		sum += (int)ch;
        	}
        }
        */
        // System.out.println(id);

        for(int i = 0; i < keta; i++){
        	if(i%2==0){
        		if(id.substring(i,i+1).equals("*")){
        			starcount_even++;
        		}else{
        			nnn = 2 * Integer.parseInt(id.substring(i,i+1));
                    // System.out.println(nnn);
        			if(nnn >= 10){
        				sum += nnn - 9;
        			}else{
        				sum += nnn;
        			}
        		}
        	}else{
        		if(id.substring(i,i+1).equals("*")){
        			starcount_odd++;
        		}else{
        			sum += Integer.parseInt(id.substring(i,i+1));
                    // System.out.println(Integer.parseInt(ch));                 
        		}
        	}
            // System.out.println("sum=" + sum);
        }

/*
        System.out.println(starcount_odd);
        System.out.println(starcount_even);
        System.out.println(sum);
*/
        int allstar = starcount_even+starcount_odd;
        int[] tryArray = new int[allstar];

        int k =sc.nextInt();
        int[] kouho = new int[k];
        for(int i = 0; i < k; i++){
        	kouho[i] = sc.nextInt();
        }

//how we have to try
        int allnum = 1;
        for(int i = 0; i < allstar; i++){
        	allnum *= k;
        }

        // System.out.println("allnum=" + allnum);

        int nowcheck = 0;
        int nokori = 10 - sum % 10;
        if(nokori==10){
            nokori = 0;
        }

        int answer = 0;
        int sub_i;

        for(int i = 0; i < allnum; i++){
        	sub_i = i;
        	nowcheck = 0;
        	for(int j = 0; j < allstar; j++){
        		tryArray[j] = kouho[sub_i % k];
        		sub_i /= k;
        	}
        	for(int j = 0; j < allstar; j++){
        		if(j < starcount_odd){
        			nowcheck += tryArray[j];
        		}else{
        			if(tryArray[j] < 5){
        				nowcheck += tryArray[j] * 2;
        			}else{
        				nowcheck += tryArray[j] * 2 - 9;
        			}
        		}
        	}
        	if(nowcheck%10 == nokori){
        		answer++;
        	}
        }

        System.out.println(answer);
    }
}

Measured memory_bytes: 34272
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int A, B, C; cin >> A >> B >> C;
    if (C - A - B >= 0 && 4 * A * B < (C - A - B) * (C - A - B)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

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

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, B, C;
    cin >> A >>B >> C;

    print(max(0, C - A + B));
    
}


Measured memory_bytes: 3652
v[999][4];main(i,j,n,c){for(;scanf("%d",&n),n;!c?puts("NA"):1){
for(i=0;i<n;i++)
	for(j=0;j<4;j++)scanf("%d",v[i]+j);
for(j=0;j<4;j++)scanf("%d",v[n]+j);
for(c=i=0;i<n;i++)
	if(v[i][1]<=v[n][0]&&v[i][2]<=v[n][1]&&v[i][3]<=v[n][2]&&v[i][1]*4+v[i][2]*9+v[i][3]*4<=v[n][3])
		printf("%d\n",v[i][0]),c++;
}exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;

int main() {
  int n;
  cin >> n;
  vector<int>p(n);
  rep(i,n) cin >> p.at(i);
  int cnt = 0;
  int mn = 1000000;
  rep(i,n){
    if(p.at(i) <= mn){
      cnt++;
      mn = p.at(i);
    }
  }
  cout << cnt << endl;  
  return 0;
}

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

using namespace std;

#define int long long

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

//--------



signed main(){
    int A, B;
    cin >> A >> B;
    if(B % A == 0)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << B - A << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    cout << a[n-1] << " ";
    int r = a[n-1]*2;
    int dif = a[n-1];
    int mid = (a[n-1])/2;
    REP(i,n-1){
        if(abs(a[i]-mid)<=dif){
            r = a[i];
            dif = abs(a[i]-mid);
        }
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
import itertools
s=input()
t=len(s)
seq=[0,1]
l=itertools.product(seq,repeat=t-1)
m=[]
for i in l:
  tmp=""
  for j in range(t-1):
    tmp+=s[j]+"+"*i[j]
  tmp+=s[-1]
  m.append(tmp)

ans=0  
for j in m:
  ans+=eval(j)
  
print(ans)

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

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 A, B, C, D;
    cin >> A >> B >> C >> D;
    bool tw = false;
    while(1) {
        C -= B;
        if (C <= 0) {
            tw = true;
            break;
        }
        A -= D;
        if (A <= 0) {
            break;
        }
    }
    cout << (tw? "Yes" : "No") << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);

void solve()
{
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2;	


}

int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
 
int main()
{
	int ANS=0;
	string S;
	cin >> S;
	
	for(int i=0;i<S.size();i++){
		if(S[i]!=S[S.size()-i-1]){
			ANS++;
		}
	}
	cout << ANS/2 << endl;
}

Measured memory_bytes: 256