akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<string, int>;
template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
    for(const auto& itr : v){
        os << itr << (itr != v.back() ? " " : "");
    }
  return os;
}

// ------------------------

void solve() {
    int N;
    cin >> N;
    map<string, int> mp, mp_ans;
    rep(i, N){
        string s; cin >> s;
        ++mp[s];
    }
    // prioriy que
    auto greater = [](const P& x, const P& y){
        return x.second < y.second;
    };
    priority_queue< P, vector<P>, decltype(greater) > que(greater);
    for (auto m : mp){
        que.push(m);
    }

    int max_count = que.top().second;

    while (!que.empty()) {
        if(max_count == que.top().second){
            ++mp_ans[que.top().first];
            que.pop();
        }else
        {
            break;
        }
    }

    for(auto m : mp_ans){
        cout << m.first << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 39788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    
    if (b >= c) {
        ans = b + c;
    }
    else {
        ans += 2 * b;
        c -= b;
        
        if (a > c) {
            ans += c;
        }
        else {
            ans += min(a + 1, c);
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(){
  long long n, a, b;
  cin >> n;
  long long v[100001], w[100001];
  pair<long long, long long> max_a, sec_max_a, max_b, sec_max_b;
  max_a.second = 0;
  sec_max_a.second = 0;
  max_b.second = 0;
  sec_max_b.second = 0;
  for (int i = 0; i < 100001; i++){
    v[i] = 0;
    w[i] = 0;
  }
  for (int i = 0; i < n / 2; i++){
    cin >> a >> b;
    v[a] += 1;
    w[b] += 1;
    if (v[a] > max_a.second){
      if (a != max_a.first){
        sec_max_a = max_a;
        max_a.first = a;}
      max_a.second = v[a];}
    else if (v[a] > sec_max_a.second){
      sec_max_a.first = a;
      sec_max_a.second = v[a];}
    if (w[b] > max_b.second){
      if (b != max_b.first){
        sec_max_b = max_b;
        max_b.first = b;}
      max_b.second = w[b];}
    else if (w[b] > sec_max_b.second){
      sec_max_b.first = b;
      sec_max_b.second = w[b];}
  }
  if (max_a.first != max_b.first)
    cout << (n - max_a.second - max_b.second) << endl;
  else
    cout << (n - max(max_a.second + sec_max_b.second, sec_max_a.second + max_b.second)) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
string s;
set<string> st;
void solve(){
	cout << st.size() << endl;
	return;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i,1,n){
		cin >> s;
		st.insert(s);
	}
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  string a = "hi";

  rep(i, 6) {
    if (s == a) {
      cout << "Yes" << endl;
      return 0;
    }

    a += "hi";
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())
x = input()
split_x = x.split()
int_split_x = [int(i) for i in split_x]
result = 0

for i in range(0, len(int_split_x)):
    if abs(K - int_split_x[i]) > abs(0 - int_split_x[i]):
        result += (abs(0 - int_split_x[i]))*2
    else:
        result += (abs(K - int_split_x[i]))*2

print(result)


Measured memory_bytes: 3064
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b) = sc.nextLine.split(" ").map(_.toInt)
    print((a to b).map(_.toString).count(number => number(0) == number(4) & number(1) == number(3)))
  }

}


Measured memory_bytes: 42116
import numpy as np
n = int(input())
A = np.array([list(map(int,input().split())) for _ in range(n)])
s = np.argsort(A[:,1])
A = A[s]
aa = 0
ans = 'Yes'
for a,b in A:
    aa += a
    if aa > b:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 64932
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c,i;
    scanf("%d",&n);
    if(n==2)
    {
        printf("%d",n);
        return 0;
    }
    while(1)
    {
        for(i=2; i<n; i++)
        {
            c=0;
            if(n%i==0)
            {
                c=1;
                break;

            }
        }
        if(c==0)
        {
            printf("%d",n);
            break;
        }
        n++;
    }
}

Measured memory_bytes: 256
// A - Can't Wait for Holiday
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string s; cin>>s;
	vector<string> W{"SUN","MON","TUE","WED","THU","FRI","SAT"};
	rp(i,0,W.size()) if(s==W[i]) cout<< 7-i <<endl;
}

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

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

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 1_000_000_007;

fn solve() {
    let N = read!(usize);
    let mut C = read![usize; N];

    for i in 0..N {
        C[i] -= 1;
    }
    let M = C.iter().cloned().max().unwrap();

    let mut last = vec![N; M + 1];
    let mut next = vec![N; N + 1];
    let mut i = 0;
    while i < N {
        while i + 1 < N && C[i] == C[i + 1] {
            i += 1;
        }

        next[last[C[i]]] = i;
        last[C[i]] = i;
        i += 1
    }
    debug!(next);

    // dp[r]: 0..r の塗り方が決まって、r.. に操作が及んでないときの場合の数

    let mut dp = vec![P; N + 1];
    dp[N] = 1;

    let mut i = N - 1;
    loop {
        dp[i] = dp[i + 1];

        if next[i] != N {
            dp[i] += dp[next[i]];
            dp[i] %= P;
        }

        if i == 0 {
            break;
        }
        i -= 1;
    }
    debug!(dp);

    println!("{}", dp[0]);
}

fn main() {
    solve();
}


Measured memory_bytes: 12540
// ARC060-C
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int NN = 111, WW = 11111;
int N, W;
int w[111], v[111];
int dp[NN][NN*WW];

int rec(int idx, int wSum) {
   if (idx == N) {
      return 0;
   }
   if (dp[idx][wSum] != -1) {
      return dp[idx][wSum];
   }
   if (wSum + w[idx] > W) {
      return rec(idx + 1, wSum);
   } else {
      int in = rec(idx + 1, wSum + w[idx]) + v[idx];
      int noIn = rec(idx + 1, wSum);
      return dp[idx][wSum] = max(in, noIn);
   }
}

int main() {
   rep (i, NN) {
      rep (j, WW) {
         dp[i][j] = -1;
      }
   }
   cin >> N >> W;
   rep (i, N) {
      cin >> v[i] >> w[i];
   }

   cout << rec(0, 0) << endl;

   return 0;
}


Measured memory_bytes: 8404
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n)	for(int i=0;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;
int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a < b); 
} 

void solve()
{
	int n;
	cin>>n;
	vi v(n);
	int count2[200000];
	ll sum=0;
	fr(i,n){cin>>v[i];sum=sum+v[i];count2[v[i]]++;}
	int q;
	cin>>q;

	int x,y;
	// int count1=0;
	// sort(all(v));
	fr(i,q)
	{
		cin>>x>>y;
		// count1=count(all(v),x)
		// count2[x]=0
		// count1=0;
		// auto it= find(all(v),x);
		// while(it!=v.end()&&*it==x)
		// {
		// 	*it=y;
		// 	it++;
		// 	count1++;
		// }
		sum = sum-(x-y)*count2[x];
		count2[y]=count2[y]+count2[x];
		count2[x]=0;
		cout<<sum<<endl;
		// sort(all(v));
	}


}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;
	
}



Measured memory_bytes: 4020
N = int(input())

# 10*10の二次元配列を初期化する
d = [10*[0] for _ in range(10)]
#print(d)

# 1~nまでの数字に対して調べる
for i in range(1, N+1):
    # 数字を文字に変換
    s = str(i)
    # 先頭から末尾に0があったら次へ
    if s[0]=="0" or s[-1]=="0":continue
    # 先頭の数字と末尾の数字の出現回数を1増やす
    d[int(s[0])][int(s[-1])]+=1

ans =0
for i in range(10):
    for j in range(10):
        # 入れ替えた数字の出現回数を掛け合わせると答えになる
        ans += d[i][j]*d[j][i]

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		String S = keyboard.next();
		String ans = "ABC";
		if(S.equals("ABC")){
			ans = "ARC";
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}


Measured memory_bytes: 35540
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int x = 2019;
    int L, R; cin >> L >> R;

    int res = x + 10;
    rep(i, L, min(L + 2 * x, R + 1)){
        rep(j, i + 1, min(L + 2 * x, R + 1)){
            chmin(res, i % x * (j % x) % x);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
	nes;
	ll n;
	cin>>n;
	vector<ll>v(n);
	for(int i=0;i<n;++i) cin>>v[i];
	//sort(v.begin(),v.end());
	ll p=0;
	for(int i=1;i<n;++i){
		if(v[i-1]<=v[i]) continue;
		else{
			p+=(v[i-1]-v[i]);
			v[i]=v[i-1];
		}
	}
	cout<<p;
	return 0;
}

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

using namespace std;

int n[1600]={};
char c[1600][150] = {};



int main(){
    int s = 0;
    while(1){
        scanf("%d",&n[s]);
        if(n[s] == 0) break;
        for(int i=0;i<n[s];i++) cin >> c[s][i] ;
        s++;
    }
    int times = s;
    int alpha[26]={};
    
    for(int i=0;i<times;i++){
        int first = 0,second = 0;
        int first_alpha = 0;
        for(int j=0;j<26;j++) alpha[j] = 0;
        for(int j=0;j<n[i];j++){
            int al = c[i][j] - 'A';
            alpha[al]++;
            if(alpha[al] > first) {
                first = alpha[al];
                first_alpha = 'A' + al;
            }
            else{
                if(alpha[al] > second){
                    second = alpha[al];
                }
            }
           if(first - second > n[i] - (j+1) ){
                printf("%c %d\n",first_alpha,j+1);
                break;
            }else if(first == second && j == n[i]-1){
                cout << "TIE" << endl;
            }
        }
    }
}


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

using namespace std;


int main()
{
    string S,T;

    cin >> S >> T;

    //cout << S.size() << endl;
    T.erase(T.size()-1,1);

    if(S == T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    


    return 0;
    

}

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

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

    ll A, B, K;
    cin >> A >> B >> K;
    if(A >= K){
        A -= K;
    }else{
        K -= A;
        A = 0;
        B -= K;
        if(B < 0){
            B = 0;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    char b;
    cin>>b;
    if(b=='A'){
        cout<<'T'<<endl;
    }else if(b=='T'){
        cout<<'A'<<endl;
    }else if(b=='C'){
        cout<<'G'<<endl;
    }else{
        cout<<'C'<<endl;
    }
}


Measured memory_bytes: 256
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverse(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

struct query {
	int t;
	int f = 0;
	string c = "";
};

itn main() {
	ios::sync_with_stdio(false);

	string s;
	int n;

	cin >> s >> n;

	vector<query> q(n);

	REP(i, n) {
		cin >> q[i].t;
		if (q[i].t == 2) {
			cin >> q[i].f >> q[i].c;
		}
	}

	bool turn = false;
	string res = s;

	REP(i, n) {
		if (q[i].t == 1) {
			turn = !turn;
		}
		else {
			if (q[i].f == 1) {
				if (turn) {
					res += q[i].c;
				}
				else {
					res.insert(0, q[i].c);
				}
			}
			else {
				if (turn) {
					res.insert(0, q[i].c);
				}
				else {
					res += q[i].c;
				}
			}
		}
	}

	if (turn) {
		REVERSE(res);
	}

	cout << res;

	return 0;
}


Measured memory_bytes: 15116
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	if (k == 0) {
		cout << n * n << endl;
		return 0;
	}
	for (ll i = k + 1;i <= n;i++) {
		ans += (i - k)*(n / i);
		ans += max((ll)0,(n%i) - (k - 1));
	
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#A
A=[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]
K=int(input())
print(A[K-1])

#C
if False:
    A,B,C=map(int,input().split())
    if 4*A*B<(C-A-B)**2:
        if C-A-B>=0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

#D


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, K;
    cin >> N >> K;
    int cnt = 1;
    while ((N /= K) > 0) cnt++;
    cout << cnt << endl;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
  ll n,a,b=0;
  cin >> n;
  for(int i = sqrt(n)/1;i > 0;i--) {
    if(n%i==0){
      a = n/i;
      b = i;
      break;
    }
  }
  if(a==0) {
    cout << n-1 << endl;
  }else{
    cout << a+b-2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
d, g = map(int, input().split())
g=g//100
pc=[[0,0]]
ans=sys.maxsize
for i in range(d):
  pc.append(list(map(int,input().split())))

for i in range(2**d):
  temp=0
  cnt=0
  for j in range(1,d+1):
    p=pc[j][0]
    c=pc[j][1]//100
    if (i>>(j-1)) & 1:
      temp+=(p*j+c)
      cnt+=p
  if temp >= g:
    ans=min(ans,cnt)
  else:
    for j in range(d,0,-1):
      p=pc[j][0]
      if (not ((i>>(j-1)) & 1)):
        if temp + j*p >= g:
          h=(((g-temp)//j)+1)
          if (g-temp)%j == 0:
            h-=1
          cnt+=h
          ans=min(ans,cnt)
        break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
void solve()
{
	ll h, w;
	cin >> h >> w;
	ll ans = 0;

	if (h == 1 or w == 1)
	{
		ans = 1;
		cout << ans << endl;
		return;
	}
	if (w % 2 == 0)
	{
		ans = h * (w / 2);
	}
	else
	{
		if (h % 2 == 0)
		{
			ans = h * w / 2;
		}
		else
		{
			ans = (ll)(w / 2 + 1) * (h / 2 + 1) + (w / 2) * (h / 2);
		}
	}
	
	
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  vector<int> wa(n);
  vector<int> ac(n);
  int tot = 0;
  int penalties = 0;
  for (int i = 0; i < m; i++) {
    int p; string s; cin >> p >> s; p -= 1;
    if (s == "AC") {
      if (!ac[p]) {
        tot += 1;
        penalties += wa[p];
        ac[p] = 1;
      }
    } else {
      wa[p]++;
    }
  }

  cout << tot << " " << penalties << '\n';
  return 0;

}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

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

int main() {
    int K; 
    cin>>K;
    int sum = 0;
    REP(i, 1, K+1){
        REP(j, 1, K+1){
            REP(k, 1, K+1){
                int temp = gcd(i, j);
                sum += gcd(temp, k);                 
            }
        }
    }
    cout << sum << endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
 
int main()
{
	int h, w ;
	cin >> h >> w ;
	vector<string> a(h);
	rep(i, h)cin>>a[i];

	map<int,bool> gyou;
	map<int,bool> retu;

	rep(i,h){
		bool check = true;
		rep(j,w){
			if(a[i][j] == '#') check = false;
		}
		if(check){
			gyou[i] = true;
		}
	}
	rep(j,w){
		bool check = true;
		rep(i,h){
			if(a[i][j] == '#') check = false;
		}
		if(check){
			retu[j] = true;
		}
	}

	rep(i,h){
		int count = 0;
		rep(j,w){
			if(gyou[i] || retu[j])continue;
			cout << a[i][j];
			count++;
		}
		if(count != 0){
			cout << endl;
		}
	}
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 2000000
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int fac[MAXN+5], e[MAXN+5]; int X1, Y1, X2, Y2, X3, Y3, X4, Y4, X5, Y5, X6, Y6, MX, ans;
inline int fastpow(int s, int n){int a = 1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
#define C(n,k) (n<0||k<0||n<k ? 0ll : (!k||n==k ? 1ll : 1ll*fac[n]*e[k]%MOD*e[n-k]%MOD))
#define f(sx,sy,tx,ty) C(abs((sx)-(tx))+abs((sy)-(ty)),abs((sy)-(ty)))
inline int F(int sx, int sy, int tx1, int ty1, int tx2, int ty2, bool dir)
{
	return (dir ? 0ll+f(sx,sy,tx1,ty1)+f(sx,sy,tx2+1,ty2+1)+MOD-f(sx,sy,tx1,ty2+1)+MOD-f(sx,sy,tx2+1,ty1)
				: 0ll+f(sx,sy,tx2,ty2)+f(sx,sy,tx1-1,ty1-1)+MOD-f(sx,sy,tx2,ty1-1)+MOD-f(sx,sy,tx1-1,ty2)) % MOD;
}
int main()
{
	X1 = read(), X2 = read(), X3 = read(), X4 = read(), X5 = read(), X6 = read(), Y1 = read(), Y2 = read(), Y3 = read(), Y4 = read(), Y5 = read(), Y6 = read(), MX = max(Y6-Y1,X6-X1)<<1;
	fac[0] = 1; for(rint i = 1; i <= MX; fac[i] = 1ll*fac[i-1]*i%MOD, i++); e[MX] = fastpow(fac[MX],MOD-2); for(rint i = MX; i; e[i-1] = 1ll*e[i]*i%MOD, i--);
	for(rint x = X3, y = Y4; x <= X4; ans += 	1ll*F(x,y,X1,Y1,X2,Y2,0)*F(x,y+1,X5,Y5,X6,Y6,1)%MOD*(x+y  )%MOD, ans<MOD?:ans-=MOD, x++);
	for(rint x = X3, y = Y3; x <= X4; ans +=MOD-1ll*F(x,y-1,X1,Y1,X2,Y2,0)*F(x,y,X5,Y5,X6,Y6,1)%MOD*(x+y-1)%MOD, ans<MOD?:ans-=MOD, x++);
	for(rint x = X4, y = Y3; y <= Y4; ans += 	1ll*F(x,y,X1,Y1,X2,Y2,0)*F(x+1,y,X5,Y5,X6,Y6,1)%MOD*(x+y  )%MOD, ans<MOD?:ans-=MOD, y++);
	for(rint x = X3, y = Y3; y <= Y4; ans +=MOD-1ll*F(x-1,y,X1,Y1,X2,Y2,0)*F(x,y,X5,Y5,X6,Y6,1)%MOD*(x+y-1)%MOD, ans<MOD?:ans-=MOD, y++); printf("%d\n",ans); return 0;
}

Measured memory_bytes: 15872
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskAtcoder158A {
        public void solve(int testNumber, FastReader in, PrintWriter out) {

            char[] a = in.nextLine().toCharArray();
            int x = 0, y = 0;
            for (char t : a
            ) {
                if (t == 'A')
                    x++;
                else y++;

            }
            if (x != 0 && y != 0)
                out.println("Yes");
            else
                out.println("No");

        }

    }

    static class FastReader {
        BufferedReader br;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



Measured memory_bytes: 22356
MOD=10**9+7
x , y = map(int, input().split())
a=(2*x-y)//3
b=(2*y-x)//3
if 2*a+b!=x:
    print(0)
    exit()

factorial = [1]
inverse = [1]

n=a+b
r=a

for i in range(1, n+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))

def combi(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD

ans = combi(n,r)
print(ans)


Measured memory_bytes: 115180
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		int n = s.size();
		unordered_map<int,int> dp;
		dp[0] = 0;
		using bs = bitset<26>;
		bs tmp = 0;
		int ans;
		REP(i,n){
			int c = s[i]-'a';
			tmp[c] = !tmp[c];
			int mi = INF;
			REP(j,26){
				auto t = tmp;
				t[j] = !t[j];
				auto ite = dp.find(t.to_ulong());
				if(ite != dp.end()) {
					chmin(mi, ite->S+1);
				}
			}
			{
				auto ite = dp.find(tmp.to_ulong());
				if(dp.find(tmp.to_ulong()) != dp.end()){
					chmin(mi,ite->S+1);
				}
			}
			ans = mi;

			{
				auto ite = dp.find(tmp.to_ulong());
				if(ite == dp.end()) {
					dp[tmp.to_ulong()] = INF;
				}
			}
			chmin(dp[tmp.to_ulong()], mi);
		}
		cout << ans << endl;
	}
	return 0;
}


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

int N, K;
vector<int> S;
vector<int> csum;

int count(int l, int r, int state){
    int a = 1;
    if(S[l] == 1) a = 0;
    return csum[r] - csum[l] + a;
/*
    int sum = csum[r] - csum[l];
    int len = r - l;
    if(state == 0){
        return len - sum;
    }else{
        return sum;
    }
    */
}

int solve(int state){
    int res = 0;
    int r = 0;
    for(int l = 0; l < N; l++){
        while(r < N && count(l, r, state == 0 ? 1 : 0) <= K){
            r++;
        }
        res = max(res, r-l);
        // cout << l << " " << r << " " << r-l << endl;
        if(r == l){
            r++;
        }else{

        }
    }
    return res;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> K;
    S.reserve(N);
    csum = vector<int>(N, 0);
    {
        string _S;
        cin >> _S;
        for(const auto& s: _S) S.push_back(s - '0'); 
    }

    csum[0] = (S[0] == 0) ? 1 : 0;
    for(int i = 1; i < N; i++){
        if(S[i-1] == 1 && S[i] == 0){
            csum[i] = csum[i-1] + 1;
        }else{
            csum[i] = csum[i-1];
        }
    }
    // for(const auto& c: csum) cout << c << " "; cout << endl;

    cout << solve(1) << endl;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int s=0,t=0,x;
	for(int i=0;i<8;i++){
		cin >> x;
		if(i<4){
			s += x;
		}else{
			t += x;
		}
	}
	cout << max(s,t) << endl;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

long long int to_int(string S){
    int n = S.size();
    long long int ans = 0;
    vector<int> B(n);
    for(int i =0;i < n;i++){
      bool frag = 1;
        for(int j = 0;j < 10;j++){
            char a = '0' + j;
            if(S[i] == a){
                B[i] = j;
                frag = 0;
                break;
            }
        }
        if(frag) return -1;
    }
    for(int i = 0;i < n;i++){
        ans += B[i]*pow(10,(n-i-1));
    }
    return ans;
}

bool Primefactor(ll n){
  ll a = n;
  for(ll i = 2;i * i <= n;i++){
    if(n % i == 0){
      return false;
    }
  }
  return true;
}

int CA[12]{31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  ll N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int r = -1,s = -1,p = -1;
  ll rc=0,sc=0,pc=0;
  vector<vector<bool>> cnt(100010,vector<bool>(3,0));
  int i = 0;
  for(int i = 0;i < N;i++){
    if(T[i] == 'r' && !cnt[i][0]){
      int c = 1;
      int j = K;
      while(j + i < N){
        if(T[j+i] == 'r'){
          c++;
          cnt[i+j][0] = 1;
          j += K;
          
        }else{
          break;
        }
      }
      rc += c / 2;
    }
  }
  i = 0;
  for(int i = 0;i < N;i++){
    if(T[i] == 's' && !cnt[i][1]){
      int c = 1;
      int j = K;
      while(j + i < N){
        if(T[j+i] == 's'){
          c++;
          cnt[i+j][1] = 1;
          j += K;
          
        }else{
          break;
        }
      }
      sc += c / 2;
    }
  }
  i = 0;
  for(int i = 0;i < N;i++){
    if(T[i] == 'p' && !cnt[i][2]){
      int c = 1;
      int j = K;
      while(j + i < N){
        if(T[j+i] == 'p'){
          c++;
          cnt[i+j][2] = 1;
          j += K;
          
        }else{
          break;
        }
      }
      pc += c / 2;
    }
  }
  ll ans = 0;
  //cout << rc << ' ' << sc << ' ' << pc << endl;
  ans += (count(T.begin(),T.end(),'r') - rc) * P;
  ans += (count(T.begin(),T.end(),'s') - sc) * R;
  ans += (count(T.begin(),T.end(),'p') - pc) * S;
  cout << ans << endl;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int k,s;
  cin >> k>>s;
  int ans = 0;
  rep(x,k+1) rep(y,k+1) if(0<=s-x-y && s-x-y<=k) ans++;
  cout<<ans<<endl;
}



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

using namespace std;

int main()
{
    string A, B;
    cin >> A >> B;

    if (A == B)
    {
        cout << "EQUAL";
    }

    if (A.length() > B.length())
    {
        cout << "GREATER";
    }

    if (A.length() == B.length() && int(A[0]) > int(B[0]))
    {
        cout << "GREATER";
    }

    if (A.length() < B.length())
    {
        cout << "LESS";
    }

    if (A.length() == B.length() && int(A[0]) < int(B[0]))
    {
        cout << "LESS";
    }
}

Measured memory_bytes: 256
object Main extends App {
  val S = io.StdIn.readLine
  val T = io.StdIn.readLine

  val out = if ((0 until S.size).filter(j => T(0) == S(j)).exists(i => (S.drop(i) ++ S.take(i)).mkString == T)) "Yes" else "No"

  println(out)
}


Measured memory_bytes: 27292
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




string str;

int main() {
	while (cin >> str) {
        long long num;
        istringstream sin(str);
        sin >> num;
        int di = 0;
        for (int i = 0; i < str.size(); ++i) {
            di += (int)(str[i] - '0');
        }
        if (num % di == 0) puts("Yes");
        else puts("No");
	}
}



















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

int main() {
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(n + 1, vector<ll>(2501)));
	dp[0][0][0] = 1;
	rep(i, n){
		rep(j, n + 1){
			rep(k, 2501){
				if(k < x[i] || j < 1) dp[i + 1][j][k] = dp[i][j][k];
				else dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - x[i]];
			}
		}
	}
	ll out = 0;
	for(int i = 1; i <= n; i++) out += dp[n][i][a * i];
	cout << out << endl;
}


Measured memory_bytes: 55240
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


K = int(input())

G = [[0] * (K + 1) for _ in range(K + 1)]

for a in range(1, K + 1):
    for b in range(1, K + 1):
        G[a][b] = gcd(a, b)

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            if G[a][b] == 1:
                ans += 1
                continue
            ans += gcd(G[a][b], c)
print(ans)


Measured memory_bytes: 72072
/****************##################################*************************************************
*                #   Editor : Jewel Mahmud        #                                  *
*                #   CSE 13th, MBSTU              #                                  *
*                #   Date : 20-Jun-19             #                                  *
*****************##################################************************************************/

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define S string
#define D double


int main()
{
    LL n;
    while(cin>>n)
    {
        LL arr1[n+1],arr2[n+1];
        for(LL i=0; i<n; i++)
        {
            cin>>arr1[i];
        }

        for(LL i=0; i<n; i++)
        {
            arr2[i]=arr1[i];
        }

        sort(arr2,arr2+n);

        LL m=arr2[n-1];
        LL s=arr2[n-2];
        for(LL i=0; i<n; i++)
        {
            if(arr1[i]==m)
                cout<<s<<endl;
            else
                cout<<m<<endl;
        }
    }
     return 0;
}



Measured memory_bytes: 4736
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-6;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

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

int n;
string s;
main() {
    file("walk");
    ios;
    cin>>n>>s;
    if (n>=3200) cout<<s;
    else cout<<"red";
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll a=in(),b=in(),c=in(),d=in(),e=in();
    cout<<max(c*60+d-(a*60+b)-e,0ll)<<endl;
}

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/








ll a[N],v[N];
int main()
{
    ll n,q,k,i,j,l;
    cin>>n>>k>>q;
    for(i=1;i<=q;i++)
    {
        cin>>a[i];
        v[a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        j=k-(q-v[i]);
        if(j>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
	return 0;
}
































Measured memory_bytes: 2176
{-# LANGUAGE TupleSections #-}
import Control.Monad
import Data.List
import qualified Data.IntMap as MP
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

includingBoxes h w [a, b] = [w * x + y |
  x <- [a -2, a - 1, a], x >= 0, x <= h - 3,
  y <- [b -2, b - 1, b], y >= 0, y <= w - 3]

frequency :: [Int] -> [(Int, Int)]
frequency = MP.toList . MP.fromListWith (+) . map (, 1)

solve h w ls = find <$> [0..9]
    where boxes    = ls >>= includingBoxes h w
          boxFreqs = frequency boxes
          freqs    = frequency . filter (<= 9) . map snd $ boxFreqs
          zeros    = (h - 2) * (w - 2) - length boxFreqs
          find v   = MP.findWithDefault 0 v $ MP.fromList $ (0, zeros):freqs

main = do
    [h, w, n] <- map read . words <$> getLine
    ls        <- replicateM n $ map pred <$> readInts
    mapM print $ solve h w ls


Measured memory_bytes: 212348
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created on 2017/10/25 7:07.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < N; i++) {
                int A = sc.nextInt();
                if (set.contains(A)) {
                    set.remove(A);
                } else {
                    set.add(A);
                }
            }
            System.out.println(set.size());
        }
    }
}

Measured memory_bytes: 60924
import sys

m = [list(map(int, input().split())) for _ in range(3)]

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')


Measured memory_bytes: 3064