akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")

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

using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;

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

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

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);


    ll K;
    cin >> K;

    cout << K * 2 *  M_PI  << "\n"; 

    return 0;



}


Measured memory_bytes: 3804
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n = int(input())
L = len(make_divisors(n))
i,j = make_divisors(n)[L//2-1], make_divisors(n)[L//2]

if (n**0.5).is_integer():
    print(int(2*(n**0.5-1)))
else:
    print(i+j-2)


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

int d[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	int k;
	cin >> k;
	vector<int> ans;
	rep(i,32){
		ans.push_back(d[i]);
	}
	cout << ans[k-1] << endl;
    return 0;
}



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

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll r = 0, g = 0; 
  rep(i,n) {
    if (s[i]=='R') r++;
    if (s[i]=='G') g++;
  }
  ll b = n-r-g;
  ll a = 0;
  rep(i,n) {
    for (ll j=i+1; j<(n); j++) {
      ll k = 2*j-i;
      if ((k < n) && (s[i] != s[j]) && (s[j] != s[k]) && (s[k] != s[i])) a++;
    }
  }
  cout << r*g*b-a << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
int main(){
    char s[1200] = {0};
    int c[26] = {0};
    int i=0,p;
    while(scanf("%c",&s[i])!=EOF){
        if(s[i]>=65&&s[i]<=90){
            p = s[i]-65;
            c[p]++;
        }
        else if(s[i]>=97&&s[i]<=122){
            p = s[i]-97;
            c[p]++;
        }
        i++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",i+97,c[i]);
    }
    return 0;
}

Measured memory_bytes: 2712
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a[i] = tmp;
  }
  vector<long long> lb(n + 1);
  vector<long long> ub(n + 1);
  lb[n] = 2;
  ub[n] = 3;
  for (int i = n - 1; i >= 0; i--) {
    lb[i] = (lb[i + 1] + a[i] - 1) / a[i] * a[i];
    ub[i] = (ub[i + 1] + a[i] - 1) / a[i] * a[i];
  }
  if (lb[0] == ub[0]) {
    cout << -1 << '\n';
  } else {
    cout << lb[0] << ' ' << ub[0] - 1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 2176
import Data.Char
  ( digitToInt )

main :: IO ()
main = do
  n <- readLn
  putStrLn $ if isHarshad n then "Yes" else "No"

isHarshad
  :: Int -> Bool
isHarshad x 
  = let fx = sumDigits x  
    in 0 == x `rem` fx

sumDigits
  :: Int -> Int
sumDigits = sum . map digitToInt . show



Measured memory_bytes: 508
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;
}

Measured memory_bytes: 3628
local n,k=io.read("n","n")
local h={}
for i=1,n do
    h[i]=io.read("n")
end

local INF=10^20
local dp={0}
for i=2,n do
    dp[i]=INF
end

for i=1,n do
    for j=1,k do
        if i+j<=n then
            dp[i+j]=math.min(dp[i+j],dp[i]+math.abs(h[i]-h[i+j]))
        end
    end
end
print(dp[n])

Measured memory_bytes: 4612
N=int(input())
A=list(map(int,input().split()))
S=[0] #累積和、S[i]はi番目の領域の始点
for i in range(N):
    S.append(S[-1]+A[i])
L=S[-1] #棒の長さの初期値

Sh=0 #中央に近い切れ込みの位置(領域の始点)
Dh=L #中央と切れ込みの差の最小値
for j in range(N+1):
    if Dh>abs(S[j]-L/2):
        Dh=abs(S[j]-L/2)
        Sh=j
if Dh==0:
    print(0)
else:
    print(int(Dh*2))

Measured memory_bytes: 26220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


using real = double;

struct C {
	real x, y;

	C() : x(0), y(0) {}

	C(real x, real y) : x(x), y(y) {}

	inline C operator+(const C &c) const { return C(x + c.x, y + c.y); }

	inline C operator-(const C &c) const { return C(x - c.x, y - c.y); }

	inline C operator*(const C &c) const { return C(x * c.x - y * c.y, x * c.y + y * c.x); }

	inline C conj() const { return C(x, -y); }
};

const real PI = acosl(-1);
int base = 1;
vector<C> rts = { { 0, 0 },
{ 1, 0 } };
vector<int> rev = { 0, 1 };


void ensure_base(int nbase) {
	if (nbase <= base) return;
	rev.resize(1 << nbase);
	rts.resize(1 << nbase);
	for (int i = 0; i < (1 << nbase); i++) {
		rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
	}
	while (base < nbase) {
		real angle = PI * 2.0 / (1 << (base + 1));
		for (int i = 1 << (base - 1); i < (1 << base); i++) {
			rts[i << 1] = rts[i];
			real angle_i = angle * (2 * i + 1 - (1 << base));
			rts[(i << 1) + 1] = C(cos(angle_i), sin(angle_i));
		}
		++base;
	}
}

void fft(vector<C> &a, int n) {
	assert((n & (n - 1)) == 0);
	int zeros = __builtin_ctz(n);
	ensure_base(zeros);
	int shift = base - zeros;
	for (int i = 0; i < n; i++) {
		if (i < (rev[i] >> shift)) {
			swap(a[i], a[rev[i] >> shift]);
		}
	}
	for (int k = 1; k < n; k <<= 1) {
		for (int i = 0; i < n; i += 2 * k) {
			for (int j = 0; j < k; j++) {
				C z = a[i + j + k] * rts[j + k];
				a[i + j + k] = a[i + j] - z;
				a[i + j] = a[i + j] + z;
			}
		}
	}
}

vector<int64_t> multiply(const vector<int> &a, const vector<int> &b) {
	int need = (int)a.size() + (int)b.size() - 1;
	int nbase = 1;
	while ((1 << nbase) < need) nbase++;
	ensure_base(nbase);
	int sz = 1 << nbase;
	vector<C> fa(sz);
	for (int i = 0; i < sz; i++) {
		int x = (i < (int)a.size() ? a[i] : 0);
		int y = (i < (int)b.size() ? b[i] : 0);
		fa[i] = C(x, y);
	}
	fft(fa, sz);
	C r(0, -0.25 / (sz >> 1)), s(0, 1), t(0.5, 0);
	for (int i = 0; i <= (sz >> 1); i++) {
		int j = (sz - i) & (sz - 1);
		C z = (fa[j] * fa[j] - (fa[i] * fa[i]).conj()) * r;
		fa[j] = (fa[i] * fa[i] - (fa[j] * fa[j]).conj()) * r;
		fa[i] = z;
	}
	for (int i = 0; i < (sz >> 1); i++) {
		C A0 = (fa[i] + fa[i + (sz >> 1)]) * t;
		C A1 = (fa[i] - fa[i + (sz >> 1)]) * t * rts[(sz >> 1) + i];
		fa[i] = A0 + A1 * s;
	}
	fft(fa, sz >> 1);
	vector<int64_t> ret(need);
	for (int i = 0; i < need; i++) {
		ret[i] = llround(i & 1 ? fa[i >> 1].y : fa[i >> 1].x);
	}
	return ret;
}

int main() {
	int n; ll m; cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> b(100001), c(100001);
	for (int i = 0; i < n; i++) b[a[i]]++;
	c = b;
	auto d = multiply(b, c);
	ll cnt = 0, ans = 0;
	for (int i = 200000; i >= 0; i--) {
		if (cnt + d[i] >= m) {
			ans += (m - cnt)*i;
			cnt += m - cnt;
		}
		else {
			cnt += d[i];
			ans += d[i] * i;
		}

		if (cnt >= m) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12160
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> lltpl;

int dy8[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx8[8] = { 1,-1,1,-1,2,-2,2,-2 };
int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };


/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = LLONG_MAX;
constexpr ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }


int dp[50];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;

	dp[0] = dp[1] = 1;
	for (int i = 2; i <= n; i++)
	{
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	
	cout << dp[n] << endl;

	return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  for(int i = 1; i < n; i++){
    if(a[i-1] < a[i]) a[i]--;
  }
  bool ok = true;
  for(int i = 1; i < n; i++){
    if(a[i-1] > a[i]) ok = false;
  }
  cout << (ok ? "Yes" : "No");
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3732
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 200050;
int N;
int a[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    int min = a[1];
    int max = a[1];

    for (int i = 1; i <= N; i++) {
        min = std::min(min, a[i]);
        max = std::max(max, a[i]);
    }

    if (min == max) {
        if (max == N - 1) {
            // all different, all wrong
            std::cout << "Yes" << std::endl;
            return 0;
        } else {
            // all correct
            if (max * 2 <= N) {
                std::cout << "Yes" << std::endl;
                return 0;
            } else {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    } 

    if (min + 1 < max) {
        std::cout << "No" << std::endl;
        return 0;
    }

    int min_cat_num = 0;

    for (int i = 1; i <= N; i++) {
        if (a[i] == min) {
            min_cat_num++;
        }
    }

    int max_cat_num = N - min_cat_num;
    int max_kind_num = max - min_cat_num;

    if (max_kind_num <= 0) {
        std::cout << "No" << std::endl;
        return 0;
    }

    //std::cout << max_cat_num << " " << max_kind_num << std::endl;

    if (max_kind_num * 2 <= max_cat_num) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;

}

Measured memory_bytes: 640
#include <stdio.h>

long long n, cont = 0;
long long num[19];

void genera(long long lim, int p, long long v){
    if(p >= 10)
        return;
    num[p] = v;
    long long c = 0, pot =1;
    bool a7=false, a5=false, a3=false;
    for(int i=p; i>=0; i--){
        if(num[i] == 7) a7 = true;
        if(num[i] == 5) a5 = true;
        if(num[i] == 3) a3 = true;
        c += num[i]*pot;
        pot*=10;
    }
    if(c <= lim && a7 && a5 && a3){
        cont ++; //printf("%lld\n", c);
    }
    genera(lim, p+1, 7);
    genera(lim, p+1, 5);
    genera(lim, p+1, 3);
}

int main(){
    scanf("%lld", &n);

    genera(n, 0, 3);
    genera(n, 0, 5);
    genera(n, 0, 7);

    printf("%lld\n", cont);
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int X = cin.nextInt();
        int[] x = cin.arrayInt();

        for (int i = 0; i<N; i++) {
            x[i] = Math.Abs(x[i] -X);
        }

        long ans = x[0];
        for (int i = 1; i<N; i++) {
            ans = gcd(ans, x[i]);
        }

        Console.WriteLine(ans);
    }

    long gcd(long a, long b)
    {
        long tmp;
        if (b > a)
        {
            tmp = a;
            a = b;
            b = tmp;
        }

        if (b == 0)
        {
            return a;
        }

        return gcd(b, a % b);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

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

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


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

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

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 18400
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<ll> xs(n);
    rep(i, n) cin >> xs[i];
    ll ans = INF;
    if (k == 1) {
        ll ans = 0;
        rep(i, n) chmin(ans, abs(xs[i]));
        cout << ans << endl;
        return 0;
    }
    rep(i, n-k+1) {
        // cout << i << endl;
        int l = i, r = i+k-1;
        ll cost = min(abs(xs[l])+abs(xs[r]-xs[l]), abs(xs[r])+abs(xs[r]-xs[l]));
        chmin(ans, cost);
    }   
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 1e3 + 100;

int n, m, k;
int s[N][N];

int32_t main(){_
   
   cin>>n>>m>>k;

   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {
         char c;
         cin >> c;
         s[i][j] = c - '0';
      }
   }

   int bst = inf;
   for (int i = 0; i < (1LL << (n - 1)); ++i)
   {
      vector<bool> seen(n-1, 0);
      for (int j = 0; j < (n-1); ++j)
      {
         if(i & (1LL << j)){
            seen[j] = 1;
         }
      }

      int bits = __builtin_popcountll(i);
      int ans = 0;
      vector<int> v(bits+1, 0);

      bool leave = false;
      for (int col = 0; col < m; ++col)
      {
         vector<int> prev = v;
         int sum = 0, ptr = 0;
         bool bad = false;
         for (int row = 0; row < n; ++row)
         {
            sum += s[row][col];
            if(row == n-1 or seen[row]){
               if(sum > k){
                  leave = true;
                  break;
               }
               v[ptr] += sum;
               assert(ptr < (int)(v.size()));
               if(v[ptr] > k){
                  bad = true;
               }
               sum = 0;
               ptr++;
            }
         }

         if (leave){
            break;
         }

         if (bad){
            
            ans++;
            for (int j = 0; j < (int)(v.size()); ++j)
            {
               v[j] -= prev[j];
               tr(col, j, v[j]);
               assert(v[j] <= k);
            }

         }

      }

      if(!leave)
         smin(bst, bits + ans);
   }
   
   assert(bst != inf);   
   cout<<bst;

   return 0;
}

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

#define Online 1
// #define multitest 1
#define Debug
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
    int n;
    string Str;
    cin >> n >> Str;
    int a,b;
    a = b = 0;
    for(char ch : Str)
        if(ch=='R') a++;
        else b++;
    if(a>b) cout << "Yes";
    else cout << "No";
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}


Measured memory_bytes: 256
dp = Array.new(10){ Array.new(1001) {0} }
dp[0][0] = 1

0.upto(100) do |i|
  1000.downto(0) do |j|
    9.downto(1) do |k|
      dp[k][j] += dp[k-1][j-i] if j-i>=0
    end
  end
end

while gets do
  n, s = $_.split(' ').map(&:to_i)
  break if n == 0 and s == 0
  puts dp[n][s]
end

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

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

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

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

int main(){
    iostream_init();
    int a, b, c;
    cin >> a >> b >> c;
    int s = a + b + c;
    bool ok = false;
    if(a == b+c) ok = true;
    if(b == c+a) ok = true;
    if(c == a+b) ok = true;
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 764
from math import ceil, log, pow

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

def main():
    N, K = mi()
    ans = 0
    for i in range(1, N+1):
        ans += pow(0.5, max(0, ceil(log(K, 2)-log(i, 2))))/N
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 40300
#include <bits/stdc++.h>
using namespace std;
long long N,K,tmp,zerocn;
long long x[100000+10]={};
long long sa[100000+10]={};
long long mina=1000000000,maxi,mini;
long long dis=0;

int main(){
  cin >> N >> K;
  //x[0]=0;
  for(long long i=0;i<N;i++){
    cin >> x[i];
    tmp=x[i];
    /*if(x[i-1]<=0 && x[i]>=0){
    x[i]=0;
    zerocn=i;
    x[i+1]=tmp;
    i++;
  }*/
}

for(long long i=0;i<=N-K;i++){
  maxi=x[i+K-1];
  mini=x[i];
  mina=min(mina,abs(mini)+abs(maxi-mini));
  mina=min(mina,abs(maxi)+abs(maxi-mini));
}

cout << mina << endl;


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
#define raftar ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'

using namespace std;

signed main()
{ raftar
    int odd,even; cin>>odd>>even;
    cout<<((even*(even-1))/2)+((odd*(odd-1))/2);
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>
#include <functional>

using namespace std;
using ll = long long;

#define all(x) (x).begin(),(x).end()
#define PRI(n) cout << n << " "<<endl;
#define PRI2(n, m) cout << n << " " << m << " "<<endl;

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

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

struct edge;
struct UnionFind;

bool isPrime(ll x);

ll GCD(ll a, ll b);

ll LCM(ll a, ll b);

ll nCr(int n, int r);


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) {
        for (int i = 0; i < N; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

ll M, N;
bool A[100010];
ll F[100010];

int main() {
    ll N, M;
    cin >> N >> M;
    REP(i, M) {
        int a;
        cin >> a;
        A[a] = 1;
    }
    F[0] = 1;
    for (int i = 0; i < N; i++) {
        if (A[i + 1] && A[i + 2]) {
            PRI(0)
            return 0;
        }
        if (!A[i + 1])F[i + 1] = (F[i] + F[i + 1]) % MOD;
        if (!A[i + 2])F[i + 2] = (F[i] + F[i + 2]) % MOD;
    }
    PRI(F[N])
    return 0;
}

struct edge {
    int to, cost;
    bool flag = false;
};

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    int values[5];
    for (int i = 0; i < 5; ++i)
    {
        cin >> values[i];
        if (values[i] == 0)
        {
            cout << (i + 1) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3160
K,A,B=map(int,input().split())

if A+2 >= B or K <= A:
  print(K+1)
else:
  cnt=K-(A-1)
  ans=A
  if cnt%2==0:
    ans+=((cnt//2)*(B-A))
    print(ans)
  else:
    ans+=((cnt//2)*(B-A))
    ans+=1
    print(ans)

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

buttons = {}
for i in range(N):
    buttons[i+1] = int(input())
    
pushed = []

b = 1
cnt = 0
flag = False
for i in range(N):
    cnt += 1
    next_button = buttons[b]
    if next_button == 2:
        flag = True
        break
    b = next_button
        
if flag:
    print(cnt)
else :
    print(-1)

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

using LL = long long;

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

  int N;
  cin >> N;

  if (N < 1000) {
    cout << "ABC" << '\n';
  } else {
    cout << "ABD" << '\n';
  }

  return 0;
}

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

int n, sol, x;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) {
        x = n - i;
        for(int i = 1; i * i<= x; i++) {
            if(x % i == 0) {
                sol++;
                if(i != x / i) {
                    sol++;
                }
            }
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x = max(x, y)
#define chmin(x,y) x = min(x, y)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1) {
    for(int u : to[v]) {
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main()
{
    int n, q;
    cin >> n >> q;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].pb(b);
        to[b].pb(a);
    }
    ans.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main() {
  int N,P=0,W=0,G=0,Y=0;;
  cin >> N;
  for (int i=0 ; i < N ; i++) {
    string color;
    cin >> color ;
	
    if(color == "P"){
      P = 1 ;
    }
    else if(color == "W"){
      W = 1 ;
    }
    else if(color == "G"){
      G = 1 ;
    }
    else if(color == "Y"){
      Y = 1 ;
    }    
  }
  int C = P + W + G + Y;
  if(C == 4){
    cout << "Four" << endl;
  }
  else if(C == 3){
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    print(A[-1]-A[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    string s; cin >> s;
    int n = s.size();
    int a[n];
    fill(a,a+n,0);
    int num = 1;
    vector<int> v;
    vector<int> R,L;
    int r = 1, l = 0;
    for(int i = 1; i < n; i++){
        if (s[i-1] == 'R' && s[i] == 'R'){
            r++;
        } else if (s[i-1] == 'R' && s[i] == 'L'){
            R.push_back(r);
            l = 1;
            r = 0;
        } else if (s[i-1] == 'L' && s[i] == 'R'){
            L.push_back(l);
            r = 1;
        } else {
            l++;
        }
    }
    L.push_back(l);
    int index = 0;
    for(int i = 0; i < n-1; i++){
        if (s[i] == 'R' && s[i+1] == 'L'){
            a[i] = R[index];
            a[i+1] = L[index]; 
            index++;
        }
    }
    



    for(int i = 0; i < n; i++){
        if (a[i] > 0){
            if ((a[i]+a[i+1]) % 2 == 0){
                a[i] = (a[i]+a[i+1])/2;
                a[i+1] = a[i];
            } else if (a[i] % 2 == 1){
                int tmp = (a[i]+a[i+1]);
                a[i] = tmp/2 + 1;
                a[i+1] = tmp/2;
            } else {
                int tmp = (a[i]+a[i+1]);
                a[i] = tmp/2;
                a[i+1] = tmp/2 + 1;
            }
            i++;
        }
    }
    for(int i = 0; i < n; i++){
        cout << a[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1532
s=int(input())
l=[s]
while True:
  if s%2==0:
    if s//2 in l:
      break
    else:
      l.append(s//2)
      s//=2
  else:
    if s*3+1 in l:
      break
    else:
      l.append(s*3+1)
      s=s*3+1
print(len(l)+1)

Measured memory_bytes: 3060
a, b, h, m = map(int, input().split())

rad = abs((30*h+0.5*m)-6*m)
if rad > 180:
	rad = 360 - rad

import math

c = a*a + b*b -2*a*b*math.cos(math.radians(rad))

print(math.sqrt(c))

Measured memory_bytes: 9408
S = list(map(int, list(input())))
N = len(S) - 1
ans = 0
prev = 0
for i in range(2**N):
    prev = 0
    for j in range(N):
        prev *= 10
        prev += S[j]
        if (i >> j) % 2 == 1:
            ans += prev
            prev = 0
    prev *= 10
    prev += S[-1]
    ans += prev
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


int main(){
    int N; vector<int> A(3010);
    cin >> N;

    int ans = 0;
    rep(i, N) {
        cin >> A[i];
        ans += A[i]-1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a[100],s[5000],i,j,box,p;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	p=0;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			s[p]=a[i]-a[j];
			if(s[p]<0){
				s[p]=s[p]*-1;
			}
			p++;
		}
	}
	for(i=0;i<p-1;i++){
		for(j=i+1;j<p;j++){
			if(s[i]<=s[j]){
				box=s[i];
				s[i]=s[j];
				s[j]=box;
			}
		}
	}
	printf("%d\n",s[0]);
	return 0;
}


Measured memory_bytes: 128
#include <string>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
string a, b;
int main() {
	cin >> a >> b;
	if (a == b) cout << "EQUAL" << endl;
	else if (a.size() != b.size()) cout << (a.size() < b.size() ? "LESS" : "GREATER") << endl;
	else cout << (a < b ? "LESS" : "GREATER") << endl;
	return 0;
}

Measured memory_bytes: 256
int(input())
A = [0 for i in range(2000000)]
back = 999999
front = 1000000

def push(d,x):
	global back, front
	if d == 0:
		front -= 1
		A[front] = x
	else:
		back += 1
		A[back] = x
def randomAccess(p):
	print(A[front + p])
def pop(d):
	global back, front
	if d == 0:
		front += 1
	else:
		back -= 1

while(1):
	try:
		a = input()
		b = [int(i) for i in a.split()]
		if b[0] == 0:
			push(b[1],b[2])
		elif b[0] == 1:
			randomAccess(b[1])
		else:
			pop(b[1])
	except EOFError:
		break





Measured memory_bytes: 34028
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

map<char,int> t;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    rep(i,n){
        ++t[s[i]];
    }
    int od=0,ev=0;
    for(auto it:t){
        if(it.second%2==0) ++ev;
        else ++od;
    }
    if(n%2==0){
        cout<<od/2<<endl;
    }
    else{
        if(od==0) cout<<1<<endl;
        else cout<<od/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
template<typename T>
inline void read(T& s)
{
    s=0;int f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){s=s*10+c-'0';c=getchar();}
    s*=f;
}
int box[200005],las[400005],edv[400005],cnt=0;
void adde(int u,int v)
{
	las[++cnt]=box[u];
	box[u]=cnt;
	edv[cnt]=v;
}
int n;
int m;
char str[200005];
int dc[200005][2];
int cc;
bool vis[200005];
queue<int>q;
int main()
{
	read(n);
	read(m);
	cc=n;
	scanf("%s",str+1);
	for(int i=0;i<m;i++)
	{
		int a,b;
		read(a);
		read(b);
		adde(a,b);
		adde(b,a);
		dc[a][str[b]-'A']++;
		dc[b][str[a]-'A']++;
	}
	for(int i=1;i<=n;i++)
		if(!(dc[i][0] && dc[i][1]))
		{
			q.push(i);
			vis[i]=1;
		//	cout<<"P"<<dc[i][0]<<' '<<dc[i][1]<<endl;
		}
	while(!q.empty())
	{
		int now=q.front();
		q.pop();
		cc--;
		for(int i=box[now];i;i=las[i])
		{
			int v=edv[i];
			if(vis[v])	continue;
			if(!(--dc[v][str[now]-'A']))
			{
				q.push(v);
				vis[v]=1;
			}
		}
	}
	if(cc>0)	cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

using Graph = vector<vector<int>>;

int modpow(int x, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) {  // nが奇数のとき
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return res;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

	string S;
	cin >> S;
	int N = S.size();
	int ans = 0, ans1 = 1;
	rep(i,N){
		if(S[i] == '1'){
			ans += ans1 * modpow(3, N-i-1, MOD);
			ans1 *= 2;
			ans1 %= MOD;
			ans %= MOD;
		}
	}
	cout << (ans + ans1) % MOD << endl;
}

Measured memory_bytes: 512
#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> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


ll v = 1005,e;
vector<vector<pair<ll,ll>>> graph(v,vector<pair<ll,ll>>());
vector<ll> shortest(v,LINF);

//ベルマンフォードもし負の閉路があったらfalseをかえす
bool bellmanford(ll start){
    shortest[start] = 0;
    int cnt = 0;
    while(1){
        bool update = false;
        bool goal = false;
        for(int i=0;i<v;i++){
            if(shortest[i] == LINF) continue;
            for(pair<ll,ll> edge:graph[i]){
                if(shortest[edge.second] > shortest[i] + edge.first){
                    if(cnt < v) shortest[edge.second] = shortest[i] + edge.first;
                    else shortest[edge.second] = -LINF;
                    update = true;
                    if(edge.second==v-1){
                        goal = true;
                    }
                }
            }
        }
        if(!update) break;
        cnt ++;
        if(cnt >= v && goal){
            return false;
        }
        if(cnt > 3*v){
            return true;
        }
    }
    return true;
}

int main(){
    cin >> v >> e;
    rep(i,e){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        --a;--b;
        graph[a].push_back(pll{-c,b});
    }

    if(bellmanford(0)){
        cout << -shortest[v-1] << endl;
    }else{
        cout << "inf" << endl;
    }

    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int W, a, b;
    cin >> W >> a >> b;
    int left = min(a, b);
    int right = max(a, b);
    if(right - (left + W) >= 0){
        cout << right - (left + W) << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++){
        if (A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;
}
int main(){
    int i, q;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    q = partition(0, n - 1);

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


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pi 3.1415926535
#define mod1 1000000007
#define mod2 1000000009
#define no_of_digits(n) floor(log10(n)) + 1
#define lcm(a, b) (a/__gcd(a,b)*b

using namespace std;


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

  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  int ok = 1;
  for(int i = 0; i < n; i++){
    if(v[i]&1){
      continue;
    }
    else{
      if(v[i]%3!=0 and v[i]%5!=0){
        ok = 0;
      }
    }
  }
  cout << (ok?"APPROVED":"DENIED");
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  !al <- replicateM h $ map (== '#') <$> getLine
  let
    red = [1..h] >>= \i -> return $ [1..w] >>= \j -> return $ (j == 1 || odd i) && j /= w
    blue = map (map not) red
    po = zipWith (zipWith (||)) al
    printColor = putStrLn . unlines . map (map (\b -> if b then '#' else '.'))
  printColor (po red)
  printColor (po blue)


Measured memory_bytes: 42876
#124
n = int(input())
h = list(map(int, input().split()))

res = 0
for i in range(n):
    jud = 1==1
    for j in range(0,i):
        if h[i] < h[j]:
            jud = 1==0
            break
    if jud:
        res += 1
print(res)

Measured memory_bytes: 3060
buf=[-1 for i in range(90)]
def ryuka(N):
    global buf
    if buf[N]!=-1:
        return buf[N]
    else:
        if N==1:
            return 1
        elif N==0:
            return 2
        else:
            buf[N]=ryuka(N-1)+ryuka(N-2)
            return ryuka(N-1)+ryuka(N-2)

N=int(input())
print(ryuka(N))



Measured memory_bytes: 3316
import math
def gud(a,b):
  if a%b==0:
    return b
  else:
    return gud(b,a%b)
a=int(input())
ans=0
for i in range(1,a+1):
  for j in range(1,a+1):
    n=math.gcd(i,j)
    for k in range(1,a+1):
      ans+=math.gcd(n,k)
print(ans)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> s(n);
    ll sum = 0;
    rep(i, 0, n) {
        cin >> s[i];
        sum += s[i];
    }
    sort(s.begin(), s.end());
    ll ans = 0;
    if (sum % 10 != 0) ans = sum;
    else {
        rep(i, 0, n) {
            if (s[i] % 10 != 0) {
                ans = sum - s[i];
                break;
            }
        }
    }
    cout << ans << endl;
}

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


int main(){
  string s;
  int i;
  getline(cin,s);
  for (i=0;i<s.size();i++){
    if (s[i]>='A'&&s[i]<='Z')s[i]+='a'-'A';
    else if (s[i]>='a'&&s[i]<='z')s[i]+='A'-'a';
  }
  cout<<s<<endl;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m;
int s,t;
vector<int> adj[1000000];
int vis[1000000][4];
int dist[1000000][4];
void bfs(int v){
    vis[v][0]=1;
    dist[v][0]=0;
    queue<pair<int,int> > q;
    q.push({v,0});
    while(!q.empty()){
        auto p = q.front();q.pop();
        v = p.first;
        int md = p.second;
        int nmd = md+1;
        nmd%=3;
        for (auto u:adj[v]){
            if (vis[u][nmd])continue;
            vis[u][nmd]=1;
            dist[u][nmd]=dist[v][md]+1;
            q.push({u, nmd});
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    cin>>s>>t;
    bfs(s);
    if (vis[t][0]==1)cout<<dist[t][0]/3<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 33024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 100000
#define More1 1000000007
int main(int argc,char const* argv[])
{
  long long int pow=1;
  long long int ans;
  int n,i;
  cin >> n;
  for(i=1;i<=n;i++)
    {
      pow=i*(pow%More1);
    }
  ans=pow%More1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main()
{
	char b;
	scanf("%s", &b);
	if (b == 'A')
		printf("T\n");
	if (b == 'G')
		printf("C\n");
	if (b == 'C')
		printf("G\n");
	if (b == 'T')
		printf("A\n");

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[22],b[22],c[22];

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		x--;
		a[i]=x;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		b[i]=x;
		ans+=b[i];
	}
	for(int i=0;i<n-1;i++){
		ll x;
		cin>>x;
		c[i]=x;
	}
	for(int i=1;i<n;i++){
		//cout << ans;
		if(a[i]==a[i-1]+1){
			ans+=c[a[i-1]];
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256