akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")


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

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

// @formatter:on


class AAirConditionerEditorial {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << '\n';
  }
};

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


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

int main() {
  int N, devider = 0;
  cin >> N;
  for (int n = N; n != 0; n /= 10) {
    devider += n % 10;
  }

  if (N % devider == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    int N;
    cin >> N;
    int A[N+1],B[N+1];

    for(int i=0;i<N+1;i++){
        cin >> A[i];
    }

    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    B[N] = 0;


    int ans = 0;

    for(int i=0;i<N+1;i++){
        if(A[i]<B[i]){
            ans += A[i];
            B[i] -= A[i];
            if(i!=N){
                if(A[i+1] < B[i]){
                    ans += A[i+1];
                    A[i+1] = 0;
                }else{
                    ans += B[i];
                    A[i+1] -= B[i];
                }
            }
        }else{
            ans += B[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	fastio();
	int n;
	cin>>n;
	int ans=1000*(n/500);
	n=n%500;
	ans+=5*(n/5);
	cout<<ans<<endl;
}


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

def num_divisors_table(n):
  table = [0] * (n + 1)
  for i in range(1, n + 1):
    for j in range(i, n + 1, i):
      table[j] += 1
  return table

table = num_divisors_table(1000000)

# a x b + c == n
# n - c == a x b

res = 0
for i in range(1, N):
  res += table[i]

print(res)

Measured memory_bytes: 16784
n=int(input())

def main():
    if(n<600):
        print(8)
        return
    elif(n<800):
        print(7)
        return
    elif(n<1000):
        print(6)
        return
    elif(n<1200):
        print(5)
        return
    elif(n<1400):
        print(4)
        return
    elif(n<1600):
        print(3)
        return
    elif(n<1800):
        print(2)
        return
    else:
        print(1)
        return
if __name__=="__main__":
    main()

Measured memory_bytes: 9208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aizu
{
	class Program
	{
		static void Main(string[] args)
		{
			var k = int.Parse(Console.ReadLine());
			var queens = new List<int[]>();

			for(var i = 0; i < k; i++)
			{
				queens.Add(Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray());
			}

			var array = new int[8];
			for(int i = 0; i < 8; i++)
			{
				array[i] = i;
			}

			var permutations = GetAllPermutation(array);

			foreach(var permutation in permutations)
			{
				var isOk = true;
				for(var i = 0; i < k; i++)
				{
					if(queens[i][1] != permutation[queens[i][0]])
					{
						isOk = false;
						break;
					}
				}

				if(!isOk)
				{
					continue;
				}

				for(var i = 0; i < 8; i++)
				{
					var index = 1;
					while(i - index >= 0 && permutation[i] - index >= 0)
					{
						if(permutation[i - index] == permutation[i] - index)
						{
							isOk = false;
							break;
						}
						index++;
					}
					if (!isOk)
					{
						break;
					}

					index = 1;
					while (i + index < 8 && permutation[i] - index >= 0)
					{
						if (permutation[i + index] == permutation[i] - index)
						{
							isOk = false;
							break;
						}
						index++;
					}
					if (!isOk)
					{
						break;
					}

					index = 1;
					while (i - index >= 0 && permutation[i] + index < 8)
					{
						if (permutation[i - index] == permutation[i] + index)
						{
							isOk = false;
							break;
						}
						index++;
					}
					if (!isOk)
					{
						break;
					}

					index = 1;
					while (i + index < 8 && permutation[i] + index < 8)
					{
						if (permutation[i + index] == permutation[i] + index)
						{
							isOk = false;
							break;
						}
						index++;
					}
					if (!isOk)
					{
						break;
					}
				}

				if (isOk)
				{
					for(var i = 0; i < 8; i++)
					{
						var row = "........";
						row = row.Insert(permutation[i], "Q");
						row = row.Remove(row.Length - 1, 1);
						Console.WriteLine(row);
					}

					return;
				}
			}
		}

		private static List<int[]> GetAllPermutation(int[] array)
		{
			var permutations = new List<int[]>();
			permutations.Add(array);

			while(true)
			{
				int i;
				var list = permutations[permutations.Count - 1].ToList();

				for (i = list.Count - 2; i >= 0; i--)
				{
					if (list[i] < list[i + 1])
					{
						break;
					}
				}

				if (i < 0)
				{
					break;
				}

				for(var j = list.Count - 1; j > i; j--)
				{
					if(list[i] < list[j])
					{
						var tmp = list[i];
						list[i] = list[j];
						list[j] = tmp;

						list.Reverse(i + 1, list.Count - (i + 1));
						permutations.Add(list.ToArray());
						break;
					}
				}
			}

			return permutations;
		}
	}
}



Measured memory_bytes: 28692
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll a,b,c;cin>>a>>b>>c;
    ll ans=0;
    repl(i,a,b+1)if(c%i==0)ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3112
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
ll power(ll x,ll p){ll a=1;while(p>0){if(p%2==0){x*=x;p/=2;}else{a*=x;p--;}}return a;}
map<ll, int> prime_factor(ll num) {
	map<ll, int> mp;
	ll k = (ll)sqrt(num);
	mp[1]++;
	rep(i, 2, k + 1) {
		while (num % i == 0) {
			num /= i;
			mp[i]++;
		}
	}
	if (num != 1)mp[num]++;
	return mp;
}
int main() {
	ll N, P, r = 1;
	cin >> N >> P;
	map<ll, int> mp = prime_factor(P);
	for (auto m : mp) {
		r *= power(m.first, m.second / N);
	}
	printf("%lld\n", r);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
int n;
cin>>n;
int a=3;
int b=0;
while(a<=n){
    int c=0;
    for(int i=1;i<=n;i++){
        if(a%i==0) c++;
    }
    if(c==8) b++;
    a+=2;
}
cout<<b<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MX = 1e6+2;
int seen[MX], arr[MX], sieve[MX];
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	for(int i=2; i<MX; i++) {
		if(!sieve[i]) {
			for(int j=i*i; j<MX; j+=i) {
				sieve[j] = i;
			}
		}
	}

	int n, allgcd = 1;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> arr[i];
		if(!i) {
			allgcd = arr[i];
		} else {
			allgcd = gcd(allgcd, arr[i]);
		}
	}
	bool ok = 1;
	vector<int> v;
	for(int i=0; i<n; i++) {
		v.clear();
		int t = arr[i];
		while(sieve[t]) {
			v.push_back(sieve[t]);
			t /= sieve[t];
		}
		if(t != 1) {
			v.push_back(t);
		}
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
		for(int k: v) {
			if(seen[k]) {
				if(allgcd == 1) {
					return !(cout << "setwise coprime");
				} else {
					return !(cout << "not coprime");
				}
			}
			seen[k] = 1;
		}
	}
	cout << "pairwise coprime";
}

Measured memory_bytes: 19824
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong a, b, c; cin >> a >> b >> c;
    llong ans = 0;
    if (a + b + 1 >= c) ans = b + c;
    else ans = 2 * b + a + 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> a >> b;
	ans = max(a+b , max(a-b , a*b));

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


Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
   int ans = 0;
   int n, K;
   cin >> n >> K;
   vector<int>a(n);
   rep(i,n)cin >> a[i];
   for(int i = 0; i <= min(n,K); i++){
      for(int j = 0; j <= min(n,K) and i + j <= n; j++){
         int num = K - i - j;
         if(num < 0)continue;
         priority_queue<int>pq;
         int sum = 0;
         for(int k = 0; k < n; k++){
            if(i<=k and k < n-j)continue;
            sum += a[k];
            if(a[k]<0)pq.push(-a[k]);
         }
         int sz = (int) pq.size();
         rep(hoge,min(num,sz)){
            int x = pq.top();
            pq.pop();
            sum += x;
         }
         ans = max(ans, sum);
      }
   }
   cout << ans << endl;
}

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

using namespace std;

int main() {
 long long zv,n,x,s=0,d;
 cin>>zv>>n;
 while(n--){
     cin>>x;
     s+=x;
 }
 d=zv-s;
 if(d<0) cout<<-1;
 else   cout<<d;
 return  0;
}


Measured memory_bytes: 3612
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
int n;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	cout<<48-n;
	return 0;
}

Measured memory_bytes: 256
using System;
 
namespace _0208
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                string s = Convert.ToString((n), 8);
                s = s.Replace("7", "9");
                s = s.Replace("6", "8");
                s = s.Replace("5", "7");
                s = s.Replace("4", "5");
                Console.WriteLine(s);
            }
        }
    }
}

Measured memory_bytes: 9060
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func calculateFactorizations(n int) []int {
	factors := make([]int, n+2)
	i := 2
	for {
		if i > n {
			break
		} else if n%i == 0 {
			n = n / i
			factors[i]++
		} else {
			i++
		}
	}
	return factors
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	factors := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		factors[i] = calculateFactorizations(a[i])
	}
	// fmt.Println(factors)

	aMax := 0
	for i := 0; i < n; i++ {
		aMax = max(aMax, a[i])
	}
	// fmt.Println("aMax =", aMax)

	lcm := 1.0
	for j := 2; j <= aMax; j++ {
		fMax := 0
		for i := 0; i < n; i++ {
			if j < len(factors[i]) {
				fMax = max(fMax, factors[i][j])
			}
		}
		// fmt.Println("fMax =", fMax)
		if fMax > 0 {
			lcm *= math.Pow(float64(j), float64(fMax))
		}
	}
	fmt.Println(int64(lcm))
}



Measured memory_bytes: 1148
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n;
	cin >> n;
	vi a(n),b(n),c(n-1);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n-1) cin >> c[i];
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans += b[i];
	}
	for(int i = 0; i < n-1; i++){
		if(a[i+1]-a[i] == 1) ans += c[a[i]-1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	int h, w;
	string abc="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	cin >> h >> w;
	string s[26][26];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> s[i][j];
		}
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j]=="snuke"){
				cout << abc[j] << i+1 << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,d=0;
  scanf("%d %d",&a,&b);
  int c[a];
  for(int i=0; i<a; i++){scanf("%d",&c[i]);}
  d++;a-=b;b--;
  while(a>0){a-=b;d++;}
  printf("%d",d);
  return 0;}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{

	int n;
	int cards[5][14]={{0}};
	char pattern;
	int num;

	
	cin>>n;	
	for( int i=0; i<n; i++ ) {
		cin>>pattern>>num;
		switch( pattern ) {
			case 'S':
				cards[0][num-1]=true;
				break;
			case 'H':
				cards[1][num-1]=true;
				break;
			case 'C':
				cards[2][num-1]=true;
				break;
			case 'D':
				cards[3][num-1]=true;
				break;
			}
	}
	for( int i=0; i<4; i++ ) {
		for( int j=0; j<13; j++ ) {
			if( false == cards[i][j] ) {
				switch( i ) {
					case 0:
						cout <<"S "<<(j+1)<<endl;
						break;
					case 1:
						cout <<"H "<<(j+1)<<endl;
						break;
					case 2:
						cout <<"C "<<(j+1)<<endl;
						break;
					case 3:
						cout <<"D "<<(j+1)<<endl;
						break;
				}
			}
		}
	}
	
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
struct date{
  long long y;
  int m;
  int d;
  date(): y(1), m(1), d(1){
  }
  date(long long y, int m, int d): y(y), m(m), d(d){
  };
};
bool is_leap_year(long long x){
  if (x % 4 != 0){
    return false;
  } else if (x % 100 != 0){
    return true;
  } else if (x % 400 != 0){
    return false;
  } else {
    return true;
  }
}
date next(date X){
  long long Y = X.y;
  int M = X.m;
  int D = X.d;
  if (M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M == 10){
    if (D == 31){
      M++;
      D = 1;
    } else {
      D++;
    }
  } else if (M == 12){
    if (D == 31){
      Y++;
      M = 1;
      D = 1;
    } else {
      D++;
    }
  } else if (M == 4 || M == 6 || M == 9 || M == 11){
    if (D == 30){
      M++;
      D = 1;
    } else {
      D++;
    }
  } else if (M == 2){
    if (is_leap_year(Y)){
      if (D == 29){
        M++;
        D = 1;
      } else {
        D++;
      }
    } else {
      if (D == 28){
        M++;
        D = 1;
      } else {
        D++;
      }
    }
  }
  return date(Y, M, D);
}
long long f(date X){
  long long Y = X.y;
  int M = X.m;
  int D = X.d;
  long long ans = 0;
  Y--;
  ans += 688 * (Y / 400);
  Y %= 400;
  Y++;
  int day = 2;
  date C;
  while (C.y != Y || C.m != M || C.d != D){
    if (C.d == 13 && day == 6){
      ans++;
    }
    day++;
    if (day == 8){
      day = 1;
    }
    C = next(C);
  }
  return ans;
}
int main(){
  long long Y1;
  int M1, D1;
  long long Y2;
  int M2, D2;
  cin >> Y1 >> M1 >> D1 >> Y2 >> M2 >> D2;
  date A(Y1, M1, D1);
  date B(Y2, M2, D2);
  //increment Y2M2D2
  B = next(B);
  cout << f(B) - f(A) << endl;
  /*
  date C;
  int cnt = 0;
  int day = 2;
  while (C.y != 401){
    if (C.d == 13 && day == 6){
      cnt++;
    }
    day++;
    if (day == 8){
      day = 1;
    }
    C = next(C);
  }
  cout << cnt << endl;
  */
}


Measured memory_bytes: 3104
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct edge{
    ll from,to,cost;
    edge(ll from,ll to,ll cost):from(from),to(to),cost(cost) {}
};
int main(){
    ll n,m,p;
    cin>>n>>m>>p;
    V<edge> g;
    for(int i=0;i<m;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        g.emplace_back(a,b,-c+p);
    }
    V<ll> d(n,inf);
    d[0]=0;
    for(int i=0;i<n;i++){
        for(auto &e:g){
            if(d[e.from]>=inf)continue;
            chmin(d[e.to],d[e.from]+e.cost);
        }
    }
    for(int i=0;i<n;i++){
        for(auto &e:g){
            if(d[e.from]>=inf)continue;
            if(chmin(d[e.to],d[e.from]+e.cost)){
                d[e.to]=-inf;
            }
        }
    }
    if(d[n-1]<=-inf)cout<<-1<<"\n";
    else cout<<(-d[n-1]>0?-d[n-1]:0)<<"\n";
}


Measured memory_bytes: 3792
#include<iostream>
using namespace std;
  int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    int cnt = 0;
    for(int x = a; x <= b; x++){
       if(c % x == 0) cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3120
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        List<int> list = new List<int>();
        List<int> list2 = new List<int>();
        for (var i = 0; i < 5; i++) {
            var a = int.Parse(Console.ReadLine());
            if (a % 10 == 0) {
                list.Add(a);
            } else {
                list2.Add(a);
            }
        }
        
        list2 = list2.OrderByDescending(d => d % 10).ToList();
        
        var sum = 0;
        for (var i = 0; i < list.Count; i++) {
            sum += list[i];    
        }
        for (var i = 0; i < list2.Count - 1; i++) {
            sum += list2[i] + (10 - list2[i] % 10);
        }
        if (list2.Count > 0) {
            sum += list2.Last();
        }

        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, x: "List[int]"):
    mn = 1e9
    for i in range(N-K+1):
        n = abs(x[i])
        a = abs(x[i+K-1])
        if x[i+K-1] * x[i] < 0:
            mn = min([mn, 2*a+n, 2*n+a])
        else:
            mn = min([mn, max(a, n)])
    print(mn)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17492
N=int(input())
A=[int(input()) for _ in range(N)]

AL=[A[0]]
AR=[A[-1]]
for i in range(1,N):
    AL.append(max(A[i],AL[i-1]))
    AR.append(max(A[N-i-1],AR[i-1]))
AR.reverse()
del AL[-1]
del AR[0]

print(AR[0])
for i in range(1,N-1):
    print(max(AL[i-1],AR[i]))
print(AL[-1])

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; }

void dfs(int v, int &now, vector<vector<int>> &G, vector<int> &T) {
	int N = G[v].size();
	T[v] = -1;
	for (int i = 0; i < N; i++) {
		if (T[G[v][i]] != -2) continue;
		dfs(G[v][i], now, G, T);
	}
	T[v] = ++now;
}

void dfs2(int v, int g, vector<vector<int>> &ret, vector<vector<int>> &G_rev, vector<pii> &P, vector<int> &visit) {
	visit[v] = 1;
	ret[g].push_back(v);
	int N = G_rev.size();
	for (int i = 0; i < (int)G_rev[v].size(); i++) {
		if (visit[G_rev[v][i]]) continue;
		dfs2(G_rev[v][i], g, ret, G_rev, P, visit);
	}
}

void solve() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	vector<vector<int>> G_rev(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G_rev[b].push_back(a);
	}

	vector<int> T(N, -2);
	int now = 0;
	for (int i = 0; i < N; i++) {
		if (T[i] == -2) dfs(i, now, G, T);
	}

	vector<pii> P(N);
	for (int i = 0; i < N; i++) {
		P[i] = {T[i], i};
	}

	sort(P.rbegin(), P.rend());

	vector<int> visit(N);
	vector<vector<int>> ret;
	int g = 0;
	for (int i = 0; i < N; i++) {
		if (visit[P[i].second]) continue;
		ret.push_back(vector<int>());
		dfs2(P[i].second, g, ret, G_rev, P, visit);
		g++;
	}

	vector<int> group(N);
	for (int i = 0; i < (int)ret.size(); i++) {
		for (int j = 0; j < (int)ret[i].size(); j++) {
			group[ret[i][j]] = i;
		}
	}
	
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		if (group[a] == group[b]) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(16);
	solve();
	return 0;
}


Measured memory_bytes: 5224
local n, x = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local cnt = 1
local sum = 0
for i = 1, n do
  sum = sum + t[i]
  if sum <= x then cnt = cnt + 1 end
end
print(cnt)


Measured memory_bytes: 760
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = A[::-1] + B

right = 0
size = 0
ans = 0
for left in range(N+M):
    while right < (N+M) and size+C[right] <= K:
        size += C[right]
        right += 1
    if left <= N and N <= right:
        ans = max(ans, (right-left))
    if left == right:
        right += 1
    else:
        size -= C[left]

print(ans)


Measured memory_bytes: 118672
#include<bits/stdc++.h>
using namespace std;
long long n,k,p[5555],c[5555];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>p[i];
		p[i]--;
	}
	for(int i=0;i<n;i++)
		cin>>c[i];
	long long res=-1e18;
	for(int s=0;s<n;s++){
		vector<long long> v;
		for(int i=s;;i=p[i]){
			v.push_back(c[i]);
			if(p[i]==s)
				break;
		}
		long long m=v.size();
		long long sum=0;
		for(int i=0;i<m;i++)
			sum+=v[i];
		long long cur=0;
		for(int r=1;r<=m;r++){
			if(r>k)
				break;
			cur+=v[r-1];
			res=max(res,cur+(k-r)/m*max(sum,(long long)0));
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3792
#include<cstdio>
const int Mod=1e9+7;
inline int MyPow(int a,int b){
    int ss=1;
    for(;b;b>>=1){
        if(b&1) ss=1ll*ss*a%Mod;
        a=1ll*a*a%Mod;
    }
    return ss;
}
inline int C(const int n,int m){
    if(n<m) return 0;
    if(n==m) return 1;
    if(m>n-m) m=n-m;
    int sn=1,sm=1;
    for(register int i=0;i<m;i++){
        sn=1ll*(n-i)%Mod*sn%Mod;
        sm=1ll*(m-i)%Mod*sm%Mod;
    }
    return 1ll*sn*MyPow(sm,Mod-2)%Mod;
}
inline int Lucas(const int n,const int m){
    if(!m) return 1;
    return 1ll*C(n%Mod,m%Mod)*Lucas(n/Mod,m/Mod)%Mod;
}
inline int Get(const int a,const int b){
    return Lucas(a+b,a);
}
int r1,r2,c1,c2;
int main(){
    scanf("%d %d %d %d",&r1,&c1,&r2,&c2);
    r1++;c1++;r2++;c2++;
    printf("%d\n",(((Get(r2,c2)+Get(r1-1,c1-1))%Mod-(Get(r1-1,c2)+Get(r2,c1-1)%Mod))%Mod+Mod)%Mod);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

ll suml,sumr;
int main()
{
	int n,k;
	cin>>n>>k;
	F(i,1,k-1) suml+=i-1,sumr+=n+1-i;
	ll ans=0;const ll p=1000000007;
	F(i,k,n+1) {suml+=i-1,sumr+=n+1-i;ans=(ans+sumr-suml+1)%p;}
	cout<<ans<<endl;
	return 0;
}

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

int min_d = (int)2e9;
int N, K;
vector<int> H;

int main(void) {
	cin >> N >> K;
	H.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> H[i];

	sort(H.begin(), H.end());
	for (int i = 0; i <= N - K; ++i) {
		int d = H[i + K - 1] - H[i];
		min_d = min(d, min_d);
	}

	cout << min_d << '\n';
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define pb push_back
#define eb emplace_back

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;
}

using ll = long long;
using namespace std;

ll GetNum(ll N, ll M, const vector<ll> &s, const vector<ll> &c)
{
	int num[3]{-1, -1, -1};

	rep(i, M)
	{
		ll index = s[i] - 1;
		if ((num[index] == -1) || (num[index] == c[i]))
		{
			num[index] = c[i];
		}
		else
		{
			return -1; // 同じ桁に別の値指定がされた
		}
	}

	// 2桁以上の0開始はNG
	if ((num[0] == 0) && (1 < N))
	{
		return -1;
	}

	// 2桁以上で先頭が定まっていない -> 強制的に最低値の1
	if ((num[0] == -1) && (1 < N))
	{
		num[0] = 1;
	}

	// 未指定箇所を0埋め
	rep(i, 3)
	{
		if (num[i] == -1)
		{
			num[i] = 0;
		}
	}

	// 結果を返す
	switch (N)
	{
	case 1:
		return num[0];
	case 2:
		return num[0] * 10 + num[1];
	case 3:
		return num[0] * 100 + num[1] * 10 + num[2];
	}
	return -1;
}

int main()
{
	ll N, M;
	cin >> N >> M;
	vector<ll> s, c;
	rep(i, M)
	{
		ll tmp;
		cin >> tmp;
		s.eb(tmp);
		cin >> tmp;
		c.eb(tmp);
	}

	ll result = GetNum(N, M, s, c);
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
int main(){
	int N,K;
	int i,sum=1;
	scanf("%d",&N);
	scanf ("%d",&K);
	for(i=0;i<N;i++){
		if (sum>=K) sum+=K;
		else sum+=sum;
	}
	printf ("%d\n",sum);
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int d,t,s;
	cin >> d >> t >> s;
	if(t*s >= d) printf("Yes");
	else printf("No");
	
	return 0;
}


Measured memory_bytes: 3784
H,W = map(int,input().split())
Data = []
MOD = 10**9+7
for _ in range(H):
    Data.append(input())
DP = [[-1]*(W) for _ in range(H)]

for h in range(H):
    for w in range(W):
        if h == 0 and w == 0:
            DP[h][w] = 1 
        elif Data[h][w] == '.':
            path = 0
            if w > 0 and DP[h][w-1] != -1:
                path += DP[h][w-1]
            if h > 0 and DP[h-1][w] != -1:
                path += DP[h-1][w]
            DP[h][w]= path % MOD


print(DP[H-1][W-1])

Measured memory_bytes: 54380
#include<cstdio>
using namespace std;
const int N=205;
const int inf=1<<30;
struct dd{int nex,to,flow;}e[40005];
int n,m,s,t,sx,sy,tx,ty,p,q,tot=1,num,ans,last[N],co[N],cur[N],d[N],a[N][N];
char ch;
int min(int a,int b){return a<b?a:b;}
void add(int x,int y,int z)
{
	e[++tot]=(dd){last[x],y,z},last[x]=tot;
	e[++tot]=(dd){last[y],x,0},last[y]=tot;
}
int dfs(int x,int y)
{
	if (x==t) return y;
	int u=0,p;
	for (int i=cur[x];i;i=e[i].nex)
	{
		cur[x]=i;
		if (e[i].flow>0 && d[e[i].to]+1==d[x])
		{
			p=dfs(e[i].to,min(e[i].flow,y-u));
			u+=p,e[i].flow-=p,e[i^1].flow+=p;
			if (u==y) return u;
		}
	}
	cur[x]=last[x];
	if (!(--co[d[x]])) d[s]=num;
	++co[++d[x]];
	return u;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("\n");
		for (int j=1;j<=m;j++)
		{
			scanf("%c",&ch),p++;
			if (ch=='S') s=p;
			if (ch=='T') t=p;
			if (ch=='o') a[i][j]=1;
		}
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		if (a[i][j]) add(i,n+j,1),add(n+j,i,1);
	sx=(s+m-1)/m,sy=(s-1)%m+1+n;
	tx=(t+m-1)/m,ty=(t-1)%m+1+n;
	num=n+m;
	add(num+1,sx,inf),add(num+1,sy,inf);
	add(tx,num+2,inf),add(ty,num+2,inf);
	s=num+1,t=num+2,num+=2;
	co[0]=num;
	for (;d[s]<num;) ans+=dfs(s,inf);
	if (ans>=inf) ans=-1; 
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
int main()
{
int a,b;
scanf("%d%d",&a,&b);
if(a<=5)
printf("0\n");
  if(a>5&&a<13)
 printf("%d\n",b/2);
  if(a>=13)
    printf("%d\n",b);
return 0;
}

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

int main(){
	int a;
	string b; 
	cin>>a>>b;
	int c = b.size();
	if(a<c){
		for(int i = 0 ; i < a ; i++){
			cout<<b[i];
		}
		cout<<"...";
	}else{
		cout<<b;
	}
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];
    
    int gcd = A[0]; bool ok = false;
    REP(i, 0, N) {
        gcd = __gcd(gcd, A[i]);
        if (A[i] >= K) ok = true;
    }
    
    if (!ok) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    if (K % gcd == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		char[,] grid = new char[N, N];
		for(int i = 0; i < N; i++)
		{
			string S = GetString();
			for(int j = 0; j < N; j++)
				grid[i, j] = S[j];
		}

		int ans = 0;
		for(int A = 0; A < N; A++)
		{
			char[,] tmp = new char[N, N];
			for(int i = 0; i < N; i++)
				for(int j = 0; j < N; j++)
					tmp[i, j] = grid[(i + A) % N, j];

			if(isSymmetric(tmp))
				ans += N;
		}

		Console.WriteLine(ans);
	}

	private static bool isSymmetric(char[,] grid)
	{
		int N = grid.GetLength(0);
		for(int i = 0; i < N; i++)
		{
			for(int j = i; j < N; j++)
			{
				if(grid[i, j] != grid[j, i])
				{
					return false;
				}
			}
		}
		return true;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 28136
#include<bits/stdc++.h>
using namespace std;
string solve(string s){
	if(s.size()<=25){
		for(char c='a';c<='z';c++){
			if(s.find(c)==string::npos){
				s+=c;
				return s;
			}
		}
	}
	char t[26];
	for(int i=0;i<s.size();i++){
		t[i]=s[i];
	}
	if(s.size()==26){
		string cnt="";
		if(!next_permutation(t,t+s.size()))return "-1";
		for(int i=0;i<s.size();i++){
			cnt+=t[i];
			if(t[i]!=s[i])break;
		}
		return cnt;
	}
}
int main(){
	string s;
	cin>>s;
	cout<<solve(s)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, x =0;
	cin >> N;
	for(int i =0; i < N; i++) {
		int a;
		cin >> a;
		if(a%2 != 0) x++;}
	if(x%2 == 0) cout << "YES\n";
	else cout << "NO\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (d2 == 1) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

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

int main() {
	long long int N;
	cin >> N;
	long long int a = 0, b = 0;
	for( size_t i = 0; i < N; i++ ) {
		long long int x, z;
		char y;
		cin >> x >> y >> z;
		if( y == '(' ) {
			a += z;
		} else {
			b += z;
		}
		if( a == b ) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 3092
N, K = map(int, input().split())
As = sorted(map(int, input().split()))

ng = 0
ok = 1001001001

while ok - ng > 1:
    mid = (ng + ok) // 2
    count = 0
    for A in As:
        count += -((-A) // mid)
        count -= 1

    if count <= K:
        ok = mid
    else:
        ng = mid

print(ok)

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


int main() {
  int N;
  cin>>N;
  int A=N/1000;
  int B=(N%1000)/100;
  int C=(N%100)/10;
  int D=N%10;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        int a=A;
        if(i==0){a-=B;}
        else{a+=B;}
        if(j==0){a-=C;}
        else{a+=C;}
        if(k==0){a-=D;}
        else{a+=D;}
        if(a==7){
          cout<<A<<(i==0 ? '-' : '+')<<B<<(j==0 ? '-' : '+')<<C<<(k==0 ? '-' : '+')<<D<<"=7"<<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S0 = sc.next();
    String S1 = sc.next();
    String S2 = sc.next();
    System.out.println("" + S0.charAt(0) + S1.charAt(1) + S2.charAt(2));
  }
}

Measured memory_bytes: 20948
import itertools, math

x=[]

n=int(input())

for i in range(n):x.append(list(map(int,input().split())))

p = itertools.permutations(x, n)

def dif(x, y):
 return math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2)

l=[]

for z in p:
  for i in zip(z[1:],z[:-1]):l.append(dif(i[0],i[1]))

print (sum(l)/math.factorial(len(z)))






Measured memory_bytes: 12080
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string>
#include <numeric>
#include <functional>
using namespace std;

int main()
{
	int N,x;
	cin >> N >> x;
	vector<int> a(N);
	int res = 0;
	for (int i = 0;i < N;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
		for (int i = 0;i < N;i++) {
			if (i == N - 1&& x != a[i]) {
				break;
			}
			if (x < 0) {
				break;
			}
			x -= a[i];
			if (x >= 0) {
				res++;
			}
		}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

const int inf = 1e9;
vector<ll>h, dp;

ll recc(int n, int k) {
  if(n < 0)
    return inf;
  if(dp[n] != -1)
    return dp[n];
  dp[n] = inf;
  int j = 1;
  for(int i = k; i > 0 and n-j >= 0; i--, j++) {
    dp[n] = min(dp[n], recc(n-j, k) + abs(h[n] - h[n-j]));
  }
  return dp[n];
}

void solve(){
  int n, k;
  cin >> n >> k;
  dp.resize(n, -1);
  h.resize(n);
  dp[0] = 0;
  for(ll &i : h) cin >> i;
  ll ans = recc(n-1, k);
 /*
  for(ll &i : dp)
    cout << i << ' ' ;
  cout << endl;
  */
  cout << ans << endl;
}

int main(){
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1, tt = 0;
	//	cin >> t;
		while(t--){
			//tt++;
			//cout << "Case #" << t << ": ";
			solve();
		}
	return 0;
}


Measured memory_bytes: 12624
#include<stdio.h>
#include<string.h>
#define N 36
typedef struct{
  int value;
  char c;
}Record;

void bubble(Record A[],int n){
  int i,j;
  Record s;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1; j--){
      if(A[j].value < A[j-1].value){
	s= A[j];
	A[j] = A[j-1];
	A[j-1] = s;
      }
    }
  }
}

void selection(Record S[],int n){
  int i,j,minj;
  Record s;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j < n; j++){
      if(S[j].value < S[minj].value)minj = j;
    }
    s = S[i];
    S[i]= S[minj];
    S[minj] = s;
  }
}

int hantei(Record A[],Record S[],int n){
  int i,flag;
  for(i=0; i<n; i++){
    if(A[i].c==S[i].c)flag = 0;
    else return -1;
  }
  return flag;
}


int main(){
  Record A[N],S[N];
  int n,i,j,judge;
  char c;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&A[i].c,&A[i].value);
    S[i]=A[i];
  }
  //デバッグ用
  /*
  printf("デバッグ用\n");
  for(i=0;i<n-1;i++){
   printf("%c%d ",A[i].c,A[i].value);
 }
 printf("%c%d\n",A[n-1].c,A[n-1].value);
 for(i=0;i<n-1;i++){
  printf("%c%d ",S[i].c,S[i].value);
 }
 printf("%c%d\n",S[n-1].c,S[n-1].value);
  printf("ここまで\n");
  //ここまで
  */
  
    
    
    bubble(A,n);
  selection(S,n);

  for(i=0;i<n-1;i++){
  printf("%c%d ",A[i].c,A[i].value);
    }
  printf("%c%d\n",A[n-1].c,A[n-1].value);
  printf("Stable\n");
  
  for(i=0;i<n-1;i++){
  printf("%c%d ",S[i].c,S[i].value);
    }
  printf("%c%d\n",S[n-1].c,S[n-1].value);
  judge = hantei(A,S,n);
  if(judge==0)printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;
}



Measured memory_bytes: 2108