akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	long long a, b, n;
	cin >> a >> b >> n;
	long long ans, ans1;

	ans = b*((n / b));
	ans1 = b*((n / b) + 1);
	if (ans1 - n >= ans - n)ans = n;
	else ans = ans - 1;
	if ((n % b) == 0)ans = n - 1;

	long long a1 = (a*ans) / b;
	long long a2 = a*(ans / b);
	long long aa = a1 - a2;
	long long ab=0;
	if (n >= b){
		a1 = (a*(b-1)) / b;
		a2 = a*((b - 1) / b);
		ab = a1 - a2;
	}
	if (aa > ab){
		cout << aa<< "\n";
	}
	else
		cout << ab << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
bool comp(const pair<int,int>& a,const pair<int,int>& b){
    return a.second<b.second;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>a(m);
    for(int i=0;i<m;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end(),comp);
    ll ans=1,pos=a[0].second;
    for(int i=0;i<m;i++){
        if(a[i].first>=pos){
            ans++;
            pos=a[i].second;
        }
    }
    cout<<ans<<endl;

}




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

int main(){
  int N; cin >>N;
  long long int dp[110][4][4][4]; int M=1e9+7;

  for(int i=0; i<4; i++){
    for(int j=0; j<4; j++){
      for(int k=0; k<4; k++){
        if((i==1&&j==2&&k==0)||(i==2&&j==1&&k==0)||(i==1&&j==0&&k==2)) dp[3][i][j][k]=0;
        else dp[3][i][j][k]=1;
      }
    }
  }

  for(int i=4; i<105; i++){
    for(int j=0; j<4; j++){
      for(int k=0; k<4; k++){
        for(int l=0; l<4; l++){
            dp[i][j][k][l] = 0;
          for(int m=0; m<4; m++){
            if(j==1&&k==2&&m==0) continue;
            else if(j==1&&k==2&&l==0) continue;
            else if(j==1&&k==0&&l==2) continue;
            else if(j==2&&k==1&&l==0) continue;
            else if(j==1&&l==2&&m==0) continue;
            else {
              dp[i][j][k][l] += dp[i-1][k][l][m]%M;
            }
          }
        }
      }
    }
  }

  long long int ans = 0;
  for(int i=0; i<4; i++){
    for(int j=0; j<4; j++){
      for(int k=0; k<4; k++){
        ans += dp[N][i][j][k];
        ans %= M;
      }
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, s, a[100009], sum[100009];
int main() {
	cin >> n >> s;
	for(int i = 0; i < n; i++) cin >> a[i], sum[i + 1] = sum[i] + a[i];
	int ret = 999999999;
	for(int i = 0; i < n && sum[n] - sum[i] >= s; i++) {
		int ptr = lower_bound(sum, sum + n + 1, sum[i] + s) - sum;
		ret = min(ret, ptr - i);
	}
	cout << (ret <= n ? ret : 0) << endl;
	return 0;
}

Measured memory_bytes: 3856
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll l[105];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l, l + n);
	ll ans = 0;
	for (int i = 0; i < n-2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k] && l[i] + l[j] > l[k]) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned int ui;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector<vector<T>>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector<vector<T>>>(a,vector<vector<T>>(b,vector<T>(c,t))){}};
// #include "../l/mod.h"

class E {
public:
	void solve(istream& cin, ostream& cout) {
		string S, T; cin >> S >> T;
		int N = S.size(), M = T.size();
		vector<int> SA(N+1, 0), TA(M+1, 0);
		for (int i = 0; i < N; ++i) {
			SA[i + 1] = SA[i] + (S[i] == 'A');
		}
		for (int i = 0; i < M; ++i) {
			TA[i + 1] = TA[i] + (T[i] == 'A');
		}

		int Q; cin >> Q;
		for (int q = 0; q < Q; ++q) {
			int a,b,c,d; cin >> a >> b >> c >> d;
			int sa = SA[b] - SA[a-1];
			int ta = TA[d] - TA[c-1];
			int sb = b-a+1-sa;
			int tb = d-c+1-ta;
			sa = (sa + 2*sb) % 3;
			ta = (ta + 2*tb) % 3;
			cout << (sa==ta ? "YES" : "NO") << endl;
		}
	}
};


int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	E solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 1744
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==1&&b==2|| a==2&&b==1)
        printf("3");
    else if(a==1&&b==3 || a==3&&b==1)
        printf("2");
        else if(a==2&&b==3 || a==3&&b==2)
            printf("1");

return 0;
}


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

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        int* students = new int [n + 1];
        for (int i = 2; i <= n; i++) {
            students[i] = 0;
        }
        int* a = new int [m];
        int* b = new int [m];
        for (int i = 0; i < m; i++) {
            cin >> a[i] >> b[i];
            if (a[i] == 1) {
                students[b[i]] = 1;
            }
        }
        for (int i = 0; i < m; i++) {
            if (students[a[i]] == 1 && students[b[i]] == 0) {
                students[b[i]] = 2;
            } else if (students[b[i]] == 1 && students[a[i]] == 0) {
                students[a[i]] = 2;
            }
        }
        int count = 0;
        for (int i = 2; i <= n; i++) {
            if (students[i] == 1 || students[i] == 2) {
                count++;
            }
        }
        cout << count << endl;
        delete[] students;
        delete[] a;
        delete[] b;
    }
}

Measured memory_bytes: 0
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)


def isPossible(i):
    # Get highest rank with the same score
    i = A.index(A[i])

    # If already high rank, can vote top V to keep relative ordering
    if i < P:
        return True

    numVotes = V
    # Otherwise have every judge vote for i-th first
    # Each judge has V - 1 votes remaining
    score = A[i] + M
    numVotes -= 1
    # This is the best possible rank (more voting can only decrease rank)
    # If it isn't good enough, return early
    if A[P - 1] > score:
        return False
    # Soak up votes by voting for everything after i-th
    # Since adding M to everything, they will still be smaller
    numVotes -= N - i - 1
    # Soak up more votes by voting for everything in the top P - 1
    # Our element just needs to be within top P even if it's last
    numVotes -= P - 1
    if numVotes > 0:
        # If there are any votes remaining, it will be for indices P-1 thru i-1
        # We currently have:
        # A[i] + M >= A[P-1] >= A[P-2] >= ... >= A[i - 1] > A[i]
        # We want to distribute the remaining votes so that none of these become
        # greater than A[i] + M
        remainingVotes = numVotes * M
        gap = sum(score - x for x in A[P - 1 : i])
        return gap >= remainingVotes
    return True


if not isPossible(0):
    print(0)
elif isPossible(N - 1):
    print(N)
else:
    # If i-th is possible, so is 0th to (i-1)th
    # So binary search for the last index possible
    lo = 0
    hi = N - 1
    assert isPossible(lo)
    assert not isPossible(hi)
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if isPossible(mid):
            lo = mid
        else:
            hi = mid
    assert isPossible(lo)
    assert not isPossible(lo + 1)
    # If index i is possible, there are i+1 possible problems
    print(lo + 1)


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

int main() {
    int h1, m1, h2, m2, diff = 0, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    if(m2 < m1){
        m2 = m2 + 60;
        h2--;
    }
    if(h2 < 0){
        h2 = 24 + h2;
    }
    diff = m2 - m1 - k;
    while(h2 != h1){
        diff = diff + 60;
        h1 = (h1 + 1) % 24;
    }
    cout << diff << "\n";
	return 0;
}

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

int main(){
    int A, B, ans = 0;
    string op;

    cin >> A >> op >> B;
    if(op == "+"){
        ans = A + B;
    }
    else if(op == "-"){
        ans = A - B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    print(n%k)
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#G
def G():
    n = I()

    return

#H
def H():
    n = I()

    return

#I
def I_():
    n = I()

    return

#J
def J():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39408
#include <iostream>
#include <array>
#include <cstdlib>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    const int MOD = (const int)1e9 + 7;

    if (abs(n - m) >= 2) {
        cout << 0;
    }
    else {
        int p = 1;

        for (int i = 2; i <= n; i++) {
            p = (p * 1LL * i) % MOD;
        }

        for (int i = 2; i <= m; i++) {
            p = (p * 1LL * i) % MOD;
        }

        if (abs(n - m) == 0) p = (p * 2LL) % MOD;
        cout << p;
    }

    return 0;
}


Measured memory_bytes: 256
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 3003
#include <bits/stdc++.h>
using namespace std;



int main() {
    ll n, res = 0;
    cin >> n;
    res += (n/500) *  1000;
    n %= 500;
    res += (n/5) * 5;
    cout << res << endl;
    return 0;
}


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

int main(){
	int n,a;
	int mx=0,mx2,num;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		if(a>=mx){
			mx2=mx;
			mx=a;
			num=i;
		}
		else if(a>mx2) mx2=a;
	}
	for(int i=1;i<=n;i++){
		if(num==i) printf("%d\n",mx2);
		else printf("%d\n",mx);
	}
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void func()
{
    ll n,k;
    cin>>n>>k;
    ll r=n%k;
    ll ans=min(r,abs(r-k));
    cout<<ans<<"\n";

}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r" , stdin);
    // freopen("output.txt", "w" , stdout);
    // #endif


    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }

}

Measured memory_bytes: 256
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 1001
#define most_prime_number 2000010
#define prime_MAX_arr 2000010/2
ll PRIME[2000010];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/

#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 2000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;
string s;
bool palin(ll a, ll b)
{
    a--;
    b--;
    while(a<=b)
    {
        if(s[a++]!=s[b--]) return 0;
    }
    return 1;
}
int main()
{
       ll a, b, n;
       cin >> n >> a >> b;
       ll res;
       if(!(a||b))
       {
           cout << 0 ;
           R_0;
       }
       res = (n/(a+b))*a;
        res += min(n%(a+b), a);
        cout << res;
      R_0;
}



Measured memory_bytes: 256
import itertools
max_753_numbers = {2: 0}
for i in range(3, 10):
    max_753 = pow(3, i) - (3 * pow(2, i) - 3 * pow(1, i))
    max_753_numbers[i] = max_753_numbers[i-1] + max_753


def main():
    n_str = input()
    if len(n_str) <= 2:
        print(0)
        return
    n = int(n_str)

    base_number = max_753_numbers[len(n_str)-1]
    cnt= 0
    for combi in itertools.product('357', repeat=len(n_str)):
        if '3' in combi and '5' in combi and '7' in combi:
            if int(''.join(combi)) <= n:
                cnt += 1

    ans = base_number + cnt
    print(ans)
    return



main()


Measured memory_bytes: 3064
while 1 :
	n, m = map(int,raw_input().split(" "))
	if (n, m) == (0,0):
		break
	Lon = [0 for i in range(1000 * n + 1)]
	Lat = [0 for i in range(1000 * m + 1)]
	Lon_sum = [0 for i in range(n)]
	Lat_sum = [0 for i in range(m)]
	for i in range(0,n):
		h = int(raw_input())
		for j in range(i+1):
			Lon_sum[j] += h
			Lon[Lon_sum[j]] += 1
	for i in range(0,m):
		tmp_Lat_sum = [0]
		w = int(raw_input())
		for j in range(i+1):
			Lat_sum[j] += w
			Lat[Lat_sum[j]] += 1
	max_width = min(Lon_sum[0],Lat_sum[0])
	print sum([Lon[i]*Lat[i] for i in range(1,max_width+1)])

Measured memory_bytes: 99104
# 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina1(x): return int(x) - 1


def read_ints(tozero=False):
    if tozero == False:
        return list(map(int, read().split()))
    else:
        return list(map(mina1, read().split()))


def read_a_int():
    return int(read())


from bisect import bisect_left, bisect_right
from collections import defaultdict
N = read_a_int()
A = read_ints()
tree = defaultdict(lambda: [])
for _ in ra(N - 1):
    u, v = read_ints(True)
    tree[u].append(v)
    tree[v].append(u)

LIS = []
ans = [0] * N  # 各ノードのlen(LIS)を記録


def dfs(now, p):  # 現在のノード、親
    a = A[now]
    # LISの更新
    idx = bisect_left(LIS, a)
    is_append = False
    if idx == len(LIS):
        LIS.append(a)
        is_append = True
    else:
        old = LIS[idx]   # なんの値だったか持っておく
        LIS[idx] = a  # aに更新

    ans[now] = len(LIS)  # 答えを記録
    # 次のノードを探索
    for to in tree[now]:
        if to == p:
            continue
        dfs(to, now)

    # 抜けるときにLISを復元
    if is_append:
        del LIS[idx]
    else:
        LIS[idx] = old


dfs(0, -1)
print(*ans, sep='\n')


Measured memory_bytes: 232276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,l,a[200010];
ll s1[200010],s2[200010];
int main()
{
	scanf("%d%d",&l,&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		s1[i]=s1[i-1]+a[i];
	}
	for (int i=n;i;i--)
	{
		s2[i]=s2[i+1]+(l-a[i]);
	}
	ll ans=max(l-a[1],a[n-1]);
	for (int i=1;i<n;i++)
	{
		if (i<n-i)
		{
			ans=max(ans,(s1[i]+s2[i+1]-s2[i+i+1])*2-a[i]);
			ans=max(ans,(s1[i]+s2[i+1]-s2[i+i+2])*2-(l-a[i+1]));
		}
		else if (i==n-i)
		{
			ans=max(ans,(s1[i]+s2[i+1])*2-min(a[i],l-a[i+1]));
		}
		else
		{
			ans=max(ans,(s1[i]-s1[i-(n-i)-1]+s2[i+1])*2-a[i]);
			ans=max(ans,(s1[i]-s1[i-(n-i)]+s2[i+1])*2-(l-a[i+1]));
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>

int main(void){
  int i, j;
  int n = 10;
  int sub;
  int x[n];

  for (i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }

  for (i = 0; i < n-1; i++) {
    for(j = n - 1; i < j; j--) {
      if (x[j-1] > x[j]) {
	sub = x[j];
	x[j] = x[j-1];
	x[j-1] = sub;
      }
    }
  }

  printf("%d\n%d\n%d\n", x[n-1], x[n-2], x[n-3]);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;

	vector<double> v(n);
	for(int i=0;i<n;i++)
		cin >> v.at(i);

	sort(v.begin(), v.end());
	double ans = v.at(0);
	for(int i=1;i<n;i++)
		ans = (ans + v.at(i)) / 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a,b;
  string s;
  bool f=true;
  cin >> a >> b >> s;
  for(int i=0;i<a+b+1;i++){
    if(i!=a&&s[i]=='-'){
     f=false;
     break;
    }else if(i==a&&s[i]!='-'){
     f=false;
     break;
    }
  }
  if(f) cout << "Yes\n";
  else cout << "No\n";
} 


Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string n;
    std::cin >> n;
    for (int i = 0; i < 3; ++i) {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }
    std::cout << n << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N= 1e5 + 10;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int sum[200005];
map<int, int> mp;

int main()
{
    int ans = 0;
    string s;
    cin >> s;
    mp[0] = 1;
    int len = s.size(), x = 0, cnt = 1;
    for (int i = len - 1; i >= 0;i--)
    {
        x=((s[i]-'0')*cnt+x)%2019;
        ans += mp[x];
        mp[x]++;
        cnt = cnt * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cassert>
#include<vector>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long inf = 1145141919810000;
typedef pair<int, int> P;
int h[114514];
signed main() {
	int n, k; cin >> n >> k;
	rep(i, n)cin >> h[i];
	int ans = inf;
	sort(h, h + n);
	for (int i = 0; i < n - k + 1; i++)ans = min(ans, h[i + k - 1] - h[i]);
	cout << ans << endl;

}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto x_y = readln.to!(wchar[]);
    writeln(x_y[0] > x_y[2] ? ">" : x_y[0] < x_y[2] ? "<" : "=");
}

Measured memory_bytes: 256
#define C

#ifdef C
#include <stdio.h>
#define abs(a) ((a) < 0 ? -(a) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define isdigit(a) ((a) >= '0' && (a) <= '9' ? true : false)
#endif
#ifdef Cpp
#include <bits/stdc++.h>
using namespace std;
#endif

#define freopen(x) freopen(x".in", "r", stdin);freopen(x".out", "w", stdout)
#define repl(i, t) for (int i = fi[t]; i; i = ne[i])
#define rep(i, a, b) for (int i = (int) a;  i <= (int) b; ++i)
#define per(i, a, b) for (int i = (int) a;  i >= (int) b; --i)
#define _r read()
#define readtype long long

typedef long long var;

const int INF = 0x3f3f3f3f;

readtype read();
char s[100000];

int main() {
  int n = _r;
  scanf("%s", s);
  if (n < 3200) puts("red");
  else puts(s);
  return 0;
}

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, k, q;
int a;
int r[100010];
string ans;
signed main() {
    cin >> n >> k >> q;
    for (int i=0;i<q;i++) {
        cin >> a; a--;
        r[a]++;
    }
    for (int i=0;i<n;i++){
        ans = (r[i]>q-k)? "Yes":"No";
        cout << ans << endl;
    }
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    lint X;
    cin >> X;

    double yokin = 100;
    lint n = 0;
    while (yokin < X) {
        n++;
        yokin += (lint)(yokin * 0.01);
    }
    cout << n << endl;
}

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


Measured memory_bytes: 3648
#include <stdio.h>

long w[100];
int m,n;
long minhaba=1500000L;

long meyasuhaba;

int okeruka(int haba){
        int i;
        int dan=0;
        int danhaba=0;

        for(i=0;i<n;i++){
                if(w[i]>haba)return 0;
                if(danhaba+w[i]>haba){
                        dan++;
                        danhaba=0;
                }
                danhaba+=w[i];
        }
        return dan<m ? 1 : 0;
}

main(){
        long i;
        int sum;
        long  head,tail;
        while(1){
                scanf("%d %d",&m,&n);
                if(m==0)break;
                for(i=0;i<n;i++)scanf("%ld",&w[i]);
                head=0;
                tail=1500000L;
                do{
                        //printf("head,tail %ld,%ld\n",head,tail);
                        i=(head+tail)/2;
                        if(okeruka(i))
                                tail=i-1;
                        else
                                head=i+1;
                }while(tail-head>=0);
                i--;
                while(!okeruka(i))i++;
                printf("%ld\n",i);
        }

        return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


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

  int res = 0;
  for(int i = 4; i <= m; i++){
    for(int j = 2; j <= 9; j++){
      int k = i / j;
      if(i % j == 0 && 2 <= j && j <= 9 && 2 <= k && k <= 9 && j + 10 * k <= n){
        res++;
      }
    }
  }

  cout << res << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 256
import copy
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
A = [[0 for i in range(26)]]
B1 = []
B2 = []
AA = []
ans = 0
for i in range(D):
  K = []
  for k in range(26):
    c = 0
    for j in range(26):
      if j != k:
        c += C[j] * (i+1-A[-1][j])
    an = S[i][k]-c
    K.append([an, k+1])
  K.sort()
  a = K[-1][1]
  B = copy.copy(A[-1])
  B[a-1] = i+1
  A.append(B)
  ans += K[-1][0]
  AA.append(ans)
  B1.append(a)
  B2.append(K[-2][1])

A = [0 for i in range(26)]
ans = 0
b, B1[-2] = B1[-2], B2[-2]
for i in range(D):
  k = B1[i] - 1
  c = 0
  for j in range(26):
    if j != k:
      c += C[j] * (i+1-A[j])
    an = S[i][k]-c
  ans += an
if ans < AA[-1]:
  B1[-2] = b
for i in range(D):
  print(B1[i])

Measured memory_bytes: 9812
w, h, x, y, r = map(int, input().split(" "))

ans = "Yes"

if x - r < 0:
    ans = "No"
elif x + r > w:
    ans = "No"
if y - r < 0:
    ans = "No"
elif y + r > h:
    ans = "No"

print(ans)



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

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

    map<int, vector<int>> m;
    for (int i = 0; i < n; i++) {
        vector<int> x;
        m.insert(make_pair(i, x));
        for (int j = 0; j < d; j++) {
            int xx;
            cin >> xx;
            m[i].push_back(xx);
        }
    }

    vector<int> dist;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int diff = 0;
            for (int k = 0; k < d; k++) {
                diff += (m[i][k] - m[j][k]) * (m[i][k] - m[j][k]);
            }
            dist.push_back(diff);
        }
    }

    int ans = 0;
    for (int i = 0; i < dist.size(); i++) {
        for (int j = 0; j * j <= dist[i]; j++) {
            if (j * j == dist[i]) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

c_count=0

ans=0

for i in range(n):
    ans+=b[a[i]-1]
    if i>=1 and a[i]-a[i-1]==1:
        ans+=c[a[i-1]-1]
        c_count+=1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

    int N;
    ll ans = 0;
    cin >> N;
    vector<string> S(N);
    map<string,ll> mp{};
    for(int i=0;i<N;i++) cin >> S[i];
    
    for(int i=0;i<N;i++){
        sort(S[i].begin(),S[i].end());
        if(mp.count(S[i]) == 0) {
             mp[S[i]] = 1;
        } else {
             mp[S[i]]++;
        }
    }
    
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
         if(itr->second > 1) {
             ans += (itr->second*(itr->second-1)/2);
         }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 14008
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N, X;
    cin >> N >> X;
    int L[N];
    Fp(i, 0, N) cin >> L[i];
    int i = 2, sum = 0;
    while((sum += L[i - 2]) <= X && i <= N + 1){
        i++;
    }
    cout << i - 1 << endl;
}


Measured memory_bytes: 256
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))

# 最小値付近から攻める
idx = a.index(min(a))

ans = 10**12
for i in range(k):
    right = n - idx - 1 - i
    left = max(idx - k + 1 + i, 0)
    
    q1,r1 = divmod(left, k-1)
    q2,r2 = divmod(right, k-1)
    ans = min(ans, q1 + q2 + min(r1,1) + min(r2,1))

print(ans+1)

Measured memory_bytes: 20636
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
 *	   "Winners Never Quit and Quitters Never Win".
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;

/*******************************************************************/


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t = 1, z = 1;
	// cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n + 1, 0), b(m + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		b[i] += b[i - 1];
	}
	int ans = 0, j = m;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k) break;
		int g = a[i];
		while (j > 0 && (g + b[j]) > k)
			j--;
		ans = max(ans, i + j);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6348
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define MAXN 2019
#define MOD 2019
#define LL long long
int l,r;
int cnt[MAXN];

int main()
{
	int l1,r1,ans=2019;
	scanf("%d %d",&l1,&r1);
	l=l1%MOD,r=r1%MOD;
	//printf("%d\n",r1-l1+1);
	if((r1-l1+1>=2019)||(l>r))
	{
		printf("0\n");
		return 0;
	}
	for(int i=l;i<=r;i++)
		for(int j=l;j<i;j++)
			ans=min(ans,(i*j)%MOD);
	printf("%d\n",ans);
	/*int a1=2020,a2=2020;
	for(int i=l%MOD;i<=r%MOD;i++)
	{
		int tmp=i%MOD;
		if(tmp<=a1)
		{
			a2=a1,a1=tmp;
			continue;
		}
		if(tmp<=a2)
			a2=tmp;
	}
	printf("%d\n",(a1*a2)%MOD);
	for(int i=l;i<=r;i++)
		cnt[i%MOD]++;
	if(cnt[0]>=1)
	{
		printf("0\n");
		return 0;
	}
	int a1=-1,a2=-1;
	for(int i=1;i<=2018;i++)
	{
		if(cnt[i]==0) continue;
		//bool f=0;
		while(cnt[i]--)
		{
			if(a1==-1) 
			{
				a1=i;
				continue;
			}
			else if(a2==-1) 
			{
				a2=i;
				printf("%d\n",(a1*a2)%MOD);
				return 0;
				//continue;
			}
			//else if(a1>0&&a2>0)
			//{
				//f=1;
				//break;
			//}
		}
		//if(f) break;
	}*/
	return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let i = s.find('C');
    let j = s.rfind('F');
    if i.is_some() && j.is_some() && i.unwrap() < j.unwrap() {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int n;
int A[20];

int  judge(int i ,int M){
  if(M==0) return 1;
  if(i>=n) return 0;
  int ret1 = judge(i+1,M-A[i]);
  int ret2 = judge(i+1,M);
  return ret1==1 || ret2==1;

}

int main(){
  scanf("%d",&n);
  int i;
  for (i=0;i<n;i++) scanf("%d",&A[i]);
  int m;
  scanf("%d",&m);
  int M;
  for (i=0;i<m;i++){
    scanf("%d",&M);
    if(judge(0,M))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
  
  

Measured memory_bytes: 2592
#include<iostream>
using namespace std;
#include<vector>
#define int long long int
int function(int arr[],int initial,int final,int curr,int memo[][3])
{
	if(initial>final)
	{
		if(curr>0)
		{
			return -100000000000000;
		}
		else
		  return 0;
	}
	if(memo[initial][curr]!=-1)
	  return memo[initial][curr];
	else
	{
		if(curr==0)
		{
			int val=arr[initial]+function(arr,initial+2,final,curr,memo);
			memo[initial][curr]=val;
			return memo[initial][curr];
		}
		else
		{
			int val1=arr[initial]+function(arr,initial+2,final,curr,memo);
			int val2=arr[initial]+function(arr,initial+3,final,curr-1,memo);
			memo[initial][curr]=max(val1,val2);
			return memo[initial][curr];
		}
	}
}
int function2(int arr[],int initial,int final,int curr,int memo[][2])
{
	if(initial>final)
	{
		if(curr==0&&initial==final+4)
		  return -1000000000000000;
		if(curr>0)
		   return -1000000000000000;
		return 0;
    }
    if(memo[initial][curr]!=-1)
      return memo[initial][curr];
    else
    {
		if(curr==0)
		{
			
			int x=arr[initial]+function2(arr,initial+2,final,curr,memo);
			memo[initial][curr]=x;
			return memo[initial][curr];
		}
		else
		{
			int x=arr[initial]+function2(arr,initial+2,final,curr,memo);
			int y=arr[initial]+function2(arr,initial+4,final,curr-1,memo);
			memo[initial][curr]=max(x,y);
			return memo[initial][curr];
		}
	}
}
int32_t main()
{
		int n;
		cin>>n;
		int arr[n+1];
		int j;
		for(j=1;j<=n;j++)
		{
			cin>>arr[j];
		}
		int memo[n+1][3];
		int i;
		for(i=0;i<=n;i++)
		{
			for(j=0;j<3;j++)
			{
				memo[i][j]=-1;
			}
		}
		if(n%2==0)
		{
			int val1=function(arr,1,n,1,memo);
			int val2=function(arr,2,n,0,memo);
			cout<<max(val1,val2)<<endl;
		}
		else
		{
			int val1=function(arr,1,n,2,memo);
			int val2=function(arr,2,n,1,memo);
			int val3=function(arr,3,n,0,memo);
			int answer2=max(val1,max(val2,val3));
			int memo2[n+1][2];
			for(i=0;i<=n;i++)
			{
				memo2[i][0]=-1;
				memo2[i][1]=-1;
			}
			int val4=function2(arr,1,n,1,memo2);
			answer2=max(answer2,val4);
			cout<<answer2<<endl;
		}
}


Measured memory_bytes: 22352
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, int r) {
        int res = r + max(0, 100 * (10 - n));
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, r;
    cin >> n >> r;
    Solution sol;

    cout << sol.solve(n, r) << "\n";

    return 0;
}

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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    string s1,s2;
    cin >> n;
    cin >> s1 >> s2;
    for(int i=0 ; i<n ; i++)
        cout << s1[i] << s2[i];

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import static java.lang.System.*;

public class Main extends CodingSupport {
    protected void solve() {
        Map<Integer, Integer> resultPattern = new HashMap<>();
        for(int i = 0; i <= 9; i++ ) {
            for(int j = 0; j <=9; j++ ) {
                for(int k = 0; k <=9; k++ ) {
                    for(int l = 0; l <= 9; l++ ) {
                        // List<Integer> tmpList = Arrays.asList(i, j, k, l);
                        // Collections.sort(tmpList);
                        // String key = String.format("%d%d%d%d", tmpList.get(0), tmpList.get(1), tmpList.get(2), tmpList.get(3));
                        // resultPattern.put(key, i+j+k+l);
                        Integer key = i+j+k+l;
                        if(resultPattern.containsKey(key)) {
                            resultPattern.put(key, resultPattern.get(key) + 1 );
                        } else {
                            resultPattern.put(key, 1);
                        }
                    }
                }
            }
        }
        while(sc.hasNext()) {
            int targetSum = scanInt();
            int patternCount = 0;
            if(resultPattern.get(targetSum) == null) {
                print(0);
            } else {
                print(resultPattern.get(targetSum));
            }
        }
    }
}

abstract class CodingSupport {
    protected Scanner sc;
    protected CodingSupport() {
        sc = new Scanner(in);
    }
    
    public static void main(String[] args) throws Exception {
        new Main().solve();
    }
    
    protected abstract void solve();
    
    protected void print(Object o) {
        out.println(o);
    }
    
    protected Double[] scanDoubles() {
        return 
          Arrays
              .stream(scanInts())
              .map(Integer::doubleValue)
              .toArray(Double[]::new);
    }
    
    protected Integer[] scanInts() {
       return strArrayToIntArray(sc.nextLine().split(" "));
    }
    
    protected String[] scanLineToTokens(String delimiter) {
        return sc.nextLine().split(delimiter);
    }
    
    protected int scanInt() {
       return sc.nextInt();
    }

    protected List<Integer> strArrayToIntList(String[] strArray) {
        List<Integer> intList =
          Arrays
            .stream(strArray)
            .map(Integer::valueOf)
            .collect(Collectors.toList());
        return intList;
    }
    
    protected Integer[] strArrayToIntArray(String[] strArray) {
        Integer[] intArray =
        Arrays
            .stream(strArray)
            .map(Integer::valueOf)
            .toArray(Integer[]::new);
        return intArray;
    }
}


Measured memory_bytes: 28080
package main

import (
	"fmt"
)

func main() {
	var n int
	var result uint64
	fmt.Scanf("%d", &n)
	arr := make([]uint64, n)
	for i:=0; i<n; i++ {
		fmt.Scanf("%d", &arr[i])
	}
	result = 1
	for _,value := range arr {
		if value == 0 {
			fmt.Printf("%d", 0)
			return
		}
	}
	for _,value := range arr {
		if result > 1e18/value {
			fmt.Printf("-1")
			return
		}
		result *= value
	}
	fmt.Printf("%d", result)
}


Measured memory_bytes: 6328
import math
a, b, x = map(int, input().split())
x = x / a
if x >= a*b/2:
  K = (a*b - x)/a*2
  L = K/math.sqrt(K**2+a**2)
  ans = math.degrees(math.asin(L))
  print(ans)
else:
  K = 2*x/b
  L = b/math.sqrt(K**2+b**2)
  ans = math.degrees(math.asin(L))
  print(ans)

Measured memory_bytes: 9356
//aoj 0546
#include<iostream>
#include<set>
#include<string>
using namespace std;

int n, k, ans;
set<string> nums;
string card[10], usenum[4];
bool use[10];

void find(int t = 0)
{
	if (t < k) {
		for (int i = 0; i < n; i++) {
			if (use[i]) continue;
			use[i] = true;
			usenum[t] = card[i];
			find(t + 1);
			use[i] = false;
		}
	}
	else {
		string num = "";
		for (int i = 0; i < k; i++) num += usenum[i];
		if (nums.find(num) == nums.end()) {
			ans++;
			nums.insert(num);
		}
	}
	return;
}

int main()
{
	while (true) {
		cin >> n >> k;
		if (!n && !k) break;
		ans = 0;
		nums.clear();
		for (int i = 0; i < n; i++) cin >> card[i];
		find();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1460
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	    
}

// ATCODER DP CONTEST FROG 1
 
int32_t main()
{ 
	inputoutput() ;

	int n;
	cin>>n;
	vector<int> ar(n);

	for(int i=0 ; i<n ; ++i)
		cin>>ar[i] ;

	// dp[i] -> total min cost till ar[0],ar[1]...ar[i]

	int dp[n] ;

	dp[0]=0;
	dp[1]=abs(ar[0]-ar[1]);

	for(int i=2 ; i<n ; ++i)
	{
		dp[i]=min( dp[i-2]+abs(ar[i]-ar[i-2]) , dp[i-1]+abs(ar[i]-ar[i-1]) ); 
	}
	
	cout<<dp[n-1]<<"\n";



	return 0;
}


Measured memory_bytes: 3948
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    VVI d(2,VI(3));
    REP(i,0,2) REP(j,0,3) cin >> d[i][j];
    VVLL dp(2, VLL(25'000'000+1));
    REP(i,0,2) {
        REP(j,0,3) {
            if (d[i][j] >= d[1-i][j]) continue;
            REP(k,0,25'000'000+1-d[i][j]) {
                dp[i][k+d[i][j]] = max(dp[i][k+d[i][j]], dp[i][k] + d[1-i][j] - d[i][j]); 
            }
        }
    }
    n += dp[0][n];
    n += dp[1][n];
    cout << n << endl;
}

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

Measured memory_bytes: 586240
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S;cin>>S;
    int ans=0;
    for(int i=0;i<4;i++){
        ans+=(S[i]=='+')?1:-1;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	for (int i = 0; i <= N / 4; i++) {
		for (int j = 0; j <= N / 7; j++) {
			if (4 * i + 7 * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout <<  "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		var V = GL;
		int N = I[0], K = I[1];
		var max = 0L;
		for (var l = 0; l < N; l++)
			for (var r = Max(l, N - K + l); r <= N; r++)
			{
				var x = new List<long>(V.Take(l));
				x.AddRange(V.Skip(r));
				x.Sort();
				var k = 0;
				while (k < x.Count && x[k] < 0) k++;
				max = Max(max, x.Skip(Min(k, K - N + r - l)).Sum());
			}
		WriteLine(max);
	}
}
static class Func { }


Measured memory_bytes: 13652