akhauriyash/Code-Regression huggingface dataset:
/*
	0502:Dice
*/
#include	<iostream>
#include	<string>

using namespace std;

int main(void) {
	while(1) {
		int n;
		int Top = 1, Front = 2, RigSide = 3, LefSide = 4, Back = 5, Under = 6;
		int sum = 1;
		cin >> n;
		if(n == 0) { break; }
		
		for(int i = 0; i < n; i++) {
			string command;
			cin >> command;
			if(command == "North") {
				int tmp = Top;
				Top = Front;
				Front = Under;
				Under = Back;
				Back = tmp;
			} else if(command == "East") {
				int tmp = Top;
				Top = LefSide;
				LefSide = Under;
				Under = RigSide;
				RigSide = tmp;
			} else if(command == "West") {
				int tmp = Top;
				Top = RigSide;
				RigSide = Under;
				Under = LefSide;
				LefSide = tmp;
			} else if(command == "South") {
				int tmp = Top;
				Top = Back;
				Back = Under;
				Under = Front;
				Front = tmp;
			} else if(command == "Right") {
				int tmp = Front;
				Front = RigSide;
				RigSide = Back;
				Back = LefSide;
				LefSide = tmp;
			} else {
				int tmp = Front;
				Front = LefSide;
				LefSide = Back;
				Back = RigSide;
				RigSide = tmp;
			}
			sum += Top;
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
s = input()

x = ["A","C","G","T"]

ans = 0
cnt = 0

for i in range(len(s)):
    if s[i] not in x:
        ans = max(ans,cnt)
        if i != (len(s)-1):
            cnt = 0
    else:
        cnt += 1
            
ans = max(ans,cnt)
        
print(ans)

Measured memory_bytes: 8868
import sys
n,m = map(int,input().split())
if m == 1:
    input()
    print('IMPOSSIBLE')
    sys.exit()
mid = [];move = [None]*m
for i in range(m):
    a,b = map(int,input().split())
    move[i] = [a,b]
    if a == 1:mid.append(b)
    if b == 1:mid.append(a)
    if a == n:mid.append(b)
    if b == n:mid.append(a)
check = False
if len(mid) != len(set(mid)):check = True
if check == True:print('POSSIBLE')
else:print('IMPOSSIBLE')

Measured memory_bytes: 46984
fn main() {
    let s = {
        let mut s = String::new(); // バッファを確保
        std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
        s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
    };

    let i: i32 = s.parse().unwrap();
    println!("{}", i * i * i);
}


Measured memory_bytes: 5032
#include <iostream>
#include<bits/stdc++.h>
#define ll long long 

#define pb push_back
#define pii pair<int,int>
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;


void solve(){
	int n;
	cin >> n;
	vector<int> v(n);
	
	int x =0;
	f(i,n){
		cin >> v[i];
		x^=v[i];
	}
	
	f(i,n){
		v[i] = x^ v[i];
	}
	
	f(i,n){
		cout << v[i] << " " ;
	}
	
}

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


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


int main(){
int x,n;
cin >> x >> n;
set<int> suu;
rep(i,n) {
  int a;
  cin >> a;
  suu.insert(a);
}
for (int i = 0;i < INF;i++) {
  if (suu.count(x-i)) {

  } else {
    cout << x-i << endl;
    return 0;
  }
  if (suu.count(x+i)) {
    
   } else {
     cout << x+i << endl;
    return 0;
   }
}


return 0;
}

Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
e = []
def kome(p):
    c = 0
    for i in range(n):
        c = c + (abs(a[i] - b[i]) ** p)
        e.append(abs(a[i] - b[i]))
    d = c ** (1 / p)
    return d
    
print(kome(1))
print(kome(2))
print(kome(3))
print(float(max(e)))


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

int main(){
  int h,n;
  int cou=0;
  cin >> h >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
      cin >> a[i];
      cou=cou+a[i];
  }

  if(h<=cou){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }

  
   return 0; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(true)
  {
    C-=B;if(C<=0)return cout<<"Yes"<<endl,0;
    A-=D;if((A<=0))return cout<<"No"<<endl,0;
  }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M, vector<int>(N));
    vector<int> p(M);
    
    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> s[i][j];
        }
    }
    rep(i, M) cin >> p[i];

    int count = 0;
    int max = pow(2, N);
    rep(i, max) {
        stringstream ss;
        ss << bitset<10>(i);
        string swt = ss.str();
        int f = 1;
        rep(j, M) {
            int tbit = 0;
            rep(l, k[j]) {
                tbit ^= swt[10-s[j][l]] - '0';
            }
            if(tbit^p[j]) {
                f = 0;
                break;
            }
        }
        if(f) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,k;
	cin >> n >> k;
	ll cur = n%k;
	cout << min( cur, k-cur );

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n, i, j, k, a, flg[8], cnt = 0, ans = 0;
  scanf("%d", &n);
  for(i = 0; i < 8; ++i) flg[i] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%d", &a);
    if(a < 3200) flg[(a / 400)] = 1;
    else cnt++;
  }
  for(i = 0; i < 8; ++i) if(flg[i]) ans++;
  printf("%d %d", ans ? ans : 1, ans + cnt);
  return 0;
}


Measured memory_bytes: 128
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    unordered_map<string, int> data;
    string s;
    FOR (i, 0, n) {
        cin >> s;
        data[s]++;
    }

    cout << "AC x " << data["AC"] << "\n";
    cout << "WA x " << data["WA"] << "\n";
    cout << "TLE x " << data["TLE"] << "\n";
    cout << "RE x " << data["RE"] << "\n";


}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    int t = 1;
    tc(t) {
        solve();
    }

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


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


    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        string s;
        cin>>s;
        int n=s.size();
        for(int i=0;i<n;i++){
            if(s[i]=='?' && ((i+1<n && s[i+1]=='P') || (i-1>=0 && s[i-1]=='P'))){
                s[i]='D';
            }
            else if(s[i]=='?' && i+1<n && s[i+1]=='?'){
                s[i]='P';
                s[i+1]='D';
            }
            else if(s[i]=='?' && i+1<n && s[i+1]=='D')
                s[i]='P';
            else if(s[i]=='?')
                s[i]='D';
        }
        cout<<s;
        
//        for(int i=0;i<n;i++){
//            if(s[i]=='?')
//                s[i]='D';
//        }
//        cout<<s;
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i =0;i<n;i++){
    cin >> a.at(i);
  }
  
  for(int i=k;i<n;i++){
    if(a.at(i-k)<a.at(i)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int k,a,b;
    cin >> k >> a >> b;
    FOR(i,a,b+1){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;    
    return 0;
}

Measured memory_bytes: 3636
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N; std::cin >> N;
	std::vector<Int> A(N), B(N), C(N);
	std::unordered_map<Int, Int> m;
	rep(i, N) {
		std::cin >> A[i];
		B[i] = A[i] + i;
		C[i] = A[i] - i;
		m[C[i]]++;
	}
	std::sort(all(C));
	Int ans = 0;
	rep(i, N) {
		ans += m[-B[i]];
	}

	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 23124
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		Console.WriteLine(input[0] + (input[1]) / 2);
	}
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

lli kr(lli n,lli mod = MOD) {
	if (n == 1)return 1;
	return ((n * (n - 1)) / 2) % mod;
}

int main() {
	lli N, K;
	cin >> N >> K;
	vector<lli> A(N);
	for (lli i = 0; i < N; i++) {
		cin >> A[i];
	}
	lli ans = 0;
	for (lli i = 0; i < N; i++) {
		lli left = 0;
		lli right = 0;
		for (lli j = 0; j < N; j++) {
			if (A[i] < A[j]) {
				if (i > j) {
					left++;
				}
				else {
					right++;
				}
			}
		}
		ans += (left * kr(K+1));
		ans %= MOD;
		ans += (right * kr(K));
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
H = [int(s) for s in input().split()]
if N == 1:
  print('Yes')
else:
  Hc = H.copy()
  Hc[0] = Hc[0]-1
  flg = 'Yes'
  for i in range(N-1):
    if Hc[i+1] - Hc[i] >= 1:
      Hc[i+1] = Hc[i+1] - 1
    elif Hc[i+1] - Hc[i] < 0:
      flg = 'No'
  print(flg)

Measured memory_bytes: 14224
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll a;
    string s;
    std::cin >> a;
    std::cin >> s;
    if( a >= 3200){
        std::cout << s << std::endl;
    }else{
        std::cout << "red" << std::endl;
    }
}


Measured memory_bytes: 256
import math
from bisect import bisect_right
from copy import copy
n = int(input())
li = set([357,375,537,573,735,753])
li2 = set()
for i in li:
    li2.add(str(i))
li4 = copy(li2)
for k in range(6):
    li3 = set()
    for i in li4:
        for j in range(len(i)):
            i1 = i[:j]+'3' +i[j:]
            i2 = i[:j]+'5' +i[j:]
            i3 = i[:j]+'7' +i[j:]
            li3.add(i1)
            li3.add(i2)
            li3.add(i3)
    li4 = copy(li3)
    for j in li4:
        li2.add(j)
li5 = []
for i in li2:
    li5.append(int(i))
li5.sort()
k = bisect_right(li5, n)
print(k)

Measured memory_bytes: 78492
#include <iostream>
using namespace std;
int main(void){
    //入力
    int A, B, T;
    cin >> A >> B >> T;
    
    //1秒からT秒の間に何枚生産されるかを調べる
    int ans = 0;
    for (int i = 1; i <= T; i++){
        
        //秒数がAの倍数ならばB枚加算する
        if (i % A == 0) ans += B;
    }
    
    //出力
    cout << ans << endl;
    
}

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

int main() {
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n){
    cin >> l[i];
  }
  int pos = 0;
  int count = 0;
  if (pos <= x) count++;
  rep(i,n){
    pos += l[i];
    if (pos <= x) count++;
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define um unordered_map
#define all(x) (x).begin(),(x).end()
#define forn(i,n) for(int i=0;i<int(n);++i)
#define for1(i,n) for(int i=1;i<=int(n);++i)
#define che(x) cout<<#x<<" having "<<x<<endl 
using namespace std;
typedef long double ld;typedef long long ll;
typedef vector<int> vi;typedef vector<pair<int, int>> vpi;typedef vector<vi> vvi;
typedef vector<ll> vll;typedef vector<pair<ll, ll>> vpll;typedef vector<vll> vvll;
template<class T>bool uin(T &a,T b){return a>b?(a=b,true):false;}
template<class T>bool uax(T &a,T b){return a<b?(a=b,true):false;}
const ll MOD=1e9+7,INF=1e18;
/********************************************************************************/
 

 
int32_t main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);
    cout.precision(10);cout<<fixed;
 
    int n; cin>>n;
    int a[n];
    forn(i,n) cin>>a[i];
    ld ans=0;
    sort(a,a+n);
    ans=1.0*a[0];
    for1(i,n-1){
        ans=1.0*((ans+a[i])/2);
    }
    cout<<ans<<endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		sc.close();

		int arr[] = {a, b, c};
		Arrays.sort(arr);

		for(int i=0; i<arr.length; i++) {
			System.out.print(arr[i]);
			if(i != arr.length-1) System.out.print(" ");
		}
		System.out.println("");

	}

}


Measured memory_bytes: 26148
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


struct aa {
	int now;
	int time;
	int use;
};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.use> r.use;
	}
};
int main() {
	while (1) {
		int N, M, C; cin >> N >> M >> C;
		if (!N)break;
		vector<vector<int>>memo(N, vector<int>(M + 1,1e9));
		if (!N)break;
		vector < vector<pair<int, int>>>edges(N);
		for (int i = 0; i < M; ++i) {
			int f, t, c; cin >> f >> t >> c;
			f--; t--;
			edges[f].push_back(make_pair(t, c));
		}
		priority_queue<aa, vector<aa>, Compare>que;
		que.push(aa{ 0,0,0 });
		memo[0][0] = 0;
		int ans = -1;
		while (!que.empty()) {
			aa atop(que.top());
			if (atop.now == N - 1) {
				ans = atop.use;
				break;
			}
			que.pop();
			for (auto e : edges[atop.now]) {
				const int next = e.first;
				if (atop.time + e.second <= C) {
					if (memo[next][atop.use]>atop.time + e.second) {
						memo[next][atop.use] = atop.time + e.second;
						que.push(aa{ next,atop.time + e.second,atop.use });
					}
				}
				{
					if (memo[next][atop.use+1]>atop.time ) {
						memo[next][atop.use+1] = atop.time;
						que.push(aa{ next,atop.time,atop.use+1 });
					}
				}
			}
		}
		cout << ans << endl;

	}
	
	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;
bool pal(string s)
{
	string lol=s;
	reverse(all(s));
	if(lol==s) return true;
	return false;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	int n=s.length();
	// cout<<s.substr(0,(n-1)/2-1+1)<<" "<<s.substr((n+3)/2-1,n-(n+3)/2+1)<<"\n";
	if(pal(s)&&pal(s.substr(0,(n-1)/2-1+1))&&pal(s.substr((n+3)/2-1,n-(n+3)/2+1)))
	{
		cout<<"Yes";
	}
	else cout<<"No";
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
    	var AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B) = (AB[0], AB[1]);
        
        var sum = A+B;
        var dif = A-B;
        var mul = A*B;
        var ans = Math.Max(Math.Max(sum, dif), mul);
        
        WriteLine(ans);
    }
}


Measured memory_bytes: 28140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<pair<char, int>> a;
	a.emplace_back(make_pair(s[0], 1));
	for (int i = 1; i < s.length(); i++) {
		if (s[i] != s[i - 1]) {
			a.emplace_back(make_pair(s[i], 1));
		} else {
			a[a.size() - 1].second++;
		}
	}

	vector<int> b(a.size() + 2), w(a.size() + 2);
	for (int i = 0; i < a.size(); i++) {
		if (a[i].first == '.') {
			w[i + 1] = a[i].second;
		} else {
			b[i + 1] = a[i].second;
		}
	}
	for (int i = 2; i < a.size() + 2; i++) {
		w[i] += w[i - 1];
		b[i] += b[i - 1];
	}

	int ans = 1010101010;
	for (int i = 1; i <= a.size(); i++) {
		ans = min(ans, b[i - 1] - b[0] + w[a.size() + 1] - w[i]);
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
 
  unsigned long long A, b, ans = 0;
  //ll A, b, ans = 0;
  float B;
 
  cin >> A >> B;
   b = B * 100 + 0.5;
  ans = A * b;
  ans = ans / 100;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <queue>

using namespace std;

int D[100100];//始点からの距離を入れる

int g[1001][1001]={{0}};//要素を0で初期化
void bfs(int src,int n){//srcは開始位置この場合だと頂点1だから0
  // cerr << "bfs_root = " << src << endl;
  queue<int> Q;
  Q.push(src);
  D[src] = 0;
  while (! Q.empty()  ){
    int cur = Q.front();
    Q.pop();
    // cerr << "visiting_" << cur << " " <<D[cur] <<endl;
    for(int dst= 0; dst < n; dst++){
      if(g[cur][dst]==1 && D[dst]==0){
        D[dst]=D[cur]+1;
        Q.push(dst);
      }
    }
  }
}
void ans(int n){
  cout << 1 <<" "<< 0 <<endl;
  for (int i = 1; i < n; ++i)
  {
    if(D[i]==0){
      cout << i+1 << " "<< -1 <<endl;
    }else{
      cout << i+1 <<" "<< D[i]<<endl;
    }
  }

}

int main(){
  // int g[1001][1001]={{0}};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    cin >> a >> b ;
    for (int i = 0; i < b; ++i)
    {
      cin >> c;
      g[a-1][c-1]=1;/* code */
    }
  }
  bfs(0,n);
  ans(n);
  // for (int i = 0; i < n; ++i)
  // {
  //    for (int j = 0; j < n; ++j)
  //    {
  //     if (j==n-1)
  //     {
  //       cout << g[i][j] << endl;
  //     }else{
  //       cout << g[i][j] <<" ";
  //     }
  //    }
  // }


}

Measured memory_bytes: 3636
S=input()
lenS=len(S)
ls=[]
ls.append(S[0])
for i in range(1,lenS):
	if len(ls)==0:
		ls.append(S[i])
		continue
	tmp=ls.pop(-1)
	if tmp==S[i]:
		ls.append(tmp)
		ls.append(S[i])
print(lenS-len(ls))





Measured memory_bytes: 3956
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  
  RREP(i,N) ans+=i*(N/i)*(N/i+1)/2;
  
  co(ans);
  return 0;
}

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

using namespace std;
typedef long long LL;
const int MaxN = 1e5;


string s;


int main()
{
	cin >> s;
	int k = 0;
	for(int i = 0;i < 3;i++)
	{
		if(s[i] == 'o')  k++;
	}
	cout << 700 + k * 100 << endl;
}



Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let x: i64 = sc.read();
    let mut a: i64 = 100;
    let mut n: i64 = 0;
    loop {
        n += 1;
        a += a / 100;
        if a >= x {
            println!("{}", n);
            return;
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2156
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[6];
    rep(i,2){
        cin >> A[i];
        A[i]=(A[i]+12)%14;
    }
    //sort(A,A+3);
    cout << (A[0]>A[1] ? "Alice" : (A[0]<A[1] ? "Bob" : "Draw")) << endl;
}

Measured memory_bytes: 256
A = [[0 for _ in range(3)] for _ in range(3)]
B = [[0 for _ in range(3)] for _ in range(3)]
for i in range(3):
    tmp = input().split()
    for j in range(3):
        A[i][j] = int(tmp[j])

N = int(input())

for n in range(N):
    b = int(input())
    flag = False
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1
                flag = True
                break
        if flag:
            break

C = [0]*8
for i in range(3):
    for j in range(3):
        if i == j:
            C[6] += B[i][j]
        if i+j==2:
            C[7] += B[i][j]
        C[i] += B[i][j]
        C[j+3] += B[i][j]

for i in range(8):
    if C[i]==3:
        print('Yes')
        break
    if i == 7:
        print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int i, j;
	
	for( i = 1; i <= 9; i++ ){
		for( j = 1; j <= 9; j++ ){
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#define LL long long 
using namespace std;

LL dp[105][315];
LL w[105],v[105];
 
int main(){
    LL n,W;
    scanf("%lld%lld",&n,&W);
    LL sum=0;
    scanf("%lld%lld",&w[1],&v[1]);
    for(int i=2;i<=n;i++)
    {
    	scanf("%lld%lld",&w[i],&v[i]);
    	w[i]-=(w[1]-1);
    	sum+=w[i];
	}
	sum+=1; 
	LL ww=w[1]-1;
	w[1]=1;
	LL ans=0;
 
    for(LL i=1;i<=n;i++)
	{
        for(LL j=i;j>=1;j--)
		{
            for (LL k=sum;k>=w[i];k--)
			{
                dp[j][k]=max(dp[j][k],dp[j-1][k-w[i]]+v[i]);
                if(j*ww+k<=W) 
				{
					ans=max(dp[j][k],ans);
				}
            }
        }
    }
 	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 512
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]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


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


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    print(sum_of_arithmetic_progression(1, 1, N - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <iostream>
#include <ctime>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include<cstring>
#include <set>
#include <map>
using namespace std;
int c[505]; //到一个车站的花费时间
int s[505]; //一个车站出发的等待时间
int f[505];  //一个车站每f秒出发一个车
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    for(int i=1;i<=n;i++){
        int ans=0;
        for(int j=i;j<n;j++){
            if(ans<s[j])   //小于等待时间重新赋值
                ans=s[j];
            if(ans%f[j]!=0)    //是否处于间隔时间
                ans=ans+f[j]-ans%f[j];
            ans+=c[j];
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int N;
  int flag = 0;
  cin >> N;
  for(int i=1; i<10; i++){
    if(((N/i) < 10)&&(N%i)==0){
      flag = 1;
    }
  }
  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;

const int maxn = 100000 + 5;
struct T
{
	int s;
	int e;	
};
int N, Q;
string str;
T mem[maxn];
int check[maxn];

void solve()
{
	int cnt = 0;
	for(int i = 1; i < N; i++)
	{
		if(str[i-1] == 'A')
			if(str[i] == 'C') cnt++;
		check[i] = cnt;
	}

	//for(int i = 0; i < N; i++) printf("%d ", check[i]);
	//printf("\n");

	for(int i = 0; i < Q; i++)
	{
		int result = check[mem[i].e-1] - check[mem[i].s-1];
		printf("%d\n", result);
	}
}

int main()
{
	cin >> N >> Q; getchar();
	cin >> str;
	for(int i = 0; i < Q; i++)
	{
		cin >> mem[i].s; cin >> mem[i].e;
	}
	solve(); 
}


Measured memory_bytes: 2176
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e3+10;
double dp[N][N];
void raushan_kumar(){
	int n;cin>>n;
	double a[n];
	fo0(i,n){
		cin>>a[i];
	}
	// dp[i][j]----i coins feke j heads => n-j tails
	//dp[i][j]=dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i])
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j) dp[i][j]+=dp[i-1][j-1]*a[i-1];
			dp[i][j]+=dp[i-1][j]*(1-a[i-1]);
		}
	}
	double ans=0.0;
	for(int i=0;i<=n;i++){
		if(i>n-i){
			ans+=dp[n][i];
		}
	}
	printf("%.12f\n",ans);
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 92800
using System;
class Program
{
    static void Main(string[] args)
    {
        bool isFirst = true;
        int[] coins = new int[] { 10, 50, 100, 500 };
        int range = 4;
        int bill, ownedMoney, changeMoney;
        int[] ownedCoins = new int[range], changeCoins = new int[range], paymentCoins = new int[range];

        while (true)
        {
            bill = int.Parse(Console.ReadLine());
            if (bill == 0) break;
            if (isFirst) { isFirst = false; } else { Console.WriteLine(); }
            ownedCoins = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            ownedMoney = 0;
            for (int i = 3; i >= 0; i--)
                ownedMoney += coins[i] * ownedCoins[i];

            changeMoney = ownedMoney - bill;

            for (int i = 3; i >= 0; i--)
            {
                changeCoins[i] = changeMoney / coins[i];
                changeMoney = changeMoney % coins[i];
                paymentCoins[i] = ownedCoins[i] - changeCoins[i];
            }
            for (int i = 0; i <= 3; i++)
                if (paymentCoins[i] > 0) Console.WriteLine("{0} {1}", coins[i], paymentCoins[i]);
        }
    }
}


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

int main() {
  string in;
  cin >> in;
  int a = in[0] - '0', b = in[1] - '0', c = in[2] - '0', d = in[3] - '0';
  char key[] = {'+', '-'};
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int n = a;
        if (i == 0)
          n += b;
        else
          n -= b;
        if (j == 0)
          n += c;
        else
          n -= c;
        if (k == 0)
          n += d;
        else
          n -= d;

        if (n == 7) {
          cout << a << key[i] << b << key[j] << c << key[k] << d << "=7"
               << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

signed main()
{ // #define int long long をしてるのでscanfを使うと意味不明な値が入力され死にます
    int T; cin >> T;

    rep(_, T) {
        int N, D; cin >> N >> D;
        int ans = 0;

        rep(i, N - 1) {
            D ^= 127;
            ans += 127;
        }
        ans += D;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<functional>
#include<stack>
#include<set>
typedef long long ll;

using namespace std;

vector<int> xd{-1,1,0,0};
vector<int> yd{0,0,-1,1};
int X, Y;

int bfs(vector<string>& b, int x, int y){
    if(b[y][x] == '#'){return 0;}
    vector<vector<int>> ds(Y, vector<int>(X, 50000));
    queue<pair<int,int>> st;
    int maxD = 0;
    st.push(make_pair(x,y));
    ds[y][x]=0;
    while(!st.empty()){
        auto now = st.front();
        st.pop();
        int nx=now.first;
        int ny=now.second;
//        cout << now.first << now.second << ds[now.second][now.first] << endl;
        for(int d=0;d<4;d++){
            int tx = now.first+xd[d];
            int ty = now.second+yd[d];
            if(tx < 0 || tx >= X || ty < 0 || ty >= Y || b[ty][tx]=='#'){continue;}
            if(ds[ty][tx] <= ds[ny][nx]+1){continue;}
            ds[ty][tx] = ds[ny][nx]+1;
            st.push(make_pair(tx,ty));
        }
    }

    for(int y=0;y<Y;y++){
        for(int x=0;x<X;x++){
            if(b[y][x] == '#' || ds[y][x] == 50000){continue;}
            maxD = max(maxD, ds[y][x]);
        }
    }
    if(maxD == 50000){return 0;}
    return maxD;    
}



int main(){
    cin >> Y >> X;
    vector<string> b(Y);
    for(int y=0;y<Y;y++){
        cin >> b[y];
    }
    int maxD = 0;
    for(int y=0;y<Y;y++){
        for(int x=0;x<X;x++){
            maxD = max(maxD, bfs(b ,x, y));
        }
    }

    cout << maxD;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        double inta = Double.parseDouble(str);
 
        System.out.printf("%f %f", inta*inta*Math.PI, inta*2*Math.PI );
 
    }
 
}

Measured memory_bytes: 26444
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int>v;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	long long ans=0;
	for(int i=0;i<k;i++)ans=ans+v[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3172
N,X,D=map(int,input().split())
r=N*(X!=0)+1
if D:
 f,c,r={},[0]*10**8,0
 for x,y,z in sorted((((N-k)*j+~-k)*k//2+k*X//D,j,k*X%D)for k in range(N+1)for j in[0,2]):
  if c[z]+y<1:
   f[z]=x
  r+=(x-f[z]+1)*(c[z]<y)
  c[z]-=y-1
print(r)

Measured memory_bytes: 887772
# -*- coding: utf-8 -*-
"""
C - Exception Handling
https://atcoder.jp/contests/abc134/tasks/abc134_c

"""
import sys


def solve(arr):
    sarr = sorted(arr)
    ans = [sarr[-1] if a != sarr[-1] else sarr[-2] for a in arr]
    return ans


def main(args):
    N = int(input())
    arr = [int(input()) for _ in range(N)]
    ans = solve(arr)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 17216
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> v(n);
    for (Int i = 0; i < n; i++) cin >> v[i];
    Int res = 0;
    for (Int i = 1; i <= min(n, k); i++) {   
        for (Int j = 0; j <= i; j++) {
            vector<Int> x;
            for (Int l = 0; l < j; l++) {
               x.emplace_back(v[l]);
            }
            for (Int l = 0; l < i - j; l++) {
               x.emplace_back(v[n - 1 - l]);
            }
            sort(x.begin(), x.end(), greater<Int>());
            Int m = (Int)x.size();
            for (Int l = 0; l < min(k - i, m); l++) {
                if (x.back() >= 0) break;
                x.pop_back();
            }
            Int ma = 0;
            for (auto l : x) ma += l;
            res = max(res, ma);
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int N;
	cin >> N;
	bool F = false;
	int A;
	for (int i = 0;i <= N;i++) {
		A = i * 1.08;
		if (A == N) {
			cout << i << endl;
			F = true;
			break;
		}
	}
	if (F == false){
		cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<cctype>
#include<sstream>

using namespace std;

const int MAX = 10;

stack<int> stk;

int main()
{
	char s[MAX];
	while(~scanf("%s", s))
	{
		if(isdigit(s[0]))
		{
			stringstream ss(s);
			int tmpnum;
			ss >> tmpnum;
			stk.push(tmpnum);
		}
		else if(s[0] == '-')
		{
			int a = stk.top();
			stk.pop();
			int b = stk.top();
			stk.pop();
			stk.push(b - a);
		}
		else if(s[0] == '+')
		{
			int a = stk.top();
			stk.pop();
			int b = stk.top();
			stk.pop();
			stk.push(b + a);
		}
		else if(s[0] == '*')
		{
			int a = stk.top();
			stk.pop();
			int b = stk.top();
			stk.pop();
			stk.push(b * a);
		}
	}
	printf("%d\n", stk.top());
	return 0;
}



Measured memory_bytes: 3268
def primeFactorize(n):
    factors = []

    while n % 2 == 0:
        factors.append(2)
        n //= 2

    i = 3
    max_factor = n ** 0.5

    while i <= max_factor:
        while n % i == 0:
            factors.append(i)
            n //= i
            max_factor = n ** 0.5
        i += 2

    if n > 1:
        factors.append(n)

    return factors


n = int(input())
factors = primeFactorize(n)
print("{0}:".format(n), end="")
for factor in factors:
    print(" {0}".format(factor), end="")
print()

Measured memory_bytes: 6792
fun main(args:Array<String>):Unit {
    val (n, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val time = Array(n){readLine()!!.trim().toLong()}
    val diff = Array(n - 1){time[it + 1] - time[it] - 1}.sortedDescending()
    println(
            time.last() - time[0] - diff.take(k - 1).sum() + 1
    )
}


Measured memory_bytes: 47480
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if W >= V:
  print("NO")
  exit()

dis = abs(A-B)
vel = abs(V-W)

c = vel*T

if dis <= c:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9192
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

print(n*(n-1)//2)

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

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<vector<pair<int, int>>> G;

G graph;
vint ans;

void dfs(int v,int color = -1, int p = -1)//pは前の場所,vは今の場所 
{
	int k = 1;
	rep(i, graph[v].size())
	{
		int nextnode = graph[v][i].first,edgenum = graph[v][i].second;
		if (nextnode == p)
		{
			continue;
		}
		if (k == color)
		{
			k++;
		}
		ans[edgenum] = k;
		k++;
		dfs(nextnode,ans[edgenum], v);
	}
}

int main()
{
	int n;
	cin >> n;
	graph.resize(n);
	ans.resize(n);
	rep(i, n-1)
	{
		int a, b;
		cin >> a >> b;
		a--; 
		b--;
		graph[a].push_back({ b,i });
		graph[b].push_back({ a,i });
	}
	dfs(0);
	auto itr = max_element(ans.begin(), ans.end());
	cout << *itr << endl;
	rep(i, n-1)
	{
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 8320
n, a, b = map(int, input().split())
m = 10 ** 9 + 7

nf = 10 ** 5 * 2 + 100
fact = [0] * (nf + 1)
fact[0] = 1
for i in range(nf):
    # fact[i + 1] = (fact[i] * (n - i) / (i + 1)) % m
    fact[i + 1] = (fact[i] * (n - i) * pow((i + 1), m - 2, m)) % m





ans = pow(2, n, m) - 1 - fact[a] - fact[b]
# ans = (2 ** n - 1) % m - fact[a] - fact[b]


ans = ans % m
print(int(ans))


Measured memory_bytes: 12308
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int H = sc.nextInt();
   int A = sc.nextInt();
   
   int ans = H/A +1;
   if(H%A==0) ans-=1;
   System.out.println(ans);
 }
}

Measured memory_bytes: 23764
#include <stdio.h>
 
int main() {
 
  int n,i,sum,k;
  int j;
 
  while(1) {
    sum = 0;
    k = 0;
    scanf("%d",&n);
 
    if(n == 0) break;
 
    for(j=1;j<=n;j++) {
      sum = 0;
    for(i=j;i<=n;i++) {
      sum += i;
 
      if(sum == n && i != n) k++;
      else if(sum > n) i = n+1;
 
    }
    }
 
    printf("%d\n",k);
 
  }
 
  return 0;
 
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int l[m],r[m];
  for(int i=0;i<m;i++){
    cin>>l[i]>>r[i];  
  }
  sort(l,l+m);
  sort(r,r+m);
  if(r[0]<l[m-1]){
      cout<<0<<endl;
      return 0;
  }
  cout<<r[0]-l[m-1]+1<<endl;
}


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


void solve(long long N, std::vector<long long> d){
    long long ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < i; ++j){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		scan.close();
		long t = n;
		List<Long> list = new ArrayList<Long>();
		for(long i = 2; i * i <= n; i++) {
			if(n % i == 0) {
				list.add(i);
				while(n % i == 0) {
					n = n / i;
				}
			}
		}
		if(n != 1) {
			list.add(n);
		}
		long k = 1;
		for(long i : list) {
			k *= (i - 1);
			t /= i;
		}
		System.out.println(k * t);
	}
}


Measured memory_bytes: 26336