akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define MAX_N 100005
#define mm(a,b) memset(a,b,sizeof(a))
#define ll long long

ll n,k,ans;

int main() {
    while(~scanf("%lld %lld",&n,&k)){
        if(n == 1){
            ans = k;
        }
        else if(n == 2){
            ans = k * (k - 1);
        }
        else{
            if(n % 2 == 1 && k == 2){
                ans = 0;
            }
            else{
                ans = k * pow((k-1),(n-1));
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define T pair<int, int>
#define ordered_set tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
vector<vector<int>> adj;
signed main(){
    fast();
    int n, x, y;
    cin >> n >> x >> y;
    adj.resize(n+1);
    for(int i=1; i<n; i++){
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    adj[x].pb(y);
    adj[y].pb(x);
    vector<int> ans(n, 0);
    for(int i=1; i<=n; i++){
        int s = i;
        queue<int> q;
        vector<bool> used(n+1, 0);
        vector<int> d(n+1, 0);
        q.push(s);
        used[s] = true;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int u : adj[v]) {
                if (!used[u]) {
                    used[u] = true;
                    q.push(u);
                    d[u] = d[v] + 1;
                    // p[u] = v;
                }
            }
        }
        for(auto j: d){
            ans[j]++;
        }
    }
    for(int i=1; i<n; i++)  cout << ans[i]/2 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

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

int main() {
    string S, T; cin >> S >> T;
    cout << T << S << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
l = -1  
m = 0 
for i in range(n):
        m += b[a[i]-1] 
        if l == a[i]-1:
                m += c[a[i]-2]
        l = a[i] 
print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int N;cin >> N;
    vector<int> vec;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.push_back(b);
    }

    vector<int> dp(N,0);
    for(int a = 1;a < N;a++){
        if(a == 1)dp[a] = abs(vec.at(a)-vec.at(a-1));
        else dp[a] = min(abs(vec.at(a)-vec.at(a-1)) + dp[a-1],abs(vec.at(a)-vec.at(a-2)) + dp[a-2]);
    }

    /*
    vector<int> dp(N,INF);
    for(int a = 1;a < N;a++){
        for(int b = max(0,a-K);b < a;b++){
            dp[a] = min();
        }
    }
    */
    cout<<dp[N-1]<<endl;
    return 0;
}


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

using namespace std;

long long data[2000009], n;

void sift_up(int p)
{
    //cout << "SIFT_UP" << p << endl;
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
    bool done = false;
    if(p == 1)return;
    while(p != 1 && ! done)
    {
        if(data[p] > data[p >> 1])
            swap(data[p], data[p >> 1]);
        else done = true;
        p >>= 1;
    }
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
}

void sift_down(int p)
{
    //cout << "SIFT_DOWN" << endl;
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
    bool done = false;
    if((p << 1) > n)return;
    while((p << 1) <= n && !done)
    {
        p <<= 1;
        if(p + 1 <= n && data[p] < data[p + 1])p ++;
        if(data[p >> 1] < data[p])
            swap(data[p], data[p >> 1]);
        else done = true;
    }
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
}

void insert_node(int x)
{
    n ++;
    data[n] = x;
    sift_up(n);
}

void delete_node(int p)
{
    int x = data[p], y = data[n];
    //cout << x << ' ' << y << endl;
    n --;
    if(p == n + 1)return ;
    data[p] = y;
    if(y >= x)sift_up(p);
    else sift_down(p);
}

long long delete_max(int p)
{
    long long x = data[1];
    delete_node(1);
    return x;
}

void makeheap()
{
    for(int i = n >> 1; i >= 1; i --)
        sift_down(i);
}

int main()
{
    ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string str;
    long long x;
    n = 0;
    while(cin >> str)
    {
        if(str == "insert")
        {
            cin >> x;
            insert_node(x);
        }
        else if(str == "extract")
        {
            cout << delete_max(1) << endl;
        }
        else if(str == "end")
            break;
    }
    return 0;
}
/*
insert 1982
extract
insert 922
extract
insert 19821
insert 19823
extract
insert 1
extract
*/



Measured memory_bytes: 10972
require 'matrix'

class Matrix
  def to_s
    "#{self[0, 0]} #{self[1, 0]}"
  end
end

def koch_curve(n, p1, p2)
  return if n.zero?
  angle = Math::PI / 3
  r = Matrix[[Math.cos(angle), -Math.sin(angle)],
             [Math.sin(angle), Math.cos(angle)]]
  s = (p1 * 2 + p2) / 3
  t = (p1 + p2 * 2) / 3
  points = t - s
  u = (r * points) + s
  koch_curve n - 1, p1, s
  puts s.to_s
  koch_curve n - 1, s, u
  puts u.to_s
  koch_curve n - 1, u, t
  puts t.to_s
  koch_curve n - 1, t, p2
end

n = gets.to_i
p1 = Matrix.column_vector([0.0, 0.0])
p2 = Matrix.column_vector([100.0, 0.0])
puts p1.to_s
koch_curve n, p1, p2
puts p2



Measured memory_bytes: 7188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S, T;
		S = sc.next();
		T = sc.next();

		for (int i = 0; i < S.length(); i++) {
			if (S.equals(T)) {
				System.out.println("Yes");
				return;
			}
			S = rotate(S);
		}

		System.out.println("No");
	}

	private static String rotate(String S) {
		return S.substring(1) + S.charAt(0);
	}
}

Measured memory_bytes: 23764
import bisect
N,M = map(int, input().split())
q = [[int(j) for j in input().split()] for i in range(M)]
li = [[] for k in range(N+1)]

for i,j in sorted(q):
    li[i].append(j)

for p,y in q:
    z = bisect.bisect(li[p],y)
    print("{:0=6}".format(p) + "{:0=6}".format(z))

Measured memory_bytes: 102880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

int main(void){
    ll N; cin >> N;
    
    int ans = 9999999;
    for(int A = 1; A <= sqrt(N); A++){
        if (N % A != 0) continue;
        int B = N / A;
        int len_A = to_string(A).size();
        int len_B = to_string(B).size();
        ans = min(ans, max(len_A, len_B));
    }
    cout << ans << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
  REP(i, T.size()) {
    string myfirst = T;
    string mysecond = T;

    if((myfirst.substr(i) + mysecond.erase(i)) == S) {
      goto yes;
    }
  }

  cout << NO << endl;
  return;
  yes:
  cout << YES << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(A: Long, B: Long){
    // gcd(A, B)の素数の約数を数える
    val g = gcd(A, B)
    val factors = PrimeUtils.primeFactorize(g)
    println(factors.size + 1)
    return
}

tailrec fun gcd(x: Int, y: Int): Int = if (y == 0) x else gcd(y, x % y)
tailrec fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y)


object PrimeUtils {
    fun isPrime(num: Long): Boolean {
        if (num == 1L) return false
        if (num in listOf(2L, 3L)) return true
        if (num % 6 in listOf(0L, 2L, 3L, 4L)) return false
        val sqrt = Math.sqrt(num.toDouble()).toLong()
        for (n in 5..sqrt step 6) {
            if (num % n == 0L) return false
        }
        for (n in 7..sqrt step 6) {
            if (num % n == 0L) return false
        }
        return true
    }

    fun generatePrimesBelow(sup: Long): Sequence<Long> {
        if (sup < 2L) return sequenceOf()
        if (sup < 3L) return sequenceOf(2L)
        val seq = (0..sup / 6L)
                .asSequence()
                .flatMap { sequenceOf(6 * it + 5L, 6 * it + 7L) }
                .filter { it < sup }
        return sequenceOf(2L, 3L) + seq.filter { isPrime(it) }
    }

    fun primeFactorize(num: Long): Map<Long, Int> {
        var n = num
        val result = mutableMapOf<Long, Int>()
        val sqrt = Math.sqrt(num.toDouble()).toLong()
        val trialDivs = sequenceOf(2L) + (3..sqrt step 2).asSequence()
        for (trialDiv in trialDivs) {
            if (trialDiv > n) break
            val divideRes = iterateDivide(n, trialDiv)
            if (divideRes.first > 0) {
                result[trialDiv] = divideRes.first
                n = divideRes.second
            }
        }
        if (n != 1L) result[n] = 1
        return result
    }
}


fun iterateDivide(num: Long, divisor: Long): Pair<Int, Long> {
    var n = num
    var count = 0
    while (num != 0L && n % divisor == 0L) {
        n /= divisor
        count++
    }
    return Pair(count, n)
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    solve(A, B)
}



Measured memory_bytes: 38744
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
typedef std::pair<int, int> pr;
const int inf = 1e9;
int n;
struct mes {
	int oddmin, evenmin;
	pr v0, v1;
};
const mes lol = (mes) {inf, inf, pr(inf, inf), pr(inf, inf)};
inline mes add(const mes & x,const mes & y) {
	return (mes){std::min(x.oddmin, y.oddmin), std::min(x.evenmin, y.evenmin), 
		std::min(pr(x.oddmin, y.evenmin),std::min(x.v0, y.v0)),
		std::min(pr(x.evenmin, y.oddmin),std::min(x.v1, y.v1)), };
}
mes tree[maxn << 2];
int p[maxn], ip[maxn];
inline void build(int cur = 1,int l = 1,int r = n) {
	if(l == r) {
		if(l & 1) {
			tree[cur].oddmin = p[l];
			tree[cur].evenmin = inf;
		} else {
			tree[cur].oddmin = inf;
			tree[cur].evenmin = p[l];
		}
		tree[cur].v0 = tree[cur].v1 = pr(inf, inf);
		return ;
	}
	int mid = l + r >> 1;
	build(cur << 1, l, mid); 
	build(cur << 1 | 1, mid + 1, r);
	tree[cur] = add(tree[cur << 1], tree[cur << 1 | 1]);
}
inline mes qry(int ql,int qr,int cur = 1,int l = 1,int r = n) {
	if(ql <= l && r <= qr) return tree[cur];
	int mid = l + r >> 1; mes ans = lol;
	if(ql <= mid) ans = add(ans, qry(ql, qr, cur << 1, l, mid));
	if(mid < qr) ans = add(ans, qry(ql, qr, cur << 1 | 1, mid + 1, r));
	return ans;
}
struct range {
	int l, r; pr v;
	inline range(int L,int R) { mes x = qry(l = L, r = R); v = L & 1 ? x.v0 : x.v1; }
	inline bool operator < (const range & b) const {
		return v > b.v;
	}
};
std::priority_queue<range> heap;
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n) {
		cin >> p[i];
		ip[p[i]] = i;
	}
	build();
	heap.emplace(1, n);
	for(;!heap.empty();) {
		range x = heap.top(); heap.pop();
		int L = x.l, Lx = ip[x.v.first], Rx = ip[x.v.second], R = x.r;
		cout << p[Lx] << ' ' << p[Rx] << ' ';
		if(L < Lx - 1) heap.emplace(L, Lx - 1);
		if(Lx + 1 < Rx - 1) heap.emplace(Lx + 1, Rx - 1);
		if(Rx + 1 < R) heap.emplace(Rx + 1, R);
	}
}


Measured memory_bytes: 22644
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int n;
	int a, b;
	int mx_p, mx_n = -1;

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> a >> b;
		if(b > mx_n)
		{
			mx_p = a;
			mx_n = b;
		}
		else if(b == mx_n && a < mx_p)
		{
			mx_p = a;
		}
	}

	printf("%d %d\n", mx_p, mx_n);
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int maxn = 1e6+5;


int main()
{
    string s; cin >> s;
    int sum1 = 0, sum2 = 0;
    for(int i = 0; i < 3; i++) {
        if(s[i]=='A') sum1++;
        else sum2++;
    }
    if(sum1&&sum2) cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e9;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  ll a[n + 5];
  ll b[n + 5];
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (ll i = 0; i < n; i++) {
    cin >> b[i];
  }

  ll res = inf;

  for (ll mask = 0; mask < (1 << n); mask++) {
    vector<ll> event[52][2];
    for (ll i = 0; i < n; i++) {
      if ((mask >> i) & 1) {
        event[b[i]][1 - (i & 1)].push_back(i);
      } else {
        event[a[i]][i & 1].push_back(i);
      }
    }

    vector<ll> indices;
    for (ll i = 0; i < n; i++)
      indices.push_back(i);
    ll st = 0;
    bool bad = false;
    ll cost = 0;
    for (ll i = 1; i <= 50; i++) {
      if (event[i][0].empty() && event[i][1].empty())
        continue;

      ll sz = event[i][0].size() + event[i][1].size();

      ll cntOdd = sz / 2;
      ll cntEven = sz - cntOdd;

      if (st & 1)
        swap(cntOdd, cntEven);

      if (event[i][1].size() != cntOdd or event[i][0].size() != cntEven) {
        bad = true;
        break;
      }

      ll itOdd = 0, itEven = 0;
      for (ll j = st; j < st + sz; j++) {
        if (j & 1) {
          ll indx = find(indices.begin(), indices.end(), event[i][1][itOdd]) -
                    indices.begin();

          //   cout << indx << " " << event[i][1][itOdd] << endl;
          cost += indx;
          indices.erase(indices.begin() + indx);
          itOdd++;
        } else {
          ll indx = find(indices.begin(), indices.end(), event[i][0][itEven]) -
                    indices.begin();

          // cout << indx << " " << event[i][0][itEven] << endl;
          cost += indx;
          indices.erase(indices.begin() + indx);
          itEven++;
        }
      }
      st += sz;
    }
    if (bad)
      continue;
    res = min(res, cost);
  }
  cout << ((res == inf) ? -1 : res) << en;

  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	long int a,b;
	scanf("%ld %ld",&a,&b);
	if(a>0 && b>0){
		printf("Positive\n");
		
	}
	if(a<0 && b<0){
		if((b-a+1)%2==0){
			printf("Positive\n");
		}
		else{
			printf("Negative\n");
		}
	}
	if(a<0 && b>0){
		printf("Zero\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans;

        if ((1 <= a && a <= 9) && (1 <= b && b <= 9)) {
            ans = a * b;
        }else {
            ans = -1;
        }
        // 出力
        System.out.println(Integer.toString(ans));

    }
}


Measured memory_bytes: 21844
import java.util.*;
public class Main{

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long ans = 1;
    for(int i = 1; i <= n; i++){
      ans = (ans * i) % 1000000007;
    }
 
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 23892
#!/usr/bin/env ruby

n = gets.split[0].to_i
1.upto(n) do |i|
  line = gets
  a, b, c = line.split.map(&:to_i).sort
  if a ** 2 + b ** 2 == c ** 2
    puts "YES"
  else
    puts "NO"
  end
end



Measured memory_bytes: 6864
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        A: [i64; N],
    }
    let mut cs = vec![0_i64; N+1];
    for ind in 0..N {
        cs[ind+1] = cs[ind] + A[ind];
    }

    let mut b = 1;
    let mut d = 
        match cs.binary_search(&((cs[N] + cs[2])/2)) {
            Ok(ind) => ind,
            Err(ind) => ind - 1,
        };
    let mut mmin = std::i64::MAX;
    for c in 2..N-1 {
        while (cs[b]*2 - cs[c]).abs() > (cs[b+1]*2 - cs[c]).abs() {
            b = b+1;
        }
        while (cs[d]*2 - cs[N] - cs[c]).abs() > (cs[d+1]*2 - cs[N] - cs[c]).abs() {
            d = d+1;
        }
        let pqrs = [cs[b], cs[c]-cs[b], cs[d]-cs[c], cs[N]-cs[d]];
        mmin = cmp::min(mmin, pqrs.iter().max().unwrap() - pqrs.iter().min().unwrap());
    }
    println!("{}", mmin);
    
}



Measured memory_bytes: 8444
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll h,w;
    cin >> h >> w;
    ll a[h][w];
    for (ll i=0;i<h;i++){
        for (ll j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    vector<pair<pair<ll,ll>,pair<ll,ll> > > ans;
    for (ll i=0;i<w;i++){
        if (i%2){
            for (ll j=h-1;j>=0;j--){
                if (i==w-1 and j==0)break;
                if (a[j][i]%2){
                    pair<ll,ll> p1,p2;
                    p1=make_pair(j,i);
                    a[j][i]--;
                    if (j==0){
                        p2=make_pair(j,i+1);
                        a[j][i+1]++;
                    }else{
                        p2=make_pair(j-1,i);
                        a[j-1][i]++;
                    }
                    ans.push_back(make_pair(p1,p2));
                }
            }
        }else{
            for (ll j=0;j<h;j++){
                if (i==w-1 and j==h-1)break;
                if (a[j][i]%2){
                    pair<ll,ll> p1,p2;
                    p1=make_pair(j,i);
                    a[j][i]--;
                    if (j==h-1){
                        p2=make_pair(j,i+1);
                        a[j][i+1]++;
                    }else{
                        p2=make_pair(j+1,i);
                        a[j+1][i]++;
                    }
                    ans.push_back(make_pair(p1,p2));
                }
            }
        }
    }
    cout << ans.size() << endl;
    for (ll i=0;i<ans.size();i++){
        pair<ll,ll> p1,p2;
        p1=ans[i].first;
        p2=ans[i].second;
        cout << p1.first+1 << " " << p1.second+1 << " " << p2.first+1 << " " << p2.second+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 9376
#include <iostream>

using namespace std;

int main()
{
	int m, d;
	cin >> m >> d;
	int ans = 0;
	int t;
	for (int i = 22; i <= d; i++) {
		if (i % 10 > 1 && i / 10 > 1) {
			t = (i % 10) * (i / 10);
			if (t <= m && t > 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	n*=3;
	vi in(n);
	rep(i,n)cin>>in[i];
	vi a(n/3+1),b(n/3+1);
	priority_queue<ll>que1,que2;
	ll sum1=0,sum2=0;
	rep(i,n/3){
		que1.push(-in[i]);
		que2.push(in[n-1-i]);
		sum1+=in[i];
		sum2+=in[n-1-i];
	}
	a[0]=sum1;b[n/3]=sum2;
	rep(i,n/3){
		que1.push(-in[i+n/3]);
		ll t=que1.top();
		que1.pop();
		sum1+=in[i+n/3]+t;
		a[i+1]=sum1;
		
		que2.push(in[n-n/3-1-i]);
		t=que2.top();
		que2.pop();
		sum2+=in[n-n/3-1-i]-t;
		b[n/3-1-i]=sum2;
	}
	ll out=-inf;
	rep(i,a.size())out=max(out,a[i]-b[i]);
	cout<<out<<endl;
}










Measured memory_bytes: 5996
x, y = map(int, input().split())
if (x-4)*(x-6)*(x-9)==0 and (y-11)*(y-6)*(y-9)==0:
  print('Yes')
  exit()
elif (x-1)*(x-3)*(x-5)*(x-7)*(x-8)*(x-10)==0 and (y-12)*(y-3)*(y-5)*(y-7)*(y-8)*(y-10)==0:
  print('Yes')
  exit()
print('No')  

Measured memory_bytes: 3064
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M,long long MOD) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2,MOD);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int X;cin >> X;
    if(X == 0) cout << 1 << endl;
    if(X == 1) cout << 0 << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>   
#include<tr1/unordered_map>
#define ll long long int  
#define mkp make_pair 
#define mod 1000000007 
#define maxn 1000002 
#define ff first
#define ss second 
using namespace std;      
bool isprime(ll n){    
    if(n==2||n==1)return true;
   if(n==0||n%2==0)return false; 
    
   for(int i=3;i*i<=n;i+=2)   
         if(n%i==0)return false; 
    return true;
}
int main(){    
  ios_base::sync_with_stdio(false);  
    
  cin.tie(NULL);      
  int n; 
  cin>>n;  
  ll res;
  ll arr[n];   
  for(int i=0;i<n;++i){  
       cin>>arr[i]; 
       if(i==0)res=arr[0]; 
       else res=__gcd(res,arr[i]);
    } 
  set<ll>s; 
  bool pc=true,sc=true,nc=true; 
  for(int i=0;i<n;++i){    
      for(int j=2;j*j<=arr[i];++j){ 
       int cnt=0;
       while(arr[i]%j==0){  
           ++cnt;arr[i]/=j;
         }  
       if(cnt){   
           if(s.find(j)!=s.end()){ 
               pc=false;break; 
           } 
          else s.insert(j);
       } 
    }  
     if(arr[i]>1){  
          if(s.find(arr[i])!=s.end()){ 
           pc=0;break;} 
         else s.insert(arr[i]);
     }
      
  }  
  if(res!=1)sc=false; 
  if(pc)cout<<"pairwise coprime"; 
  else if(sc)cout<<"setwise coprime"; 
  else cout<<"not coprime";
  return 0;
}

Measured memory_bytes: 11436
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;

int N;
long long int A[333];
long long int Z, X, Y, S;
int main(void) {

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

	S = A[1] + A[2];

	for (int i = 3; i <= N; i++) {
		Z ^= A[i];
	}

	if (S < Z) { cout << -1 << endl; return 0; }
	long long int tmp = S - Z;

	tmp = tmp / 2;

	long long int tot = S - tmp * 2;

	X = tmp; Y = tmp;

	/*cout << "S=   " << bitset<64>(S) << endl;
	cout << "Z=   " << bitset<64>(Z) << endl;
	cout << "X&Y= " << bitset<64>(tmp) << endl;
	*/
	for (int i = 60; i >= 0; i--) {
		long long int val = 1LL << i;
		if (tot >= val) {
			tot -= val;
			if (X + val <= A[1]) { X += val; }
			else { Y += val; }
		}
		
	}

	/*cout << "X=   " << bitset<64>(X) << endl;
	cout << "Y=   " << bitset<64>(Y) << endl;
	cout << "A[1]=" << bitset<64>(A[1]) << endl;
	*/
	if (X + Y == S && (X^Y) == Z && ((X&Y)==tmp) && A[1]>=X && X>0) { cout << (A[1] - X)<< endl; }
	else { cout << -1 << endl; }

	return 0;
}

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

using namespace std;

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

#define EACH(i,a) for(auto&i:a)
#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for(ll i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x, vec) is >> x;
    return is;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, A, B; cin >> n >> m >> A >> B;
    set<ll> used;
    vector<ll> D(n); cin >> D;
    REP(i, n) {
        if (D[i] >= A) {
            used.insert(i);
        }
        else {
            break;
        }
    }
    if (n - used.size() < m) {
        RREP(i, n) {
            if (used.count(i) == 0) continue;
            if (D[i] <= B) {
                used.erase(i);
            }
            else {
                break;
            }
        }
    }
    cout << used.size() << endl;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n;
cin >> n;
vi v(n);
rep(i,n) cin >> v[i];

int now = INF;
int ans = 0;

rep(i,n){
    if(v[i] > now ) continue;
    now = v[i]-1;
    ans++;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>

#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)

using namespace std;

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




const ll INF = 1e9;


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


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	
	int n;
	cin >> n;
	int mini = INF;
	int idx = 0;
	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		if (mini > c) {
			mini = c;
			idx = i + 1;
		}
	}

	cout << idx << endl;



	return 0;
}



Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn = 100001;

int num[maxn];

int main() {

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", num + i);
	}

	int now = 1;
	int i;
	int ans = -1;
	for (i = 1; i <= n; i++) {
		if (num[now] == 2) {
			ans = i;
			break;
		} else {
			now = num[now];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using ull = unsigned long long;

const char* YesNo(bool b)
{
	if (b)
	{
		return "Yes";
	}
	else
	{
		return "No";
	}
}


int main()
{
	int N, K;
	std::cin >> N >> K;
	std::vector<ull> H(N);
	for (int i = 0; i < N; i++)
	{
		std::cin >> H[i];
	}

	std::sort(begin(H), end(H), std::greater<int>());

	ull ans;
	if (N < K)
	{
		ans = 0ull;
	}
	else
	{
		ans = std::accumulate(begin(H)+K, end(H), 0ull);
	}
	
	std::cout << ans;
}


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

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int c(int x) {
    int rt = 1;
    while (x) rt *= x % 10, x /= 10;
    return rt;
}

int main() {
    int m = read(), d = read(), res = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= d; ++j) {
            if (c(j) == i && j % 10 > 1 && j / 10 > 1) res++;
        }
    }
    printf("%d\n", res);
    return 0;
}

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

#define all(x) (x).begin(),(x).end()
using namespace std;

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

    set<int> a,b,c;
    int n,m;
    int x;

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        a.insert(x);
    }

    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        b.insert(x);
    }

    set_intersection(all(a),all(b),inserter(c,c.end()));

    for(int i:c)
    {
        cout<<i<<endl;
    }

    return 0;
}




Measured memory_bytes: 23712
n = int(input())
a = [*map(int, input().split())]
for i in range(n * 3):
    a[i] -= 1

INF = 1<<30
dp = [[-INF] * n for i in range(n)]
mx = [-INF] * n
mx_all = -INF
add_all = 0

dp[a[0]][a[1]] = dp[a[1]][a[0]] = 0
mx[a[0]] = mx[a[1]] = 0
mx_all = 0

for i in range(n - 1):
    x, y, z = sorted(a[i * 3 + 2 : i * 3 + 5])
    update = []
    # パターン1
    if x == y == z:
        add_all += 1
        continue
    # パターン2
    if x == y:
        for j in range(n):
            update.append((j, z, dp[j][x] + 1))
    if y == z:
        for j in range(n):
            update.append((j, x, dp[j][y] + 1))
    # パターン3
    update.append((y, z, dp[x][x] + 1))
    update.append((x, z, dp[y][y] + 1))
    update.append((x, y, dp[z][z] + 1))
    # パターン2-2
    for j in range(n):
        update.append((j, x, mx[j]))
        update.append((j, y, mx[j]))
        update.append((j, z, mx[j]))
    # パターン3-2
    update.append((y, z, mx_all))
    update.append((x, z, mx_all))
    update.append((x, y, mx_all))
    # in-place にするために更新を遅延させる
    for j, k, val in update:
        if dp[j][k] < val:
            dp[j][k] = dp[k][j] = val
        if mx[j] < val:
            mx[j] = val
        if mx[k] < val:
            mx[k] = val
        if mx_all < val:
            mx_all = val

# 最後の 1 回
if mx_all < dp[a[-1]][a[-1]] + 1:
    mx_all = dp[a[-1]][a[-1]] + 1
print(mx_all + add_all)

Measured memory_bytes: 223136
X, K, D = gets.chomp.split(" ").map(&:to_i)

if X.abs >= K*D then
  puts X.abs - K*D
else
  x = X.abs
  x -= D if K.odd?
  wk = x - x/(2*D)*2*D
  puts [wk.abs, (wk-2*D).abs].min
end


Measured memory_bytes: 14352
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int count = x / 100;
		int mod = x % 100;
		if ((mod + 5 - 1) / 5 > count) {
		    System.out.println(0);
		} else {
		    System.out.println(1);
		}
	}
}


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

long long int gcd(long long int a, long long int b)  
{ 
        if (b == 0) return a;  
        return gcd(b, a%b);
}

long long int lcm(long long int a, long long int b)
{
        return (a*b)/gcd(a,b);
}

int main()
{
        long long int a,b,c,d,rB,rA;
        cin >> a >> b >> c >> d;
        rB = b/c + b/d - b/lcm(c,d);
        rA = (a-1)/c + (a-1)/d - (a-1)/lcm(c,d);
        a--;
        cout << (b - a) - (rB - rA)<< endl;
        return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>

using ull =  long long;
using namespace std;

const int MAX_N = 2 * 10e5 + 5;
ull arr[MAX_N];//start from 1, arr[1] = 0
int n;
int pre_l, pre_r;

ull solve(int mid) {
    ull pre_diff = numeric_limits<ull>::max();
    ull curr_diff;
    int l = mid - 1, r = n - 1;
    for (int i = pre_l; i < mid; ++i) {
        curr_diff = abs(arr[mid] - arr[i] - arr[i]);
        if (curr_diff >= pre_diff) {
            l = i - 1;
            break;
        }
        pre_diff = curr_diff;
    }
    pre_diff = numeric_limits<ull>::max();
    for (int j = pre_r; j < n; ++j) {
        curr_diff = abs(arr[n] - arr[j] - (arr[j] - arr[mid]));
        if (curr_diff >= pre_diff) {
            r = j - 1;
            break;
        }
        pre_diff = curr_diff;
    }
    ull sum[4];
    sum[0] = arr[l];
    sum[1] = arr[mid] - arr[l];
    sum[2] = arr[r] - arr[mid];
    sum[3] = arr[n] - arr[r];
    ull mi, ma;
    ma = *max_element(sum, sum + 4);
    mi = *min_element(sum, sum + 4);
    pre_l = l;
    pre_r = r;
    return ma - mi;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", arr + i);
        arr[i] += arr[i - 1];
    }
    ull mi = numeric_limits<ull>::max();
    pre_l = 1;
    pre_r = 3;
    for (int i = 2; i <= n - 2; ++i) {
        ull ans = solve(i);
        mi = mi < ans ? mi : ans;
    }
    printf("%lld", mi);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,i,flag;
    cin>>x;
    while(1)
    {
        flag=0;
        if(x==2)
        {
            cout<<x;
            break;
        }
        for(i=2; i<=sqrt(x); i++)
        {
            if(x%i==0)
            {
                flag=1;
                break;
            }

        }
        if(flag==0)
        {
            cout<<x;
            break;
        }
        else
            x++;

    }
}


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

int main() {
	int n;
	while (cin >> n, n) {
		vector<double> a(n);
		double sum = 0;
		for (double& i : a) {
			cin >> i;
			sum += i;
		}
		int ans = 0;
		for (double& i : a) {
			if (i <= sum / n) ++ans;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3272
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	foundC := false
	for _, r := range s {
		if foundC && r == 'F' {
			fmt.Println("Yes")
			return
		} else if r == 'C' {
			foundC = true
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll DIV = (ll)8e3+7;
const ll MAXN = (ll)8e3+7;

bool dp[MAXN*4+1];

void Update(ll v) {
   bool dp1[MAXN*4+1];
   rep(i,0,MAXN*4+1) dp1[i] = false;
   rep(i,0,MAXN*4+1) {
      if (dp[i]) {
         if (i+v< MAXN*4+1 && i+v>=0) dp1[i+v] = true;
         if (i-v< MAXN*4+1 && i-v>=0) dp1[i-v] = true;
      }
   }
   swap(dp,dp1);
   return;
}


int main(void) {
   string S;
   cin>>S;
   ll x,y;
   cin>>x>>y;
   vector<ll> vx[2];
   ll now = 0;
   ll dir = 0;
   rep(i,0,S.size()) {
      if(S[i] == 'F') now++;
      if (S[i] == 'T' || i == S.size()-1) {
         vx[dir].push_back(now);
         dir++;
         dir = dir%2;
         now = 0;
      }
   }

   if (!vx[0].size()) {
      if (x!=0) {
         cout<<"No"<<endl;
         return 0;
      }
   } else {
      auto itr = vx[0].begin();
      x -= vx[0][0];
      vx[0].erase(itr);
   }

   // for (auto el: vx[0]) cout<<el<<endl;
   // for (auto el: vx[1]) cout<<el<<endl;
   // cout<<x<<" "<<y<<endl;
   bool ans = true;

   rep(i,0,MAXN*4+1) dp[i] = false;
   dp[MAXN*2] = true;
   for (auto el: vx[0]) Update(el);
   if (!dp[MAXN*2+x]) ans = false;

   rep(i,0,MAXN*4+1) dp[i] = false;
   dp[MAXN*2] = true;
   for (auto el: vx[1]) Update(el);
   if (!dp[MAXN*2+y]) ans = false;

   if (ans) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

   return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <iostream>

using namespace std;

int a[1000000];

int main() {
	int n;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i + 1]);
	}
	
	int cnt = 0;
	for (int i = 1; i < n + 1; i++){
		if (i == a[a[i]] && a[i] > a[a[i]]){
			cnt++;
		}
	}
	
	cout << cnt << endl;

	return (0);
}


Measured memory_bytes: 640
import numpy as np

n = int(input())
a = np.array([np.array(input().split(), dtype=np.uint64) for _ in range(n)], dtype=np.uint64)

for i in range(n):
  a[i,i] = 1e9 + 1

ans = 0
for u in range(n):
    for v in range(u + 1, n): 
        dist = a[u,v]
        cd = np.min(a[u] + a[v])
        if dist > cd:
            print(-1)
            exit(0)
        if dist < cd:
            ans += dist
 
print(int(ans))

Measured memory_bytes: 13896
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long a[4],i,j,k,l;
	cin>>a[1]>>a[2]>>a[3];
	cin>>l;
	for(i=1;i<=2;i++)
	    for(j=i+1;j<=3;j++){
	    	if(a[i]>=a[j]){
	    		k=a[i];a[i]=a[j];a[j]=k;
			}
		}

	cout<<a[1]+a[2]+a[3]*pow(2,l);
}

Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed           as V

main :: IO ()
main = do
  _ <- getLine
  (h:hs) <- map read . words <$> getLine :: IO [Int]
  print $ 1 + f hs h
  where
    f [] _ = 0
    f (x:xs) m | x >= m = 1 + f xs x
               | otherwise = f xs m


Measured memory_bytes: 508
#include <stdio.h>

int main(void) 
{
	int i,N,a=0;
  	scanf("%d", &N );
	int A[N];	
	int res = 0;
	
	for (i = 0 ; i < N ; i++)
		scanf("%d",&A[i]);
		
	while (a == 0)	
	{
		
		for (i = 0 ; i < N ; i++)
		{
			if (A[i] % 2 != 0) 
			{a = 1;
			break;}
			else	A[i] /= 2	;	
		} 
		if (a == 0)
			res++;	
	}
	
	printf("%d",res);
	return 0;
}


Measured memory_bytes: 128
# 8クイーン問題
from itertools import permutations
k = int(input())
S = set(tuple(map(int, input().split())) for _ in [0]*k)
A = set()

dirs = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
QUEEN = 2

for r, c in S:
    A.add((r, c))
    for dy, dx in dirs:
        y, x = r, c
        while 0 <= x+dx < 8 and 0 <= y+dy < 8:
            y += dy
            x += dx
            A.add((y, x))

for I in permutations(range(8)):
    T = set(s for s in S)

    for r, c in enumerate(I):
        if (r, c) in S:
            continue
        elif (r, c) in T or (r, c) in A:
            break

        for dy, dx in dirs:
            y, x = r, c
            while 0 <= x+dx < 8 and 0 <= y+dy < 8:
                y += dy
                x += dx
                if (y, x) in T:
                    break
            else:
                continue
            break
        else:
            T.add((r, c))
            continue
        break
    else:
        S = T
        break


for y in range(8):
    for x in range(8):
        if (y, x) in S:
            print('Q', end='')
        else:
            print('.', end='')
    print()



Measured memory_bytes: 5668
# Crane and Turtle
X,Y=map(int,input().split())
def solve(X, Y):
    return (2*X - (1/2)*Y, -X + (1/2)*Y)
a, b = solve(X, Y)
ans = ['No', 'Yes'][((a>=0)&(b>=0))&((a%1==0)&(b%1==0))]
print(ans)


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;



int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a, b;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (i + j == (n % 2 == 0 ? n + 1 : n)) {
                continue;
            }
            a.push_back(i);
            b.push_back(j);
        }
    }
    cout << a.size() << "\n";
    for (int i = 0; i < a.size(); ++i) {
        cout << a[i] << " " << b[i] << "\n";
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
///source: https://atcoder.jp/contests/abc149/submissions/9237911
long long n, m;
vector<long long> a, sum;

long long solve();
long long check(long long x);

int main() {
  cin >> n >> m;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end(), greater<long long>());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, l = 0, r = a[0] * 3;
  while(r - l > 1) {
    long long now = (l + r) / 2;
    if(check(now) >= m)
      l = now;
    else
      r = now;
  }
  sum = a;
  for(int i = 1; i < n; ++i) sum[i] += sum[i - 1];
  for(int i = 0; i < n; ++i) {
    if(a[0] + a[i] < l) continue;
    long long now = upper_bound(a.begin(), a.end(), l - a[i], greater<long long>()) - a.begin();

    res += now * a[i] + sum[now - 1];
  }
  res -= l * (check(l) - m);
  return res;
}

long long check(long long x) {
  long long cnt = 0;
  for(int i = 0; i < n; ++i) {
    if(a[0] + a[i] < x) continue;
    cnt += upper_bound(a.begin(), a.end(), x - a[i],greater<long long>()) - a.begin();
  }
  return cnt;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read
s = input()
res = [0]*2019
res[0] = 1
t = 1
now = 0
for i in s[::-1]:
    i = int(i)
    now += i*t
    now %= 2019
    res[now] += 1
    t = t*10%2019
 
ans = 0    
for i in res:
    ans += i*(i-1)//2
 
print(ans)

Measured memory_bytes: 9296