akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using vl=vector<ll>;
using vp=vector<pll>;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll k;
    cin>>k;
    ll tmp=0;
    FOR(i,1,k){
        tmp=(tmp*10+7)%k;
        if(tmp%k==0){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(void)
{
	int x;
	scanf("%d",&x);
	if(x>=30) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int x,y; cin >>x >>y;
  int ans = 0;
  if (x==1 || x==2 || x==3){
    ans += 400000 - x * 100000;
  }
  if (y==1 || y==2 || y==3){
    ans += 400000 - y * 100000;
  }
  if (x==1&&y==1){
    ans += 400000;
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL a,b,c;
  cin >> a >> b >> c;

  c -= a-b;
  c = max(c,0ll);
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            string[] Reader = ReadLine().Split(' ');

            int A = int.Parse(Reader[0]);
            int B = int.Parse(Reader[1]);
            int C = int.Parse(Reader[2]);
            int K = int.Parse(Reader[3]);

            if (A > K)
            {
                WriteLine(K);
                return;
            }
            else 
            {
                WriteLine(A + Math.Max(0, K - A - B) * -1);
                return;
            }
        }

        #region Functions
        public static decimal floor(float d) => Math.Floor((decimal)d);

        public static double nqrt(int n, int value) 
        {
            if (n >= 0)
            {
                // 通常のn乗根
                return Math.Pow(n, 1.0 / (double)n);
            }
            else
            {
                if ((n % 2) != 0)
                {
                    // 奇数乗根の場合
                    return -Math.Pow(-n, 1.0 / (double)n);
                }
                else
                {
                    // 偶数乗根の場合
                    return double.NaN;
                }
            }
        }
        #endregion
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value)
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion

        #region 拡張: List<string>
        public static string Sum(this List<string> THIS, string Split)
        {
            string RetValue = "";

            for (int loop = 0; loop < THIS.Count; loop++)
            {
                RetValue += THIS[loop];
            }

            return RetValue;
        }
        #endregion
    }
}

Measured memory_bytes: 17908
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll m = 1000;
    for(int i = 0 ; i+1 < n; ++i) {
        if(a[i]>=a[i+1]) continue;
        else {
            ll k = m/a[i];
            m %=a[i];
            m += a[i+1] * k;
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

const ll INF=1e18;

ll N,K;
vector<ll> A;

int main(){
    cin>>N>>K;
    for(int i=0;i<N;++i){
        int a;
        cin>>a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());


    ll r=INF,l=-INF-1;
    ll m;
    while(r-l>1){
        m=(r+l)/2ll;
        ll cnt=0;
        for(int i=0;i<N;++i){
            if(A[i]==0){
                if(m>=0)cnt+=i;
            }
            else{
                ll d;
                ll id;
                if(A[i]>0){
                    d=m/A[i];
                    if(m<=0&&m%A[i]!=0)d--;
                    cnt+=upper_bound(A.begin(),A.begin()+i,d)-A.begin();     
                }
                else{
                    d=m/A[i];
                    cnt+=A.begin()+i-lower_bound(A.begin(),A.begin()+i,d);;
                }
            }
        }
        if(cnt>=K)r=m;
        else l=m;
    }
    cout<<r<<endl;
}

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

int main(){
  long int a,b;cin >> a >> b;
  long int x = a*b;
  if(a<b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  int r = a%b;
  while(r!=0){
    a = b;
    b = r;
    r = a%b;
  }
 
  cout << x/b << endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    ll n,k;
    ll ans=0;
    cin >> n >> k;
    for(int b=k+1;b<=n;++b){
        int numr = b - k;
        ans += numr * (n / b);
        if(n%b>=k){
            ans += n%b - k + 1;
        }
    }
    if(k==0) ans-=n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	vector<long> a(x), b(y), c(z), d;
	for(int i=0; i<x; ++i) cin >> a[i];
	for(int i=0; i<y; ++i){
	    cin >> b[i];
	    for(int j=0; j<x; ++j) d.push_back(a[j]+b[i]);
	}
	for(int i=0; i<z; ++i) cin >> c[i];
	sort(c.begin(), c.end(), greater<long>());
	sort(d.begin(), d.end(), greater<long>());
	priority_queue<long> pq;
	pq.push(0);
	int cnt=0, now=0;
	while(cnt<k){
	    if(now<min(x*y, z)){
	        if(pq.top()<c[now]+d[now]){
	            pq.push(c[now]+d[now]);
	            for(int i=now+1; i<min(3000, x*y); ++i) pq.push(c[now]+d[i]);
	            for(int i=now+1; i<z; ++i) pq.push(c[i]+d[now]);
	            ++now;
	        }
	    }
	    cout << pq.top() << endl;
	    pq.pop();
	    ++cnt;
	}
	return 0;
}


Measured memory_bytes: 10480
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int N;
	cin >> N;
	cout << 180 * (N - 2) << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void)
{
    int n;
    ll anagrams = 0;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < n-1;) {
        for (int j = i+1; j < n; j++) {
            if (s[i] == s[j]) {
                anagrams += j - i;
            } else {
                i = j;
                break;
            }
            if (j == n-1) i = n;
        }
    }
    cout << anagrams << endl;

    return 0;
}



Measured memory_bytes: 7296
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

struct Env {
    X: usize,
    B: Vec<usize>,
    P: Vec<usize>,
}

fn f(e: &Env, n: usize, x: i64) -> usize {
    if n == 0 {
        if x <= 0 { 0 } else { 1 }
    } else if x as usize <= 1 + e.B[n-1] {
        f(e, n-1, x-1)
    } else if x as usize == 2 + e.B[n-1] {
        1 + e.P[n-1]
    } else {
        1 + e.P[n-1] + f(e, n-1, x - e.B[n-1] as i64 - 2)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let X: usize = sc.get();
    let mut B = vec![0; N+1];
    let mut P = vec![0; N+1];
    let mut b = 1;
    let mut p = 1;
    for i in 0..N+1 {
        B[i] = b;
        P[i] = p;
        b = b * 2 + 3;
        p = p * 2 + 1;
    }
    let e = Env{ X: X, B: B, P: P };
    println!("{}", f(&e, N, X as i64));
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit

int	main() {
	int N;
	cin >>N;
	vector<int> A;
	if (N==3) {
		cout <<"2 5 63" <<endl;
		return 0;
	}
	if (N==4) {
		cout <<"2 5 20 63" <<endl;
		return 0;
	}
	if (N==5) {
		cout <<"2 3 4 6 9" <<endl;
		return 0;
	}
	int K=2;
	int n=N/6*6;
	for (;;) {
		while(((0!=K%2)&&(0!=K%3))||(0==K%6))
			K++;
		if (K>30000)
			break;
		A.push_back(K);
		K++;
		if (n==A.size())
			break;
	}
	K=6;
	while(A.size()<N) {
		A.push_back(K);
		K +=6;
	}
	sort(A.begin(), A.end());
	for (int i=0; i<A.size(); i++) 
		if (i==0)
			cout <<A.at(i);
		else
			cout <<' ' <<A.at(i);
	cout <<endl;
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int b[105];
	for(int i = 1;i <= n - 1;i++)
		cin >> b[i];
	long long sum = b[n - 1];
	for(int i = n - 1;i > 1;i--)
	{
		sum += min(b[i],b[i - 1]);
	}
	sum += b[1];
	cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    ans = ''
    for char in s:
        if char == 'B':
            ans = ans[:-1] if ans else ''
        else:
            ans += char

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int dp[n+1][k+1];
    for(int i=1;i<=a[n-1];i++)
    {
        int flag = 0;
        for(int j=0;j<n;j++)
        {
            if(i<a[j])
                dp[j][i] = 0;
            else if(i == a[j])
                dp[j][i] = 1;
            else
                dp[j][i] = 1 - dp[n][i-a[j]];
            if(dp[j][i]==1)
                flag = 1;
        }
        if(flag == 1)
            dp[n][i] = 1;
        else
            dp[n][i] = 0;
    }
    for(int i=a[n-1]+1;i<=k;i++)
    {
        int flag = 0;
        for(int j=0;j<n;j++)
        {
            dp[j][i] = (1 - dp[n][i-a[j]]);
            if(dp[j][i]==1)
                flag = 1;
        }
        if(flag == 0)
            dp[n][i] = 0;
        else
            dp[n][i] = 1;
    }
    // for(int j=0;j<=n;j++)
    // {
    //     for(int i=1;i<=k;i++)
    //         cout<<dp[j][i]<<" ";
    //     cout<<endl;    
    // }
    if(dp[n][k] == 1)
        cout<<"First";
    else
        cout<<"Second";
    
    
}

Measured memory_bytes: 39680
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const op = input.split(" ")[1];
  const b = parseInt(input.split(" ")[2], 10);
  if(op=="+"){
    console.log(a+b);
  }else{
    console.log(a-b);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [int(10000000000)]*100000
dp[0] = 0
cost = 0
if k > len(h):
  k = len(h)
for i in range(0, n):
  for j in range(1, k+1):
    if dp[i] > dp[i-j]+abs(h[i]-h[i-j]):
      dp[i] = dp[i-j]+abs(h[i]-h[i-j])
print(dp[n-1])

Measured memory_bytes: 52448
#include <stdio.h>
int main(void){
char s[100];
  int count=0;
  scanf("%s",s);
  if(s[0]=='1'){count++;}
  if(s[1]=='1'){count++;}
  if(s[2]=='1'){count++;}
  if(s[3]=='1'){count++;}
  if(s[4]=='1'){count++;}
  if(s[5]=='1'){count++;}
  printf("%d",count);
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int n, i, sum;
    double m, a, b;
    
    while(1){
        a=0;
        b=0;
        sum=0;
        scanf("%d", &n);
        if(n==0) break;
        int S[n];
        for(i=0; i<n; i++){
            scanf("%d", &S[i]);
            sum += S[i];
        }
        m=1.00000*sum/n;
        
        for(i=0; i<n; i++){
            b += (S[i] - m) * (S[i] - m);
        }
        b = b / n;
        a = sqrt(b);
        printf("%f\n", a);
    }
    return 0;
}



Measured memory_bytes: 2100
#include<stdio.h>

int main() {
  int a = 0, b = 0;
  scanf("%d%d", &a, &b);
  
  if((a+b) % 2) {
    puts("IMPOSSIBLE");
  } else {
    printf("%d\n", (a+b)/2);
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  int a, b, c, d, e, f;
  double x, y;

  while (scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) != EOF) {
  y = (double)(d * c - a * f) / (b * d - a * e);
  x = (double)(e * c - b * f) / (a * e - d * b);

  if (x > -0.0005 && x <= 0) x = 0;
  if (y > -0.0005 && y <= 0) y = 0;

  printf("%.3f %.3f\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	// string input1, input2, input3, output;
	// cin >> input1;
	// cin >> input2;
	// cin >> input3;

	// vector<int> v = {stoi(input1), stoi(input2), stoi(input3)};

	vector<int> v;
	for (int i = 0; i < 3; i++)
	{
		int input;
		cin >> input;
		v.push_back(input);
	}

	sort(v.begin(), v.end());

	string output = "";
	int count = 0;
	for (const auto &e : v)
	{
		count++;
		output += to_string(e);
		if (v.size() > count)
		{
			output += " ";
		}
	}
	cout << output << endl;

	return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int calc_change_times(vector<int> numbers, int divisor);

int main(void)
{
    int array_length;
    int max_change_count;
    vector<int> numbers;

    cin >> array_length >> max_change_count;

    int sum = 0;
    for(int i = 0; i < array_length; i++){
        int n;
        cin >> n;
        sum += n;
        numbers.push_back(n);
    }

    int gcd = 1;
    int div = 1;
    while(div * div <= sum){
        if(sum % div == 0){
            int change_times = calc_change_times(numbers, div);
            if(change_times != -1 && change_times <= max_change_count){
                gcd = max(gcd, div);
            }
            
            change_times = calc_change_times(numbers, sum / div);
            if(change_times != -1 && change_times <= max_change_count){
                gcd = max(gcd, sum / div);
            }
        }

        div += 1;
    }

    cout << gcd << endl;

    return 0;
}

int calc_change_times(vector<int> numbers, int divisor)
{
    int left_sum = 0;
    int right_sum = 0;

    vector<int> exceeds;

    for(int i = 0; i < numbers.size(); i++){
        left_sum += numbers[i] % divisor;
        exceeds.push_back(numbers[i] % divisor);
    }

    sort(exceeds.begin(), exceeds.end());

    int border = numbers.size() - 1;
    while(left_sum != right_sum){
        left_sum -= exceeds[border];
        right_sum += divisor - exceeds[border];

        if(border == 0){
            return -1;
        }

        border -= 1;
    }

    return left_sum; // same as the times to change
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  int i,start,end;
  char s[200000];

  scanf("%s",s);

  for(i=0;i<strlen(s);i++){
    if(s[i]=='A'){
      start=i;
      break;
    }
  }
  for(i=strlen(s)-1;i>=0;i--){
    if(s[i]=='Z'){
      end=i;
      break;
    }
  }

  printf("%d\n",end-start+1);

  return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author liymsheep
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();

            int answer = 0;
            for (int i = 0; i < s.length; ++i) {
                if (i % 2 == 0) {
                    if (s[i] == 'p') {
                        --answer;
                    }
                } else {
                    if (s[i] == 'g') {
                        ++answer;
                    }
                }
            }
            out.println(answer);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    throw new UnknownError();
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 11216
L, R = map(int, input().split())
m = 2019
if R - L >= 2019:
  print(0)
else:
  m=2019
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      m = min((i*j)%2019, m)
  print(m)

Measured memory_bytes: 3060
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>
#include <tuple>
#include <queue>
#include <cassert>
#include <set>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define el '\n'
 

 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m, k;
	cin >> n >> m>> k;
	int x, y;
	vector<int> vx(n, 0);
	vector<int> vy(m, 0);
	//vector<set<int>> st(n);
	set<pair<int,int> > pii;
	for (int i = 0; i < k ; i++){
		cin >> x>> y;
		x--;
		y--;
		vx[x]++;
		vy[y]++;
		//st[x].insert(y);
		pii.insert(MP(x,y));
	}

	int mx = INT_MIN, my = INT_MIN;
	vector<int> mmx, mmy;
	for (int i = 0; i <n; i++){
		mx = max(vx[i],mx);
	}	
	for (int i = 0; i <m; i++){
		my = max(vy[i], my);
	}

	vector<int> X,Y;

	for (int i = 0; i < n; i++){
		if (vx[i] == mx){
			X.PB(i);
		}
	}
	for (int i = 0; i < m; i++){
		if (vy[i] == my){
			Y.PB(i);
		}
	}

	for (int i = 0; i< X.size(); i++){
		for (int j = 0; j < Y.size(); j++){
			if (pii.count(MP(X[i],Y[j])) == 0){
				//cout << vx[i]<<" "<<vy[j]<<endl;
				cout << mx + my<< endl;
				return 0;
			}
		}
	}

	cout << mx + my - 1<<endl; 	



    return 0;
}

Measured memory_bytes: 23460
a,b = gets.strip.split.map(&:to_i)
resa = []
resb = []
numa = 1
numb = 1
while (numa*0.08).floor <= a do
  if (numa*0.08).floor == a
    resa.push(numa)
  end
  numa+= 1
end
while (numb*0.1).floor <= b do
  if (numb*0.1).floor == b
    resb.push(numb)
  end
 numb+=1
end
isbreak = false
resa.each do |ra|
  resb.each do |rb|
    if ra == rb
      isbreak = true
      puts ra
      break
    end
  end
  break if isbreak
end
puts -1 unless isbreak






Measured memory_bytes: 3836
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (b == 1) {
			System.out.println(0);
		} else {
			System.out.println((b  - 2) / (a - 1) + 1);
		}
	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

	return 0;
}

Measured memory_bytes: 0
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
const int N=100001;
vector<int> adj[N];
int vis[N],dp[N],ma[N],vis1[N],ans=0;
stack<int> st;
void dfs(int x){
    vis[x]=1;
    for(int i=0;i<adj[x].size();i++){
        int ch=adj[x][i];
        //dp[ch]=max(dp[ch],dp[x]+1);
        if(vis[ch]==0){
            //dp[ch]=dp[x]+1;
            dfs(ch);
            //ma[x]=max(ma[x],ma[ch]);
        }
    }
    st.push(x);
}
void dfs2(){
    if(st.empty())return;
    int x=st.top();
    st.pop();
    for(int i=0;i<adj[x].size();i++){
        int ch=adj[x][i];
        dp[ch]=max(dp[ch],dp[x]+1);
        ans=max(ans,dp[ch]);
    }
    ans=max(ans,dp[x]);
    dfs2();
}
int main(){
    std::ios::sync_with_stdio(false);
    //string s1,s2;
    int n,m;
    cin>>n>>m;
    set<int> se;
    forn(i,m){
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        se.insert(b);
    }
    forn(i,n){
        adj[0].pb(i+1);
        //adj[i+1].pb(0);
    }
    vector<int> vec;
    forn(i,n)if(se.count(i+1)==0)vec.pb(i+1);
    //int dp[n+1]={0},vis[n+1]={0};
        //cout<<vec[i]<<endl;
        dfs(0);
        dp[0]=0;
        dfs2();
    //int ans=0;
    //forn(i,n)ans=max(ans,ma[i+1]);
    cout<<ans-1;

    return 0;
}


Measured memory_bytes: 14076
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <string>



int main()
{
    //cin.tie(nullptr);

    int K;
    std::string S;
    std::cin >> K;
    std::cin >> S;
    if (S.length() > K)
    {
        std::cout << S.substr(0, K) << "..." << std::endl;
    }
    else
    {
        std::cout << S << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

   string s; cin >> s;
   int start = 0;
   int end = (int)s.size() -1;
   while(s[start] != 'A') start++;
   while(s[end] != 'Z') end--;

   cout << end - start + 1 << endl;

   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {

    double h,w,n;
    cin>>h>>w>>n;

    cout<<min(ceil(n/h),ceil(n/w))<<endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int n;	
  cin>>n;

  while(n--){
  	int t;
    cin>>t;
    if(t%2 == 0) {
    	if(t%3 != 0 && t%5 != 0) {cout<<"DENIED\n"; return 0;}
    } 
  }
  cout<<"APPROVED\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define  MAX 100
using namespace std;
int a[MAX];
int main() {
	int n, minv, maxv;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (i == 0)
		{
			minv = a[i];
			maxv = a[i];
		}
		else
		{
			if (minv > a[i]) minv = a[i];
			if (maxv < a[i]) maxv = a[i];
		}
	}
	long long cost = 0, res = 9223372036854775807;
	for (int j = minv; j <= maxv; ++j)
	{
		if (cost != 0) {
			if (cost < res) res = cost;
			cost = 0;
		}
		for (int i = 0; i < n; ++i)
		{
			cost += (a[i] - j) *  (a[i] - j);
		}
	}
	cout << (res == 9223372036854775807 ? 0 :res) << endl;
	return 0;
}

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

num = 0
while A >= B:
    B *= 2
    num += 1

while B >= C:
    C *= 2
    num += 1

#print('num:', num)
if num <= K:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9160
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  map<int, int> mp;
  for(int i = 0; i < n; i++) {
    mp[v[i] - 1]++;
    mp[v[i]]++;
    mp[v[i] + 1]++;
  }
  int id = 0;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    if(mp[id] < it->second) {
      id = it->first;
    }
  }
  cout << mp[id] << endl;
  return 0;
}


Measured memory_bytes: 5120
package main

import (
	"fmt"
	"math/big"
)

func main() {
	n := 0
	_, _ = fmt.Scan(&n)
	var v int64
	for i := 0; i < n; i++ {
		var tmp int64
		_, _ = fmt.Scan(&tmp)
		v = gcd(v, tmp)
	}
	fmt.Println(v)
}

func gcd(m, n int64) int64 {
	if m == 0 {
		return n
	} else if n == 0 {
		return m
	}
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(uint64(m))
	b := new(big.Int).SetUint64(uint64(n))
	return z.GCD(x, y, a, b).Int64()
}

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

using namespace std;
#define ll long long
const int N = 2e5 + 5;
int a[N];
bool vis[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    for(int i = 1 ; i <= n  ;i++) cin >> a[i];
    vector < int > v;
    int cur = 1;
    if (k <= 2 * n) {
        int cur = 1;
        while(k--) {
            cur = a[cur];
        }
        return cout << cur, 0;
    }
    vector < int > z;
    while(1) {
        if (vis[cur]) {
            while(v.back() != cur) {
                z.push_back(v.back());
                v.pop_back();
            }
            z.push_back(v.back());
            v.pop_back();
            k -= v.size();
            reverse(z.begin(), z.end());
            break;
        }
        vis[cur] = 1;
        v.push_back(cur);
        cur = a[cur];
    }
    k %= (long long)z.size();
    cout << z[k];
    return 0;
}

Measured memory_bytes: 5712
#include <iostream>

using namespace std;

long long int C[100005], a[100005],b[100005];

int main(void) {

	long long int N, K;
	cin >> N >> K;

	

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

	long long int sum = 0;
	for (int i = 1; i <= 100000; i++) {
		sum += C[i];
		if (sum >= K) { cout << i << endl; break; }
	}


	//system("pause");
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()

{int n;
long long int sum=0;
cin>>n;
long long int a[n+1];
long long int b[n];

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

for(int i=0;i<n;i++)
{
    if(b[i]>a[i] && b[i]<=a[i+1] && b[i]<=a[i]+a[i+1]) {sum=sum+b[i]; a[i+1]=a[i+1]-b[i]+a[i];}
    else if(b[i]>a[i] && b[i]>=a[i+1] && b[i]<=a[i]+a[i+1]) {sum=sum+b[i]; a[i+1]=a[i+1]+a[i]-b[i];}
    else if(b[i]>a[i] && b[i]>=a[i+1] && b[i]>=a[i]+a[i+1]){sum=sum+a[i]+a[i+1]; a[i+1]=0;}
    else if(b[i]==a[i]) {sum=sum+b[i];}
     else if(b[i]<a[i]) {sum=sum+b[i];}

}



cout<<sum<<endl;













}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int h,a;
    cin >> h >> a;
    if(h%a==0){
        cout << h/a << endl;
    }else{
        cout << h/a + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
std::ostream& operator<<(std::ostream& os, __int128 T)
{
    if (T<0) os<<"-";if (T>=10 ) os<<T/10;if (T<=-10) os<<(-(T/10));
    return os<<( (int) (T%10) >0 ? (int) (T%10) : -(int) (T%10) ) ;
}
const int maxn=1e5+10;
int dp[maxn];
bool bro[maxn];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	int x;
	for(int i=0;i<m;i++)
	{
		scanf("%d",&x);
		bro[x]=1;
	}
	dp[0]=1;
	if(!bro[1])dp[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(bro[i])continue;
		dp[i]=(dp[i-1]+dp[i-2])%MOD;
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d;
    while(cin>>d){
        int s=0;
        for(int i=0; i<600; i+=d) s+=i*i*d;
        cout<<s<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		long [] in = new long [100000];
        long base = 1;
        for(int i=0;i<9;i++){in[i] = base;
                             base++;
                            }
		int point = 0;
        int search = 9;        
        while(search<100000){if(search<100000 && in[point]%10!=0){
          in[search]=10*in[point]+in[point]%10-1;
          search++;
         }
                             if(search<100000){in[search]=10*in[point]+in[point]%10;
                                              search++;}
                             if(search<100000 && in[point]%10!=9){
          in[search]=10*in[point]+in[point]%10+1;
          search++;}
                        point++;}        
		System.out.println(in[k-1]);
	}
}

Measured memory_bytes: 36588
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

namespace std {
    bool operator<(const Point &a, const Point &b) {
        return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
    }
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Line: public pair<Point, Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

struct Circle {
    Point p;
    double r;
    Circle() {}
    Circle(const Point &p, const double r): p(p), r(r) {}
};

pair<Point, Point> get_tangents(const Circle &c, const Point &p) {
    Point v=c.p-p;
    double w=sqrt(norm(v)-c.r*c.r);

    Point p1=p+w*Point(w, c.r)*v/norm(v);
    Point p2=p+w*Point(w, -c.r)*v/norm(v);

    if (p2 < p1)
        swap(p1, p2);

    return make_pair(p1, p2);
}

int main() {
    double x, y, r;
    scanf("%lf %lf", &x, &y);
    Point p(x, y);

    scanf("%lf %lf %lf", &x, &y, &r);
    Circle c(Point(x, y), r);

    pair<Point, Point> tangents=get_tangents(c, p);
    printf("%.9f %.9f\n", real(tangents.first), imag(tangents.first));
    printf("%.9f %.9f\n", real(tangents.second), imag(tangents.second));
    return 0;
}

Measured memory_bytes: 2796
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;
int n;

vector<vector<ll>> pr(vector<vector<ll>> a, vector<vector<ll>> b) {
  vector<vector<ll>> ans(n, vector<ll>(n, 0));
  rep(i, n) rep(j, n) {
    rep(k, n) (ans[i][j] += a[i][k]*b[k][j]) %= mod;
  }
  return ans;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  ll k;
  cin >> n >> k;
  vector<vector<ll>> a(n, vector<ll>(n, 0));
  rep(i, n) rep(j, n) cin >> a[i][j];
  vector<vector<ll>> dp(n, vector<ll>(n, 0));
  rep(i, n) dp[i][i] = 1;
  while(k>0) {
    if (k%2) dp = pr(dp, a);
    a = pr(a, a);
    k /= 2;
  }
  ll ans = 0;
  rep(i, n) rep(j, n) ans += dp[i][j];
  cout << ans%mod << endl;
}

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

namespace ABC144B
{
    class Program
    {
        static void Main(string[] args)
        {
            //var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var inputInt = int.Parse(Console.ReadLine());

            //int ans = 0;
            string ans = "No";

            for(int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                    if (i * j == inputInt) ans = "Yes";
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int N, M, Q;
vector<int> a, b, c, d;

ll solve(const vector<int> &A) {
    ll cnt = 0;
    for (int i = 0; i < Q; i++) {
        if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) {
            cnt += d.at(i);
        }
    }
    return cnt;
}

ll dfs(vector<int> &A) {
    if (A.size() == N) {
        return solve(A);
    }
    ll last, ans = 0;
    if (A.size() == 0) {
        last = 0;
    }    
    else {
        last = A.back();
    }
    for (int u = last; u < M; u++) {
        A.push_back(u);
        ans = max(ans, dfs(A));
        A.pop_back();
    }
    return ans;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
        a.at(i)--, b.at(i)--;
    }
    vector<int> A;
    cout << dfs(A) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h> 
char s[5]; 
int main() { 
  scanf("%s",&s); 
  if(s[0]==s[1]&&s[1]==s[2])puts("Yes"); 
  else if(s[1]==s[2]&&s[2]==s[3])puts("Yes"); 
  else puts("No"); 
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	string s;
  	cin >> s;
  	reverse(all(s));
  	s.push_back('0');
  	ll sz = s.size();


    vector<vll> dp(sz+5, vll(2));
	// dp[x][0] -> 繰り上がりなし
  	// dp[x][1] -> 繰り上がりあり
	int temp = s[0]-'0';
  	dp[0][0] = temp;
  	dp[0][1] = 10-temp;
  
  	rep(i,sz){
      	// 下から i+1 桁目を見る
      	temp = s[i+1]-'0';
      	if(temp == 9){
			dp[i+1][0] = dp[i][0] + temp;
        }else{
			dp[i+1][0] = min(dp[i][0], dp[i][1]+1) + temp;
        }
      	dp[i+1][1] = min(dp[i][0]+10-temp, dp[i][1]+9-temp);
    }
    cout << min(dp[sz-1][0], dp[sz-1][1]) << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 55964
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string solveMeFirst(vector<int>x,vector<int>y){
    int xmax = *max_element(x.begin(), x.end());
    int ymin = *min_element(y.begin(), y.end());
    if (xmax < ymin){
        return "No War";
    }else{
        return "War";
    }
}

int main(){
    int n,m,x,y;
    cin >> n  >>m >> x >> y;
    vector<int> xs,ys;
    int s;
    for(int i = 0; i<n;i++){
        cin >>s;
        xs.push_back(s);
    }
    for(int i = 0; i<m;i++){
        cin >>s;
        ys.push_back(s);
    }
    xs.push_back(x);
    ys.push_back(y);
    string d = solveMeFirst(xs,ys);
    cout << d;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int maxn = 1e2 + 5;
long long seq[maxn];
int main(){
    int n;
    std::cin >> n;
    for (int i= 1; i <= n; ++ i) std::cin >> seq[i];
    int cnt = 0;
    for (int i = 1; i <= n; ++ i){
        for (int j = 1; j <= n; ++ j){
            for (int k = 1; k <= n; ++ k){
                if (i == j || j == k || i == k) continue;
                if (seq[i] == seq[j] || seq[j] == seq[k] || seq[i] == seq[k]) continue;
                if (seq[i] + seq[j] > seq[k] && seq[i] + seq[k] > seq[j] && seq[j] + seq[k] > seq[i]){
                    cnt ++;
                }
            }
        }
    }
    std::cout << cnt / 6 << std::endl;
}

Measured memory_bytes: 3544
sub f{my($u,$p)=@_;push@{--$|?b:c},$u;$_-$p&&f($_,$u)for@$u;--$|}$n=<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;@a=($,=$",(f 1)x$n);--$x;@b>$n/3&@c>$n/3?(map$a[$_]=$x+=3,@b)+map$a[$_]=++$y*3-2,@c:map$a[$_]=$x+=$x%3,@b>@c?@b:@c;print map$_<=$n&&$_||3*++$z,@a

Measured memory_bytes: 269440
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int SURP = 1000000007;

int main(){
	int N;
	cin >> N;
	int A[N];

	FOR(i,0,N){
		cin >> A[i];
	}
	sort(A,A+N);

	vector<int> vi;
	vector<int> num;
	int tmp = A[0];
	int numt = 1;
	FOR(i,1,N){
		if(tmp != A[i]){
			vi.push_back(tmp);
			num.push_back(numt);
			tmp = A[i];
			numt = 1;
		}else{
			numt++;
		}
	}
	vi.push_back(tmp);
	num.push_back(numt);

	int ret = 0;
	int even = 0;
	FOR(i,0,num.size()){
		int a = num.at(i);
		if(a > 1){
			if (a%2 == 1) ret += 1;
			else{
				ret += 2;
				even++;
			}
		}else{
			ret++;
		}
	}
	ret -= (even+1)/2 * 2;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1660