akhauriyash/Code-Regression huggingface dataset:
//1162
#include <bits/stdc++.h>

using namespace std;

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

const int MAX_N=30,MAX_C=30;
const double INF=1e8;
const double ESP=1e-8;

#define EQ(a,b) fabs(a-b)<ESP

int n,m;
int s,g;
struct edge{
	int to,dist,c;
};
vector<edge> G[MAX_N];

struct S{
	int town,v,pre;
	double cost;
	bool operator<(const S &a) const{
		return cost>a.cost;
	}
};

double cost[MAX_N][MAX_C+1][MAX_N];
bool visited[MAX_N][MAX_C+1][MAX_N];

void dijkstra(){
	REP(i,n){
		REP(j,MAX_C+1){
			REP(k,n){
				cost[i][j][k]=INF;
				visited[i][j][k]=false;
			}
		}
	}
	priority_queue<S> pq;
	pq.push(S{s,0,s,0.0});
	while (!pq.empty()){
		S s=pq.top();
		pq.pop();
		if (visited[s.town][s.v][s.pre]) continue;
		visited[s.town][s.v][s.pre]=true;
		REP(i,G[s.town].size()){
			edge e=G[s.town][i];
			if (e.to==s.pre) continue;
			FOR(acc,-1,1+1){
				if (s.v+acc>0 && s.v+acc<=e.c && cost[e.to][s.v+acc][s.town]>s.cost+(double)e.dist/(s.v+acc)){
					cost[e.to][s.v+acc][s.town]=s.cost+(double)e.dist/(s.v+acc);
					pq.push((S){e.to,s.v+acc,s.town,cost[e.to][s.v+acc][s.town]});
				}
			}
		}
	}
}

int main(){
	do{
		scanf("%d %d",&n,&m);
		if (n){
			scanf("%d %d",&s,&g);
			s--;
			g--;
			REP(i,n){
				G[i].clear();
			}
			REP(i,m){
				int x,y,d,c;
				scanf("%d %d %d %d",&x,&y,&d,&c);
				x--;
				y--;
				G[x].push_back(edge{y,d,c});
				G[y].push_back(edge{x,d,c});
			}
			dijkstra();
			double ans=INF;
			REP(i,n){
				ans=min(ans,cost[g][1][i]);
			}
			if (ans==INF){
				printf("unreachable\n");
			}
			else{
				printf("%.6f\n",ans);
			}
		}
	}while (n);
	return 0;
}

Measured memory_bytes: 3816
import sys

# https://ikatakos.com/pot/programming_algorithm/data_structure/union_find_tree
class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def is_linked(self):
        if len(set([self._root(i) for i in range(len(self.table))])) <= 1:
            return True
        else:
            return False

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    edges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    ans = 0
    for i in range(m):
        uf = UnionFind(n)
        for j in range(m):
            if j == i:
                continue
            uf.union(*edges[j])
        if not uf.is_linked():
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int N, K, i;
  cin >> N >> K;
  vector<int> l(N);
  for (i = 0; i < N; i++) cin >> l.at(i);
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int s = 0;
  for (i = 0; i < K; i++) s += l.at(i);
  
  cout << s << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll A,B,C; cin>>A>>B>>C;
	rep(i,B){
		if(A*i%B==C){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <random>
#include <string>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  vector<int> abc(3); cin >> abc[0] >> abc[1] >> abc[2];
  sort(ALL(abc));
  cout << abc[2] * 10 + abc[1] + abc[0] << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <stdbool.h>

#define MAX_N 100000

int s[MAX_N];
int n = 0;

bool
search(int x)
{
	int l = 0, r = n - 1;
	while (l <= r)
	{
		int i = (l + r) / 2;
		if (x > s[i])
			l = i + 1;

		else if (x < s[i])
			r = i - 1;

		else
			return true;
	}

	return false;
}

int
cmp_func(const void *l_, const void *r_)
{
	const int* l = (const int*) l_;
	const int* r = (const int*) r_;

	if (*l < *r)
		return -1;

	if (*l > *r)
		return 1;

	return 0;
}

int
main(int argc, char** argv)
{
	int q = 0;
	int t = 0;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &s[i]);

	qsort(s, n, sizeof(int), cmp_func);

	scanf("%d", &q);
	int count = 0;
	for (i = 0; i < q; ++i)
	{
		scanf("%d", &t);
		if (search(t))
			count++;
	}

	printf("%d\n", count);
	return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;

vector<ll> a,ret;

bool isOK(int index, int key) {
    /*indexが条件を満たすかどうかを判定(今回はkeyよりおおきいか)*/
    if(ret[index] < key)
        return true;
    else
        return false;
}

int binary_search(int key) {
    int ng = -1;
    int ok = (int)ret.size();
    //okとngの初期値によって最大値だけでなく最小値も求められる.
    //ng=-1の時はkey以上の数値の最小値

    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if(isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }

    return ok;
}

int main() {
    ll i,n;
    cin >> n;
    a.resize(n);
    for(i=0;i<n;i++){
        cin >> a[i];
    }

    ret.resize(n,-1);
    for(i=0;i<n;i++){
        int x = binary_search(a[i]);
        ret[x] = a[i];
    }
    ll cnt = 0;

    for(i=0;i<n;i++){
        if(ret[i]!=-1)cnt++;
        else break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1000000007;
string s;
ll dp[100010][4];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  for (int i = 0; i < 4; i++) {
    dp[s.size()][i] = (i == 3);
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    dp[i][3] = (s[i] == '?' ? 3 : 1) * dp[i + 1][3] % MOD;
    for (int j = 0; j < 3; j++) {
      dp[i][j] += (s[i] == '?' ? 3 : 1) * dp[i + 1][j] % MOD;
      dp[i][j] %= MOD;
      dp[i][j] += (s[i] == '?' || s[i] == "ABC"[j] ? 1 : 0) * dp[i + 1][j + 1] % MOD;
      dp[i][j] %= MOD;
    }
  }
  cout << dp[0][0] << endl;

  return 0;
}

Measured memory_bytes: 3664
from math import sqrt

def make_divisors(n):
    divisors = []
    for i in range(1, int(sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N = int(input())

# N-1 mod K == 0 となる K の数
res = 0
res += len(make_divisors(N-1))
res -= 1 # 1 は今回の条件から除外

# N mod K == 0 となる K で N を割り切れなくなるまで割った後に mod が 1 になる数
divisors = make_divisors(N)
divisors.remove(1)
for d in divisors:
    n = N
    while n != 0 and n % d == 0:
        n /= d
    if n % d == 1:
        res += 1

print(res)


Measured memory_bytes: 3188
console.log((args=>{
  const [[N],L] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  if (N<3) return 0;
  let count = 0;
  for ( let i = 0; i < N-2; i++ ) {
    for ( let j = i+1; j < N-1; j++ ) {
      if ( L[j] === L[i] ) continue;
      for ( let k = j+1; k < N; k++ ) {
        if ( L[k] === L[j] || L[k] === L[i] ) continue;
        if ( L[i] + L[j] > L[k]
          && L[i] + L[k] > L[j]
          && L[k] + L[j] > L[i] ) count++;
      }
    }
  }
  return count;
})(require('fs').readFileSync('/dev/stdin','utf8')));


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


int main(){
    int N;
    cin>>N;
    bool flag=false;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(4*i+7*j==N)flag=true;
        }
    }


    string ans=flag?"Yes":"No";
    cout<<ans<<endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  function<void(const string&, char)> dfs = [&](const string& s, char c) {
    if (s.length() == n) {
      cout << s << '\n';
      return;
    }
    for (char j = 'a'; j < c; ++j)
      dfs(s + j, c);
    dfs(s + c, c + 1);
  };
  dfs("", 'a');

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1536
using System;

namespace A___Changing_a_Character
{
    class Program
    {
        static void Main(string[] args)
        {
            var N_K = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var S = Console.ReadLine().ToCharArray();
            int N = N_K[0];
            int K = N_K[1];

            S[K-1] = char.ToLower(S[K - 1]);

            Console.WriteLine(new string(S));

        }
    }
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  if (s.front() == s.back()) {
    if (s.size() % 2 == 0) {
      std::cout << "First" << std::endl;
    } else {
      std::cout << "Second" << std::endl;
    }
  } else {
    if (s.size() % 2 == 1) {
      std::cout << "First" << std::endl;
    } else {
      std::cout << "Second" << std::endl;
    }
  }
  return 0;
}

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

int main(){
	double r;
	double pi = 3.14159265358979;
//	scanf("%lf", &r);
	cin >> r;
	printf("%10lf %10lf\n", pi*r*r, 2.0*pi*r);
	return 0;
}

Measured memory_bytes: 1248
//15
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  for(int n[2];cin>>n[0]>>n[1],n[0]|n[1];){
    int hw[2][1501]={{}};
    for(int i=0;i<2;i++){
      for(int j=1;j<=n[i];j++){
	cin>>hw[i][j];
	hw[i][j]+=hw[i][j-1];
      }
    }
    vector<int> v;
    for(int i=0;i<=n[0];i++){
      for(int j=i+1;j<=n[0];j++){
	v.push_back(hw[0][j]-hw[0][i]);
      }
    }
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<=n[1];i++){
      for(int j=i+1;j<=n[1];j++){
	ans+=upper_bound(v.begin(),v.end(),hw[1][j]-hw[1][i])-lower_bound(v.begin(),v.end(),hw[1][j]-hw[1][i]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 14080
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC147A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var A1 = NN;
            var A2 = NN;
            var A3 = NN;
            if (A1 + A2 + A3 >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 12640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n);
    loop(i, n) cin >> a[i];
    sort(all(a));
    if (n % 2 == 0)
    {
        ll ans = 0;
        loop(i, n / 2)
        {
            if (i == n / 2 - 1)
                ans -= a[i];
            else
                ans -= 2 * a[i];
        }
        Loop(i, n / 2, n)
        {
            if (i == n / 2)
                ans += a[i];
            else
                ans += 2 * a[i];
        }
        putout(ans);
    }
    else
    {
        ll ans1 = 0, ans2 = 0;
        //case1
        loop(i, n / 2)
        {
            ans1 -= 2 * a[i];
        }
        Loop(i, n / 2, n)
        {
            if (i <= n / 2 + 1)
                ans1 += a[i];
            else
                ans1 += 2 * a[i];
        }
        //case2
        loop(i, n / 2 + 1)
        {
            if (i >= n / 2 - 1)
                ans2 -= a[i];
            else
                ans2 -= 2 * a[i];
        }
        Loop(i, n / 2 + 1, n)
        {
            ans2 += 2 * a[i];
        }
        putout(max(ans1, ans2));
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  map<int,int> mp;
  int joker = 0;
  rep(i,N) {
    int a;
    cin >> a;
    int rate = a / 400;
    if(a >= 3200) {
      joker++;
    } else {
      mp[rate]++;
    }
  }
  int mi = max(sz(mp),1);
  int ma = sz(mp)+joker;
  cout << mi << " " << ma << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  vector<int> L(M),R(M);
  int l = 0;
  int r = P;
  rep(i,M) 
  {
    cin >> L[i] >> R[i];
    L[i] --;
    R[i] --;
    l = max(l,L[i]);
    r = min(r,R[i]);
  }
  if(r-l>=0)
  {
    cout << r - l + 1 << endl;
  }
  else
  {
    cout << 0 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4004
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;

void file() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    if (freopen("input.txt", "r", stdin));
    if (freopen("output.txt", "w", stdout));
#endif
}


string s, k , ans;
int memo[3002][3002];

int solve(int i, int j) {
    if (i >= szz(s) || j >= szz(k))return 0;
    
    int& ret = memo[i][j];
    if (~ret)return ret;
    ret = 0;

    if (s[i] == k[j])
        ret = solve(i + 1, j + 1)+1;
    ret = max(ret, solve(i + 1, j));
    ret = max(ret, solve(i , j + 1));
    return ret;
}

void build(int i, int j) {
    if (i >= szz(s) || j >= szz(k))return;

    int optimal = solve(i, j);

    int ch1 = -1, ch2 = -1, ch3 = -1;

    if(s[i]==k[j])
         ch1 = solve(i+1, j+1)+1;
    ch2 = solve(i + 1, j);
    ch3 = solve(i, j + 1);

    if (ch1==optimal){
        ans += s[i];
        build(i + 1, j + 1);
    }
    else if (ch2 == optimal)
        build(i + 1, j);
    else
        build(i, j + 1);
}



int main() {
    //file();

    memset(memo, -1, sizeof memo);
    cin >> s >> k;
    solve(0, 0);
    build(0,0); 
    cout << ans << endl;

}

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

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

  ll N;
  cin >> N;
  vector<pair<ll,ll>> A(N);
  rep(i, N) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(all(A));
  reverse(all(A));
  
  vector<vector<ll>> dp(N+1, vector<ll>(N+1));
  
  for(ll i=0; i<=N-1; ++i) for(ll j=0; j<=i+1; ++j){
    if (j==0) {
      dp[i+1][j] = dp[i][j] + A[i].first * (N-1-i+j - A[i].second);
    }else if (j==i+1) {
      dp[i+1][j] = dp[i][j-1] + A[i].first * (A[i].second - (j-1));
    }else {
      dp[i+1][j] = max(dp[i][j-1] + A[i].first * (A[i].second - (j-1)),
                       dp[i][j] + A[i].first * (N-1-(i-j) - A[i].second));
    }
  }
  
  ll ans = dp[N][0];
  for(ll i=1; i<=N; ++i) ans = max(ans, dp[N][i]);
  
  cout << ans << '\n';
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

#define MAX_V 128
const ll INF = (ll)1e40;

// graph by adjacency list

struct Graph {
  int V;
  ll Adj[MAX_V][MAX_V];

  Graph(int V) : V(V) {
    for (int i = 0; i < V; i++) {
      std::fill(Adj[i], Adj[i] + V, INF);
      Adj[i][i] = 0;
    }
  }

  void add_edge(int src, int dst, ll weight) {
    Adj[src][dst] = weight;
  }
};

struct AllPairsShortestPath {
  Graph g;
  
  AllPairsShortestPath(const Graph &g) : g(g) { }

  void warshall_floyd() {
    for (int k = 0; k < g.V; k++) {
      for (int i = 0; i < g.V; i++) {
	for (int j = 0; j < g.V; j++) {
	  if (g.Adj[i][k] != INF && g.Adj[k][j] != INF)
	    g.Adj[i][j] = min(g.Adj[i][j], g.Adj[i][k] + g.Adj[k][j]);
	}
      }
    }
  }

  bool has_negative_loop() {
    for (int i = 0; i < g.V; i++) {
      if (g.Adj[i][i] < 0) return true;
    }
    return false;
  }
};
  
int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;
  Graph g(V);
  REP(i, E) {
    int src, dst, weight;
    cin >> src >> dst >> weight;
    g.add_edge(src, dst, weight);
  }

  AllPairsShortestPath alsp(g);
  
  alsp.warshall_floyd();
  
  if (alsp.has_negative_loop()) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    REP(i, V) {
      REP(j, V) {
	if (alsp.g.Adj[i][j] == INF) {
	  cout << "INF" << (j == V-1 ? '\n' : ' ');
	} else {
	  cout << alsp.g.Adj[i][j] << (j == V-1 ? '\n' : ' ');
	}
      }
    }
  }  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,char> ii;
typedef pair<ll,int> iii;
#define INF 100000000
#define N 53
#define M 2000
#define PI acos(-1)
#define rep(i,a,b) for(int i = a; i < b; i++)
#define reps(i,a,b) for(int i = a; i >= b; i--)
#define sc scanf
#define pc printf
#define pb push_back
#define F first
#define S second

string s;

int main()
{
    cin >> s;
    int n = s.size();

    int p1,p2;
    rep(i,0,n){
        if(s[i] == 'A'){
            p1 = i;
            break;
        }
    }

    reps(i,n-1,0){
        if(s[i] == 'Z'){
            p2 = i;
            break;
        }
    }


    pc("%d\n",p2-p1+1);

    return 0;
}







Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i;
  ll t,a,tn,an,r;
  
  cin >> n;
  
  tn=an=1;
  for (i=0;i<n;i++){
    cin >> t >> a;
    r=max((tn+t-1)/t,(an+a-1)/a);
    tn=t*r;
    an=a*r;
  }
  
  cout << tn+an << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) << endl ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(int i=0;i<n;i++){
		ll sub ; cin >> sub ;
		if(sub==0){
			cout << 0 << endl ;
			return 0 ;
		}
		a.at(i) = sub ;
	}
	ll ans = 1 ;
	for(int i=0;i<n;i++){
		if(ans>(ld)1e18/a.at(i)){
			cout << -1 << endl ;
			return 0 ;
		}
		ans *= a.at(i) ;
	}
	cout << ans << endl; 
}

Measured memory_bytes: 4052
while 1:
    m,nmi,nma=map(int,input().split())
    if not m and not nmi and not nma:break
    l=[int(input()) for _ in range(m)]
    tg=[l[:i][-1]-l[i:][0] for i in range(nmi,nma+1)]    
    print(nma-tg[::-1].index(max(tg)))



Measured memory_bytes: 5620
//ABC014-A
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;
int main(void){
    int A,B;
    cin>>A>>B;
    if(A==1)A=100;
    if(B==1)B=100;
    if(A<B)cout<<"Bob"<<endl;
    else if(A>B)cout<<"Alice"<<endl;
    else cout<<"Draw"<<endl;
    
    return 0;
  }


Measured memory_bytes: 256
using System;
using System.Linq;

namespace EDPC
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int[] DP = new int[N].Select(x => int.MaxValue).ToArray();
            DP[0] = 0;
            DP[1] = Math.Abs(h[1] - h[0]);
            for (int i = 2; i < N; i++)
            {
                for (int j = 1; j <= 2; j++)
                {
                    DP[i] = Math.Min(DP[i], DP[i - j] + Math.Abs(h[i] - h[i - j]));
                }
            }

            Console.WriteLine(DP[N - 1]);

        }
    }
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<ll> luca(87);
	luca[0] = 2; luca[1] = 1;
	For(i,2,n+1){
		luca[i] = luca[i-1] + luca[i-2];
	}
	cout << luca[n] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 string str;
 cin>>str;
 ll n=str.length();
 string s1=str.substr(0,n/2);
 string s2=str.substr(n/2+1,n-1);;
 ll n1=s1.length();
 ll n2=s2.length();
 ll p=0,q=n-1;
 ll ff=0;
 while(q>p)
 {
  if(str[p]!=str[q])
  {
   ff=1;
   break;
  }
  p++;
  q--;
 }
 p=0,q=n1-1;
 while(q>p)
 {
  if(s1[p]!=s1[q])
  {
   ff=1;
   break;
  }
  p++;
  q--;
 }
  p=0,q=n2-1;
 while(q>p)
 {
  if(s2[p]!=s2[q])
  {
   ff=1;
   break;
  }
  p++;
  q--;
 }
 if(ff==0)
    cout<<"Yes"<<endl;
 else
    cout<<"No"<<endl;
 return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define pip pair<ll,pii>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M           100011
#define N           20
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}



int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    cout<<(n*n*n)<<"\n";










}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n;
LL l,r;
int a[N],b[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i];
  }
  sort(a+1,a+1+n);
  sort(b+1,b+1+n);
  if(n&1){
    l=a[(n+1)/2];
    r=b[(n+1)/2];
  }else{
    l=a[n/2]+a[n/2+1];
    r=b[n/2]+b[n/2+1];
  }
  cout<<r-l+1;
  return 0;
}

Measured memory_bytes: 5168
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static int N;
    public static int M;

    public static ArrayList<Integer> Vertices[];
    public static int dp[];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter p = new PrintWriter(System.out);
        N = sc.nextInt();
        M = sc.nextInt();

        Vertices = new ArrayList[N + 1];
        dp = new int[N + 1];

        for(int i=1; i<=N; ++i)
            Vertices[i] = new ArrayList<>();

        for (int m = 1; m <= M; ++m) {
            int beg = sc.nextInt();
            int end = sc.nextInt();
            Vertices[beg].add(end);
        }

        int r = 0;

        for (int i = 1; i <= N; ++i) {
            if (Vertices[i].size() > 0) {
                r = Math.max(r, dfs(i));
            }
        }

        p.println(r);
        p.close();
    }

    public static int dfs(int idxBegVertex) {
        if(dp[idxBegVertex] > 0) {
            return dp[idxBegVertex];
        }

        for(int idxEndVertex: Vertices[idxBegVertex]) {
            dfs(idxEndVertex);
            dp[idxBegVertex] = Math.max(dp[idxBegVertex], dp[idxEndVertex] + 1);
        }

        return dp[idxBegVertex];
    }
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int a,b;
int main(){
    cin >> a;
    cin >> b;
    int ans = 6 - (a+b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = []
for i in range(n):
    a_list.append(int(input()))

a_list_sorted = sorted(a_list)
max1 = a_list_sorted[-1]
max2 = a_list_sorted[-2]

for a in a_list:
    if a == max1:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 14112
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; }return 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vi T, A;

int main() {
    cin >> N;
    T.resize(N);
    A.resize(N);
    rep(i, N) {
        cin >> T[i] >> A[i];
    }

    ll t = T[0], a = A[0];
    rep(i, 1, N) {
        if (t <= T[i] && a <= A[i]) {
            t = T[i];
            a = A[i];
        }
        else if (t <= T[i]) {
            a = (a + A[i] - 1) / A[i] * A[i];
            t = a / A[i] * T[i];
        }
        else if (a <= A[i]) {
            t = (t + T[i] - 1) / T[i] * T[i];
            a = t / T[i] * A[i];
        }
        else {
            if ((double)t * A[i] < (double)a * T[i]) {
                a = (a + A[i] - 1) / A[i] * A[i];
                t = a / A[i] * T[i];
            }
            else {
                t = (t + T[i] - 1) / T[i] * T[i];
                a = t / T[i] * A[i];
            }
        }
    }

    write(a + t);
}

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

int main() {
  int D;
  cin >> D;
  switch(D) {
    case 25:
      cout << "Christmas";
      break;
    case 24:
      cout << "Christmas Eve";
      break;
    case 23:
      cout << "Christmas Eve Eve";
      break;
    case 22:
      cout << "Christmas Eve Eve Eve";
      break;
  }
  return 0;
}

Measured memory_bytes: 256
N, K = input().split()
N = int(N)
K = int(K)
Alist = [int(x) for x in input().split()]

noMinLen = len(Alist) - Alist.count(min(Alist))
result = noMinLen / (K-1)

if result > noMinLen // (K-1):
    result = (noMinLen // (K-1)) + 1

print(int(result))

Measured memory_bytes: 13880
import math
X = int(input())
X -= 1

while True:
    flg = 0
    X += 1
    lim = int(math.sqrt(X))
    for i in range(2, lim+1):
        if X % i == 0:
            flg = 1
            break
    if flg == 1:
        continue
    break
print(X)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define mm 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define siz(x) (int)x.size()

#define show(x) cout<<#x<<" "<<x<<'\n'
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

int main()
{
    iosbase;
    int n,i;
    cin>>n;
    
    vector<ll> h(n+1),ans(n+1,0);

    for(i=1;i<=n;i++) cin>>h[i];
    ans[2]=abs(h[2]-h[1]);

    for(i=3;i<=n;i++)
    {
        ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<ans[n]<<'\n';
}

Measured memory_bytes: 1792
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);
 
    std::vector<std::string> result;
 
    while (first < str.size()) {
        std::string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == std::string::npos) {
            last = str.size();
        }
    }
 
    return result;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double ans = 0;
    REP(i,n){
        long double x;
        string s;
        cin >> x >> s;
        if(s!="JPY")x *= 380000.0;
        ans += x;
    }
    printf("%.8lf",ans);
    return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int N;
bool input(){
  cin>>N;

  return N!=0;
}

void solve(){
  int counter=0;
  for(int i=1;i+i+1<=N;i++){
    int sum=0;
    for(int j=i;sum<N;j++){
      sum+=j;
    }
    if(sum==N)counter++;
  }
  cout<<counter<<endl;
}

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

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

#define ll long long

using namespace std;

int main()
{
   int n,c=0;
   cin>>n;
   string s;
   cin>>s;
   for(int i=0; i<n; i++){
       if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')){
           c++;
       }
   }
    cout<<c<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int r,g,b;
	
	scanf("%d %d %d",&r,&g,&b);
	
	if(((r*100)+(g*10)+b)%4==0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const int MAXN=2e5+5;
vi adj[MAXN];
int ans[MAXN];
vi red, blue;

void dfs(int u, int p, bool isred) {
    if(isred) red.push_back(u);
    else blue.push_back(u);

    for(int to: adj[u]) {
        if(to!=p)
            dfs(to, u, !isred);
    }
}

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

    int n; cin>>n;
    FOR(i,n-1) {
        int a,b;cin>>a>>b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    dfs(0, -1, true);
    if(sz(red) > sz(blue))
        swap(red, blue);

    stack<int> m0, m1, m2;
    RNG(i,1,n) {
        if(i % 3==0) m0.push(i);
        if(i % 3==1) m1.push(i);
        if(i % 3==2) m2.push(i);
    }

    if(red.size() <= sz(m0)) {
        for(auto idx : red)
            ans[idx] = m0.top(), m0.pop();
        for(auto idx : blue)
            if(m1.size())
                ans[idx] = m1.top(), m1.pop();
            else if(m2.size())
                ans[idx] = m2.top(), m2.pop();
            else
                ans[idx] = m0.top(), m0.pop();

    } else {
        for(auto idx : red)
            if(m1.size())
                ans[idx] = m1.top(), m1.pop();
            else
                ans[idx] = m0.top(), m0.pop();

        for(auto idx : blue)
            if(m2.size())
                ans[idx] = m2.top(), m2.pop();
            else
                ans[idx] = m0.top(), m0.pop();
    }

    FOR(i,n)
    cout<<ans[i]<<' ';

}

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

int main()
{
    int a, b;
    int area = 0;
    int length = 0;

    cin >> a >> b;
    area = a * b;
    length = a * 2 + b * 2;

    cout << area << " " << length << endl;

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    LL dig[10][10] = {};
    for(int i = 1; i <= N; ++i) {
        int b = i % 10;
        int t = i;
        while(t >= 10) {
            t /= 10;
        }
        dig[t][b]++;
    }

    LL res = 0;
    for(int i = 1; i <= N; ++i) {
        int b = i % 10;
        int t = i;
        while(t >= 10) {
            t /= 10;
        }
        res += dig[b][t];
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256