akhauriyash/Code-Regression huggingface dataset:
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  [m, n] <- readInts
  if m == 0 && n == 0 then return ()
  else do
  bs <- replicateM n readInt
  print $ binarySearch (check bs m) 0 1500000
  main

check :: [Int] -> Int -> Int -> Bool
check bs n lw = go bs 0 0
  where go [] _ _ = True
        go (b:bs) i w
          | i == n = False
          | lw-w >= b = go bs i (w+b)
          | otherwise = go (b:bs) (i+1) 0

binarySearch :: (Int -> Bool) -> Int -> Int -> Int
binarySearch f l r
  | l >= r     = r
  | f m       = binarySearch f l m
  | otherwise = binarySearch f (m+1) r
  where m = (l+r) `div` 2

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"

Measured memory_bytes: 4024
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a = 0, b = 0; string s; cin >> n >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == ')' && b == 0) { a++; }
		else if (s[h] == ')' && b != 0) { b--; }
		else if (s[h] == '(') { b++; }
	}
	for (int h = 0; h < a; h++) {
		cout << '(';
	}cout << s;
	for (int h = 0; h < b; h++) {
		cout << ')';
	}cout << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

double p, ans, ret;
int n;
vector< vector< i_i > > g;

int cnt;

void solve(int pos, int bef, double per);
void dfs(int pos, int bef, double per);
double calc(int pos, int bef, double per);

signed main()
{
    cin >> p >> n;
    g.assign(n+1, vector< i_i >());
    rep(i, n-1) {
        int2(a, b);
        Int(c);
        g[a].pb(mp(b, c));
        g[b].pb(mp(a, c));
    }

    solve(1, 0, p);
    //printf("%.10lf\n", ans);
    dfs(1, 0, 1.0);
    printf("%.10lf\n", ans + ret);

    //printf("%.10lf\n", ret);

    return 0;
}


void solve(int pos, int bef, double per)
{
    //cout << pos << endl;

    if (per < EPS) return ;
    for (i_i i : g[pos]) {
        if (i.first == bef) continue;
        solve(i.first, pos, per * p);
        ans += per * (double)i.second;
    }
}
        
void dfs(int pos, int bef, double per)
{
    if (per < EPS) return;
    ret += per * ans;
    for (i_i i : g[pos]) {
        if (i.first == bef) continue;
        dfs(i.first, pos, per * p);
    }
}

double calc(int pos, int bef, double per)
{
   // cout << cnt++ << endl;
    if (per < EPS) return 0.0;
    for (i_i i : g[pos]) {
        if (i.first == bef) continue;
        ans += per * i.second + calc(i.first, pos, per * p) * per;
    }
    return ans;
}

Measured memory_bytes: 16076
fn main() {
    let n = read::<usize>();
    let ps = read_vec::<u32>();
    let mut qs = vec![false; ps.len()];

    for (i, &p) in ps.iter().enumerate() {
        if i + 1 == p as usize {
            qs[i] = true;
        }
    }

    let mut count = 0;
    let mut i = 0;
    let len = qs.len();
    while i < len {
        if qs[i] {
            count += 1;
            i += 2;
        } else {
            i += 1;
        }
    }

    println!("{}", count);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

from collections import defaultdict

def main():
	n=II()
	A=LI()
	
	X=defaultdict(int)
	Y=defaultdict(int)
	
	for i,v in enumerate(A):
		X[i+v]+=1
		Y[i-v]+=1
	
	ans=0
	for k,v in X.items():
		ans+=v*Y[k]
	print(ans)
	
	







if __name__=="__main__":
	main()


Measured memory_bytes: 176664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],o,p;
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    m=n;
    while(1){
        c=(n-1)%26+97;
        s=c+s;
        n-=1;
        n/=26;
        if(n==0){
            break;
        }
    }
    cout<<s;
}


Measured memory_bytes: 10508
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long Int;
typedef pair<int, int> P;
Int h, w, k;
string field[1100000];
vector<vector<Int> > dist;

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

void bfs(int sx, int sy)
{
    queue<P> q;
    dist[sx][sy] = 0;
    q.push(P(sx, sy));
    while (!q.empty()) {
        P from = q.front();
        q.pop();
        int fx = from.first, fy = from.second;
        for (int d = 0; d < 4; d++) {
            for (int j = 1; j <= k; j++) {
                int tx = fx + dx[d] * j;
                int ty = fy + dy[d] * j;
                if (tx < 0 || tx >= h || ty < 0 || ty >= w)
                    break;
                if (field[tx][ty] == '@')
                    break;
                if (dist[tx][ty] != -1 && dist[tx][ty] <= dist[fx][fy])
                    break;
                if (dist[tx][ty] != -1)
                    continue;
                dist[tx][ty] = dist[fx][fy] + 1;
                q.push(P(tx, ty));
            }
        }
    }
}

int main()
{
    Int sx, sy, gx, gy;
    cin >> h >> w >> k;
    dist = vector<vector<Int> >(h, vector<Int>(w, -1));
    cin >> sx >> sy >> gx >> gy;
    sx--, sy--, gx--, gy--;
    for (int i = 0; i < h; i++) {
        cin >> field[i];
    }

    bfs(sx, sy);
    cout << dist[gx][gy] << endl;
  return 0;
}


Measured memory_bytes: 52972
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

vector<int>A;
vector<int>sum;

int N;

int func1(int start, int num) {
	//startから数えていってnum以上になる最初の添字。ないなら-1

	int offset = 0;
	if (start)offset = sum[start - 1];

	if (sum[N - 1] - offset < num)return -1;

	int lb = start - 1, ub = N;
	while (lb + 1 < ub) {
		const int mid = (lb + ub) / 2;
		if (sum[mid] - offset >= num)ub = mid;
		else lb = mid;
	}
	return ub;
}

pair<int,int> solve1(int pos) {
	//[0,pos]を２つに切るときの最善の最小最大

	int lb = 0, ub = intmax;

	while (lb + 1 < ub) {
		const int mid = (lb + ub) / 2;

		//最小値mid以上を達成できるか？
		int x1 = func1(0, mid);
		if (x1 == -1 || x1 >= pos) {
			ub = mid;
			continue;
		}
		int y = sum[pos] - sum[x1];
		if (y < mid) {
			ub = mid;
			continue;
		}
		lb = mid;
	}

	const int ansmin = lb;
	int x1 = func1(0, ansmin);
	int ans1 = sum[x1];

	int ans2 = sum[pos] - sum[x1];

	return make_pair(min(ans1, ans2), max(ans1, ans2));
}

pair<int, int> solve2(int pos) {
	//[pos,N-1]を２つに切るときの最善の最小最大

	int lb = 0, ub = intmax;

	while (lb + 1 < ub) {
		const int mid = (lb + ub) / 2;

		//最小値mid以上を達成できるか？
		int x1 = func1(pos, mid);
		if (x1 == -1 || x1 == N-1) {
			ub = mid;
			continue;
		}
		int y = sum[N-1] - sum[x1];
		if (y < mid) {
			ub = mid;
			continue;
		}
		lb = mid;
	}

	const int ansmin = lb;
	int x1 = func1(pos, ansmin);
	int ans1 = sum[x1] - sum[pos - 1];

	int ans2 = sum[N-1] - sum[x1];

	return make_pair(min(ans1, ans2), max(ans1, ans2));
}

signed main()
{
	std::cin.sync_with_stdio(false);
	std::cin.tie(0);

	cin >> N;
	A = vector<int>(N);
	rep(i, N) {
		cin >> A[i];
	}

	sum = vector<int>(N);
	sum[0] = A[0];
	REP(i, 1, N)sum[i] = sum[i - 1] + A[i];

	int ans = intmax;
	for (int pos = 1; pos <= N - 2; ++pos) {
		auto x1 = solve1(pos);
		auto x2 = solve2(pos + 1);
		int x3 = min(min(x1.first, x1.second), min(x2.first, x2.second));
		int x4 = max(max(x1.first, x1.second), max(x2.first, x2.second));
		int score = x4 - x3;
		ans = min(ans, score);
	}

	cout << ans << endl;


	return 0;
}

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

int main() {
    long long n;
    long long ans = 0;
    cin >> n;

    for(int i=1; i<=n; i++)
    {
        ans += (n/i)*(i + (n/i)*i)/2;
    }

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



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;
ll y[2000][2000]={};
ll t[2000][2000]={};

int main()
{
ll h,w;
cin >> h>>w;
string ta[h] = {};
rep(i, h){
    cin >> ta[i];
}
rep(i, h)
{
    ll co = 0;
    ll see = 0;
    rep(j, w)
    {
        
        if (ta[i][j] == '.')
            co++;
        if (ta[i][j] == '#'){
            rep(k,co){
                y[i][k+see]=co;
            }
            co=0;
            see=j+1;
        }
        if(j==w-1){
            rep(k,co){
            y[i][k+see]=co;
            }
        }
    }
}
rep(i, w)
{
    ll co = 0;
    ll see = 0;
    rep(j, h)
    {
        
        if (ta[j][i] == '.')
            co++;
        if (ta[j][i] == '#'){
            rep(k,co){
                t[k+see][i]=co;
            }
            co=0;
            see=j+1;
        }
        if(j==h-1){
            rep(k,co){
            t[k+see][i]=co;
            }
        }
    }
}

//2次元配列の中身を見る

/* for (int i = 0; i < h; ++i){
for (int j = 0; j < w; ++j) {
    cout << t[i][j] << " ";
}cout  << endl;}
 */
rep(i,h)rep(j,w){
    ans=max(ans,t[i][j]+y[i][j]-1);
}

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

Measured memory_bytes: 66816
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


string s;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/range/irange.hpp>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/algorithm/string/classification.hpp>
#include<boost/algorithm/string/split.hpp>
#include<boost/algorithm/string/join.hpp>
#include<boost/algorithm/string/replace.hpp>
#include<boost/math/tools/minima.hpp>
#include<boost/pending/disjoint_sets.hpp>
using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;
using boost::algorithm::split;
using boost::is_any_of;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::math::tools::brent_find_minima;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
  char in;
  cin >> in;
  vector<char>c{'a', 'i', 'u', 'e', 'o'};
  bool check = false;
  for(auto i: c){
    if(in == i)check = true;
  }
  string ans = (check)?"vowel":"consonant";
  cout << ans << endl;
}   



Measured memory_bytes: 256
// / #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <stack>
#include <sstream>
#include <regex>
 
#define prev asasddlsa
#define rank aljds
 
using namespace std;
 
typedef long long ll;
typedef long double dbl;

// mt19937 mrand(random_device{} ());
// int rnd(int x = INT_MAX) {
//     return mrand() % x;
// }

template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x << ' ';
    cout << endl;
}
 
template<class T>
void print(const T* s, int n){
    for (int i = 0; i < n; i++){
        cout << s[i] + 1 << ' ';
    }
    cout << endl;
}
 
template<class T>
void print(vector<vector<T>> s){
    for (int i = 0; i < s.size(); i++)
        print(s[i]);
}

const int mod = 1e9 + 7;

ll power(ll a, ll n){
    ll res = 1;
    while (n){
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll inv(ll a){
    return power(a, mod - 2);
}

const int maxn = 1e5 + 7;

ll fact[maxn];

int main(){
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = fact[i - 1] * i % mod;
    vector<int> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    ll summa = 0, answer = 0;
    for (int i = 1; i < n; i++){
        summa += inv(i);
        if (summa >= mod)
            summa -= mod;
        // cout << summa << endl;
        answer = (answer + summa * (s[i] - s[i - 1])) % mod;
    }
    cout << answer * fact[n - 1] % mod << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;
int n;

class Node {
public:
    int id;
    int p;
    int l;
    int r;
};

Node T[30];

void preOrder(int u) {
    if (u == -1) {
        return;
    }
    cout << " " << u;
    preOrder(T[u].l);
    preOrder(T[u].r);
}

void midOrder(int u){
    if(u==-1){
        return;
    }
    midOrder(T[u].l);
    cout << " " << u;
    midOrder(T[u].r);
}

void postOrder(int u){
    if(u==-1){
        return;
    }
    postOrder(T[u].l);
    postOrder(T[u].r);
    cout << " " << u;
}

int main() {
    cin >> n;
    int id, left, right;
    for(int i=0;i<n;i++){
        T[i].p=-1;
    }
    for (int i = 0; i < n; i++) {
        cin >> id >> left >> right;
        T[id].l = left;
        T[id].r = right;
        T[left].p = T[right].p = id;
    }
    int root;
    for(int i=0;i<n;i++){
        if(T[i].p==-1){
            root=i;
        }
    }
    cout<<"Preorder"<<endl;
    preOrder(root);
    cout<<endl<<"Inorder"<<endl;
    midOrder(root);
    cout<<endl<<"Postorder"<<endl;
    postOrder(root);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>
 
int main(void){
  char s[11];
  char t[11];
  scanf("%s",s);
  scanf("%s",t);
  int len = strlen(t);
  t[len-1] = '\0';
  if(strcmp(s,t) == 0){
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            var n = int.Parse(input[0]);
            var m = int.Parse(input[1]);

            var listA = new List<List<char>>();

            var listB = new List<List<char>>();

            for (var i = 0; i < n; i++)
            {
                listA.Add(new List<char>());
                var inputString = Console.ReadLine();

                for (var j = 0; j < n; j++)
                {
                    listA[i].Add(inputString[j]);
                }
            }

            for (var i = 0; i < m; i++)
            {
                listB.Add(new List<char>());
                var inputString = Console.ReadLine();

                for (var j = 0; j < m; j++)
                {
                    listB[i].Add(inputString[j]);
                }
            }

            var flag = true;

            for (var i = 0; i < n - m + 1; i++)
            {
                for (var j = 0; j < n - m + 1; j++)
                {
                    for (var k = 0; k < m; k++)
                    {
                        for (var l = 0; l < m; l++)
                        {
                            if (listA[i + k][j + l] == listB[k][l])
                            {
                                flag = true;
                            }
                            else
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
                if (flag)
                {
                    break;
                }
            }
            if (flag)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
def powmod(x, y, mod):
    res = pow(x, y) % mod
    return res

N = int(input())
mod = pow(10, 9) + 7
# (x + y) mod z = (x mod z + y mod z) mod z
ans = powmod(10, N, mod) - 2 * powmod(9, N, mod) + powmod(8, N, mod)
ans = ans % mod
print(ans)

Measured memory_bytes: 10684
#include <cstdio>

const int kMaxN = 2000000;
const int kMaxAi = 10000;

void CountingSort (int A[], int B[], int k, int n) {
  int i;
  int C[k + 1] = {};
  for (i = 0; i < n; ++i) { ++C[A[i]]; }
  for (i = 1; i < k + 1; ++i) { C[i] += C[i - 1]; }
  for (i = n - 1; i > -1; --i) {
    B[C[A[i]] - 1] = A[i];
    --C[A[i]];
  }
}

int main() {
  int n, i;
  std::scanf("%d", &n);
  int A[n], B[n];
  for (i = 0; i < n; ++i) { std::scanf("%d", &A[i]); }
  CountingSort(A, B, kMaxAi, n);
  for (i = 0; i < n - 1; ++i) { std::printf("%d ", B[i]); }
  std::printf("%d\n", B[n - 1]);
  return 0;
}

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

char toA(int num){
  switch(num){
    case 1: return 'a';
    case 2: return 'b';
    case 3: return 'c';
    case 4: return 'd';
    case 5: return 'e';
    case 6: return 'f';
    case 7: return 'g';
    case 8: return 'h';
    case 9: return 'i';
    case 10: return 'j';
    case 11: return 'k';
    case 12: return 'l';
    case 13: return 'm';
    case 14: return 'n';
    case 15: return 'o';
    case 16: return 'p';
    case 17: return 'q';
    case 18: return 'r';
    case 19: return 's';
    case 20: return 't';
    case 21: return 'u';
    case 22: return 'v';
    case 23: return 'w';
    case 24: return 'x';
    case 25: return 'y';
    case 0: return 'z';
    default : return -1;
  }
}

int main() {
    //入力
    long long n;
    cin >> n;
    int name[15];
    //10^15+1を26で11回割ると0.~になるので(26進数と考える))
    int temp = 0;
    for (int i=1; i<=14; i++) {
        name[i] = n % 26;
        n = (n-1) / 26;
        temp++;
        if (n <= 0) break;
    }
    string ans;
    for (int i=temp; i>=1; i--) {
        if (i == temp) ans = toA(name[temp]);
        else ans += toA(name[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;

vector<ii> edges;

int main() {
   int N;
   scanf("%d", &N);
   bool flag = (N & 1);
   int l = 1;
   int r = N - flag;
   while (l < r) {
      for (int i = 1; i <= N; i++) {
         if (i != l && i != r) {
            if (i > l)
               edges.push_back(ii(l, i));
            if (i > r)
               edges.push_back(ii(r, i));
         }//if
      }//for
      l++; r--;
   }//while
   printf("%d\n", (int)edges.size());
   for (auto& e : edges)
      printf("%d %d\n", e.first, e.second);
   return 0;
}//main


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <stack>

using namespace std;

int main()
{
    stack<int> stk;
    char s[100];
    int a, b;
    while( scanf( "%s", s ) != EOF ) {
	if ( s[0] == '+' ) {
	    b = stk.top(); stk.pop();
	    a = stk.top(); stk.pop();
	    stk.push( a + b );
	}
	else if ( s[0] == '-' ) {
	    b = stk.top(); stk.pop();
	    a = stk.top(); stk.pop();
	    stk.push( a - b );
	}
	else if ( s[0] == '*' ) {
	    b = stk.top(); stk.pop();
	    a = stk.top(); stk.pop();
	    stk.push( a * b );
	}
	else {
	    int v = atoi( s );
	    stk.push( v );
	}
    }
    
    printf("%d\n", stk.top());

    return 0;

}

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

#define _LL long long
#define rep(i, n) for(_LL i = 0; i < (_LL)(n); i++)

_LL sub(pair<_LL,_LL> *c, _LL t, _LL index, _LL goal)
{
    _LL cost = 0;
    rep(i, index)
    {
        if( -c[i].first > goal )
        {
            cost += (-c[i].first - goal - 1) / c[i].second + 1;
        }
    }
    if( cost <= t ) return true;
    return false;
}

int main()
{
    _LL n, k;
    cin >> n >> k;
    _LL *a = new _LL[n];
    _LL *f = new _LL[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a, a + n);
    sort(f, f + n);
    pair<_LL,_LL> *c = new pair<_LL,_LL>[n];
    rep(i, n) 
    {
        c[i] = make_pair( -a[i] * f[n - 1 - i], f[n - 1 - i]);
    }

    _LL bmax = 0;
    rep(i, n) bmax = max(bmax, -c[i].first);
    _LL bmin = 0;
    while( bmax > bmin )
    {
        _LL half = (bmin + bmax) / 2;
        if( sub(c, k, n, half) )
        {
            bmax = half;
        }
        else
        {
            bmin = half + 1;
        }
//        cout << "[" << bmin << "," << bmax << "]" << endl;
    }
    cout << bmax << endl; 
}

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


int main(){
    long long N,M;
    cin >> N >> M;
    vector<long long> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vector<ll> S(N+1,0);
    //S[0] = A[0];

    rep(i,N){
        S[i+1] = S[i] + A[i];
    }
    ll L = -1, R = 1e6;
    while(L+1 < R){
        ll X = (L+R)/2;
        ll tot = 0;
        rep(i,N){
            ll l = -1, r = N;
            while(l+1 < r){
                ll x = (l+r)/2;
                if(A[i] + A[x] >= X) r = x; else l = x;
            }
            tot += N - r;
        }
        if(tot >= M) L = X; else R = X;
    }
    ll sum = 0;
    ll tot = 0;
    //cout << L << " "<< R << endl;
    rep(i,N){
        ll l = -1, r = N;
        while(l+1 < r){
            ll x = (l+r)/2;
            if(A[i] + A[x] >= L) r = x; else l = x;
        }
        tot += N - r;
        //cout <<"aaa:" <<S[r]<<"b;"<< S[N]<<endl;
        //cout << "S[N]-S[r]:"<<S[N]-S[r]<<endl;
        //cout << i << " "<<r<< endl;
        sum += S[N] - S[r] + A[i]*(N-r);
        //cout << sum <<" " <<A[i]<< " "<< N-r <<" "<<r <<endl;
    }
    sum -= L*(tot - M);
    cout << sum << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
        int a, b;
        char op;
        
        while (1) {
                scanf("%d %c %d", &a, &op, &b);
                if (op == '?') {
                        break;
                } else if (op == '+') {
                        printf("%d\n", a + b);
                } else if (op == '-') {
                        printf("%d\n", a - b);
                } else if (op == '*') {
                        printf("%d\n", a * b);
                } else if (op == '/') {
                        printf("%d\n", a / b);
                }
        }
        return 0;       
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

template<typename T> struct BinaryIndexedTree{
    vector<T> node;

    BinaryIndexedTree(int n){
        node.resize(n+1, {});
    }

    void update(int i, T x){
        ++i;
        while(i < (int)node.size()){
            node[i] += x;
            i += (i & -i);
        }
    }

    T query(int i){
        ++i;
        lint ret = 0;
        while(i){
            ret += node[i];
            i -= (i & -i);
        }
        return ret;
    }

    T query(int l, int r){
        return query(r-1) - query(l-1);
    }
};

int main(){
    string s;
    cin >> s;
    vector<int> pos[26];
    int n = s.size();
    rep(i, n) pos[s[i] - 'a'].push_back(i);
    int cnt = count_if(pos, pos+26, [](vector<int> v){return v.size() % 2 == 1;});
    if((n%2 ==0 && cnt) || (n%2 == 1 && cnt != 1)){
        puts("-1");
        return 0;
    }

    vector<pii> seg;
    rep(i, 26)if(pos[i].size() >= 2){
        rep(k, pos[i].size()/2) seg.emplace_back(pos[i][k], pos[i][pos[i].size()-1-k]);
    }
    sort(seg.begin(), seg.end());
    vector<pii> v;
    rep(i, seg.size()){
        v.emplace_back(seg[i].fi, i);
        v.emplace_back(seg[i].se, n-1-i);
    }
    rep(i, 26)if(pos[i].size() % 2 == 1) v.emplace_back(pos[i][pos[i].size()/2], n/2);
    sort(v.begin(), v.end());

    BinaryIndexedTree<lint> bit(n);
    lint ans = 0;
    for(auto p: v){
        ans += bit.query(p.se+1, n);
        bit.update(p.se, 1);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define ci(n,a)   vi a(n); rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+7, LINF = 1e18;


int main(int argc,char* argv[])
{
    ll n,ans=1;
    string s;
    cin>>n>>s;
    map<char,ll> a;
    for(char c:s)a[c]++;
    for(auto x:a) ans*=(x.second+1)%INF,ans%=INF;
    cout<<(ans-1)%INF<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cstdlib>
#define for(i,a,b) for(i=a;i<b;i++)
using namespace std;
int main(void)
{
	int m,n,now,i,j,k,ff,suu,res;
	char say[21];
	int pflg[1001];
	while(cin>>m>>n&&m&&n) {
		for(i,0,1000) pflg[i]=0;
		now=0;
		res=m;
		for(i,0,n) {
			cin>>say;
			if(res==1) continue;
			if((i+1)%15==0){
				if(strcmp(say,"FizzBuzz")!=0) pflg[now]=1,res--;
			}
			else if((i+1)%3==0) {
				if(strcmp(say,"Fizz")!=0) pflg[now]=1,res--;
			}
			else if((i+1)%5==0) {
				if(strcmp(say,"Buzz")!=0) pflg[now]=1,res--;
			}
			else if((i+1)!=atoi(say)) pflg[now]=1,res--;
			now++;now=now%m;
			if(pflg[now]==1) {
				while(1) {
					now++;now=now%m;
					if(pflg[now]==0) break;
				}
			}
		}
		now=0;
		while(pflg[now])now++;
		cout<<now+1;
		for(i,now+1,m) {
			if(pflg[i]==0)cout<<" "<<i+1;
		}
		cout<<endl;
	}
	return 0;
}
			

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


int main() {

  int64_t L,R;
  cin>>L>>R;

  int64_t min_wk=2020;
  if(R-L>=100000)
    cout<<0<<endl;
  else{
    for(int64_t i=L;i<R;i++){
      for(int64_t j=i+1;j<=R;j++)
        min_wk = min(min_wk,(j*i)%2019);
    }
    cout<<min_wk<<endl;
  }

  return 0;
}



Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())

if x >= (a**2) * b / 2 :
    theta = math.atan(2*(b-x/(a**2))/a)
    print(math.degrees(theta))
else :
    theta = math.pi/2-math.atan(2*x/((a*(b**2))))
    print(math.degrees(theta))

Measured memory_bytes: 9348
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ctos(c) string(1,c)
#define all(c) (c).begin(), (c).end()
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n,m,x,y;
  cin>>n>>m>>x>>y;
  vector<ll> v1,v2;
  rep(i,0,n){
    ll a;
    cin>>a;
    v1.pb(a);
  }
  rep(i,0,m){
    ll a;
    cin>>a;
    v2.pb(a);
  }
  sort(all(v1));
  sort(all(v2));
  ll z = v2[0];
  if(x<z&&z<=y&&v1[v1.sz-1]<z){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    //tax:8%
    let a: f32 = read();
    //tax:10%
    let b: f32 = read();

    let min_a_price = (a / 0.08).ceil() as usize;
    let min_b_price = (b / 0.1).ceil() as usize;

    let next_a_price = ((a + 1.0) / 0.08).ceil() as usize;
    let next_b_price = ((b + 1.0) / 0.1).ceil() as usize;
 
    let mut vec_a: Vec<i32> = Vec::new();
    let mut vec_b: Vec<i32> = Vec::new();

    for i in min_a_price .. next_a_price {
        vec_a.push(i as i32);
    }
    for i in min_b_price .. next_b_price {
        vec_b.push(i as i32);
    }

    let ans = vec_a.iter().find(|i| vec_b.contains(i));
    
    println!("{}",ans.unwrap_or(&-1));

}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

bool isOddDigits(int number) {
    string s = to_string(number);
    return s.length() % 2 != 0;
}

int main() {
    int N, count = 0;
    cin >> N;
    for (int n = 1; n <= N; n++) {
        if (isOddDigits(n)) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())
ll powm(ll a,ll n,ll x=MOD){a%=x;ll r=1;while(n>0){if(n&1)r=(r*a)%x;a=(a*a)%x;n>>=1;}return r;}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  ll _=1; //cin>>_;
  while(_--)
  {
    ll n; cin>>n;
    ll a[n];
    for(ll i=0 ; i<n ; i++) cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    ll ans=0,s=0;
    n--;
    if(n>0) ans+=a[s++],n--;
    while(n>0){
      if(n>1){
        ans+=a[s]+a[s];
        s++;
        n-=2;
      }
      else ans+=a[s++],n--;
    }
    cout<<ans;LOL
  }
  return 0;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

lint n, m;

int main(){
	cin >> n >> m;
	lint ret = 1e18;
	for(int i=1; i<n; i++){
		lint w1 = i * m;
		lint w2 = max(((n - i) / 2) * m, (n - i) * (m / 2));
		lint w3 = (n - i) * m - w2;
		vector<lint> v = {w1, w2, w3};
		sort(v.begin(), v.end());
		ret = min(ret, v[2] - v[0]);
	}
	swap(n, m);
	for(int i=1; i<n; i++){
		lint w1 = i * m;
		lint w2 = max(((n - i) / 2) * m, (n - i) * (m / 2));
		lint w3 = (n - i) * m - w2;
		vector<lint> v = {w1, w2, w3};
		sort(v.begin(), v.end());
		ret = min(ret, v[2] - v[0]);
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
   int n, m, sum;
   scanf("%d %d", &n, &m);
   int a[n][m], b[m];
   int i, j;
   for (i = 0; i < n; i++) {
       for (j = 0; j < m; j++) {
           scanf("%d", &a[i][j]);
       }
   }
   for (i = 0; i < m; i++){
       scanf("%d", &b[i]);
   }
   for (i = 0; i < n; i++){
       sum = 0;
       for (j = 0; j < m; j++){
           sum += a[i][j] * b[j];
           }
       printf("%d\n", sum);
   }
   
   return 0;
}


Measured memory_bytes: 2716
fun main(args:Array<String>?): Unit {
    while(true){
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        if (x == 0 && y == 0) return
        val state = Array(y){
            readLine()!!.trim().split(' ').mapNotNull{
                when(it){
                    "0" -> State.Snow
                    "1" -> State.Barrier
                    "2" -> State.Jump
                    else -> null
                }
            }.toTypedArray()
        }
        println(
                solve(state)
        )
    }
}

fun sub(x: Int, y: Int, state: Array<Array<State>>, memo: Array<LongArray>): Long {
    return when{
        y !in state.indices || x !in state[y].indices || state[y][x] != State.Snow -> 0
        y == 0 -> 1
        memo[y][x] >= 0 -> memo[y][x]
        else -> {
            memo[y][x] = sub(x - 1, y - 1, state, memo) + sub(x, y - 1, state, memo) + sub(x + 1, y - 1, state,memo) + jumpFrom(x, y - 2, state, memo)
            memo[y][x]
        }
    }
}
fun jumpFrom(x: Int, y: Int, state: Array<Array<State>>, memo: Array<LongArray>): Long {
    return when{
        y !in state.indices || x !in state[y].indices || state[y][x] != State.Jump -> 0
        memo[y][x] >= 0 -> memo[y][x]
        else -> {
            memo[y][x] = jumpFrom(x, y - 2, state, memo) + sub(x, y - 1, state, memo)
            memo[y][x]
        }
    }
}
fun solve(state: Array<Array<State>>): Long {
    val memo = Array(state.size){LongArray(state[it].size){-1}}
    return state.last().indices.map{x -> sub(x, state.lastIndex, state, memo) + jumpFrom(x, state.lastIndex, state, memo) + jumpFrom(x, state.lastIndex - 1, state, memo)}.sum()
}
enum class State {
    Snow, Barrier, Jump
}


Measured memory_bytes: 32332
N,K=map(int,input().split())
DIV=10**9+7

num=[0]*(K+1)
ans=0

for x in range(K,0,-1):
  num[x]=pow(K//x,N,DIV)
  for temp in range(x*2,K+1,x):
    num[x]-=num[temp]
  ans += num[x] * x
  ans %= DIV

print(ans)

Measured memory_bytes: 11304
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	int t;
	sf(t);
	int ac = 0, tle = 0, wa = 0, re = 0;
	while (t--) {
		string s;
		sf(s);
		if (s == "AC") ++ac;
		else if (s == "TLE") ++tle;
		else if (s == "WA") ++wa;
		else ++re;
	}
	// AC x 3
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;

    int red = 0, blue = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 'R') red += 1;
        if(s[i] == 'B') blue += 1;
    }

    if(red > blue) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
struct Union_Find{
    int d[SIZE],num[SIZE];
    void init(int n){
        REP(i,n)d[i]=i,num[i]=1;
    }
    int find(int x){
        return (x!=d[x])?(d[x]=find(d[x])):x;
    }
    bool uu(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return 0;
        if(num[x]>num[y])swap(x,y);
        num[y]+=num[x];
        d[x]=y;
        return 1;
    }
}U;
int x[SIZE],y[SIZE];
int main(){
    DRII(N,M);
    REP(i,M)RII(x[i],y[i]);
    int an=0;
    REP(i,M){
        U.init(N+1);
        REP(j,M){
            if(i==j)continue;
            U.uu(x[j],y[j]);
        }
        bool fail=0;
        REPP(j,2,N+1)if(U.find(j)!=U.find(1))fail=1;
        if(fail)an++;
    }
    return 0*printf("%d\n",an);
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
const long long inf=1e15;
long long dp[2501][11000];
struct edge{
    int u,v,w;
};
void upd(long long &a,long long b){
    a=max(a,b);return;
}
vector<edge> e;
int n,m,p;

int main(){
    int u,v,w;
    scanf("%d%d%d",&n,&m,&p);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&u,&v,&w);
        e.push_back({u,v,w});
    }
    for(int j=0;j<=2*m;j++)
    for(int i=1;i<=n;i++)
        dp[i][j]=-inf;
    dp[1][0]=0;
    for(int j=1;j<=2*m;j++){
        for(auto i:e){
            upd(dp[i.v][j],dp[i.u][j-1]+i.w);
        }
    }
    long long ans=-inf;
    for(int j=1;j<=m;j++){
        upd(ans,dp[n][j]-1LL*p*j);
    }
    long long nans=-inf;
    for(int j=m+1;j<=2*m;j++){
        upd(nans,dp[n][j]-1LL*p*j);
    }
    if(nans>ans){
        return !printf("-1");
    }
    upd(ans,0LL);
    printf("%lld\n",ans);

}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 215040
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}
 
 
 
 
 
void test_case()
{
    
    
    int a, b, c;
    cin>>a>>b>>c;

    int x = min(a,c);

    c = c-x;

    int y = min(b,c);

    cout<<a-x<<" "<<b-y<<endl;  



 
    
}
 
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string S;
	cin >> S;
	if ((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int a,b;
  cin>>a>>b;
  if(b%a==0) {
    cout << a+b<<endl;
  } else {
    cout << b-a << endl;
  }
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,K;
    cin >> N >> K;
    vector<ll> V(N);
    REP(i,N) cin >> V[i];
    ll allsum = 0;
    REP(i,N) allsum += V[i];
    /*
    vector<ll> sum(N+1);
    REP(i,N) {
        sum[i+1] = sum[i] + V[i];
    }
    */
    ll ans = 0;
    for (int l = 0; l < N; l++) {
        for (int r = l+1; r <= N; r++) {
            if (r < l) continue;
            int n = l + N - r;
            if (n > K) continue;
            //cout << l << " " << r << endl;
            priority_queue<ll,vector<ll>,greater<ll>> t;
            REP(i,l) {
                t.push(V[i]);
            }
            for (int i=N-1; i >= r; i--) {
                t.push(V[i]);
            }
            ll sum = 0;
            REP(i,K-n) {
                if (t.empty()) continue;
                if (t.top() < 0) t.pop();
            }
            while (!t.empty()) {
                sum += t.top();
                t.pop();
            }
            //cout << n << endl;
            //cout << sum << endl << "===========" << endl;
            ans = max(ans,sum);
        }
    }
    if (K >= N) {
        ll temp = 0;
        priority_queue<ll,vector<ll>,greater<ll>> t;
        REP(i,N) {
            t.push(V[i]);
        }
        REP(i,K - N) {
            if (t.empty()) continue;
            if (t.top() < 0) t.pop();
        }
        while (!t.empty()) {
            temp += t.top();
            t.pop();
        }
        ans = max (ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
     
    using namespace std;
      vector<int> iti,sa;
int gcd(int a,int b){
	if(a<b)return gcd(b,a);
  if(b==0) return a;
  if(a%b==0)return b;
  return gcd(b,a%b);
}
int main(){
    int n,x;
cin>>n>>x;
        iti.push_back(x);
        for(int i=0;i<n;i++){
        int y;
          cin>>y;
          iti.push_back(y);
        }
        sort(iti.begin(),iti.end());
        for(int i=0;i<n;i++)sa.push_back(iti[i+1]-iti[i]);
        int g=sa[0];
        for(int i=1;i<n;i++){
        g=gcd(g,sa[i]);
        }
        cout<<g<<endl;
      return 0;
    }

Measured memory_bytes: 1400