akhauriyash/Code-Regression huggingface dataset:
pap = [[0 for x in range(10)] for y in range(10)]
ink = [ [],
        [[-1,0],[0,-1],[0,0],[0,1],[1,0]],
        [[-1,-1],[-1,0],[-1,1],[0,-1],[0,0],[0,1],[1,-1],[1,0],[1,1]],
        [[-2,0],[-1,-1],[-1,0],[-1,1],[0,-2],[0,-1],[0,0],[0,1],[0,2],[1,-1],[1,0],[1,1],[2,0]] ]

def brot(x,y,s):
    global pap
    for i in ink[s]:
        px = x + i[0]    
        py = y + i[1]
        if px in range(0,10) and py in range(0,10):
            pap[py][px] += 1

def ans():
    bmax = max(pap[y][x] for y in range(10) for x in range(10))
    wcount = sum(pap[y][x] == 0 for y in range(10) for x in range(10))
    return(wcount,bmax)

if __name__ == "__main__":
    while True:
        try:
            x,y,s = list(map(int, input().split(',')))
            brot(x,y,s)
        except EOFError:
            break

    print("%d\n%d" % ans())

Measured memory_bytes: 7764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
int n;
cin >>n;
cout << 800*n-n/15*200 << endl;


  
 
//////////////////////////////////////////////////////
return 0;}

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

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

    string s;
    cin >> s;
    int year = 0;
    rep(i, 4) year += (s.substr(0, 4)[i] - '0') * 1000 / pow(10,i);
    int month = 0;
    month = (s.substr(5, 2)[0] - '0') * 10 + s.substr(5, 2)[1] - '0';

    if(year > 2019 || (year == 2019 && month <= 4)) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=3e3+9;
int n,k;
int a[sz];
ll dp[sz][sz][2][2];
ll m=998244353;
ll add(ll a,ll b){return (a%m+b%m)%m;}
ll mul(ll a,ll b){return (a%m*b%m)%m;}

ll solve(int idx,int rem,int st,int en){
	ll &ret=dp[idx][rem][st][en];
	if(~ret) return ret;
	if(st&&en){
		return !rem;
	}
	if(!idx) return 0;
	ret=solve(idx-1,rem,st,en);
	if(!en){
		ret=add(ret,solve(idx-1,rem,st,1));
		if(a[idx]<=rem){
			ret=add(ret,solve(idx-1,rem-a[idx],st,1));
			ret=add(ret,solve(idx-1,rem-a[idx],1,1));
		}
	}else{
		ret=add(ret,solve(idx-1,rem,1,1));
		if(a[idx]<=rem){
			ret=add(ret,solve(idx-1,rem-a[idx],st,en));
			ret=add(ret,solve(idx-1,rem-a[idx],1,en));
		}
	}
	return ret;
}


int main(){
	cin>>n>>k;
	for(int i=1; i <=n; ++i){
		cin>>a[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(n,k,0,0);
    return 0;
}

Measured memory_bytes: 283520
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

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

	ll t = 1;
	// cin>>t;

	while(t--){
		ll n,m,k;
		cin>>n>>m>>k;

		vector<ll> a(n),b(m);
		ll left = k;
		for(ll i=0;i<n;++i) cin>>a[i];
		for(ll i=0;i<m;++i) {cin>>b[i]; if(i!=0) {b[i] += b[i-1];}}

		ll i = 0;
		for(;i<n;++i){
			if(left >= a[i]) {left -= a[i];}
			else break;
		}
		--i;

		ll ans = i+1;
		while(1){
			ll x = upper_bound(b.begin(),b.end(),left) - b.begin();
			ans = max(ans , i+1 + x );
			if(i >=0 ){
				left += a[i];
				--i;
			}

			if(i == -1){
				x = upper_bound(b.begin(),b.end(),left) - b.begin();
				ans = max( ans, i+1+x);
				break;
			}

		}

		cout<<ans<<"\n";
	}

	return 0;

}

Measured memory_bytes: 6368
n = int(input())
alst = list(map(int, input().split()))
alst.sort()
tmp = [0 for _ in range(10 ** 6 + 10)]
ans = 0
flg = True
if n == 1:
    print(1)
    exit()
if alst[0] == 1:
    if alst[1] == 1:
        print(0)
    else:
        print(1)
    exit()
for num in alst:
    if tmp[num] == 2:
        if flg:
            ans -= 1
            flg = False
        continue
    flg = True
    if tmp[num] == 1:
        continue
    ans += 1
    tmp[num] = 2
    xx = num * 2
    while xx < 10 **  6 + 1:
        tmp[xx] = 1
        xx += num
print(ans)

Measured memory_bytes: 32232
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	char s[n],c[n];
	for(int i=0 ;i<n;i++){
		cin>>s[i];
	}

	for(int i=0 ;i<n;i++){
		cin>>c[i];
	}
	for(int i=0 ;i<n;i++){
		cout<<s[i]<<c[i];
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,K;
main()
{
	cin>>N>>K;
	vector<int>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	while(K>0)
	{
		K--;
		vector<int>nA(N+1,0);
		for(int i=0;i<N;i++)
		{
			int L=i-A[i],R=i+A[i];
			if(L<0)L=0;
			if(R>=N)R=N-1;
			nA[L]++;
			nA[R+1]--;
		}
		for(int i=0;i<N;i++)nA[i+1]+=nA[i];
		nA.pop_back();
		if(A==nA)break;
		A=nA;
	}
	for(int i=0;i<N;i++)cout<<A[i]<<(i+1==N?"\n":" ");
}


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

int parse(const string& s, int i) {
  if (i < s.size() && s[i] == 'm') {
    i++;
    i = parse(s, i);
    if (s[i] != 'e') return i;
    i++;
    i = parse(s, i);
    if (s[i] != 'w') return i;
    i++;
  }
  return i;
}

int main() {
  string s;
  cin >> s;
  cout << (parse(s, 0) == s.size() ? "Cat" : "Rabbit") << endl;
  return 0;
}



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

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if (x >= r && y >= r && x + r <= w && y + r <= h) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

void max_self(ll &a, ll b){
    a = max(a,b);
}

int main(){
    ll n, W;
    while(cin>>n>>W){
        // Earlier:
        // for a particular weight w the maxiumum value that could be obtained 
        // Reformulate as:
        // for a particular value  v the minimum weight that has to be included (w inv prop val)
        // v = 0 to max_val(sum of vals)

        vector<ll> weight(n);
        vector<ll> value(n);
        for(int i=0; i<n; i++)
            cin>>weight[i]>>value[i];
        // vector<ll> dp(max value that could be obtained)
        ll val_sum = accumulate(all(value), 0);

        vector<ll> dp(val_sum+1, inf);
        dp[0] = 0;        

        for(int item=0; item<n; item++){
            
            for(int val_already = val_sum - value[item]; val_already>=0; val_already--){
                dp[val_already+value[item]] = min(dp[val_already+value[item]], dp[val_already] +  weight[item]);
            }
        }

        // find the max index(val) where weight W or less has been obtained
        int ans = 0;
        for(int i=0; i<=val_sum; i++){
            if(dp[i]<=W){
                ans = max(ans, i);
            }
        }

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


Measured memory_bytes: 1152
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scanf("%d", &x)

	for x < math.MaxInt32 {
		if isPrime(x) {
			fmt.Println(x)
			return
		}
		x++
	}
}

func isPrime(n int) bool {
	if n <= 1 {
		return false
	}

	if n == 2 {
		return true
	}

	if n%2 == 0 {
		return false
	}

	r := true
	for i := 3; i <= int(math.Floor(math.Sqrt(float64(n)))); i += 2 {
		if n%i == 0 {
			r = false
		}
	}
	return r
}


Measured memory_bytes: 512
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_sum = [0]
B_sum = [0]

A = A + [10 ** 10]
B = B + [10 ** 10]

for i in range(0,N):
    if A_sum[i] + A[i] > K:
        break
    A_sum.append(A_sum[i] + A[i])

for i in range(0,M):
    if B_sum[i] + B[i] > K:
        break
    B_sum.append(B_sum[i] + B[i])

ans = 0
BM = len(B_sum) - 1
for i in range(len(A_sum)):
    for j in range(BM, -1, -1):
        if A_sum[i] + B_sum[j] <= K:
            ans = max(ans, i + j)
            BM = j
            break

print(ans)

Measured memory_bytes: 40676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int a = in.nextInt();
		int b = in.nextInt();

		if ((a + b) % 3 == 0) {
			System.out.println("Possible");
		} else if (a % 3 == 0) {
			System.out.println("Possible");
		} else if (b % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}

	}
}

Measured memory_bytes: 21844
loop do
  n = gets.to_i
  break if n == 0
  s = 1
  (2..Math.sqrt(n)).each do |m|
    if n % m == 0
      s += m; s += n / m
      s -= m if m == n / m
    end
  end
  if n > s || n == 1 then puts "deficient number"
  elsif n < s then puts "abundant number"
  else puts "perfect number"
  end
end

Measured memory_bytes: 8636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int N, W;
int dp[10001];

int main(){
	rep(i, N)dp[i] = -1;
	dp[0] = 0;

	std::cin >> N >> W;
	rep(i, N){
		int v, w;
		std::cin >> v >> w;
		rrep(j, 10001){
			if (dp[j] != -1 && j + w < 10001)dp[j + w] = std::max(dp[j + w], dp[j] + v);
		}
	}
	std::cout << *std::max_element(dp, dp + W + 1) << std::endl;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

ll cnt(ll a){
  ll ret=0;
  while(a>0){
    ret++;
    a/=10;
  }
  return ret;
}

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    if(cnt(i)&1){ans++;}
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  int A[N][M];
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      cin >> A[i][j]; A[i][j]--;
    }
  }

  int ans = N, cnt = 0;
  vector <int> now(N);
  vector <bool> visited(M);
  while (cnt < M){
    vector < pair<int, int> > count(M);
    for (int i = 0; i < M; i++){
      count[i] = make_pair(0, i);
    }

    for (int i = 0; i < N; i++){
      int sport = A[i][now[i]];
      count[sport].first++;
    }
    sort(count.begin(), count.end(), greater<pair<int, int> >());
    
    ans = min(ans, count[0].first);
    visited[count[0].second] = true;

    for (int i = 0; i < N; i++){
      for (int j = now[i]; j < M; j++){
        int sport = A[i][j];
        if (visited[sport] == false){
          break;
        }else{
          now[i]++;
        }
      }
    }
    cnt++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string s;
long long ans=0,len;
int main()
{
	cin>>s;
	len=s.length();
	for(int i=1;i<len;i++)
	if(s[i]!=s[i-1])
	ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.eg", "r", stdin );

	const string code[] = { " ", "',.!?", "abcABC", "defDEF",
	"ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ" };

	string str = "";

	while (cin >> str ) {

		int len = str.length();
		str += '0';
		int number, times = 0;
		string res = "";

		for (int i = 0; i < len; ++i ) {
			number = str[i] - '0';
			if (str[i] == str[i+1] && str[i+1] != '0' ) {
				++times;
				continue;
			} // end if
			
			if (str[i] == '0' && str[i+1] != '0' ) {
				continue;
			} // end if
			
			res += code[number][times % code[number].length()];
			times = 0;
		} // end for
		if (str[len - 1] == '0'){
			res = res.substr (0, res.length() - 1);
		} // end if
		cout << res << endl;	
					
	} // end loop

	return 0;
}

Measured memory_bytes: 0
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = get!(i32, i32, i32);
    println!("{}", if a == b { c } else if a == c { b } else { a });
}

Measured memory_bytes: 2144
#include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

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

	int n; cin >> n;
	vi a(n);

	REP(i, n) {
		cin >> a[i];
	}

	bool flag = true;
	int ans = 0;
	for (int i = 0; flag; i++) {
		flag = false;
		
		for(int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				ans++;
				swap(a[j], a[j - 1]);
				flag = true;
			}
		}
	}

	REP(i, n - 1) cout << a[i] << " ";
	cout << a[n - 1] << "\n";
	cout << ans << "\n";
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            var max = line.Max();

            if (max < line.Sum() - max)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int x=sc.nextInt();
			int y= sc.nextInt();
			if(x==0&&y==0){
				break;
			}else{
				if(x>y){
					System.out.println(y+" "+x);
				}else{
					System.out.println(x+" "+y);
				}
			}
		}
	}
}

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

const int64_t INF = 1LL << 60;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<int64_t> S(A + 2, -INF), T(B + 2, -INF);
    for(int i = 0; i < A; ++i) cin >> S[i + 2];
    for(int i = 0; i < B; ++i) cin >> T[i + 2];
    S.push_back(INF);
    S.push_back(INF);
    T.push_back(INF);
    T.push_back(INF);
    while(Q--) {
        int64_t x; cin >> x;
        auto d = [&](int64_t p) -> int64_t { return abs(x - p); };
        auto sr = lower_bound(S.begin(), S.end(), x);
        auto sl = prev(sr);
        auto tr = lower_bound(T.begin(), T.end(), x);
        auto tl = prev(tr);
        int64_t ans = min(max(d(*sr), d(*tr)), max(d(*sl), d(*tl)));
        ans = min(ans, 2 * d(*sr) + d(*tl));
        ans = min(ans, d(*sr) + 2 * d(*tl));
        ans = min(ans, 2 * d(*tr) + d(*sl));
        ans = min(ans, d(*tr) + 2 * d(*sl));
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	ll ans = 0;
	ll i = n-1;
	while (i>=ans){
		ll j = 0; ll cnt = 0;
		while((i+j<=n-1)&&(cnt<i)){
			if (s.at(j)==s.at(j+i)){
				cnt++;
				ans=max(cnt,ans);
			}
			else{
				ans=max(cnt,ans);
				cnt = 0;
			}
			//cout << j << " " << i+j << " " << cnt << endl;
			j++;
		}
		i--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
using namespace std;
int main ()
{
	int n;
	scanf("%i",&n);
	string s[n+1];
	map<string,int>mapa;
	set<string>sett;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
		mapa[s[i]]++;
	}
	int maks=0;
	for(int i=1;i<=n;i++)
	{
		if(mapa[s[i]]>maks)	maks=mapa[s[i]];
	}

	for(int i=1;i<=n;i++)
	{
		if(mapa[s[i]]==maks)
		{
			sett.insert(s[i]);
		}
	}
	for(string i:sett)
	{
		cout<<i<<"\n";
	}
	return 0;
}


Measured memory_bytes: 36224
open System

let gcd a b c =
    let rec _gcd a b = if a % b = 0 then b else _gcd b (a % b)
    _gcd a b |> _gcd c

[<EntryPoint>]
let main argv =
    let K = Console.ReadLine() |> int
    let ans = seq {
        for a in 1 .. K do
            for b in 1 .. K do
                for c in 1 .. K -> gcd a b c
    }
    ans |> Seq.sum |> printfn "%d"
    0


Measured memory_bytes: 43084
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000

int main(){
  int *A,*B;
  int C[MAX+1];
  int n,i;

  scanf("%d",&n);
  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);

  for(i=0;i<=MAX;i++) C[i]=0;

  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=MAX;i++) C[i]=C[i]+C[i-1];

  for(i=1;i<=n;i++){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }

  for(i=1;i<=n;i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;

}

/*#include<stdio.h>
#include<stdlib.h>
#define MAX 10000
 
int main(){
  int *A,*B;
  int C[MAX+1];
  int n,i;
 
  scanf("%d",&n);
  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);
 
  for(i=0;i<=MAX;i++) C[i]=0;
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }
 
  for(i=1;i<=MAX;i++) C[i]=C[i]+C[i-1];
 
  for(i=1;i<=n;i++){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
 
  for(i=1;i<=n;i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
 
  return 0;
 
}*/



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

int main(){
	const int N_MAX = 100000;
	const int BigNumber = 1000000007;
	int RevFactrial[N_MAX], counter[N_MAX];
	int N,R;
	
	RevFactrial[N_MAX-1] = 1;
	for(int i=N_MAX-2; i>=0; i--){
		RevFactrial[i] =  ((long long) RevFactrial[i+1] * (N_MAX -i-1)) % BigNumber;
	}

	while(true){
		cin >> N;
		if(N==0) break;
		cin >> R;
	
		for(int n=0; n<N; n++) counter[n] = 0;
		
		for(int r=0; r<R; r++){
			int s, t;
			cin >> s >> t;
			int pc = counter[t-1];
			for(int i=t-2; i>s-2; i--){
				int c = counter[i];
				if(c > pc)	counter[i] = c-1;
				else		pc++;
			}
			swap(counter[s-1],pc);
			for(int i=s; i<t-1; i++){
				int c = counter[i];
				if(pc <= c) counter[i] =c+1;
				else		pc--;
			}
			counter[t-1] = pc;
		}
	
		long long  index = 0;
		for(int i=0; i<N-1; i++){
			index  +=  ((long long)counter[i]*RevFactrial[N_MAX-N+i])%BigNumber;
		}
		cout << index%BigNumber << endl;
	}	
	return 0;
}

Measured memory_bytes: 1936
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

ll LCM(ll x , ll y){
	return (x*y) / __gcd(x,y) ;
}

ll NumOfDiv(ll a , ll b , ll k){
	return b/k - a/k + (a%k == 0) ;
}
void start(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int res(int a , int b , int c){
	int x[3] = {a,b,c} ;
	sort(x,x+3);
	return x[1] ;
}

bool chekInt(double n){
    return int(n) == n ;
}

int main()
{
	start();
	int n , d; 
    cin >> n >> d ;
    cout << ((n%(d*2+1) == 0)? n/(d*2+1) : n/(d*2+1)+1) << endl;
	return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    E[x].push_back(y);
    E[y].push_back(x);
  }
  vector<vector<int>> c;
  vector<bool> used(N, false);
  for (int i = 0; i < N; i++){
    if (!used[i]){
      used[i] = true;
      vector<int> cost;
      cost.push_back(a[i]);
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        for (int w : E[v]){
          if (!used[w]){
            used[w] = true;
            cost.push_back(a[w]);
            Q.push(w);
          }
        }
      }
      sort(cost.begin(), cost.end());
      c.push_back(cost);
    }
  }
  int C = c.size();
  if (C == 1){
    cout << 0 << endl;
  } else {
    long long ans = 0;
    for (int i = 0; i < C; i++){
      ans += c[i][0];
    }
    vector<int> cost;
    for (int i = 0; i < C; i++){
      int cnt = c[i].size();
      for (int j = 1; j < cnt; j++){
        cost.push_back(c[i][j]);
      }
    }
    sort(cost.begin(), cost.end());
    if ((int) cost.size() < C - 2){
      cout << "Impossible" << endl;
    } else {
      for (int i = 0; i < C - 2; i++){
        ans += cost[i];
      }
      cout << ans << endl;
    }
  }
}

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

using namespace std;

using ll = unsigned long long;

// 累積和　1-indexed
template <typename T> class CumulativeSum {
  std::vector<T> _sums;

public:
  CumulativeSum(const vector<T> &v) : _sums(v) {
    _sums.insert(_sums.begin(), 0);
    for (int i = 1; i < (int)_sums.size(); ++i) {
      _sums[i] += _sums[i - 1];
    }
  }

  // sum of [1, index]
  T sum(int index) { return _sums[index]; }

  // sum of [left, right]
  T sum(int left, int right) { return sum(right) - sum(left - 1); }
};

int main() {
  int N;
  ll X;
  cin >> N >> X;
  vector<ll> x(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  CumulativeSum<ll> sums(x);
  ll ans = 1e18;
  for (int i = 1; i <= N; ++i) {
    ll ret = (N + i) * X + 2 * sums.sum(N - i + 1, N);
    auto n = N;
    for (int p = 3;; p += 2) {
      ret += p * sums.sum(max(1, n - i + 1), n);
      n -= i;
      if (n < 1)
        break;
    }
    ans = min(ans, ret);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6400
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String str  = sc.nextLine();
        String[] astr = str.split(""); //状況に合わせて
        sc.close();

        //Arrays.sort(astr);
        int ans = 1;
        String flag = astr[0];
        for(int i=1;i<astr.length;i++){
            if(!flag.equals(astr[i])){
                ans+=1;
                flag = astr[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 34108
#include<stdio.h>

int main()
{
	long long n, m,a;
	long long d=0;
	scanf("%lld",&n);
	scanf("%lld", &m);
	for (long long i = 0; i < n; i++) {
		scanf("%lld", &a);
		if (m / 2 < a) {
			d += 2 * (m - a);
		}
		else {
			d += 2 * a;
		}
	}
	printf("%lld", d);
    return 0;
}

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

int main(){
    ll x, k, d;
    cin >> x >> k >> d;

    ll t = abs(x) / d;

    if(k >= t){
        k -= t;
        if(x < 0){
            x += d * t;
        }else{
            x -= d * t;
        }
    }else{
        if(x < 0){
            x += d * k;
        }else{
            x -= d * k;
        }
        k = 0;
    }

    if(k != 0){
        if(x < 0){
            if(k % 2 != 0){
                x += d;
            }
        }else if(x == 0){
            if(k % 2 != 0){
                x = d;
            }
        }else{
            if(k % 2 != 0){
                x -= d;
            }
        }
    }

    cout << abs(x) << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll get_val(vector<ll>&ft,ll index)
{
  ll res=0;
  for(;index>=0;index=(index & (index+1))-1)
    res+=ft[index];
  return res;
}

void update(vector<ll>&ft,ll index,ll val)
{
  for(;index<(ll)ft.size();index|=index+1)
    ft[index]+=val;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //   #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    
    // Sieve();
   ll tests=1;
 // cin>>tests;
  // ll t=1;
    while(tests--)
    {
      ll l,r,d,ans=0;
      cin>>l>>r>>d;
      for(ll i=l;i<=r;i++)
      {
        if(i%d==0) ans++;
      }
      cout<<ans;

    }

    return 0;
   }

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int D, N; cin >> D >> N;
	if (N == 100) N = 101;
	int ans = 1;
	for (int i = 0; i < D; i++) {
		ans *= 100;
	}
	ans *= N;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

def main():
    N = int(input())
    links = [[] for i in range(N+1)]
    for i in range(N-1):
        a, b, c = map(int, input().split())
        links[a].append([b, c])
        links[b].append([a, c])
    # print(links)
    Q, K = map(int, input().split())

    check = [False] * (N+1)
    cost = [0] * (N+1)
    q = deque()
    q.append([K, 0])
    while len(q) > 0:
        node, now_cost = q.popleft()
        check[node] = True
        cost[node] = now_cost
        for n in links[node]:
            # print(n)
            if not check[n[0]]:
                q.append([n[0], now_cost + n[1]])
    
    for i in range(Q):
        x, y = map(int, input().split())
        print(cost[x] + cost[y])

if __name__ == "__main__":
    main()

Measured memory_bytes: 57392
#include<stdio.h>

int power(int a,int b)
{
    int i,res=1;
    for (i=1;i<=b;i++)
    {
        res=res*a;
    }
    return res;
}

int main()
{
    int a;
    scanf("%d",&a);
    printf("%d",(a+power(a,2)+power(a,3)));
}


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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;

int main() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  vector<ll> a(n), b(n);
  ll maxi = 40000;
  rep(i,n) {
    a[i] = maxi*(i+1);
    b[i] = maxi*(n-i-1) + 1;
  }
  rep(i,n) {
    a[p[i] - 1] += i;
  }
  for (auto itr : a) {
    cout << itr << " ";
  } END;
  for (auto itr : b) {
    cout << itr << " ";
  } END;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>

#define nMAX 200
#define vMAX 2000
#define wMAX 2000
#define WMAX 20000

int n,W;
int v[nMAX],w[nMAX];
int dp[nMAX][WMAX];

using namespace std;

int rec(int i,int j){
	if(dp[i][j]>=0) return dp[i][j];
	int res;
	if(i==n) res=0;
	else if(j<w[i]) res=rec(i+1,j);
	else res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i]);
	return dp[i][j]=res;
}

int main(void){
  std::ios_base::sync_with_stdio();

  cin>>n>>W;
  for(int i=0;i<n;i++){
	  cin>>v[i];
	  cin>>w[i];
  }
  memset(dp,-1,sizeof(dp));
  cout<<rec(0,W)<<endl;
 
  return 0;
}

Measured memory_bytes: 16796
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	run()
}

func run() {
	setSpace()
	a, b, c, d, e, k := readN(), readN(), readN(), readN(), readN(), readN()
	if abs(a, b) > k {
		fmt.Println(":(")
		return
	}
	if abs(a, c) > k {
		fmt.Println(":(")
		return
	}
	if abs(a, d) > k {
		fmt.Println(":(")
		return
	}
	if abs(a, e) > k {
		fmt.Println(":(")
		return
	}
	if abs(b, c) > k {
		fmt.Println(":(")
		return
	}
	if abs(b, d) > k {
		fmt.Println(":(")
		return
	}
	if abs(b, e) > k {
		fmt.Println(":(")
		return
	}
	if abs(c, d) > k {
		fmt.Println(":(")
		return
	}
	if abs(c, e) > k {
		fmt.Println(":(")
		return
	}
	if abs(d, e) > k {
		fmt.Println(":(")
		return
	}
	fmt.Println("Yay!")
}

func abs(x, y int) int {
	n := x - y
	if n > 0 {
		return n
	}
	return -n
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 640
S = input()
S += '*'
st = 'ACGT'
i, n = 0, len(S)
max_len = 0
while i < n:
    j = i
    size = 0
    while S[j] in st:
        size += 1
        j += 1
    i = j+1
    max_len = max(max_len, size)
print(max_len)

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

using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

mint choose(int n,int a){
    mint x=1;
    mint y=1;
    for(int i = 0; i < a; i++) {
        x*=n-i;
        y*=i+1;
    }
    return x/y;
}

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b;
    cin >> n >> a >> b;
    mint ans=2;
    ans=ans.pow(n)-1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3588
H, W = map(int, input().split())

w_chk = [1]*W
h_chk = [1]*H
stock = []

for i in range(H):
        grid = list(input())
        stock.append(grid)
        for j in range(W):
            if not grid[j] == '.':
                w_chk[j] *= 0
                h_chk[i] *= 0

w_chk = [i for i, x in enumerate(w_chk) if x == 0]

for i in range(H):
    if h_chk[i] == 1:
        continue
    for j in w_chk:
        print(stock[i][j], end='')
    print('\n')

Measured memory_bytes: 4596
/*
*/
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
  // 標準入力
  int N;
  cin >> N;

  map<string, int> m;

  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    auto itr = m.find(s);
    if (itr == m.end()) {//not found
      m.insert(make_pair(s, 1));
    }
    else {
      m.at(s)++;
    }
  }
  int max=0;
  string ans;
  for (auto i = m.begin(); i != m.end(); i++) {
    auto p = *i;
    if (max < i->second) {
      max = i ->second ;
      ans = i->first;
    }
    else if (max == i ->second) {
      ans += "\n";
      ans += i->first;
    }
  }
  cout << ans;
  return 0;

}

Measured memory_bytes: 27012
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors[::-1]

n,p=map(int,input().split())
divisors=make_divisors(p)
maxi=round(p**(1/n),10)

for i in divisors:
    if i<=maxi and p%i**n==0:
        print(i)
        exit()


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

int main(void){
    
    int data[3];
    int sum = 0;
    for(int i=0;i<3;i++) cin >> data[i];
    
    sort(data,data+3);
    //sum += data[0];
    for(int i=1;i<3;i++){
        sum += abs(data[i] - data[i-1]);
    }
    cout << sum <<endl;
}

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

long long a, b, c, d;

long long gcd(long long s, long long t) {

	long long p = s, q = t, r = p % q;

	while (r > 0) {
		p = q;
		q = r;
		r = p % q;
	}

	return q;
}

int main()
{
	cin >> a >> b >> c >> d;

	long long n = b - a + 1, p = c * d / gcd(c, d);

	n -= b / c - (a - 1) / c + b / d - (a - 1) / d - b / p + (a - 1) / p;
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
n,a,b,ans=int(input()),[],list(map(int,input().split())),0
for i in range(n):
  if i+1<b[i]:ans=-1
def num(list):
  x=list[:]
  maxp=x.index(max(x))
  if maxp==max(x)-1:return maxp
  else:return num(x[:maxp])
if ans==-1:print(-1)
else:
  while len(b)!=0:
    p=num(b)
    a.insert(0,b[p])
    del b[p]
for i in a:print(i)

Measured memory_bytes: 3064
public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);
    int q = ni();

    long s = 0;
    int[] d = new int[100001];
    for (int v : a) {
      d[v]++;
      s += v;
    }

    for (int i = 0; i < q; i++) {
      int b = ni();
      int c = ni();

      int cnt = d[b];
      d[c] += cnt;
      d[b] = 0;
      s += (long) cnt * (c - b);
      System.out.println(s);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 59472
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,d,r;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=((double)a)/((double)b);

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


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e2+5;
const ll INF = 2e18;

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

int main()
{
	ll n,ans = 0;
	cin >> n;
	for(ll i = 1;i <= n;++i){
		for(ll j = 1;j <= n;++j){
			for(ll k = 1;k <= n;++k){
				ans += gcd(i,gcd(j,k));
			}
		}
	}
	cout << ans;
	return 0;
}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;


int main() {
    fastio;

    int n, m;
    cin >> n >> m;
    ll answer = 1;
    if (abs(n-m) >= 2) {
        answer = 0;
    } else if (abs(n-m) == 1) {
        FOR(i, 1, n+1) {
            answer *= i % MOD;
            answer %= MOD;
        }
        FOR(i, 1, m+1) {
            answer *= i % MOD;
            answer %= MOD;
        }
    } else {
        FOR(i, 1, n+1) {
            answer *= i % MOD;
            answer %= MOD;
        }
        FOR(i, 1, m+1) {
            answer *= i % MOD;
            answer %= MOD;
        }
        answer *= 2;
    }

    cout << answer % MOD << "\n";
    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;



int main(int argc, char* argv[])
{

  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;

  int a = 0;
  int ab = 0;
  int abc = 0;
  int total_strings = 1;

  for (char c : s)
  {
    switch (c)
    {
      case 'A':
        a = (a + total_strings) % MOD;
        break;
      case 'B':
        ab = (ab + a) % MOD;
        break;
      case 'C':
        abc = (abc + ab) % MOD;
        break;
      case '?':
        abc = (3LL*abc + ab) % MOD;
        ab = (3LL*ab + a) % MOD;
        a = (3LL*a + total_strings) % MOD;
        total_strings = (3LL*total_strings) % MOD;
    }
  }

  cout << abc << "\n";

  return 0;
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        l: [usize; n],
    }

    for i in 0..n {
        let mut sum = 0;
        for j in 0..n {
            if i == j {
                continue;
            } else {
                sum+=l[j];
            }
        }
        if sum <= l[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 4352
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Char             (digitToInt)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, a, b] <- readInts
  print $ solve n a b

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve n a b = sum [x | x <- [1 .. n], sat x]
  where sat x = a <= sumDigits && sumDigits <= b
          where sumDigits = sum . map digitToInt $ show x



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

using namespace std;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < ll, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

int n, k, a[20], d[20], q[1 << 20], check[1 << 20];

bool ok(int u) {
    int c = 1, j = 1;
    FORD(i, n - 2, 0) {
        if (BIT(u, i) != BIT(u, i + 1)) {
            if (j > k) return false;
            if (c != d[j]) return false;
            c = 0; ++j;
        }
        ++c;
    }
    if (j != k) return false;
    if (c != d[j]) return false;
    return true;
}

int main() {
    cin >> n >> k;
    FORU(i, 1, n) scanf("%d", &a[i]);
    FORU(i, 1, k) scanf("%d", &d[i]);
    reverse(a + 1, a + n + 1);
    FORU(i, 1, n) q[1] += (a[i] << (i - 1));
    
    // BFS
    int l = 1, r = 1;
    check[q[1]] = 1;
    while (l <= r) {
        int u = q[l++];
        if (ok(u)) { cout << check[u] - 1 << endl; return 0; }
        FORU(i, 0, n - 2) {
            auto j = i + 1;
            auto bit_i = BIT(u, i);
            auto bit_j = BIT(u, j);
            auto v = u - 
                    (bit_i << i) - 
                    (bit_j << j) +
                    (bit_i << j) +
                    (bit_j << i);
            if (check[v]) continue;
            check[v] = check[u] + 1;
            q[++r] = v;
        }
    }
}

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

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

    vector<int> ref(A);
    vector<int> renge(B);

    for(int i =0;i<A;i++){
        cin >> ref[i];
    }
    for(int i =0;i<B;i++){
        cin >> renge[i];
    }

    vector<int> x(M);
    vector<int> y(M);
    vector<int> c(M);
    vector<int> nedan(M);

    for(int i =0;i<M;i++){
        cin >> x[i]>>y[i]>>c[i];
        nedan[i] = ref[x[i]-1]+renge[y[i]-1]-c[i];
    }


    int aMin, bMin ,nMin;
    aMin=1000000; bMin=1000000; nMin=1000000;

    for(int i =0;i<A;i++){
    if(ref[i]<aMin){aMin=ref[i];}
    }
    for(int i =0;i<B;i++){
    if(renge[i]<bMin){bMin=renge[i];}
    }
    for(int i =0;i<M;i++){
    if(nedan[i]<nMin){nMin=nedan[i];}
    }
    int count = aMin+bMin;

    int count2 = nMin;

    if(count<count2){cout << count << endl;}
    if(count>=count2){cout << count2 << endl;}  
    
}

Measured memory_bytes: 2560