akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  double pi = 3.141592653589793;
  double R;

  cin >> R;

  cout << 2.0 * pi * R << endl;
}


Measured memory_bytes: 3792
from fractions import gcd
a,b,c,d = map(int,input().split())

cd = c * d // gcd(c, d)
ans = b - a + 1 - ((b // c - (a - 1) // c) + (b // d - (a - 1) // d) - (b // cd - (a - 1) // cd))
print(ans)


Measured memory_bytes: 5048
#include <stdio.h>

int main()
{

    int N;
    int K;
    int ans;

    scanf("%d %d\n",&N,&K);

    ans=-1;

    if(N>K){
        if(N%2==0){
            if(K<=N/2){
                ans=1;
            }
        }
        else{
            if(K<=(N+1)/2){
                ans=1;
            }
        }
    }
    else if(N==1 && K==1){
        ans=1;
    }

    if(ans>0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    
    return 0;
}

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

int main() {
  ll n; cin >> n;
  ll a = 1;
  ll mod = 1000000007;
  for (ll i = 1; i <= n; i++)
    (a *= i) %= mod;
  cout << a << endl;
}

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

using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef pair <int, int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N = 2e5 + 5;
int n, k, a[N];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	ordered_set S; S.clear();
	S.insert({0, 0});
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		res += S.order_of_key({a[i] - k * i, i});
		S.insert({a[i] - k * i, i});
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<map>
#include<vector>

int const MAXN = 2e5;
int64_t N, X, D;
typedef std::vector<std::pair<int64_t, int64_t>> IA;

int64_t calc() {
  int64_t res;
  if(D == 0) {
    if(X == 0) return 1;
    return N+1;
  }
  if(D < 0) { D = -D; X = -X; }
  std::map<int64_t, IA> m;
  for(int64_t k = 0; k <= N; ++k) {
    // S = kX + jD where j in [k(k-1)/2, k(2N-1-k)/2+1)
    int64_t rem = (k*X%D+D)%D;
    int64_t l = k*X/D + k*(k-1)/2;
    int64_t r = k*X/D + k*(N+N-k-1)/2 + 1;
    m[rem].emplace_back(l, r);
  }
  int64_t ans = 0;
  for(auto ia: m) {
    IA& v = ia.second;
    std::sort(v.begin(), v.end());
    int64_t last = -1e18;
    for(auto inter: v) {
      if(inter.second <= last) continue;
      ans += inter.second - std::max(inter.first, last);
      last = inter.second;
    }
  }
  return ans;
}

int main() {
  std::cin >> N >> X >> D;
  std::cout << calc() << std::endl;
  return 0;
}



Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    cout << max(a - 2 * b, 0) << endl;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 105;
const int MAX_W = (int)1e5 + 5;

ll dp[MAX_N][MAX_W];

int main()
{
	rep (i, MAX_N) rep (j, MAX_W) dp[i][j] = -1LL;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, W; cin >> N >> W;
	vector<int> w(N, 0), v(N, 0);
	rep (i, N){
		cin >> w[i] >> v[i];
	} // end rep

	dp[0][0] = 0LL;
	rep (i, N){
		for (int j = 0; j <= W; ++j){
			if (dp[i][j] != -1LL){
				if (j + w[i] <= W){
					dp[i+1][j + w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + (ll)v[i]);
				} // end if
				dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			} // end if
		} // end for
	} // end rep

	ll res = 0LL;
	for (int j = W; j >= 0; --j){
		res = max(res, dp[N][j]);
	} // end for

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 82304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author CodeMonk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            String s = in.next();
            int[][] next = new int[s.length() + 5][26];
            s = " " + s;
            int len = s.length() - 1;
            for (int i = 0; i < 26; i++)
                next[len + 1][i] = len + 1;
            for (int i = len; i > 0; i--) {
                for (int j = 0; j < 26; j++) {
                    next[i][j] = next[i + 1][j];
                }
                next[i][s.charAt(i) - 'a'] = i;
            }
            int dp[] = new int[len + 500];
            dp[len + 1] = 1;
            for (int i = len; i > 0; i--) {
                dp[i] = len + 1;
                for (int c = 0; c < 26; c++) {
                    dp[i] = Math.min(dp[i], dp[next[i][c] + 1] + 1);
                }
            }
            List<Character> li = new ArrayList<>();
            int cur = 1;
            while (cur <= len) {
                for (int i = 0; i < 26; i++) {
                    if (dp[cur] == dp[next[cur][i] + 1] + 1) {
                        li.add((char) (i + 'a'));
                        cur = next[cur][i] + 1;
                        break;
                    }
                }
            }
            for (Character c : li) {
                out.print(c);
            }
        }

    }
}



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

#define MOD 998244353
typedef pair<long,long> pll;

class SegmentTree{
private:
	vector<long> a;
	int n, m, h;
public:
	SegmentTree(int _n): n(_n){
		m = 1; h = 1;
		while (m < n){
			m <<= 1;
			h++;
		}
		a.resize(2*m+1, 0);
	}
	void update(int idx){
		int i = m + idx - 1;
		for (int i=m+idx-1; i > 0; i=(i-1)/2){
			a[i]++;
		}
		a[0]++;
	}
	// [p,q)
	long get(int p, int q){
		return query(p, q, 0, 0, m);
	}
	long query(int p, int q, int k, int l, int r){
		if (r <= p || q <= l) return 0;
		if (p <= l && r <= q) return a[k];
		else{
			int vl = query(p, q, k*2+1, l, (l+r)/2);
			int vr = query(p, q, k*2+2, (l+r)/2, r);
			return vl+vr;
		}
	}
	void print(){
		for (int i = 0, j = 0; i < h; ++i){
			for (int k = 0; k < (1 << i); k++, j++){
				printf("%d ", a[j]);
			}
			printf("\n");
		}
	}
	void clear(){
		fill(a.begin(), a.end(), 0);
	}
};

long pow2(int n){
	if (n == 0) return 1;
	else if (n % 2 == 1) return (pow2(n-1)*2)%MOD;
	else{
		long t = pow2(n/2);
		return (t*t)%MOD;
	}
}

int n;
long x, y, ans, tmp;
vector<pll> xy;
vector<long> ur, ul, ll, lr;

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> x >> y;
		xy.emplace_back(x, y);
	}
	sort(xy.begin(), xy.end(), [](pll a, pll b){return a.second < b.second;});
	for (int i = 0; i < n; ++i) xy[i].second = i;
	sort(xy.begin(), xy.end(), [](pll a, pll b){return a.first < b.first;});

	SegmentTree tree(n);
	ur.resize(n);
	ul.resize(n);
	ll.resize(n);
	lr.resize(n);

	for (int i = 0; i < n; ++i){
		y = xy[i].second;
		ul[i] = tree.get(y+1, n);
		ll[i] = tree.get(0, y);
		tree.update(y);
	}
	tree.clear();
	for (int i = n-1; i >= 0; --i){
		y = xy[i].second;
		ur[i] = tree.get(y+1, n);
		lr[i] = tree.get(0, y);
		tree.update(y);
	}

	ans = (pow2(n-1) * n) % MOD;
	for (int i = 0; i < n; ++i){
		long bur = pow2(ur[i]);
		long bul = pow2(ul[i]);
		long blr = pow2(lr[i]);
		long bll = pow2(ll[i]);
		tmp = ((((((bur - 1)*(bll - 1)) % MOD)*bul) % MOD)*blr) % MOD;
		ans = (ans + tmp) % MOD;
		tmp = ((((((bul - 1)*(blr - 1)) % MOD)*bur) % MOD)*bll) % MOD;
		ans = (ans + tmp) % MOD;
		tmp = ((((((bur - 1)*(bll - 1)) % MOD)*(bul - 1)) % MOD)*(blr - 1)) % MOD;
		ans = (ans + (MOD - tmp)) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 14444
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll N,M,K,C;
ll a,b,c,d;
string s;
int main(){
    cin>>N>>a>>b;

    cout<<min(N*a,b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<map>
#include<cctype>
#include<sstream>
using namespace std;

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector< int > ev[501];
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		ev[x].emplace_back(y);
	}
	for (int i = 0; i <= N; i++) {
		sort(begin(ev[i]), end(ev[i]));
	}
	while (Q--) {
		int p, q;
		cin >> p >> q;
		int ret = 0;
		for (int i = p; i <= q; i++) {
			ret += upper_bound(begin(ev[i]), end(ev[i]), q) - begin(ev[i]);
		}
		cout << ret << endl;
	}

}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a[10005];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m) cin >> a[i];
    ll sum=0;
    rep(i,m) sum+=a[i];

    if(n-sum>=0){
        cout << n-sum << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include"bits/stdc++.h"
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (U == S) {
		A -= 1;
	}
	else {
		B -= 1;
	}
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#include <queue>
#define ll long long
using namespace std;

int main() {
    int s, w;
    cin>>s>>w;
    if (w >= s) {
        cout<<"unsafe";
    }else cout<<"safe";
}


Measured memory_bytes: 3624
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            for (int i = 0; i < S.Length - 1; i++)
            {
                if (S[i] == S[i + 1])
                {
                    Console.Write("Bad");
                    return;
                }
            }
            Console.Write("Good");
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC129.B();
        //    temp.Run();
        //}

    }
}

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

using namespace std;

int main()
{
	vector<int> isp(1299710,1);
	isp[0]=isp[1]=0;
	for(int i=2;i*i<isp.size();i++)
		for(int j=i*i;j<isp.size();j+=i)
			isp[j]=0;
	
	for(int k;cin>>k,k;){
		int i,j;
		for(i=k;!isp[i];i--);
		for(j=k;!isp[j];j++);
		cout<<j-i<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 6220
A=int(input())
B=int(input())
C=int(input())
X=int(input())
n=0
for i in range(A+1):
    Y=500*i
    for j in range(B+1):
        Y+=500*i+100*j
        for k in range(C+1):
            Y=500*i+100*j+50*k
            # print("i,j,k=",i,j,k)
            # print("Y=",Y)
            if Y==X:
                n+=1

print(n)

Measured memory_bytes: 3060
A,B,C,K=map(int,input().split())
takahashi=A
nakahashi=B
teihashi=C
takahashi1=0
nakahashi1=0
teihashi1=0
unfair=False
if A==B and B==C:
    print("0")
else:
    if K%2==0:
        print(takahashi-nakahashi)
    else:
        print(-(takahashi-nakahashi))



Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	S := make([]string, N)
	for i := 0; i < N; i++ {
		S[i] = sc.nextStr()
	}
	setTotal := make(map[rune]int)
	for _, r := range S[0] {
		setTotal[r]++
	}
	for i := 1; i < N; i++ {
		set := make(map[rune]int)
		for _, r := range S[i] {
			set[r]++
		}
		newTotal := make(map[rune]int)
		for k, count := range set {
			newTotal[k] = min(count, setTotal[k])
		}
		setTotal = newTotal
	}
	ans := []rune{}
	for k, count := range setTotal {
		for i := 0; i < count; i++ {
			ans = append(ans, k)
		}
	}
	sort.Sort(RuneSlice(ans))

	fmt.Fprintln(wtr, string(ans))
	wtr.Flush()
}


Measured memory_bytes: 768
#include <stdio.h>
#define SWAP(a,b) { int temp = a; a = b; b = temp; }
#define N 100

int main(){
  int minj, n, i, j, cont=0;
  int a[N];

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

  
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(a[minj] > a[j]){
	minj = j;
      }
    }
    
    if(minj != i){
      SWAP(a[i],a[minj]);
      cont++;
    }
  
  }
  

  for(i=0;i<n;i++){
    if (i!=0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cont);
  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>

long long N ,M;
long long souwa = 0;
long long money = 0;
std::vector<std::pair<long long, long long> > C;

int main()
{
  std::cin >> N >> M;
  for (long long i = 0; i < N; i++){
    long long A, B;
    std::cin >> A >> B;
    C.push_back(std::make_pair(A, B));
  }

  std::sort(C.begin(), C.end());

  for (long long i=0; i < N; i++){
    if (souwa + C[i].second > M){
      money += C[i].first * (M-souwa);
    }
    else{
      money += C[i].first * C[i].second;
    }
    souwa += C[i].second;
    if (souwa >= M){
      break;
    }
  }
  std::cout << money;
}


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

int main() {
int n;
cin>>n;
vector<int> a(100000,0);
for(int i=0;i<n;i++){
  int x;
  cin>>x;
  a[x]++;
}
int minn =-1;
for(int i=1;i<100000;i++){
  int www=a[i-1]+a[i]+a[i+1];
  minn=max(minn,www);
}
cout<<minn<<endl;
  return 0;
}



Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
ll lcm(ll l,ll a){
    return a/__gcd(l,a)*l;
}


int main(){
    //int a,b,c;cin >> a >> b >> c;
    //int a,b;cin >> a >> b;
    double a;cin >> a;
    //string s;cin >> s;
    cout << 2*(a+0.0)*3.1415926535 << endl;
}


Measured memory_bytes: 3788
function Main(input) {
  var count = Number(input.split('\n')[0]);
  var numbers = input.split('\n')[1].split(' ');
  var result = 0;
  var ary = numbers.slice();
  while(true) {
    var copy = ary.slice();
    ary = [];
    var hasOdd = false;
    for (var i = 0; i < count; i++) {
      if (Number(copy[i]) % 2 !== 0) {
        hasOdd = true;
      }
    }
    if (hasOdd) {
      break;
    }
    for (var i = 0; i < count; i++) {
      ary.push(Number(copy[i]) / 2)
    }
    result++;
  }
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void) {
  int k;
  string s;
  cin>>k;
  cin>>s;
  
  if(s.size()>k){
  	s = s.substr(0,k)+"...";
  }
  
  cout<<s<<endl;
  
  return 0;
  
}

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.141592653589793238462643383279;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} init;

string X;
signed main() {
    cin >> X;
    int ans = X.length(), nS = 0;
    rep(i, X.length()) {
        if (X[i] == 'S') {
            nS++;
        } else {
            if (nS > 0) { ans -= 2, nS--; }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    ll n, m;
    cin >> n >> m;
    ll lmx = 1, rmn = n;
    rep(i,m) {
        ll l, r;
        cin >> l >> r;
        lmx = max(lmx, l);
        rmn = min(rmn, r);
    } 
    ll ans = rmn - lmx + 1;
    if(ans > 0) cout << ans << endl;
    else cout << 0 << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n,i,j,mx=0,c=0;
  cin>>n;
  vector<int> h(n);
  for(i=0;i<n;i++) cin>>h.at(i);
  for(i=0;i<n;i++){
    if(h[i]>=mx){
      c++;
      mx=h[i];
    }

  }
  cout<<c<<endl;

}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long ans = long.max;
    foreach (i; -100 .. 101)
    {
        ans = A.map!(a => (a - i) ^^ 2).sum().min(ans);
    }
    writeln(ans);
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello {
    public static void Main () {
        var s = Console.ReadLine ().Split ();
        var n = int.Parse (s[0]);
        var k = int.Parse (s[1]);
        var p = Console.ReadLine ().Trim ().Split ().Select (int.Parse).ToArray ();
        var pexp=new double[n];
        var spex=new double[n+1];
        var ans = 0.0;
        spex[0]=0;
        for (var i = 0; i < n; i++) {
            pexp[i] = (1.0+(double)p[i])/2.0;
            spex[i+1]=pexp[i]+spex[i];
            if(i+1>=k){
                if(ans<spex[i+1]-spex[i+1-k]) ans=spex[i+1]-spex[i+1-k];
            }
        }
        Console.WriteLine (ans);
    }
}


Measured memory_bytes: 33244
#include <iostream>
using namespace std;
int main()
{
  int n,weight;
  cin>>n>>weight;
  int w[n+1]={0};
  int v[n+1]={0};
  for(int i=1;i<=n;i++)
  {
    cin>>v[i]>>w[i];
  }

  int value[n+1][weight+1];
  for(int i=0;i<=n;i++)
    for(int j=0;j<=weight;j++)
      value[i][j]=0;

  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=weight;j++)
    {
      if(j-w[i]<0)
        value[i][j]=value[i-1][j];
      else
        if(value[i-1][j]<=v[i]+value[i-1][j-w[i]])
          value[i][j]=v[i]+value[i-1][j-w[i]];
        else
          value[i][j]=value[i-1][j];
    }
  }

  cout<<value[n][weight]<<endl;
  return 0;
}

Measured memory_bytes: 7044
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n")[0].split(""),n=t.length,r=1,o="",u="",i=0;i<n-1;i++)(o+=t[i])!=u&&(r+=1,u=o,o="");u==(o+=t[n-1])&&(r-=1),console.log(r)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 11340
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N;
    cin >> N;
    ll A[N];
    rep(i,N) cin >> A[i];
    ll L[N];
    rep(i,N){
        if(i==0) L[0] = A[0];
        else L[i] = __gcd(L[i-1],A[i]);
    }
    ll R[N];
    rep(i,N){
        if(i==0) R[N-1] = A[N-1];
        else R[N-1-i] = __gcd(R[N-i],A[N-1-i]);
    }
    ll G[N];
    ll out = 0;
    rep(i,N){
        if(i==0) G[0] = R[1];
        else if(i==N-1) G[N-1] = L[N-2];
        else G[i] = __gcd(L[i-1],R[i+1]);
        out = max(out,G[i]);
    }
    cout << out << endl;
    return 0;
}


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

int main() {
  char b;
  cin >> b;

  if (b == 'A')
  cout << 'T' << endl;
  else if (b == 'C')
  cout << 'G' << endl;
  else if (b == 'G')
  cout << 'C' << endl;
  else
  cout << 'A' << endl;
}

Measured memory_bytes: 3636
import math

def input_num():
	ls = input().strip().split(" ")
	return [int(e) for e in ls]

n,k = input_num()
a_ls = input_num()

d = {}
now = 1
result_ls = [now]
cnt = 0
while True:
	d[now] = cnt
	now = a_ls[now-1]
	if now in d:
		bun = d[now]
		break
	result_ls.append(now)
	cnt += 1


if k < bun:
	print(result_ls[k])
else:
	jun = len(result_ls) - bun
	idx = bun + (k-bun)%jun
	print(result_ls[idx])


Measured memory_bytes: 39048
// ConsoleApplication63.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<cmath>
#include<cstring>
#include<iomanip>
using namespace std;
int main()
{
    int h, a,aa;
	while (cin>>h>>a)
	{
		aa = 0;
		while (h > 0)
		{
			h -= a;
			aa++;
		}
		cout << aa << "\n";
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N ;
    cin >> N ;
    vector<ll> A(N, 0);
    vector<ll> S(N, 0);
    
    rep(i, N){
        cin >> A[i];
    }
    
    S[N-1] = A[N-1];
    for(ll i = A.size() - 2; i >= 0; i --){
        S[i] = S[i + 1] + A[i];
        S[i] %= MOD;
    }
    
    ll ans = 0;
    
    rep(i, N-1){
        ans += A[i] * S[i + 1];
        ans %= MOD;
    }
    
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 6360
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int inf = 2e9 + 34333;
//const ll mod = 1e9 + 7;
const int maxn = 2e5 + 55;

vector <pair <ll, ll>> e;

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; ++i)
    {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        if (x > y) swap(x, y);
        e.pb({x, y});
    }
    ll ans = 0;
    ll V = 0;
    ll E = 0;
    for(ll i = 0; i < n; ++i)
        V += ((n - i) * (n - i + 1)) / 2;
    for(int i = 0; i < n - 1; ++i)
        E += (e[i].F + 1) * (n - e[i].S);
    cout << V - E;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt(),A[]=new int[n];
		for(int i=0;i<n;i++) {
			A[i]=Integer.parseInt(cin.next());
		}
		
		int B[]=countingSort(A);
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<B.length-1;i++) {
			out.print(B[i]+" ");
		}
		out.println(B[B.length-1]);
		out.flush();
	}
	
	static int[] countingSort(int A[]) {
		
		int m=-1,size=A.length;
		for(int i=0;i<size;i++) {
			m=Math.max(m, A[i]);
		}
		
		int C[]=new int[m+1];
		for(int i=0;i<size;i++) {
			C[A[i]]++;
		}
		
		for(int i=1;i<m+1;i++) {
			C[i]+=C[i-1];
		}
		
		int B[]=new int[size];
		for(int i=size-1;i>=0;i--) {
			int v=A[i];
			B[C[v]-1]=v;
			C[v]--;
		}
		
		return B;
	}

}



Measured memory_bytes: 310404
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	ld w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed << setprecision(10);
	cout << (w * h) / 2 << " ";
	int W = w;
	int H = h;

	if (W % 2 == 0 && H % 2 == 0 && x == w / 2 && y ==  h / 2)
	{
		cout << 1 << en;
	}
	else
	{
		cout << 0 << en;
	}




	return 0;
}



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

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

LL calc(LL rest, LL C, LL D) {
    LL d = abs(D - C);
    LL n2;
    if(d == 0) {
        if(rest > 0) {
            n2 = 10000000000LL;
        } else {
            n2 = 0;
        }
    } else {
        n2 = ((rest + d - 1) / d) * 2;
    }
    return n2;
}

bool solve(LL N, LL A, LL B, LL C, LL D) {
    if(D == 0) {
        return A == B;
    }

    N--;
    LL L = abs(B - A);
    {
        LL n1 = L / max(C, 1LL);
        LL rest; 
        if((N - n1 + 1000000000LL) % 2 == 0) {
            rest = max(0LL, L - n1 * D);
        } else {
            rest = max(0LL, (n1+1) * C - L);
        }
        if(n1 + calc(rest, C, D) <= N) {
            return true;
        }
    }
    {
        LL n1 = L / D;
        LL rest = L - n1 * D;
        if((N - n1 + 1000000000LL) % 2 == 0) {
            if(n1 + calc(rest, C, D) <= N) {
                return true;
            }
        } else {
            if(n1 + 1 <= N && C <= rest && rest <= D) {
                return true;
            }
        }
    }
    return false;
}
int main(){
    iostream_init();
    LL N, A, B, C, D;
    while(cin >> N >> A >> B >> C >> D) {
        cout << (solve(N, A, B, C, D) ? "YES" : "NO") << endl;
    }
    return 0;
}



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

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int t = sc.nextInt();
		for (int z = 0; z < t; z++) {
			int n = sc.nextInt();
			String s = sc.next();
			int count1 = 0, count2 = 0;
			count1 += (s.charAt(0) == 'Y') ? 1 : 0;
			count1 += (s.charAt(2*n-1) == 'Y') ? 1 : 0;
			for (int i = 1; i < 2*n-2; i += 2) {
				if (s.charAt(i) == 'Y' || s.charAt(i+1) == 'Y')
					count1++;
			}
			for (int i = 2*n+1; i < 4*n-2; i += 2) {
				if (s.charAt(i) == 'Y' || s.charAt(i+1) == 'Y')
					count2++;
			}
			if (s.charAt(2*n) == 'Y') count2++;
			if (s.charAt(4*n-1) == 'Y') count2++;
			if (count2 == 0) {
				out.println(count1+n);
			} else {
				int i = 0;
				while (i < 2*n) {
					if (s.charAt(i) == 'N' && s.charAt(i+2*n) == 'Y') {
						count1++;
						break;
					} else if ((s.charAt(i) == 'Y' && s.charAt(i+2*n) == 'Y') || (s.charAt(i) == 'Y' && s.charAt(i+2*n) == 'N')) {
						break;
					}
					i++;
				}
				i = 2*n-1;
				while (i >= 0) {
					if (s.charAt(i) == 'N' && s.charAt(i+2*n) == 'Y') {
						count1++;
						break;
					} else if ((s.charAt(i) == 'Y' && s.charAt(i+2*n) == 'Y') || (s.charAt(i) == 'Y' && s.charAt(i+2*n) == 'N')) {
						break;
					}
					i--;
				}
				out.println(count1+count2+n);
			}
			
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 25676
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    boolean flag = false;
    for (int i = 1; i <= b / k; i++) {
      if (k * i >= a && k * i <= b) {
        flag = true;
      }
    }
    System.out.println(flag ? "OK" : "NG");
  }

}

Measured memory_bytes: 35864
#include <stdio.h>

int main(void) {
  int y1, m1, d1, y2, m2, d2, ans;
  scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
  if(y1 > y2) {
    int t;
    t = y1, y1 = y2, y2 = t;
    t = m1, m1 = m2, m2 = t;
    t = d1, d1 = d2, d2 = t;
  }
  if(y1 != y2) {
    ans = y2 - y1;
    if(m1 < m2) printf("%d\n", ans + 1);
    else if(m1 > m2) printf("%d\n", ans);
    else {
     if(d1 < d2) printf("%d\n", ans + 1);
     else printf("%d\n", ans);
    }
  } else {
    if(m1 == m2 && d1 == d2) printf("0\n");
    else printf("1\n");
  }
  return 0;
}


Measured memory_bytes: 2708
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  rec c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const ll inf=1e18;
#define to first
#define cost second
typedef pair<int,int> edge;
vector<edge> lj[1010];
ll dis[1010];int prpr[1010],n=read(),m=read();

void bfs(){
queue<int> q;
q.push(1);
for (;!q.empty();){
  int u=q.front();q.pop();
  if (prpr[u]>=3e3) continue;
  for (edge e:lj[u]){
    if (dis[e.to]>dis[u]+e.cost){
      dis[e.to]=dis[u]+e.cost;
      prpr[e.to]++;
      q.push(e.to);
	  }
    }
  }
}

int main(){
int i;
for (i=1;i<=m;++i){
  int u=read(),v=read(),c=-read();
  lj[u].push_back(edge(v,c));
  }
fill(dis+2,dis+n+1,inf);
bfs();
prpr[n]>n?puts("inf"):write(-dis[n]);
}

Measured memory_bytes: 1280
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__


void solve(void){
  
  string S;
  int N;
  
  cin >> N >> S;
    
  REP(i,S.size()){
    if(S[i]+N>'Z'){S[i]=S[i]+N-26;}else{S[i]=S[i]+N;}
  }
  
  cout << S << endl;
  
  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
            long[] A = cin.ArrayLong(N);
            long B = 1;
            Array.Sort(A);
            if (A[0] == 0)
            {
                Console.WriteLine("0");
            }
            else
            {
                for(int i = 0; i < N; i++)
                {
                    if(A[i]<= 1000000000000000000 / B)
                    {
                        B *= A[i];
                    }
                    else
                    {
                        Console.WriteLine("-1");
                        return;
                    }
                }
                Console.WriteLine(B);
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

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

        public long NextLong()
        {
            return long.Parse(Next());
        }

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

        public double NextDouble()
        {
            return double.Parse(Next());
        }


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



Measured memory_bytes: 41020
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
 

int n, m, q;
vector<int> a, b, c, d;
int ans=0;

void dfs(vector<int> A){
    if(A.size()==n+1){
        int now=0;
        REP(i, q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}
int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    REP(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

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

int a,b;

int main()
{
    while (~scanf("%d%d",&a,&b)) {
        int x=gcd(a,b);
        int y=1ll*a*b/x;
        printf("%d %d\n",x,y);
    }
}


Measured memory_bytes: 3068
using System;

class Program
{
    static void Main(string[] args)
    {

        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = a + b;

        string ans = (a % 3 == 0 || b % 3 == 0 || c % 3 ==0)? "Possible" : "Impossible";

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#深さ優先探索
import sys
input = sys.stdin.readline
from collections import deque

#グラフ作成(無向グラフでは#を消す)
N = int(input())
graph = [deque([]) for _ in range(N+1)]
for _ in range(N):
    u, k, *v = [int(x) for x in input().split()]
    v.sort()
    for i in v:
        graph[u].append(i)
        #graph[i].append(u)
        
time = 0
arrive_time = [-1] * (N+1) #到着時刻
finish_time = [-1] * (N+1) #終了時刻

def dfs(v):
    global time
    time += 1
    stack = [v]
    arrive_time[v] = time
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if arrive_time[w] < 0:
                time += 1
                arrive_time[w] = time
                stack.append(w)
        else:
            time += 1
            finish_time[v] = time
            stack.pop()
    return [arrive_time, finish_time]


# 孤立している頂点対策
for i in range(N):
    if arrive_time[i+1] < 0:
        ans = dfs(i+1)

# 頂点番号、発見時刻、完了時刻
for i in range(N):
    temp = [i + 1, ans[0][i+1], ans[1][i+1]]
    print(* temp)


Measured memory_bytes: 6084
import java.io.*;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0")) {
				int n = Integer.parseInt(buf);
				int time[] = new int[n];
				long sum = 0;
				for (int i=0;i<n;i++) {
					time[i] = Integer.parseInt(br.readLine());
				}
				Arrays.sort(time);
				int count = n-1;
				while (count>=1) {
					sum += time[n-1-count]*count;
					count--;
				}
				System.out.println(sum);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 25324
#include <iostream>
#include <algorithm>
#include <cstring>

#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int INF=1e9;
int n;
int r[102],c[102];
int p[102];

int dp[102][102];
// [i,j)
int dfs(int i,int j) {
    //cout<<i<<", "<<j<<endl;
    if(dp[i][j]!=-1) return dp[i][j];
    if(j-i==1) return r[i]*c[i]*c[j-1];
    if(i==j) return 0;
    int ret=INF;
    for(int k=i+1;k<j;k++) {
        //ret=min(ret,dfs(i,k)+dfs(k,j)+r[i]*c[k]*c[j-1]);
        ret=min(ret,dfs(i,k)+dfs(k,j)+p[i]*p[k]*p[j]);
    }

    return dp[i][j]=ret;
}

int main() {
    memset(dp,-1,sizeof(dp));
    cin>>n;
    //rep(i,n) cin>>r[i]>>c[i];
    rep(i,n+1) if(i) cin>>p[i-1]>>p[i];
    cout<<dfs(0,n)<<endl;
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=110000;
int N;
int S[MAXN];

ll get_sum_naive(int s,int d,int k) {
	ll sum=0;
	rep(i,0,k+1) sum+=S[s+i*d];
	return sum;
}

ll check_naive(int A,int d) {
	if (A<=d) return 0;
	int k=(N-1-A)/d;
	if (A%d==0 && k>=A/d) return 0;
	return get_sum_naive(0,d,k) + get_sum_naive(A,d,k);
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N;
	rep(i,0,N) cin>>S[i];
	
	ll res=0;
	for (int d=1; d*d<=N; ++d) {
		vector<vector<ll>> sums(d);
		rep(i,0,N) {
			ll v=S[i];
			if (!sums[i%d].empty()) v+=sums[i%d].back();
			sums[i%d].push_back(v);
		}
		
		rep(A,1,N-1) if ((N-1-A)%d==0) {
			int k=(N-1-A)/d;
			res=max(res,check_naive(A,k));
			
			if (A<=d || (A%d==0 && k>=A/d)) continue;
			
			ll sum=sums[0][k];
			sum+=sums[A%d][A/d+k];
			if (A/d>0) sum-=sums[A%d][A/d-1];
			res=max(res,sum);
		}
	}
		
	cout<<res<<"\n";
}


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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main(){
    int N, M, sum = 0;
    int xi[110000], Li[110000];

    cin >> N >> M;
    rep(i, M) cin >> xi[i];

    sort(xi, xi + M);
    for(int i = 0; i < M - 1; i++) Li[i] = xi[i + 1] - xi[i];

    sort(Li, Li + M);
    for(int i = 0; i < M - N + 1; i++){
        sum += Li[i];
    }
    cout << sum << endl;
} 

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

int partition(vector<int> *a,int p,int r){
    int x = (*a).at(r);
    int i = p-1;
    for(int j = p;j<r;j++){
        if((*a).at(j) <= x){
            i++;
            swap((*a).at(i),(*a).at(j));
        }
    }

    swap((*a).at(i+1),(*a).at(r));
    return i + 1;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i<n;i++) cin >> a.at(i);
    int res = partition(&a,0,n-1);
    for(int i = 0; i < n; i++){
        if(i) cout << " ";
        if(i != res){
            cout << a.at(i);
        }else{
            cout << "[" << a.at(i) << "]";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3124