akhauriyash/Code-Regression huggingface dataset:
from collections import deque
N, M, Q = map(int, input().split(" "))
abcd = []
for i in range(Q):
    abcd.append(list(map(int, input().split(" "))))
q = deque([[i] for i in range(1, M + 1)])
A = []
while q:
    tmp = q.pop()
    if len(tmp) == N:
        A.append(tmp)
    else:
        for i in range(tmp[-1], M + 1):
            tmp_copy = tmp.copy()
            tmp_copy.append(i)
            q.append(tmp_copy)
ans = 0            
for a in A:
    score = 0
    for i in abcd:
        if a[i[1] - 1] == a[i[0] - 1] + i[2]:
            score += i[3]
    ans = max(ans, score)
print(ans)

Measured memory_bytes: 29068
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main()
{
	int N; cin >> N;
	vector<long long>A(N + 1);
	vector<long long>B(N);

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

	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		long long a1 = min(B[i], A[i]);
		A[i]-=a1;
		B[i]-=a1;

		long long a2 = min(B[i], A[i+1]);
		A[i+1] -= a2;
		B[i] -= a2;

		ans += a1 + a2;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
w, h, n = map(int, input().split())
xmin = 0
xmax = w
ymin = 0
ymax = h
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        xmin = max(xmin, x)
    if a == 2:
        xmax = min(xmax, x)
    if a == 3:
        ymin = max(ymin, y)
    if a == 4:
        ymax = min(ymax, y)
print(max(xmax-xmin, 0)*max(ymax-ymin, 0))

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll H, W; cin >> H >> W;
    vs S(H, ""); REP(i, H) cin >> S[i];
    
    vvl row(H, vl(W, 0)), col(H, vl(W, 0));
    REP(i, H){
        ll l = 0, r = 0;
        while(l < W){
            ll cnt = 0;
            while(r < W && S[i][r] == '.'){
                r++; cnt++;
            }
            FOR(j, l, r){
                row[i][j] = cnt;
            }
            l = r+1; r=l;
        }
    }
    
    REP(i, W){
        ll l = 0, r = 0;
        while(l < H){
            ll cnt = 0;
            while(r < H && S[r][i] == '.'){
                r++; cnt++;
            }
            FOR(j, l, r){
                col[j][i] = cnt;
            }
            l = r+1; r=l;
        }
    }
    ll ans = 0;
    REP(i, H) REP(j, W){
        ll tmp = row[i][j]+col[i][j]-1;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67200
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x,l,count=0;
    cin>>n>>x;
    int point=0;
    for (int i=1;i<=n+1;i++) {
        if (i!=1) {
            cin>>l;
            point+=l;
        }
        if (point<=x) {
            count++;
        }
    }
    cout<<count<<endl;
}


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

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            int N = IO.ReadLineToInt();
            string ans = ":(";

            for (int X = 1; X <= N; X++)
            {
                if (Math.Floor(X * 1.08) == N)
                {
                    ans = X.ToString();
                    break;
                }
            }


            //ここまで

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

    }

    static class Func
    {
        static public long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public long Factorial(long a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(long n, long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }

        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }

        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13140
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Random;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int D;
	int[] c;
	int[][] s;

	int[] ans;

	long score(int[] a, int dd) {
		int[] last = new int[26];

		long res = 0;

		for (int d = 0; d < dd; d++) {
			res += s[d][a[d]];
			last[a[d]] = d + 1;

			for (int j = 0; j < 26; j++) {
				res -= (c[j] * (d + 1 - last[j]));
			}
//			System.err.println(res);
		}
		return res ;
	}
	
	
	long score2(int[] a) {
		long res = 0;
		for(int i=0;i<26;i++) {
			res += scores(i, a);
		}
		return res;
	}
	//問題iについてのスコア
	long scores(int i, int[] a) {
		int last = 0;
		long res = 0;

		for (int d = 0; d < D; d++) {
			if(a[d] == i) {
				res += s[d][i];
				last = d + 1;
			}

			res -= (c[i] * (d + 1 - last));
		}
		return res ;		
	}

	public void _main(String[] args) {
		long st = System.currentTimeMillis();
		Scanner sc = new Scanner(in);

		D = sc.nextInt();
		c = new int[26];
		for (int i = 0; i < 26; i++) {
			c[i] = sc.nextInt();
		}

		s = new int[D][26];
		for (int i = 0; i < D; i++) {
			for (int j = 0; j < 26; j++) {
				s[i][j] = sc.nextInt();
			}
		}

		sc.close();

		ans = new int[D];


		for(int d=0;d<D;d++) {
			long max = score(ans, d+1);
			
			for(int i=0;i<26;i++) {
				int t = ans[d];
				ans[d] = i;
				long s = score(ans, d+1);
				
				if(s > max) {
					max = s;
				}else {
					ans[d] = t;
				}
			}
		}
		
//		System.err.println(score(ans,D));
//		System.err.println(score2(ans));
		
		Random random = new Random();
		long max = score(ans, D);
		while (System.currentTimeMillis() - st < 1900) {
			int d = random.nextInt(D);
			int i = random.nextInt(26);
			
			int t = ans[d];
			if(t==i) continue;
			
			long s = 0;
			s -= scores(i,ans);
			s -= scores(t,ans);
			
			ans[d] = i;
			
			s += scores(i, ans);
			s += scores(t, ans);
			
			if(s > 0) {
				max += s;
			}else {
				ans[d] = t;
			}
		}

//		System.err.println(max);

		StringBuilder sb = new StringBuilder();
		for (int x : ans) {
			sb.append(x+1);
			sb.append("\n");
		}
		out.print(sb.toString());

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 48932
var a:longint;
function x(a:longint):longint;
var c:longint=0;
begin
  while a<>0 do
  begin
    inc(c,a mod 10);
    a:=a div 10;
  end;
  exit(c);
end;
begin
  readln(a);
  if a mod x(a)=0 then
    writeln('Yes')
  else
    writeln('No');
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }

    return false;
}

int main()
{
    int N, M, K;
    cin >> N >> M >> K;

    vector<long long> A(N), a(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        a[i + 1] = a[i] + A[i];
    }

    vector<long long> B(M), b(M + 1, 0);
    for (int j = 0; j < M; j++)
    {
        cin >> B[j];
        b[j + 1] = b[j] + B[j];
    }

    int j = M;
    int res = 0;
    for (int i = 0; i < N + 1; i++)
    {
        if (a[i] > K)
        {
            break;
        }

        while (b[j] > (K - a[i]))
        {
            j--;
        }

        chmax(res, i + j);
    }

    cout << res << endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  
  sort(x.begin(), x.end());
  
  cout << x[0] << " " << x[1] << " " << x[2] << '\n';
}


Measured memory_bytes: 3176
import  bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
tmp=0
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp=bisect.bisect_left(L,L[i]+L[j])
        ans+=tmp-j-1

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

struct RollingHash {
    const int base = 10007;
    static const int M = 2;
    const vector<int> mod = {999999937, 1000000007};
    vector<long long> hash[M], power[M];
    RollingHash(const string &s, int base = 9973) : base(base) {
        int n = s.size();
        for (int iter = 0; iter < M; ++iter) {
            hash[iter].assign(n + 1, 0);
            power[iter].assign(n + 1, 1);
            for (int i = 0; i < n; ++i) {
                hash[iter][i + 1] = (hash[iter][i] * base + s[i]) % mod[iter];
                power[iter][i + 1] = power[iter][i] * base % mod[iter];
            }
        }
    }
    long long get(int l, int r, int id = 0) {   // [l, r)
        long long ret = hash[id][r] - hash[id][l] * power[id][r-l] % mod[id];
        return (ret < 0 ? ret + mod[id] : ret);
    }
};

int main() {
    int N, M; cin >> N >> M;
    string S; cin >> S;
    RollingHash rh(S);
    set<pair<long long, long long>> res;
    int left = 0, right = 1;    // [left, right)
    while (M--) {
        string q; cin >> q;
        if (q == "L++") left++;
        else if (q == "L--") left--;
        else if (q == "R++") right++;
        else if (q == "R--") right--;
        res.emplace(rh.get(left, right, 0), rh.get(left, right, 1));
    }
    cout << res.size() << endl;
    return 0;
}


Measured memory_bytes: 31372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		
		int s = scan.nextInt();
		int w = scan.nextInt();
		
		if(s > w) {
			System.out.println("safe");
		}else {
			System.out.println("unsafe");
		}
		
	}

}


Measured memory_bytes: 35624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<limits.h>
#include<string>
#include<vector>
#include<functional>
using namespace std;

signed main() {
	int a, b, c; cin >> a >> b >> c;
	for (int i = 1; i <= 10000; i++) {
		if (a*i%b == c) { puts("YES"); return 0; }
	}
	puts("NO");
}

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

template<class T> inline bool chmax(T &a, T b) {
    if (a < b) a = b; return true;
    return false;
}

void solve(long long X){
    if (X < 4) cout << 1 << '\n';
    else {
        int ans = 0;
        for (int i = 2; i <= 31; i++) {
            for (int j = 2; j <= 10; j++) {
                if (pow(i, j) <= X)
                    chmax(ans, (int)pow(i, j));
            }
        }
        cout << ans << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
open System.Collections.Generic

let [| N; K |] = stdin.ReadLine().Split() |> Array.map int

let s = new HashSet<int>()

for i in [ 1..K ] do
    let _ = stdin.ReadLine()
    let A = stdin.ReadLine().Split() |> Array.map int
    for j in [ 0..A.Length - 1 ] do
        s.Add(A.[j]) |> ignore

N - s.Count |> stdout.WriteLine


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110;
int vis[maxn];
void run_case()
{
    int x, n;
    cin >> x >> n;
    for (int i = 1; i <= n; i++)
    {
        int cur;
        cin >> cur;
        vis[cur] = 1;
    }
    // if (n == 0)
    // {
    //     cout << x << "\n";
    //     return;
    // }
    int ans = INF;
    int res = INF;
    for (int i = x; i <= maxn; i++)
    {
        if (abs(i - x) < res && (!vis[i]))
        {
            res = abs(i - x);
            ans = i;
        }
    }
    for (int i = x - 1; i >= 0; i--)
    {
        if (abs(i - x) <= res && (!vis[i]))
        {
            res = abs(i - x);
            ans = i;
        }
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

int N;

signed main() {
    cin >> N;
    map<int, int> m;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        m[a - 1]++;
        m[a]++;
        m[a + 1]++;
    }

    int ans = 0;
    for (auto v : m) {
        ans = max(ans, v.second);
    }

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

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

int main() {
  ll N; cin >> N;
  vector<ll> t(N+1), x(N+1), y(N+1);
  t[0] = 0, x[0] = 0, y[0] = 0;
  rep2(i, 1, N+1) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool flag = true;
  rep(i, N) {
    ll time = t[i+1] - t[i];
    ll x_tmp = abs(x[i+1] - x[i]);
    ll y_tmp = abs(y[i+1] - y[i]);
    if (time % 2 != (x_tmp + y_tmp) % 2) {
      flag = false;
      break;
    }
    else if (x_tmp + y_tmp > time) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

const int MOD = 1e9 + 7;
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int a = 'a';
    int z = 'z';
    map<int, int> M;
    for(int i = a; i <= z; i++){
        M[i] = 0;
    }
    for (int i = 0; i < S.size(); ++i) {
        M[S[i]]++;
    }
    for (int i = a; i <= z; ++i) {
        if(M[i] == 0){
            S.push_back(char(i));
            cout << S << endl;
            return 0;
        }
    }
    if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    string ans{};
    string T = S;
    next_permutation(all(T));
    REP(i, S.size()){
        cout << T[i];
        if(S[i] != T[i]) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 2e5+9;
int A[N];

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,T,cas=0;
    cin>>n;
    map<int, int> mp;
    for(int i=1;i<=n;++i) {
        cin>>A[i];
        mp[A[i]+i]++;
    }
    ll cnt=0;
    for(int i=1;i<=n;++i) {
        cnt += mp[i-A[i]];
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 21332
#include <iostream>

int main(void) {
    double r_init;
    double w_init;
    double c;
    int r;

    double dens;
    int kosuu;

    while(1) {
        std::cin >> r_init >> w_init >> c >> r;
        if (r_init == 0 && w_init == 0 && c == 0 && r == 0) {
            break;
        }

        kosuu = 0;
        while(1) {
            dens = (r_init + (double)(kosuu * r)) / (double)(w_init);
            if (dens >= c) {
                std::cout << kosuu << std::endl;
                break;
            }
            kosuu++;
        }
    }
    return 0;
}

Measured memory_bytes: 3148
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,k;
  std::cin>>n>>k;

  std::string s;
  std::cin>>s;

  ll ans=0;
  char prev=s[0];

  ll a=0,b=0;

  rep(i,1,n){
    if(prev==s[i]){
      ans++;
    }else{
      if(prev=='L')a++;
      else b++;
    }
    prev=s[i];
  }

  if(b<a)std::swap(a,b);

  ans+=2*(std::min(k,a));

  if((a!=b)&&(k>a))ans++;

  std::cout<<ans;

  return 0;
}


Measured memory_bytes: 512
main(){float a,b,c,d,e,f,x;for(;~scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(c-b*x)/a,x/=a*e-b*d+0.0))x=a*f-d*c;exit(0);}

Measured memory_bytes: 648
// 2014/04/27 Tazoe

#include <iostream>
using namespace std;

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

	return gcd(b, a%b);
}

int main()
{
	while(true){
		int a, b;
		cin >> a >> b;

		if(cin.eof())
			break;

		int g = gcd(a, b);
		cout << g << ' ' << a/g*b << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
def main():
    s = raw_input()
    check_b = lambda x: x=='B'
    check_w = lambda x: x=='W'
    if all(map(check_b, list(s))) or all(map(check_w, list(s))):
        return 0

    work = list(s)[:]
    flag_b = False
    flag_w = False
    stack = []
    cnt = 0
    for i in range(len(work)-1):
        w_list = work[i:i+2]
        if w_list[0] == w_list[1]:
            pass
        else:
            cnt += 1

    return cnt



if __name__ == '__main__':
    print main()

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

int main()
{
    int H, W;
    cin >> H >> W ;
    while(H!=0 || W!=0){
        for (int h = 0; h< H; h++){
            for ( int w = 0; w < W; w++){
                
                if ((w%2==0 and h%2==0) || (w%2==1 and h%2==1)){
                    cout << '#';
                }else
                {
                    cout << '.';
                }
                
                
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W ;
    }

}


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

int main() {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  for (ll b = 1; b <= n; b++)
    ans += n / b * max((ll)0, b - k) + max((ll)0, n % b - k + 1);
  if (k == 0) ans -= n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/

bool judge(ll &x){
    if(x < 2) return false;
    else return true; 
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int a, b; cin >> a >> b;
    bool find = false;
    FOR(i, 1, 1300){
        int p = i*2/25, q = i/10;
        if(p == a && q == b){
            cout << i << endl;
            find = true;
            break;
        }
    }

    if(!find) cout << -1 << endl;

return 0;
}

Measured memory_bytes: 3632
n = int(input())
a = map(int, input().split())
l = [0 for i in range(9)]

for i in a:
    if i // 400 >= 8:
        l[8] += 1
    else:
        l[i // 400] = 1
if sum(l[:8]) == 0:
    print(1, sum(l))
else:
    print(sum(l[:8]), sum(l))


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        int r = Integer.parseInt(s[0]);
        int c = Integer.parseInt(s[1]);
        int[][] num = new int[r][c];
        String str;
        int i=0;
        int j=0;
        int sum1=0,sum2=0,sum3=0;
        while((str=br.readLine())!=null){
            String[] sg = str.split(" ");
            for(; i<sg.length; i++){
                int a = Integer.parseInt(sg[i]);
                num[j][i] = a;
            }
            i=0;
            j++;
        }
        for(int k=0; k<r; k++){
            for(int l=0; l<c; l++){
                sum1 += num[k][l];
                System.out.print(num[k][l]+" ");
            }
            System.out.println(sum1);
            sum1=0;
        }
        for(int k=0; k<c; k++){
            for(int l=0; l<r; l++){
                sum2 += num[l][k];
            }
            System.out.print(sum2+ " ");
            sum3 += sum2;
            sum2=0;
        }
        System.out.println(sum3);
    }
}

Measured memory_bytes: 25424
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;
	
	bool flag = true;
	for (int i = 0; i < a; ++i) {
		if (!('0' <= s[i] && s[i] <= '9'))
			flag = false;
	}
	if (s[a] != '-')
		flag = false;
	for (int i = 0; i < b; ++i) {
		if (!('0' <= s[a + 1 + i] && s[a + 1 + i] <= '9'))
			flag = false;
	}
	
	if (flag)
		Yes();
	else
		No();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<cctype>
using namespace std;
int total(int a, int b) {
	int c = 0;
	for (int i = 0; i < (b + 1) - a; i++) {
		c = c + a + i;
	}
	return c;
}
int gcd(int a, int b) {
	int c, x;
	x = a * b;
	c = b % a;
	while (c != 0) {
		b = a;
		a = c;
		c = b % a;
	}
	return x / a;
}
void InitRand(){
	srand((unsigned int)time(NULL));
}
int random(int n){
	return rand() % n + 1;
}
int pri(int a) {
	int ans = 0;
	for (int i = 2; i < a; i++) {
		if (a % i != 0)ans++;
	}
	if (ans==0){
		return 0;
	}
	else {
		return 1;
	}
}
#define rep( i, n) for(int i=0;i<n;i++)
#define vint(abc, n) vector<int> abc(n);
#define vinta(abc, n, x) vector<vector<int> > abc(n,vector<int>(x);
#define vche(abc, n) vector<cher> abc(n);
#define printl(a) printf("%d \n",a);
#define printb(a)printf("%s \n",a);
#define scanl(a) scanf("%d",&a);
#define scanb(a) scanf("%s",&a);
#define in(a) cin>>a;
#define out(a) cout<<a<<endl;
#define pi 3.1415926535897932384626;
int main() {
	string s, p;
	cin >> s >> p;
	s=s+s;
	int sa = s.find(p);
	if (sa == -1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3208
// Integral

#include <iostream>
using namespace std;

int main() {
    int d; // 幅

    while (cin >> d) {
        int area = 0; // 累積の面積
        for (int x = d; x < 600; x += d) {
            area += x * x * d;
        }
        cout << area << "\n";
    }
    return 0;
}


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

using namespace std;

class StronglyConnectedComponentDecomposition
{
private:
	int V; // ????????°
	vector<vector<int>> G; // ??°???????????£??\???????????¨???
	vector<vector<int>> rG; // ?????????????????????????????°??????
	vector<int> vs; // ??°?????????????????????
	vector<bool> used; // ?????§???????????????

public:
	vector<int> cmp; // ?±????????????£????????????????????????????????????
	StronglyConnectedComponentDecomposition( int N = 0 ) {
		V = N;
		G = vector<vector<int>>( V );
		rG = vector<vector<int>>( V );
		used = vector<bool>( V );
		cmp = vector<int>( V );
	}
	void add_edge( int from, int to ) {
		G[from].push_back( to );
		rG[to].push_back( from );
	}
	void dfs( int v ) {
		used[v] = true;
		for( int i = 0; i < G[v].size(); i++ ) {
			if( !used[G[v][i]] ) dfs( G[v][i] );
		}
		vs.push_back( v );
	}
	void rdfs( int v, int k ) {
		used[v] = true;
		cmp[v] = k;
		for( int i = 0; i < rG[v].size(); i++ ) {
			if( !used[rG[v][i]] ) rdfs( rG[v][i], k );
		}
	}
	int scc() {
		used = vector<bool>( V );
		vs.clear();
		for( int v = 0; v < V; v++ ) {
			if( !used[v] ) dfs( v );
		}
		used = vector<bool>( V );
		int k = 0;
		for( int i = vs.size() - 1; i >= 0; i-- ) {
			if( !used[vs[i]] ) rdfs( vs[i], k++ );
		}
		return k;
	}
};

int main() {
	long long int V, E;
	cin >> V >> E;
	StronglyConnectedComponentDecomposition SCCD( V );
	for( size_t i = 0; i < E; i++ ) {
		int s, t;
		cin >> s >> t;
		SCCD.add_edge( s, t );
	}
	SCCD.scc();
	long long int N;
	cin >> N;
	for( size_t i = 0; i < N; i++ ) {
		int u, v;
		cin >> u >> v;
		cout << (SCCD.cmp[u] == SCCD.cmp[v]) << endl;
	}
	return 0;
}

Measured memory_bytes: 4400
import copy
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

def linearSearch(A,key,n):
    i=0
    B=copy.copy(A)
    B.append(key)
    while B[i] != key:
        i=i+1
    if i==n:
        return 0
    return 1

def BinarySearch(A,key,start,end):
    if start==end:
        if A[start]!=key:
            return 0
        else:
            return 1
    mid=(start+end)//2
    if A[mid]>=key:
        return BinarySearch(A,key,start,mid)
    else:
        return BinarySearch(A,key,mid+1,end)

ans=0
for i in range(q):
    if BinarySearch(S,T[i],0,n-1):
        ans=ans+1

print(ans)


Measured memory_bytes: 17348
import math
N, D = map(int,input().split())

X = []
for i in range(N):
    array = list(map(int, input().split()))
    X.append(array)
    
count = 0

for i in range(N):
  for j in range(i + 1, N):
    L = []
    for k in range(D):
      L.append((X[i][k] - X[j][k]) ** 2)
    y = sum(L)
    for l in range(y + 1):
      if l ** 2 == y:
        #print(l)
        count += 1

print(count)

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

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

  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i != 0)
      a[i] += a[i - 1];
  }

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

  ll ans = 0, zero = 0;
  int now = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] != a[now]) {
      ll d = i - now;
      ans += d * (d - 1) / 2;
      now = i;
    }
    if (a[i] == 0)
      ++zero;
  }
  ll d = n - now;
  ans += d * (d - 1) / 2;
  ans += zero;

  cout << ans << endl;
}

Measured memory_bytes: 1792
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, ma, mb = LI()
abc = [tuple(LI()) for _ in range(n)]
ab_max = n * 10 + 1

dp = [[[INF] * ab_max for _ in range(ab_max)] for _ in range(n + 1)]
dp[0][0][0] = 0


for i in range(n):
    ai, bi, ci = abc[i]
    for a in range(ab_max - ai):
        for b in range(ab_max - bi):
            if dp[i][a][b] == INF:
                continue
            dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
            dp[i + 1][a + ai][b + bi] = min(dp[i][a + ai][b + bi], dp[i][a][b] + ci)


ans = INF
c = 1
while True:
    a, b = c * ma, c * mb
    if a >= ab_max or b >= ab_max:
        break
    ans = min(ans, dp[n][a][b])
    c += 1

print(ans if ans != INF else -1)


Measured memory_bytes: 59500
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int n, k;
    int tmp;
    int flag = 0;
    cin >> n >> k;
    
    vector<int> v;
    int i, d;
    
    for(i = 0; i < k; i++){
        cin >> d;
        v.push_back(d);
    }
    
    while(1){
        tmp = n;
        flag = 0;
        while(tmp != 0){
            for(i = 0; i < k; i++){
                if(tmp%10 == v[i]){
                    flag = 1;
                    break;
                }
            }
            if(flag){
                break;
            }else{
                tmp /= 10;
            }
        }
        if(flag == 0){
            cout << n << endl;
            return 0;
        }
        n++;
    }
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	int win = 0;
	int lose = 0;
	for (int i = 0; i < (int)s.length(); i++) {
		if (i % 2) {
			if (s[i] == 'g') win++;
		} else {
			if (s[i] == 'p') lose++;
		}
	}
	cout << win - lose << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    int x,y; cin>>x>>y;
    cout<<(abs(x-y)>1?"Alice":"Brown")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n, m;

void solve( int a, int b, string s ) {
	if ( !a && !b ) {
		printf( "%s\n", s.c_str() );
		return;
	}
	if ( ( 5 == n && 5 != m && !a && b ) || ( 5 == m && 5 != n && a && !b ) || ( 5 == n && 5 == m && !a && b > 1 ) || ( 5 == m && 5 == n && a > 1 && !b ) || ( 6 == n && a == 1 && b ) || ( 6 == m && a && b == 1 ) ) {
		return;
	}
	if ( a ) {
		solve( a - 1, b, s + "A" );
	}
	if ( b ) {
		solve( a, b - 1, s + "B" );
	}
}

int main() {
	scanf( "%d %d", &n, &m );
	solve( n, m, "" );
	return 0;
}

Measured memory_bytes: 1200
h, w = map(int, input().split())

s_list = []
for i in range(h):
    s_list.append(input())

def countUp(hi:int, wi:int):
    if hi >= 0 and hi < h and wi >= 0 and wi < w and s_list[hi][wi] == "#":
        return 1
    else:
        return 0

output_list = []
for hi in range(h):
    s = s_list[hi]
    output = ""
    for wi in range(w):
        if s[wi] == "#":
            output += "#"
        else:
            output += str(countUp(hi-1, wi-1) + countUp(hi-1, wi) + countUp(hi-1, wi+1) + countUp(hi, wi-1) + countUp(hi, wi+1) + countUp(hi+1, wi-1) + countUp(hi+1, wi) + countUp(hi+1, wi+1))

    output_list.append(output)

for o in output_list:
    print(o)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

func main() {
	var n int
	var a []int
	var max, min int
	fmt.Scan(&n)
	for i:=0; i<n; i++ {
		var ia int
		fmt.Scan(&ia)
		a = append(a, ia)
	}

	max, min = a[0], a[0]

	for i:=1; i<n; i++ {
		if max < a[i] {
			max = a[i]
		}
		if min > a[i] {
			min = a[i]
		}
	}

	fmt.Println(abs(max-min))
}

Measured memory_bytes: 512
'''
Created on 2020/09/13

@author: okazakieiichiro
'''

a, b, c, d = (int(x) for x in input().split())

ans1 = a * c
ans2 = b * c
ans3 = a * d
ans4 = b * d

ansList = [ans1, ans2, ans3, ans4]

max = None
for ans in ansList:
    if max is None:
        max = ans
    elif max <ans:
        max = ans

print(max)


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<array<int64_t, 2>>> E(n);

    for (int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        E[l].push_back({r, d});
        E[r].push_back({l, -d});
    }

    vector<bool> visited(n);
    map<int, int64_t> D;
    auto dfs = [&](auto i, auto self) -> bool{
        if (visited[i])
            return true;
        if (D.empty())
            D[i] = 0;

        visited[i] = true;
        bool res = true;
        for (const auto &e: E[i]){
            int r = e[0];
            int64_t d = e[1];
            if (D.count(r) != 0 and D[r] != D[i] + d)
                return false;
            D[r] = D[i] + d;
            res &= self(r, self);
        }
        return res;
    };

    for (int i = 0; i < n; i++){
        D.clear();
        if (!dfs(i, dfs)){
            puts("No");
            return 0;
        }

        int64_t mi = 0, ma = 0;
        for (const auto &d: D){
            mi = min(mi, d.second);
            ma = max(ma, d.second);
        }
        if (ma - ma > int64_t(1e9)){
            puts("No");
            return 0;
        }
    }

    puts("Yes");
}


Measured memory_bytes: 24832
#include <iostream>

using namespace std;

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

int main()
{
    int x, y;
    cin >> x >> y;
    cout << (x+1)+(y+1)-gcd(x,y)-1 << endl;
}


Measured memory_bytes: 3108
using System;


class Class307
{
    static void Main()
    {
        const long mod = 1000000007;

        var nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int n = nk[0],k = nk[1];

        long[] D = new long[n + 2];
        long[] E = new long[n + 2];
        for (int i = 1; i <= n + 1; i++)
        {
            D[i] = D[i - 1] + (i - 1);
            E[i] = E[i - 1] + (n - i + 1);
        }
        long ans = 0;
        for (int i = k; i <= n; i++)
        {
            ans += E[i] - D[i] + 1;
            ans %= mod;
        }
        Console.WriteLine((ans + 1) % mod);
    }

}


Measured memory_bytes: 30656
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var a = ReadLine().Split().Select(int.Parse).ToList();
        var b = ReadLine().Split().Select(int.Parse).ToList();
        var c = b.Count(x => x < a[2]);
        var d = b.Count(x => x > a[2]);
        WriteLine(Min(c, d));
    }
}


Measured memory_bytes: 13268
from collections import defaultdict


n, k = map(int, input().split())
A = list(map(int, input().split()))
delta_count = defaultdict(int)
cumA = [0]
total = 0
for a in A:
    total += a
    total %= k
    cumA.append(total)

for i in range(1, min(n+1, k)):
    num = cumA[i]
    delta = (num - i) % k
    delta_count[delta] += 1

ans = delta_count[0]
left = 1
right = min(k-1, n)

while left <= n-1:
    popleft = (cumA[left] - left) % k
    delta_count[popleft] -= 1
    if right <= n-1:
        right += 1
        num = cumA[right]
        append = (num - right) % k
        delta_count[append] += 1

    desire = (cumA[left] - left) % k
    ans += delta_count[desire]
    left += 1

print(ans)

Measured memory_bytes: 46856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef tuple<int,int,int> T;
typedef vector<P> vp;
typedef vector<T> vt;

int main(void) {
  string s;
  cin >> s;
    if(s[1]=='B') {
      cout << "ARC" << endl;
    } else {
      cout << "ABC" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <algorithm>
#define ii pair<int, int>
#define iii pair<ii, int>
#define pq priority_queue

using namespace std;

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

    int n;
    cin >> n; //note: n always odd
    vector<int> dams(n);
    for (int i = 0; i < n; i++) {
        cin >> dams[i];
    }
    int last_sum = 0;
    //compute mt 1
    int sgn = 1;
    for (int i = 0; i < n; i++) {
        last_sum += dams[i] * sgn;
        sgn *= -1;
    }
    cout << last_sum << '\n';
    for (int i = 0; i < n - 1; i++) {
        cout << dams[i] * 2 - last_sum << '\n';
        last_sum = dams[i] * 2 - last_sum;
    }
}

Measured memory_bytes: 3728
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(long[]);
    auto A = ab[0];
    auto B = ab[1];
    if (B < A) swap(A, B);

    long s = 1, r = 1;
    long[] rest;
    void solve(long x) {
        if (A%x != 0) return;
        if (B%x != 0) return;
        if (gcd(x, s) != 1) return;
        ++r;
        s *= x;
        return;
    }
    for (long x = 2; x^^2 <= A; ++x) {
        solve(x);
        if (A%x == 0) rest ~= A/x;
    }
    reverse(rest);
    foreach (x; rest) solve(x);
    if (A != 1) solve(A);
    writeln(r);
}

Measured memory_bytes: 320
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long x;
    cin>>x;
    long long start = 100;
    int cnt = 0;
    while (start<x){
        start*=1.01;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3640
import collections

N,K = map(int, input().split())
A = list(map(int, input().split()))

c = collections.Counter(A)

cnt = 0
most_common = c.most_common()
if K < len(c.keys()):
    for i in range(1,abs(len(c.keys()) - K)+1):
            cnt += most_common[-i][1]
print(cnt)



Measured memory_bytes: 101576
S = str(input())
K = int(input())
i = 0
if S[0] == '1' and K == 1:
    print(1)
#     print('A')
elif list(map(int,list(S[:(K-1)]))).count(1) == K-1:
    print(S[K-1])
#     print('B')

elif len(S) == 1:
    print(S[0])
#     print('C')
elif S[0] != '1':
    print(S[0])
#     print('D')
else :
    while(1):
        if list(S[:(K-1)])[i] == '1':
            i = i + 1
        elif i > K:
            print(S[1])
#             print('E')
        else:
            print(list(S[:(K-1)])[i])
            break
    

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

int main() {
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		vector<int> s(n),g(n);
		vector<int> m(86400);
		for(int i=0; i<n; i++){
			string a,b;
			cin >> a >> b;
			s.at(i)=stoi(a.substr(0,2))*3600+stoi(a.substr(3,2))*60+stoi(a.substr(6,2));
			g.at(i)=stoi(b.substr(0,2))*3600+stoi(b.substr(3,2))*60+stoi(b.substr(6,2));
			m.at(s.at(i))++;
			m.at(g.at(i))--;
		}
		int ans{}, cnt{};
		for(int i=0; i<86400; i++){
			cnt += m.at(i);
			ans = max (ans, cnt);
		}
		cout << ans << endl;
	}
	
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  map<ll, int> cnt;
  for (int i = 0; i < N; i++) {
    ll A;
    cin >> A;
    ++cnt[A];
  }
  vector<ll> sides;
  for (auto ps: cnt) {
    for (int i = 0; i < ps.second / 2; i++) {
      sides.push_back(ps.first);
    }
  }
  sort(sides.begin(), sides.end());
  ll res = 0;
  for (int i = 1; i < sides.size(); i++) {
    res = max(res, sides[i] * sides[i-1]);
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
#define LL long long
#define INF 0x3f3f3f3f

const int MAXN = 1e5 + 5;
const LL MOD = 1e9 + 7;

int a[MAXN];

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    sort(a, a+n);
    LL h = 0, l = 0;
    for(int i = n-1; i > 0; i--)
    {
        if(a[i] == a[i-1])
        {
            if(h == 0)
                h = a[i];
            else
            {
                l = a[i];
                break;
            }
            i--;
        }
    }
    cout << h * l << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int k,a,b	;
	cin >> k >> a >> b;
	rep(i,a,b+1){
		if(i % k==0){
			cout << "OK\n";
			return 0;
		}
	}
	cout << "NG\n";
}


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

int main ()
{
	vector<int> num(32);
  	num = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int K;
  	cin >> K;
  	cout << num.at(K-1) << endl;
}


Measured memory_bytes: 256