akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

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

    static Scanner cin;

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

    void calc()
    {
        int n = cin.nextInt();
        n = Pow(n, 3);
        write(n);
    }

    void write(string v)
    {
        Console.WriteLine(v);
    }

    void write(int v)
    {
        Console.WriteLine(v);
    }

    void write(double v)
    {
        Console.WriteLine(v);
    }

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

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

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

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

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

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


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

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int k;
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  cin >> k;
  int flag = 0;
  

    if(vec.at(4) - vec.at(0) > k){
      flag = 1;
    }
  
  if(flag){
    cout << ":("<< endl;
  }
  else{
    cout << "Yay!"<< endl;
  }
}
     

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,dmax;
int m[300];
bool visited[300];
bool isVisit[300];
bool isGoal;
void dfs(int p){
  if(visited[p])return ;
  visited[p] = true;
  isVisit[p] = true;
  if(p == n+1){
    isGoal = true;
    return;
  }
  for(int i = 1; i <= dmax && p+i <= n+1; i++){
    int np = p+i;
    np = np + m[np];
    if(np > n + 1)np = n + 1;
    if(np < 0) np = 0;  
    dfs(np);
  }
}
void solve(){
  fill(isVisit, isVisit+300, false);
  isVisit[0] = true;
  for(int i = 0 ; i <= n; i++){
    if(!isVisit[i])continue;
    isGoal = false;
    fill(visited, visited+300, false);
    dfs(i);
    if(!isGoal)break;    
  }
  cout << (isGoal?"OK":"NG") << endl;
}
int main(){
  while( cin >> dmax, dmax ){
    cin >> n;
    fill(m, m+300, 0);
    for(int i = 0 ; i < n ;i++){
      cin >> m[i+1];
    }
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define double long double
#define INF (int)1e9
#define pb push_back
using namespace std;

long long int ncm(long long int n,long long int m){
  if(m>0) return (ncm(n,m-1)*(n-m+1))/m;
  else return 1;
}

int main(void){
  long long int n;
  vector<double> v;
  long long int a,b,i;
  double x,ave,lastv,resave;
  long long int numlv,allv,res;
  long long int nave;
  cin>>n>>a>>b;
  for(i=0;i<n;i++){
    cin>>x;
    v.pb(x);
  }
  sort(v.begin(),v.end(),greater<double>());
  res=0;
  nave=0;
  ave=0;
  lastv=-1;
  numlv=0;
  
  for(i=0;i<a;i++){
    if(lastv==v[i]) numlv++;
    else numlv=1;
    nave++;
    ave+=v[i];
    lastv=v[i];
  }
  
  allv=0;
  i=a-1;
  while(i>=0&&v[i]==lastv){
    allv++;
    i--;
  }
  i=a;
  while(i<n&&v[i]==lastv){
    allv++;
    i++;
  }

  res+=ncm(allv,numlv);
  resave=ave/nave;
  for(i=nave;i<b;i++){
    //if(resave!=((ave+v[i])/(nave+1))) break;
    if(ave*(nave+1)!=(ave+v[i])*nave) break;
    else{
      numlv++;
      ave+=v[i];
      nave++;
      res+=ncm(allv,numlv);
    }
  }
  printf("%.6Lf\n",resave);
  printf("%lld\n",res);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll k = 1;
  for(; k * (k + 1) / 2 < n; k++) {
  }
  ll s = k * (k + 1) / 2;
  rep2(i, 1, k + 1) if(i != s - n) cout << i << '\n';
}

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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
	int n;
	int i;
	scanf("%d",&n);
	for(i=0;i<3;i++){
		if(n%10 == 7){
			printf("Yes");
			return 0;
		}
		else{
			n = n/10;
		}
		
	}
	printf("No");
    return 0; 
}


Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

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

  ll N,M;
  cin>>N>>M;

  setComb();

  ll ans=0;
  for(ll i=0;i<=N;i++){
    ll res=comb(N,i);
    mul(res,comb(M,i));
    mul(res,fac[i]);
    mul(res,comb(M-i,N-i));
    mul(res,fac[N-i]);
    mul(res,comb(M-i,N-i));
    mul(res,fac[N-i]);

    if(i%2) add(ans,MOD-res);
    else add(ans,res);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 27064
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 200005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
char str[SIZE];
 
int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	ll ret=0;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(str[i]=='A') cnt++;
		else if(str[i]=='B')
		{
			if(i+1<n&&str[i+1]=='C')
			{
				ret+=cnt;
				i++;
			}
			else cnt=0;
		}
		else cnt=0;
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 384
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int from[N];

vector<int> v[N];

int main()
{
	int n,m;

	scn(n); scn(m);

	rep(i,0,m)
	{
		int a,b; scn(a); scn(b);

		v[a].pb(b); v[b].pb(a);
	}

	queue<int> q;

	q.push(1);

	while(!q.empty())
	{
		int node=q.front(); q.pop();

		for(int it:v[node])
		if(from[it]==0)
		from[it]=node,q.push(it);
	}

	rep(i,2,n+1)
	if(from[i]==0)
	{
		printf("No"); return 0;
	}

	printf("Yes\n");

	rep(i,2,n+1)
	priln(from[i]);

	return 0;
}

Measured memory_bytes: 13048
while true do
    r, a = gets.chomp.split
    break if r == '0' && a == '0'
    
    h = 0
    b = 0
    
    4.times do |i|
        if a[i] == r[i] then
            h += 1
        elsif r.include?(a[i]) then
            b += 1
        end
    end
    
    print h.to_s + " " + b.to_s + "\n"
end

Measured memory_bytes: 8756
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let _: String = read();
    let s: String = read();
    let _: String = read();
    let v: Vec<char> = s.chars().collect();

    println!("A{}C", v[0])
}


Measured memory_bytes: 4352
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    S = input()
    print(S.replace("2017/01/", "2018/01/"))


if __name__ == '__main__':
    main()


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) cout << 'x';
  cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = Integer.parseInt(in.nextLine());
		if (num <= 999) {
			System.out.println("ABC");
		} else {
			System.out.println("ABD");
		}
		in.close();
	}

}

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

int main(){
  int A, B; cin >> A >> B;
  if(A == B){
    cout << 0 << endl;
  }
  else if((A + B) % 2 == 0){
    cout << (int)(A+B)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }    
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine
{-# NOINLINE [1] tw #-}
tw :: (a -> Bool) -> [a] -> [a]
tw _ [] = []
tw p (x:xs)
  | p x = x:tw p xs
  | otherwise = []


main = do
  [n,k] <- getIntList
  p <- V.fromList . map (+(-1)) <$> getIntList
  c <- V.fromList <$> getIntList
  let acc i = tail $ scanl' (+) 0 $ map ((c V.!).(p V.!)) $ tw (/=i) (iterate (p V.!) (p V.! i)) ++ [i]
      ans i = 
        if val > 0
          then
            if rem /= 0
              then num * val + maximum (take (fromIntegral rem) list)
              else (num-1) * val + maximum list
          else maximum list
        where list = acc i
              val = last list
              len = fromIntegral $ length list
              num = k `div` len
              rem = k `mod` len
  print $ maximum $ map ans [0..n-1]


Measured memory_bytes: 7148
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::int_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::string s;
	int32 x, y;
	std::cin >> s >> x >> y;
	s.push_back('T');
	std::vector<uint32> a, b;
	int32 xs=0, ys = 0;
	bool f = 0;
	uint32 temp=0;
	uint32 i=0;
	while (s[i] == 'F') {
		++xs;
		++i;
	}
	for(;i<s.length();++i) {
		if (s[i] == 'F') {
			++temp;
		}
		else {
			if (f) {
				b.push_back(temp);
				f = 0;
				temp = 0;
			}
			else {
				a.push_back(temp);
				f = 1;
				temp = 0;
			}
		}
	}
	bool aa[9000] = {}, bb[9000] = {};
	aa[0] = 1;bb[0] = 1;
	uint32 sa = 0, sb = 0;
	rep(i, 0, a.size()) {
		sa += a[i];
		for(uint32 j=8000;~j;--j) {
			if (aa[j]) {
				if (j + a[i] < 8003) {
					aa[j + a[i]] = 1;
				}
			}
		}
	}
	rep(i, 0, b.size()) {
		sb += b[i];
		for (uint32 j = 8000;~j;--j) {
			if (bb[j]) {
				if (j + b[i] < 8003) {
					bb[j + b[i]] = 1;
				}
			}
		}
	}
	bool ans=0;
	if ((sa^(x-xs)) & 1 || (sb^y) & 1) {
		ans = 0;
	}
	else {
		if (0 <= (xs + sa - x) / 2 && (xs + sa - x) / 2 <= 8003 && 0 <= (sb - y) / 2 && (sb - y) / 2 <= 8003) {
			if (aa[(xs + sa - x) / 2] && bb[(sb - y) / 2]) {
				ans = 1;
			}
		}
	}
	std::cout << (ans ? "Yes" : "No") << std::endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N=1e5+5;
 
int n, m, ans=0;
int a[N];
vector<int> v;
 
int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
        cin>>a[i];
    sort(a+1, a+m+1);
    for(int i=2;i<=m;i++)
    {
        ans+=(a[i]-a[i-1]);
        v.push_back(a[i]-a[i-1]);
    }
    sort(v.rbegin(), v.rend());
    int rem=min(m-1, n-1);
    for(int i=0;i<rem;i++)
        ans-=v[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define INF 0x3f3f3f3f
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
using namespace std;


int main()
{
  ll n;
  cin >> n;
  ll m;
  cin >> m;
  string arr[n];
  fr(i,0,n)
  {
      cin >> arr[i];
  }
  ll dp[n][m];
  dp[0][0]=0;
  fr(i,0,n)
  {
      fr(j,0,m)
      {
          if(arr[i][j]=='#')
          {
              dp[i][j]=0;
          }
          else if(i==0&&j==0)
          {
            dp[i][j] = 1;
          }
          else if(i==0)
          {
              dp[i][j]=(dp[i][j-1])%mod;
          }
          else if(j==0)
          {
            dp[i][j] = (dp[i-1][j]) % mod;
          }
          else
          {
            dp[i][j] = ((dp[i - 1][j]) % mod + (dp[i][j - 1]) % mod)%mod;
          }
      }
  }
  cout << dp[n-1][m-1];
  
  return 0;
}


Measured memory_bytes: 9088
def maximum_profit():
    n = int(input())
    numbers = [int(input()) for _ in range(n)]
    maxpro = numbers[1] - numbers[0]
    minnum = numbers[0]
    for i in range(1, len(numbers)):
        if maxpro < (numbers[i] - minnum):
            maxpro = (numbers[i] - minnum)
        if numbers[i] < minnum:
            minnum = numbers[i]
    print(maxpro)


if __name__ == "__main__":
    maximum_profit()

Measured memory_bytes: 15600
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
//#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


//namespace mp = boost::multiprecision;

//using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	vector<int>re(5);
	rep(i, 5) {
		cin >> re[i];
	}
	sort(all(re));
	int ans = 1e9;
	do{
		int now = 0;
		rep(i, 5) {
			now += re[i];
			if (i != 4) {
				while (now % 10 != 0) {
					now++;
				}
			}
		}
		ans = min(ans, now);

	} while (next_permutation(all(re)));
	cout << ans<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define pow10(n) stoll("1"+string(n,'0'))
#define dbg(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9+7; //998244353
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;
const ld PI = acos((ld)-1);
const int dx[8] = {1,0,-1,0,1,1,-1,-1}, dy[8] = {0,1,0,-1,-1,1,1,-1};
mt19937_64 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll n) { return uniform_int_distribution<ll>(0, n)(rng); }
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    int k; cin >> k;
    int rem = 0;
    for(int i=1; i<=k; ++i) {
        rem = (rem * 10 + 7) % k;
        if(rem == 0) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int H[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>H[i];
	}
	int ans=0,p=N-1;
	for(int i=N;i--;)
	{
		if(H[i]<H[i+1])
		{
			ans=max(ans,p-i-1);
			p=i;
		}
	}
	cout<<max(ans,p)<<endl;
}


Measured memory_bytes: 640
#include <iostream> 
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

int a[100];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &a[i]);
	}
	rep(i, n) {
		if (i)printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		rep(i, n) {
			if (i)printf(" ");
			printf("%d", a[i]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

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

  int n;
  cin >> n;

  vector< vector<int> > mat(n, vector<int>(n, (1 << 21)));
  vector<int> r(n), c(n);
  
  for (int i = 0; i < n; i++) {
    mat[i][i] = 0;
    cin >> r[i] >> c[i];
  }
  
  for (int l = 1; l < n; l++) {
    for (int i = 0; i < n - l; i++) {
      int j = i + l;
      for (int k = i; k < j; k++) {
        mat[i][j] = min(mat[i][j], mat[i][k] + mat[k+1][j] + r[i] * c[k] * c[j]);
      }
    }
  }

  cout << mat[0][n-1] << eol;
  return 0;
}

Measured memory_bytes: 3184
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

vector<int> v[N];
int col[N]={0};
queue<pair<int,int>> q;
map<pair<int,int>, int> m;

void bfs()
{
    q.push({1,0});
    while(!q.empty())
    {
        int s=q.front().F;
        int pp=q.front().S;
        q.pop();
        int r=1;
        for(auto u : v[s])
        {
            if(u!=pp)
            {
                q.push({u,s});
                if(m[{s,pp}] && col[m[{s,pp}]]==r)
                {
                    r++;
                }
                col[m[{s,u}]]=r;
                r++;
            }
        }
    }
}
int main()
{
    IOS();
    int n,i,j;
    cin>>n;
    f(i,0,n-1)
    {
        int x,y;
        cin>>x>>y;
        v[x].pu(y);
        v[y].pu(x);
        m[{x,y}]=i+1;
        m[{y,x}]=i+1;
    }
    bfs();
    int mx=0;
    f(i,1,n)
        mx=max(mx,col[i]);
    cout<<mx<<'\n';
    f(i,0,n-1)
        cout<<col[i+1]<<'\n';
    
    return 0;
}

Measured memory_bytes: 19072
#include <iostream>

int main(int argc, char const* argv[])
{
    long n, k, r, s, p;
    std::string t;
    std::cin >> n >> k >> r >> s >> p >> t;

    long score = 0;
    auto cont = new bool[k];
    for (long i = 0; i < n; i++) {
        if (cont[i%k]) {
            cont[i%k] = false;
        } else {
            if (i >= k && t[i] == t[i-k]) {
                cont[i%k] = true;
                continue;
            }
        }
        if (t[i] == 'r') score += p;
        if (t[i] == 's') score += r;
        if (t[i] == 'p') score += s;
    }

    std::cout << score;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  rep2(b, k + 1, n + 1) {
    ans += n / b * (b - k);
    ll r = n % b;
    ans += max(0LL, r - k + (k != 0));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  int H, W;
  char a;
  cin >> H >> W;
  vvi mp(H, vi(W)), dp(H, vi(W, INF));
  rep(i, H) rep(j, W) {
    cin >> a;
    mp[i][j] = a - '0';
  }
  dp[0][0] = 0;
  rep(i, H) rep(j, W) {
    if (j != W - 1)
      dp[i][j + 1] = min(dp[i][j + 1], mp[i][j + 1] + dp[i][j]);
    if (i != H - 1)
      dp[i + 1][j] = dp[i][j] + mp[i + 1][j];
  }
  cout << dp[H - 1][W - 1] << endl;
  return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int h,w;
  cin >>h >> w;

  string s[h];
  rep(i,h) cin >> s[i];

  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  
  rep(i,h) rep(j,w){
    if(s[i][j]=='.') continue;
    bool ok=false;
    rep(k,4){
      int nx=j+dx[k];
      int ny=i+dy[k];
      if(nx>=0 && nx<w && ny>=0 && ny<h){
	if(s[ny][nx]=='#') ok=true;
      }
    }
    if(!ok){
      cout << "No" << endl;
      return 0;    
    }    
  }
  cout << "Yes" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a+3);
    ll f = 1;
    rep(i, 3) f &= a[i]%2;
    if(f == 0) ANS(0);
    cout << a[0]*a[1];
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

int main()
{
    int n;
    cin >> n;
    cout << prec(20);
    int a[n];
    ld ans = 0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        ans += (ld)(1.0/a[i]);
    }
    cout << (ld)1.0/ans << "\n";
}




Measured memory_bytes: 256
// Problem : A - Restricted
// Contest : AtCoder - AtCoder Beginner Contest 063
// URL : https://atcoder.jp/contests/abc063/tasks/abc063_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int a,b;cin>>a>>b;
if(a+b>=10)
cout<<"error";
else
cout<<a+b;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    int N; cin >> N;
    if (N >= 18) cout << "Yes" << endl;
    else{
        switch(N){
            case 4 : 
            case 7 :
            case 8 :
            case 11 :
            case 12 :
            case 14 :
            case 15 :
            case 16 :
            cout << "Yes" << endl; break;
            default :
            cout << "No" << endl;
            break;
        }
    }
}

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

int main(){
  int n;cin >> n;
  vector<double> v(n);
  for (auto && a : v) {
    cin>>a;
  }
  sort(v.begin(),v.end());
  for (int i = 1; i < n; i++) {
    v.at(i) = (v.at(i - 1) + v.at(i)) / 2;
  }

  cout << v.at(n-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

main(){
    string s;cin>>s;
    int i=0;
    while(s[i]=='S') i++;
    int start=i;
    int count=0;
    while(s[i]=='R'){
        count++;
        i++;
    }
    cout<<count;
}

Measured memory_bytes: 3620
/* ex2_3
   Acro  */
 
#include <stdio.h> 
int main(void){
    int n,i;
    int ans = 1;
    scanf("%d",&n);
    for(i = 1; i < 10 ; i++){
        /* 1から9まで探索 */
        if(n % i == 0){
            /* 割り切れたとき */
            if(n/i < 10){
                /* 商が10より小さければYes */
                printf("Yes\n");
                ans = 0;
                break;
            }
        }
    }
    if(ans){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
def preorder(tree, now):
    if now == -1:
        return []
    else:
        left = tree[now][0]
        right = tree[now][1]
        return [now] + preorder(tree, left) + preorder(tree, right)


def inorder(tree, now):
    if now == -1:
        return []
    else:
        left = tree[now][0]
        right = tree[now][1]
        return inorder(tree, left) + [now] + inorder(tree, right)


def postorder(tree, now):
    if now == -1:
        return []
    else:
        left = tree[now][0]
        right = tree[now][1]
        return postorder(tree, left) + postorder(tree, right) + [now]


def print_list_split_whitespace(a):
    print(" ", end="")
    for x in a[:-1]:
        print(x, end=" ")
    print(a[-1])


n = int(input())
tree = [[] for _ in range(n)]
ps = [-1 for _ in range(n)]
ss = [-1 for _ in range(n)]
for _ in range(n):
    s = input().split()
    id = int(s[0])
    left = int(s[1])
    right = int(s[2])
    tree[id] = [left, right]
    if left >= 0:
        ps[left] = id
        ss[left] = right
    if right >= 0:
        ps[right] = id
        ss[right] = left

root = ps.index(-1)

print("Preorder")
pre_list = preorder(tree, root)
print_list_split_whitespace(pre_list)

print("Inorder")
in_list = inorder(tree, root)
print_list_split_whitespace(in_list)

print("Postorder")
post_list = postorder(tree, root)
print_list_split_whitespace(post_list)


Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
using std::max;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int P,Q,R;
int main(){
  cin>>P>>Q>>R;
  int x=max(P,max(Q,R));
  prin(P+Q+R-x);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
//#include "./libb/lib.hpp"

using namespace std;

int main()
{
    uint32_t nn;
    cin >> nn;
    vector<uint32_t> ary(nn, 0);
    vector<uint32_t> ans(nn, 0);

    for(int i = 0; i < (nn - 1); i++){
        cin >> ary[i];
    }

    for(int i = 0; i < (nn - 1); i++){
        ans[ary[i] - 1]++;
    }

    for(int i = 0; i < nn; i++){
        cout << ans[i] <<endl;
    }

    return 0;
}

Measured memory_bytes: 4820
#include<iostream>

int main(){
	int n, n1, nn, t, x=0;
	std::cin >> n;
	nn = n;
	do {
		n1 = n / 10;
		t = n - n1*10;
		x += t;
		n = n1;
	} while (n > 0);
	if (nn % x == 0) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  int H,N,i,j,ans=10000000000;cin>>H>>N;
  int DP[H+1],A[N],B[N];DP[0]=0;
  REP(i,N)cin>>A[i]>>B[i];
  REP(i,H){
    DP[i+1]=1000000000;
    REP(j,N)DP[i+1]=min(DP[i+1],DP[max(0,i+1-A[j])]+B[j]);
  }
  REP(i,H)DP[H-i-1]=min(DP[H-i-1],DP[H-i]);
  REP(i,N)ans=min(ans,DP[max(0,H-A[j])]+B[j]);
  cout<<DP[H]<<endl;
  return 0;
}

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

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;

    int start = 0;
    int end = 0;
    int answer = 0;

    // inch-worm
    while(end < n){
        while(end < n && s[end] == '1'){// starting point
            end += 1;
        }
        answer = max(answer, end - start);// count the length of 11...1
        while(end < n && s[end] == '0'){
            end += 1;
        }
        k -= 1;// iterate 11...1 00...0
        
        if(k < 0){// moving to the next starting point
            while(start < n && s[start] == '1'){
                start += 1;
            }
            while(start < n && s[start] == '0'){
                start += 1;
            }
        }
        answer = max(answer, end - start);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 512
A = int(input())
B = int(input())
 
ans = ""
 
if A == 1 and B == 2:
  ans = "3"
elif A == 1 and B == 3:
  ans = "2"
elif A == 2 and B == 1:
  ans = "3"
elif A == 2 and B == 3:
  ans = "1"
elif A == 3 and B == 1:
  ans = "2"
elif A == 3 and B == 2:
  ans = "1"
  
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
 
int main(){
	int n;
	cin>>n;
	int g=0;
	
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0)g++;
	}
	
	int ma=1;
	for(int i=0;i<g;i++)ma*=2;
	
	int ans=1;
	for(int i=0;i<n;i++)ans*=3;
	
	cout<<ans-ma<<endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
orders = list(map(int, input().split()))
suf = list(map(int, input().split()))
ser = list(map(int, input().split()))
ans = 0
flug = -1
for i in orders:
  ans += suf[i-1]
  if flug+1 == i:
    ans += ser[i-2]
  flug = i
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <map>

using namespace std;

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

  int n, count = 0;
  long d;
  array<long, 2> p;
  cin >> n >> d;
  map<array<long, 2>, int> ds;
  while(n--) {
    cin >> p[0] >> p[1];
    p[0] = abs(p[0]);
    p[1] = abs(p[1]);
    if(p[0] > p[1]) p[0]^=p[1]^=p[0]^=p[1];
    ds[p]++ || (ds[p] = 1);
  }

  long D = d * d;
  for(const auto& m : ds) {
    array<long, 2> key = m.first;
    if(D >= (key[0] * key[0] + key[1] * key[1])) count += m.second;
  }
  cout << count;
}


Measured memory_bytes: 16140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<int> p(n);
    for(auto &x:p)cin >> x;

    int minval=p[0];
    int count=0;
    for(int i=0;i<n;i++){
        if(p[i]<=minval){
            count++;
            minval=p[i];
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 4028
using System;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = int.Parse(s.Split(' ')[i]);
        }

        //その時点での先頭の値を記録
        int v = A[0];
        //ループ用インデックス
        int j = 0;

        for (int i = 0; i < N; i++) {
            v = A[i];
            j = i - 1;

            //※i = 0のときは以下のループには入らない
            while (j >= 0 && A[j] > v) {
                //ひとつ前の数値をコピーしてくる
                A[j + 1] = A[j];
                j--;
            }
            //jは一個戻って、記録していた先頭の値を代入する
            A[j + 1] = v;

            //出力
            Console.WriteLine(String.Join(" ", A));

            //for (int p = 0; p < N; p++) {
            //    Console.Write(A[p]);

            //    if (p == N - 1) {
            //    } else {
            //        Console.Write(" ");
            //    }
            //}
            ////if (i == N - 1) {
            ////} else {
            //    Console.WriteLine();
            ////}
        }
    }
}


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

int main() {
  int N, l, r;
  long long int sum = 0;
  long long int diff = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    diff = r - l + 1;
    sum += diff;
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;

  int sum = a + b;
  int dif = a - b;
  int pro = a * b;

  int max = sum;
  if(max < dif) max = dif;
  if(max < pro) max = pro;
  cout << max << endl;

  return 0;
}

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

main() {
    int A,B; cin >> A >> B;
    if(A%2==0 || B%2==0)
    cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    ll N;
    cin >> N;
    if(N >= 30) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3588
nm=gets.chomp.split(" ").map(&:to_i)
lr=[]
nm[1].times do|i|
	lr[i]=gets.chomp.split(" ").map(&:to_i)
end
min=lr[0][0]
max=lr[0][1]
for i in 1..nm[1]-1
	if(min<lr[i][0])
		min=lr[i][0]
	end
	if(max>lr[i][1])
		max=lr[i][1]
	end
end
result=(max-min+1)
if(result<0)
	result=0
elsif result>nm[0]
	result=nm[0]
end
puts result

Measured memory_bytes: 9468
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
    return (a + b) % MOD;
}

int mul(int a, int b) {
    return (a * b) % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

const int K = 21;
const int N = 1004;

int fact[N];
int C[N][N];

void init() {
    C[0][0] = 1;
    for (int i = 1; i < N; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
        }
    }
    fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = mul(i, fact[i - 1]);
    }
}

int dp[K][N];

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

    init();

    int n, k;
    cin >> n >> k;
    vector<int> a(k);
    for (auto &t : a) {
        cin >> t;
    }
    dp[0][0] = 1;
    for (int i = 0; i < k; i++) {
        for (int cnt = 0; cnt <= n; cnt++) {
            for (int x = 0; x + cnt <= n && x <= a[i]; x++) {
                int cf = C[n - x][a[i] - x];
                cf = mul(cf, binpow(fact[x], MOD - 2));
                dp[i + 1][x + cnt] = add(dp[i + 1][x + cnt], mul(dp[i][cnt], cf));
            }
        }
    }
    cout << mul(dp[k][n], fact[n]) << endl;
}   

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int ninf = 0xc0c0c0c0;
const double pi = acos(-1);
using db = double;
double toRad(double x){
	return x/180*pi;
}
db COS(db x,db y,db d){
	return sqrt(x*x+y*y-2*x*y*cos(d));
}
db a,b,m,h;
int main(){
	cin>>a>>b>>h>>m;
	db ma = ((int)(h*60+m)%60)*(db)6;
	db ha = ((int)(h*60+m)%720)/(db)2;
	db delta = fabs(ma-ha);
	db Rdel = toRad(delta);
	db ans = COS(a,b,Rdel);
	printf("%.10lf\n",ans);
	return 0;
}

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

int main(){

  int a[3];

  for(int i=0;i<3;i++) cin>>a[i];

  sort(a, a+3);

  if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())

def count_d(n):
    ret = 0
    for d in range(1,n+1):
        if n%d == 0:
            ret += 1
    return ret

ans = 0
for i in range(1,N+1,2):
    if count_d(i) == 8:
        ans += 1
print(ans)

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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){
    
    int n,k;
    cin >> n >> k;
    int p;
    REP(i,n){
        int a;
        cin >> a;
        if(a==1) p = i;
    }
    int ans = 0;
    if(p%(k-1) == 0)  ans += p/(k-1);
    else ans += p/(k-1) + 1;

    if((n-p-1)%(k-1) == 0)  ans += (n-p-1)/(k-1);
    else ans += (n-p-1)/(k-1) + 1;

    if(p%(k-1) != 0 && (n-p-1)%(k-1) != 0 && p%(k-1) +(n-p-1)%(k-1) <= k-1){
        ans--;
    }




    cout << ans;
}


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

int main(){
	int a,b;
	
	cin >> a >> b;
	
	if (a<b){cout<<"a"<<" < "<<"b";}
	else if (a>b){cout<<"a"<<" > "<<"b";}
	else if (a=b){cout<<"a"<<" == "<<"b";}
	cout<<endl;
	return 0;
	
}



Measured memory_bytes: 3072