akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in combinations(l, 3):
    # print(i)
    a, b, c = i
    # print(a, b, c)
    if (a != b and b != c and c != a) and \
        (a+b>c and b+c > a and c+a>b):
        ans += 1

print(ans)


Measured memory_bytes: 9184
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<10;i++)
    {
        for(int j=1;j<10;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N = input_int()
S = input()

if N < 3:
    print(0)
    exit()
rs = []
gs = []
bs = []
for i in range(len(S)):
    if S[i] == 'R':
        rs.append(i)
    elif S[i] == 'G':
        gs.append(i)
    else:
        bs.append(i)
count = len(rs) * len(gs) * len(bs)
# for r in rs:
#     for g in gs:
#         for b in bs:
#             rgb = [r, g, b]
#             rgb.sort()
#             if rgb[1]-rgb[0] != rgb[2]-rgb[1]:
#                 count += 1

for skip in range(1, N // 2 + 1):
    for i in range(N - 2):
        if i + 2 * skip > N - 1:
            break
        elif S[i] == S[i + skip] or S[i + skip] == S[i + 2 * skip] or S[i] == S[i + 2 * skip]:
            continue
        else:
            count -= 1

print(count)

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

int quick(const void *a, const void *b) {
  return *(long *)a - *(long *)b;
}

int main(void) {
  int n, k;
  long h[100001], ans;

  if(scanf("%d %d", &n, &k) == 1);

  for(int i = 0; i < n; i++) {
    if(scanf("%ld", &h[i]) == 1);
  }

  qsort(h, n, sizeof(long), quick);

  ans = h[n - 1] + 1;

  for(int i = 0; i < n - k + 1; i++) {
    if(h[i + k - 1] - h[i] < ans) {
      ans = h[i + k - 1] - h[i];
    }
  }

  printf("%ld", ans);

  return 0;
}


Measured memory_bytes: 1788
import math
a,b,x = map(int, input().strip().split(' '))
if x*2 <= a*a*b:
  ans = 90 - math.degrees(math.atan(x*2/(a*b*b)))
else:
  ans = math.degrees(math.atan((a*a*b-x)*2/(a*a*a)))
print(ans)

Measured memory_bytes: 38384
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********

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

    ll cnt = 0, ans = 0;
    fn(i,s.length())
    {
        if(s[i]=='R')
            cnt++;
        else
            cnt = 0;
        ans = max(ans,cnt);
    }

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



Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean flag = true;
		if(s.charAt(0) != '1' || s.charAt(s.length() - 2) != '1' || s.charAt(s.length() - 1) != '0')
			flag = false;
		if(flag) {
			for(int i = 1; i < s.length() / 2; i++) {
				if(s.charAt(i) != s.charAt(s.length() - 2 - i)) {
					flag = false;
					break;
				}
			}
		}
		if(flag) {
			List<Node> node = new ArrayList<>();
			int from = 1;
			for(int i = 1; i < s.length(); i++) {
				if(s.charAt(i) == '1') {
					from = i + 2;
					node.add(new Node(1, i + 1));
					node.add(new Node(1, i + 2));
					break;
				} else {
					node.add(new Node(1, i + 1));
				}
			}
			for(int i = from - 1; i < s.length() - 1; i++) {
				node.add(new Node(from, i + 2));
				if(s.charAt(i) != '0') {
					from = i + 2;
				}
			}
			for(Node e : node) {
				System.out.println(e.getFrom() + " " + e.getTo());
			}
		} else {
			System.out.println(-1);
		}

	}
}

class Node {
	private int from;
	private int to;

	protected Node(int from, int to) {
		super();
		this.from = from;
		this.to = to;
	}

	public int getFrom() {
		return from;
	}

	public void setFrom(int from) {
		this.from = from;
	}

	public int getTo() {
		return to;
	}

	public void setTo(int to) {
		this.to = to;
	}

}


Measured memory_bytes: 51832
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let input = readInts()
    let (a, b, c, x, y) = (input[0], input[1], input[2] * 2, input[3], input[4])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var ans = Int.max
    
    for i in 0...max(x, y) {
        var value = c * i
        if x > i {
            value += a * (x - i)
        }
        if y > i {
            value += b * (y - i)
        }
        ans = min(ans, value)
    }
    print(ans)
}
main()


Measured memory_bytes: 13664
#include <iostream>
using namespace std;
int N,X,Y;
int count[2020];

int main(){
  cin>>N>>X>>Y;
  for(int i=1; i<=N-1; i++){
    for(int j=i+1; j<=N; j++){
      count[min(j-i,abs(X-i)+1+abs(Y-j))]++;
    }
  }
  for(int k=1;k<N;k++)cout<<count[k]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int power(int a, int b){ int S = 1; while(b--)S *= a; return S;}

int32_t main(){
	int n, r;
	int s;
	cin >> n >> r;
	if(n >= 10){
		s = r;
	}
	else{
		s = r + 100*(10 - n);
	}
	cout << s;

	return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

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

  ll ans = 0;
  for(ll i = 1; i <= n; i+=2)
  {
    ll divs = 0;
    for(ll j = 1; j <= n; j++)
    {
      if(i % j == 0)divs++;
    }
    if(divs == 8) ans++;
  }
  cout << fixed << ans << endl; 

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int N,M;
	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	vector<int> given;

	cin >> N >> M;

	if(N>0) answer+=N*(N-1);
	if(M>0) answer+=M*(M-1);
	
	cout << answer/2 << endl;

	return 0;
}



Measured memory_bytes: 3660
#include<cstdio>

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

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

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

	int a; cin >> a;
	cout << a + a*a + a*a*a << '\n';

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    bool okk=false;
    rep(i,N-1) if(A[i]>=A[i+1]) okk=true;
    if(!okk) dame;

    /*bis*/ ll low= 1 , high= 201010 ; // min-1, max+1
    while( abs(high-low)>1 ){ ll mid=(high+low)/2;
        bool ok=true;
        deque<P> dq; //位置,文字番号
        reps(i,1,N){
            if(A[i]>A[i-1]) continue;
            while(!dq.empty() and dq.back().first>A[i]){
                dq.pop_back();
            }
            if(!dq.empty() and dq.back().first==A[i]){
                dq.back().second++;
            }
            else{
                dq.emplace_back(A[i],1);
            }
            while(dq.back().second==mid){
                ll d=dq.back().first;
                if(d==1) {ok=false; i=N+1; break;}
                dq.pop_back();
                if(!dq.empty() and dq.back().first==d-1){
                    dq.back().second++;
                }
                else{
                    dq.emplace_back(d-1,1);
                }
            }
        }

        ( ok ? high : low ) = mid;
    }// if ok, okdir = mid
    cout<< high <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n1,n2,k;
    cin>>n1>>n2>>k;
    ll a[n1],b[n2];
    vector<ll> sum1(1+n1);
    vector<ll> sum2(1+n2);
    for(ll i=0;i<n1;i++)
    {
        cin>>a[i];
        sum1[i+1]=sum1[i]+a[i];
    }
    for(ll i=0;i<n2;i++)
    {
        cin>>b[i];
        sum2[i+1]=sum2[i]+b[i];
    }
    ll ans=0;
    ll j=n2;
    for(ll i=0;i<=n1;i++)
    {
        if(sum1[i]>k)
        {
            break;
        }
        while(sum2[j]>k-sum1[i])
        {
            j-=1;
        }
        ans=max(ans,i+j);
    }
    cout<<ans;
}

Measured memory_bytes: 9604
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m;
  std::cin>>n>>m;
  std::vector<ll> que(n);

  rep(i,0,m){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    que[a]++;que[b]++;
  }

  rep(i,0,n){
    if(que[i]%2){
      std::cout<<"NO";
      return 0;
    }
  }

  std::cout<<"YES";

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

const std::vector<int> dx{-1, 0, 1, 0}, dy{0, 1, 0, -1};

constexpr int INF = 1 << 30;

void solve() {
    int n, x, y;
    std::cin >> n >> x >> y;
    --x, --y;

    auto dp = vec(n, vec(n, INF));
    std::queue<std::pair<int, int>> que;
    for (int i = 0; i < n; ++i) {
        dp[i][i] = 0;
        que.emplace(i, i);
    }
    dp[x][y] = dp[y][x] = 1;
    que.emplace(x, y);
    que.emplace(y, x);

    while (!que.empty()) {
        int u, v;
        std::tie(u, v) = que.front();
        que.pop();

        for (int i = 0; i < 4; ++i) {
            int nu = u + dx[i],
                nv = v + dy[i];
            if (nu < 0 || n <= nu ||
                nv < 0 || n <= nv || dp[nu][nv] != INF) continue;
            dp[nu][nv] = dp[u][v] + 1;
            que.emplace(nu, nv);
        }
    }

    std::vector<int> cnt(n, 0);
    for (int v = 0; v < n; ++v) {
        for (int u = 0; u < v; ++u) {
            ++cnt[dp[u][v]];
        }
    }

    for (int k = 1; k < n; ++k) std::cout << cnt[k] << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 16000
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
R = list(map(int,input().split()))
SPC = []
S = []
P = []
C = []
ans = 10**5
for i in range(n):
    s,p,c = map(int,input().split())
    S.append(s)
    P.append(p)
    C.append(c)
    SPC.append([s,p,c])

you = list(SPC[0])
for delta in range(1,102-you[0]):
    S[0] = you[0] + delta
    SPC[0][0] = S[0]
    Ssort = sorted(S,reverse = True)
    Psort = sorted(P,reverse = True)
    Csort = sorted(C,reverse = True)
    pointS = {}
    pointP = {}
    pointC = {}
    for r,s,p,c in zip(R,Ssort,Psort,Csort):
        if s not in pointS:pointS[s] = r
        if p not in pointP:pointP[p] = r
        if c not in pointC:pointC[c] = r
    point = [pointS[s]+pointP[p]+pointC[c] for s,p,c in SPC]
    if sorted(point,reverse = True).index(point[0]) != 8:
        ans = min(ans,delta)
        break
S[0] = you[0]
SPC[0] = you.copy()
for delta in range(1,102-you[1]):
    P[0] = you[1] + delta
    SPC[0][1] = P[0]
    Ssort = sorted(S,reverse = True)
    Psort = sorted(P,reverse = True)
    Csort = sorted(C,reverse = True)
    pointS = {}
    pointP = {}
    pointC = {}
    for r,s,p,c in zip(R,Ssort,Psort,Csort):
        if s not in pointS:pointS[s] = r
        if p not in pointP:pointP[p] = r
        if c not in pointC:pointC[c] = r
    point = [pointS[s]+pointP[p]+pointC[c] for s,p,c in SPC]
    if sorted(point,reverse = True).index(point[0]) != 8:
        ans = min(ans,delta)
        break
P[0] = you[1]
SPC[0] = you.copy()
for delta in range(1,102-you[2]):
    C[0] = you[2] + delta
    SPC[0][2] = C[0]
    Ssort = sorted(S,reverse = True)
    Psort = sorted(P,reverse = True)
    Csort = sorted(C,reverse = True)
    pointS = {}
    pointP = {}
    pointC = {}
    for r,s,p,c in zip(R,Ssort,Psort,Csort):
        if s not in pointS:pointS[s] = r
        if p not in pointP:pointP[p] = r
        if c not in pointC:pointC[c] = r
    point = [pointS[s]+pointP[p]+pointC[c] for s,p,c in SPC]
    if sorted(point,reverse = True).index(point[0]) != 8:
        ans = min(ans,delta)
        break


print(ans if ans != 10**5 else 'Saiko')



Measured memory_bytes: 5640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>

template<std::uint_fast64_t Mod>
class ModInt{
    using u64 = uint_fast64_t;
public:
    u64 num;
    constexpr ModInt(const u64 x = 0) noexcept : num(x % Mod) {}
    constexpr u64 &value() noexcept { return num; }
    constexpr const u64 &value() const noexcept { return num; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt rhs) const noexcept {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt rhs) const noexcept {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt rhs) const noexcept {
        return ModInt(*this) /= rhs;
    }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        num += rhs.num;
        if (num >= Mod) {
            num -= Mod;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (num < rhs.num) {
            num += Mod;
        }
        num -= rhs.num;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        num = num * rhs.num % Mod;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Mod - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr ModInt &operator=(const u64 num) noexcept {
        this->num = num % Mod;
        return *this;
    }

    constexpr ModInt pow(u64 k){
        return pow(num, k);
    }

    static constexpr ModInt pow(ModInt x, u64 k){
        if(k == 0) return 1;
        if(k % 2 == 0) return pow((x * x).num % Mod, k / 2);
        else return (x * pow(x, k - 1)).num % Mod;
    }
};

template<std::uint_fast64_t Mod>
std::ostream &operator<<(std::ostream &out, const ModInt<Mod> &m)
{
    out << m.num;
    return out;
}
using namespace std;

static const int INF = 998244353;

int n;
vector<int> d;

int main(){
    cin >> n;
    d.resize(n);
    for(auto&& i : d){
        cin >> i;
    }
    if(d[0] != 0){
        cout << "0\n";
        return 0;
    }
    sort(begin(d), end(d));
    if(d[1] == 0){
        cout << "0\n";
        return 0;
    }
    vector<int> cnt(d.back() + 1);
    for(auto&& i : d){
        cnt[i]++;
    }
    vector<ModInt<INF>> dp(d.back() + 1);
    dp[0] = dp[1] = 1;
    for(int i = 2; i < cnt.size(); i++){
        dp[i] = dp[i - 1] * ModInt<INF>::pow(cnt[i - 1], cnt[i]);
    }
    cout << dp.back() << "\n";
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Data {
    double x;
    double y;

    Data(Double x, Double y) {
        this.x = x;
        this.y = y;
    }

    public double getDistance() {
        return this.x + this.y;
    }
}

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

        double n = sc.nextDouble();
        int n_sq = (int) Math.sqrt(n) + 1;

        List<Data> list = new ArrayList<>();
        for (double i = 0; i < n_sq; i++) {
            if (n % i == 0) {
                Data data = new Data(i, n / i);
                list.add(data);
            }
        }

        double distance = 1 + n;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getDistance() < distance) {
                distance = list.get(i).getDistance();
            }
        }

        System.out.println((long) distance - 2);

        sc.close();
    }
}

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

signed main(void){
    
    long long N,a;
    vector<long long> A;
    
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        A.push_back(a);
    }
    
    long long money=1000,stack=0;
    
    for(int i=0;i<N-1;i++){
        if(A[i]<A[i+1]){
            stack+=money/A[i];
            money %= A[i];
        }
        if(A[i]>A[i+1]){
            money += stack*A[i];
            stack = 0;
        }
    }
    money += stack*A[N-1];
    stack = 0;
    
    cout << money << endl;
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,l,a,b,c,q,s,t;
	vll ans;
	cin >> n >> m >> l;
	vvll v(n+1,vll(n+1,INF)),w(n+1,vll(n+1,INF));
	rep(i,m){
		cin >> a >> b >> c;
		v[a][b]=v[b][a]=c;
	}
	REP(k,1,n){
		REP(i,1,n){
			REP(j,1,n){
				v[i][j]=min(v[i][k]+v[k][j],v[i][j]);
				if(v[i][j]<=l) w[i][j]=1;
			}
		}
	}
	REP(k,1,n)REP(i,1,n)REP(j,1,n) w[i][j]=min(w[i][k]+w[k][j],w[i][j]);
	cin >> q;
	rep(i,q){
		cin >> s >> t;
		ans.pb(w[s][t]);
	}
	for(auto& e:ans){
		if(e==INF) cout << -1 << endl;
		else cout << e-1 << endl;
	}
	return 0;
}


Measured memory_bytes: 2808
import java.io.*;
import java.util.*;

public class Main {
  private static boolean solve(int[] abc) {
    Arrays.sort(abc);
    return abc[0] + abc[1] == abc[2];
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    out.println(solve(reader.nextInt(3)) ? "Yes" : "No");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
import sys

N, M = map(int, input().split())
X = [int(_) for _ in input().split()]

# 座標数よりコマ数が多ければ初期位置で条件を満たす
if N >= M:
    print(0)
    sys.exit()

# ソートする
X.sort()

# 隣り合う数の差を計算する
diff = list()
for m in range(M-1):
    diff.append(X[m+1] - X[m])

diff.sort(reverse=True)
print(sum(diff[N-1:]))

Measured memory_bytes: 13832
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    bool f[1000001];
    fill(f,f+1000001,true);
    f[0]=f[1]=false;
    for(int i=2;i*i<=1000001;i++)
        if(f[i])
            for(int j=i*i;j<=1e6;j+=i)
                f[j]=false;

    int n;
    while(cin>>n)
        cout<<count(f,f+n+1,true)<<endl;

}

Measured memory_bytes: 2136
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
using namespace std;

int main() {
	int H, W;
	cin>>H>>W;
	for(int i = 0; i < W+2; i++) cout << "#";
	cout << endl;
	for(int i = 0; i < H; i++) {
		string s; cin>>s;
		cout << '#' << s << '#' << endl;
	}
	for(int i = 0; i < W+2; i++) cout << "#";
	cout << endl;
	return 0;
}


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

#define inf 2000000000
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vl;
typedef vector<ii> vii;

#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define lb lower_bound
#define ub upper_bound
#define sz(x) (ll)x.size()
#define all(x) begin(x), end(x)
#define f0r(i, a) for (ll i=0; i<a; i++)
#define FOR(i, a) for (ll i=1; i<=a; i++)
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front

void solve()
{
    ll n,m,i,j,k,x;
    ll cnt=0,sum=0;
    string s,s1,s2,s3;
    ll a,b,c,d;

    cin>>a>>b>>c>>d;
     n=max((a*c),(a*d));
     m=max((b*c),(b*d));
    ll maxi=max(n,m);
    cout<<maxi<<endl;
    
}

int main()
{
    fastread;
    ll t=1;
    //cin>>t;
    while(t--){
            solve();
    }
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int x[100];

int main() {
  int n;
  while(input(n)) {
    inputs(x,n);
    ll ans = 1LL<<50;
    REP(i,101) {
      ll sum = 0;
      REP(j,n) {
        sum += (i-x[j])*(i-x[j]);
      }
      chmin(ans, sum);
    }
    cout << ans << endl;
  }
}


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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  int c = 0;
  REP(i, n){
    int d;
    cin >> d;
    if(i + 1 != d) ++c;
  }
  cout << (c <= 2 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    string ans = "";
    rep(i,s.length()){
        if(!ans.empty() && s[i] == 'B'){
            int n = ans.length();
            ans.erase(n-1);
        }else if(s[i] == '0'){
            ans += '0';
        }else if(s[i] == '1'){
            ans += '1';
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3588
n = int(input())
h = list(map(int, input().split()))

dp = [float('inf')] * n
dp[0] = 0
for i in range(0, n - 1):
    # print(i)
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    if i + 2 >= n:
        continue
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

print(dp[n - 1])


Measured memory_bytes: 13800
N = int(input())
a = list(map(int, input().split()))
color = set()
rainbow = 0

for n in range(N):
  if 1 <= a[n] < 400:
    color.add("gray")
  elif 400 <= a[n] < 800:
    color.add("brown")
  elif 800 <= a[n] < 1200:
    color.add("green")
  elif 1200<= a[n] < 1600:
    color.add("water")
  elif 1600 <= a[n] < 2000:
    color.add("blue")
  elif 2000 <= a[n] < 2400:
    color.add('yellow')
  elif 2400 <= a[n] < 2800:
    color.add('orange')
  elif 2800 <= a[n] < 3200:
    color.add('red')
  else:
    rainbow += 1

if len(color) == 0:
	color_min = 1 
	color_max = rainbow
else:
  color_min = len(color)
  color_max = color_min + rainbow

    
print(f'{color_min} {color_max}')


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n,m;
    cin>>n>>m;
    if(n==m)
    puts("Yes");
    else 
    puts("No");
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3620
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    char S = '0';
    int mode = 0; // 0: R, 1: L
    ll accL = 0;
    ll accR = 0;

    while(1){
        cin >> S;//cout << "S: " << S << endl;
        if(cin.eof()){
            break;
        }
        if(mode == 0 && S == 'R'){
            accL++;
        }
        if(mode == 0 && S == 'L'){
            accL--;
            mode = 1;
        }
        if(mode == 1 && S == 'L'){
            accR++;
        }
        if(mode == 1 && S == 'R'){
            accR--;
            for(ll i = 0; i < accL; i++){
                cout << 0 << ' ';
            }
            cout << (accL / 2) + 1 + (accR / 2) + (accR % 2) << ' ';
            cout << (accL / 2) + (accL % 2) + 1 + (accR / 2) << ' ';
            for(ll i = 0; i < accR; i++){
                cout << 0 << ' ';
            }
            accL = 1;
            accR = 0;
            mode = 0;
        }//cout << "accL: " << accL << " accR: " << accR << endl;
    }//cout << "accL: " << accL << " accR: " << accR << endl;  
    accR--;
    for(ll i = 0; i < accL; i++){
        cout << 0 << ' ';
    }
    cout << (accL / 2) + 1 + (accR / 2) + (accR % 2) << ' ';
    cout << (accL / 2) + (accL % 2) + 1 + (accR / 2) << ' ';
    for(ll i = 0; i < accR; i++){
        cout << 0 << ' ';
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ld=long double;
/*
heron
s=a+b+c)/2
S=sqrt(s*(s-a)*(s-b)*(s-c))

二分探索で近似とる？
2rr+(A+B)r=S

なんでちょっと少ないのかわからない。
ただ最大をだせる方法じゃないだけ？
どっかで誤差？
0.001だけずれるんだが
最大の保証がないのかなきっと。

*/
ld helon(ld a, ld b, ld c){
  ld s=(a+b+c)/2.0;
  ld S=sqrt(s*(s-a)*(s-b)*(s-c));
  return S;
}

ld sc(ld a, ld b, ld c){
  ld S, sin, cos;
  cos=(a*a+b*b-c*c)/2.0/a/b;
  cos*=cos;
  sin=sqrt(1.0-cos);
  S=a*b*sin/2.0;
  return S;
}

ld len(ld a1, ld b1, ld a2, ld b2){
  ld s;
  s=sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2));
  return s;
}

ld area(ld r, ld a, ld b){
  ld S;
  S=2.0*r*r+(a+b)*r;
  return S;
}

int main(){
  ld x1,y1,x2,y2,x3,y3; cin>>x1>>y1>>x2>>y2>>x3>>y3;
  ld a,b,c,ans=0;
  a=len(x1,y1,x2,y2);
  b=len(x2,y2,x3,y3);
  c=len(x3,y3,x1,y1);
  ld r=helon(a,b,c)/((a+b+c)/2.0);
  ans=max(a,max(b,c))*r/(2.0*r+max(a,max(b,c)));
  cout<<fixed<<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ta = 0,ao = 0;
  while(a>0){
    a -= d;
    ta++;
  }
  while(c>0){
    c -= b;
    ao++;
  }
  if(ta>=ao) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3584
n,k = map(int,input().split())
s = input()

cnt = [0]
now = '1'
for i in range(n):
    if(s[i]==now):
        cnt[-1] += 1
    else:
        now = s[i]
        cnt.append(1)
cnt = cnt + [0,0]

m = len(cnt)
if( m <= 2*k+1):
    print(n)
    exit()

l = 0
r = 2*k+1
tmp = sum(cnt[:r])
ans = tmp
while(r+2 <= m):
    tmp += cnt[r] + cnt[r+1] - cnt[l] - cnt[l+1]
    ans = max(ans,tmp)
    l += 2
    r += 2
print(ans)

Measured memory_bytes: 81388
sa = input()
sb = input()
sc = input()
a_idx = 0
b_idx = 0
c_idx = 0
string = "a"
winner = None
while(True):
    if string == "a":
        if a_idx == len(sa):
            winner = "A"
            break
        else:
            string = sa[a_idx]
            a_idx += 1
    elif string == "b":
        if b_idx == len(sb):
            winner = "B"
            break
        else:
            string = sb[b_idx]
            b_idx += 1
    elif string == "c":
        if c_idx == len(sc):
            winner = "C"
            break
        else:
            string = sc[c_idx]
            c_idx += 1
print(winner)


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

using namespace std;

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

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> v(n);
		REP(i, n) scanf("%d", &v[i]);
		sort(v.begin(), v.end());
		
		long long  ans = 0, tmp = 0;
		REP(i, n) {
			ans += tmp;
			tmp += v[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1296
#include<stdio.h>
#include<string.h>
int main(){
    char sentence[1050];
    int n, i, j;
    scanf("%d\n", &n);
    for(i = 0;i < n;i++){
	for(j = 0;j < 1050;j++){
	    sentence[j] = getchar();
	    if(sentence[j] == '\n'){
		sentence[j] = 0;
		break;
	    }
	}
	for(j = 0;j < 1050;j++){
	    if(sentence[j] == 0)break;
	    if(!strncmp(sentence + j, "Hoshino", 7)){
		sentence[j + 6] = 'a';
	    }	     
	}
	puts(sentence);
    }
    return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	
	int n;
	cin >> n;
	vector<double> a(n);
	rep(i, n) cin >> a[i];
	double sum = 0;
	rep(i, n) sum += 1.0 / a[i];
	cout << 1.0 / sum << '\n';
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main() {
    int N,M;
    cin >> N >> M;
    int A[M];
    for(int i=0;i<M;i++){
        cin >> A[i];
        N-=A[i];
    }
    if(N<0){
        cout << -1 << endl;
    }else{
        cout << N << endl;
    }


}


Measured memory_bytes: 3676
(a,b,n) = STDIN.gets.chomp.split(/ +/).map(&:to_i)
n.times do |i|
  if i % 2 == 0
    if a % 2 == 1
      a -= 1
    end
    a /= 2
    b += a
  else
    if b % 2 == 1
      b -= 1
    end
    b /= 2
    a += b
  end
end

puts "%d %d" % [ a, b ]

Measured memory_bytes: 1788
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        t: usize,
    }
    let mut count = 0;
    let mut ans = 0;
    while count < n {
        count += x;
        ans += t;
    }
    println!("{}", ans);
}


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

using namespace std;

int main()
{
  char s[64], t[64];
  int n, m;
  scanf("%s", s);
  scanf("%s", t);
  
  n = strlen(s);
  m = strlen(t);
  
  for (int i = n - 1; i >= 0; i--) {
    if (i + m - 1 >= n) continue;
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (s[i + j] != '?' && s[i + j] != t[j]) ok = false;
    }
    if (ok) {
      for (int j = 0; j < n; j++) {
        printf("%c", ((i <= j && j < i + m) ? t[j - i] : (s[j] == '?' ? 'a' : s[j])));
      }
      printf("\n");
      return 0;
    }
  }
  printf("UNRESTORABLE\n");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define f(i,k) for(i=0;i<k;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define input(i,n,arr) for(i=0;i<n;i++) cin>>j, arr.push_back(j)
#define vect_ll vector<long long>
#define vect_ll_it vector<long long>::iterator
#define pb(p) push_back(p)
#define endl "\n"
#define mod 1000000007
const ll inf = 1e18;
ll i, j, k, n, m, x, y, p, q;
int main()
{
	fast
	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll w;
		cin >> n >> w;
		ll a[n + 1][2], dp[n + 1][w + 1];
		for (i = 0; i < n; i++) for (j = 0; j < 2; j++) cin >> a[i][j];
		for (i = 0; i <= n; i++)
		{
			for (j = 0; j <= w; j++)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 0;
					continue;
				}

				if (a[i - 1][0] > j) dp[i][j] = dp[i - 1][j];
				else dp[i][j] = max(dp[i - 1][j], a[i - 1][1] + dp[i - 1][ j - a[i - 1][0]]);
				//cout << dp[i][j] << " ";
			}
			//cout << endl;
		}
		cout << dp[n][w] << endl;
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 82368