akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll sol(ll n) {
    if (n == 1) return 1;
    return sol(n / 2) * 2 + 1;
}

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    ll a[200005] = {}, z = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n); reverse(a, a + n);
    for (int i = k; i < n; i++) z += a[i];
    cout << z;
}


Measured memory_bytes: 5236
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli udiv(lli x, lli y) {
  return (x + y - 1) / y;
}

lli n, a, b, h[100001];
int main() {
  cin >> n >> a >> b;
  read_n(h, n);

  lli l = 1, r = 1e9+1, ans = 1e18;
  while (true) {
    lli m = (r-l) / 2 + l;
    lli s = 0;
    for (lli i=0; i<n; ++i) {
      s += max(0ll, udiv(h[i] - b*m, a - b));
    }
    cerr << m << ' ' << s << endl;
    if (s <= m) ans = min(ans, m);
    if (l >= r-1) break;
    if (s <= m) {
      r = m;
    } else {
      l = m;
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	while(1){
		int n,ans=0,a;
		cin>>n;
		if(n==0)break;
		ans=0;
		for (int i = 0; i < n * (n - 1) / 2; i++) {
				cin>>a;
				ans += a;
		}
		cout<<ans/(n-1)<<endl;
	}
    return 0;
}

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

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    s.replace(0, 4, "2018");
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll __int128
#define inf 0x7fffffff
#define infll 0x7fffffffffffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=3e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
long long T,n,m,t,k;
long long ans;
long long a,b;
int main()
{
    int i,j;
	a=read(),b=read(),n=read();
	ll r=min(b-1,n);
	ans=(__int128)a*r/b;	
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3724
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    B = list(map(int, lines.pop(0).split(' ')))

    res = 0
    ex  = 0

    for i,x in enumerate(A):
        if ( i <= len(B) - 1 ):
            bi = B[i]
        else:
            bi = 0
        if ( ex > 0 ):
            if ( ex - x >= 0 ):
                res += x
                ex = bi
                continue
            else:
                res += ex
                x -= ex
        if (bi - x >= 0):
            res += x
            bi -= x
            ex = bi
        else:
            res += bi
            ex = 0

    print(res)


lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 18460
#include<bits/stdc++.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
int main(){
  long long int n, k;
  long long int ans = 0;
  cin >> n >> k;
  long long int h[n];
  for(int i = 0; i < n; i++){
    cin >> h[i];

  }
  if(k >= n){
    cout << 0 << endl;
    return 0;
  }
  sort(h, h + SIZE_OF_ARRAY(h), greater<>());
  for(int i = k; i < n; i++){
    ans += h[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	int m, f, r;
	char grade;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)
			break;

		if (m == -1 || f == -1) {
			grade = 'F';
			cout << grade << endl;
			continue;
		}
		if (m + f >= 80) {
			grade = 'A';
		} else if (m + f >= 65) {
			grade = 'B';
		} else if (m + f >= 50) {
			grade = 'C';
		} else if (m + f >= 30) {
			if (r >= 50) grade = 'C';
			else grade = 'D';
		} else
			grade = 'F';

		cout << grade << endl;
	}

	return 0;
}



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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
	ll a, b, c; cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		if (a <= b && a <= c)
		{
			cout << a * min(b, c);
		}
		else if (b <= a && b <= c)
		{
			cout << b * min(a, c);
		}
		else
		{
			cout << c * min(a, b);
		}
		
	}
	
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int h[105];
  while(scanf("%d",&n),n!=0){
    for(int i=0;i<n+1;i++){
      scanf("%d",&h[i]);
    }
    
    int sa,zen,go;
    bool flag;
    for(int i=2;i<n+1;i++){
      sa = h[1]-h[0];
      zen = 1;
      flag = true;
      for(int j=2;j<n+1;j++){
	
	if(i != j){
	  if(sa != h[j]-h[zen]) flag = false;
	  zen = j;
	}
	
      }
      
      if(flag){
	printf("%d\n",h[i]);
	break;
      }
      
    }
    
    if(!flag){
      
      if(h[2]-h[0] == h[3]-h[2]) printf("%d\n",h[1]);
      else printf("%d\n",h[0]);
      
    }
  }
  
  return(0);
}



Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, r;
    cin >> n >> r;
    if(n < 10){
        n = 100 * (10 - n);
        cout << r + n << endl;
        return 0;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 888
package main

import (
	"fmt"
)

func main() {

	var n [][]int
	var h, w int

	for {
		fmt.Scan(&h)
		fmt.Scan(&w)

		if h == 0 && w == 0 {
			break
		}

		n = append(n, []int{h, w})

	}

	for i := 0; i < len(n); i++ {

		for j := 0; j < n[i][0]; j++ {

			isTopEnd := false

			if j == 0 || j == n[i][0]-1 {
				isTopEnd = true
			}

			for k := 0; k < n[i][1]; k++ {
				if k == 0 || k == n[i][1]-1 || isTopEnd {
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}

			}
			fmt.Print("\n")
		}

		fmt.Print("\n")
	}

}

//a, _ := strconv.ParseFloat(tmp[0], 64)



Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int sum = 0;
	if (a > k)
		sum = k;
	else
		sum = a;
	k -= a + b;
	if (k > 0)
		sum -= k;
	cout << sum << endl;
}


Measured memory_bytes: 3632
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    String s = stdIn.next();
    int count = 0;
    char[] a = new char[s.length()];
    char b = 'a';
    for(int i = 0;i<s.length();i++) {
      b = s.charAt(i);
      if(b=='o') {
	count += 1;
	}
    }
    if((15-s.length())+count>=8) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21716
import copy

def function(nums):
	path = copy.deepcopy(nums)
	clear = []

	newpath = 0
	for p1 in nums:
		for p2 in nums:
			if p1[0] == p2[1] and p1 != p2 :
				newpath = [[p1[1], p2[0]]]
				clear.append(p1[0])
				path.remove(p1)
				path.remove(p2)
				break
			elif p1[1] == p2[0] and p1 != p2 :
				newpath = [[p1[0], p2[1]]]
				clear.append(p1[1])
				path.remove(p1)
				path.remove(p2)
				break
			elif p1[1] == p2[1] and p1 != p2 :
				newpath = [[p1[0], p2[0]]]
				clear.append(p1[1])
				path.remove(p1)
				path.remove(p2)
				break
			elif p1[0] == p2[0] and p1 != p2 :
				newpath = [[p1[1], p2[1]]]
				clear.append(p1[0])
				path.remove(p1)
				path.remove(p2)
				break
		if len(clear) > 0:
			break
	newpath.append(path[0])

	if (newpath[0][0] == newpath[1][0] or newpath[0][0] == newpath[1][1] or newpath[0][1] == newpath[1][0] or newpath[0][1] == newpath[1][1]) and newpath[0] != newpath[1]:
		clear.append(newpath[0][0])
		clear.append(newpath[0][1])
		clear.append(newpath[1][0])
		clear.append(newpath[1][1])
		clear = list(set(clear))
	
	if 1 in clear and 2 in clear and 3 in clear and 4 in clear:
		print('YES')
	else:
		print('NO')

def main():
	strs = [input() for i in range(3)]
	nums = [[int(_.split(' ')[0]),int(_.split(' ')[1])] for _ in strs]
	function(nums)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  A *= 100;
  B *= 100;
  int water;
  int suger, max_suger{0};
  int all, max_all{0};
  double dens, max_dens{-1.0};
  double limit_dens{E / (100.0 + E)};
  for (int a{0}; a <= F; a += A) {
    for (int b{0}; a + b <= F; b += B) {
      water = a + b;
      for (int c{((F - water) / C) * C}; c >= 0; c -= C) {
        for (int d{((F - (water + c)) / D) * D}; d >= 0; d -= D) {
          suger = c + d;
          all = water + suger;
          dens = static_cast<double>(suger) / all;
          if (dens > limit_dens) continue;
          if (max_dens < dens) {
            max_all = all;
            max_suger = suger;
            max_dens = dens;
            break;
          }
        }
      }
    }
  }

  cout << max_all << " " << max_suger << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  N=S.size();
  DV(DP,lli,N,13,0);//DP[上位i桁まで見た][13で割った余り]
  if(S[0]=='?')rep(i,0,10)DP[0][i]=1;
  else DP[0][(S[0]-'0')]=1;
  rep(i,1,N){
    if(S[i]=='?')rep(j,0,13)rep(k,0,10){
      DP[i][(j*10+k)%13]+=DP[i-1][j];
      DP[i][(j*10+k)%13]%=mod;
    }
    else rep(j,0,13){
      DP[i][(j*10+(S[i]-'0'))%13]+=DP[i-1][j];
      DP[i][(j*10+(S[i]-'0'))%13]%=mod;
    }
  }
  Out(DP[N-1][5]%mod);
}

Measured memory_bytes: 13648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(int a=1; a<=n; a++){
    ll arem = a % k;
    ll brem = k - arem;
    ll crem = brem;
    if((brem+crem)%k==0){
      ans += pow((n-brem)/k+1,2);
    }
    else continue;
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main
import (
	"fmt"
)
func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	h := make([]int, n)
	for i:= 0; i < n; i++ {
		fmt.Scanf("%d", &h[i])
	}
	a := make([]int, m)
	b := make([]int, m)
	for i:= 0; i < m; i++ {
		fmt.Scanf("%d %d", &a[i], &b[i])
	}
	answer := countPeaks(n, m, h, a, b)
	fmt.Println(answer)
}

func countPeaks(n, m int, h, a, b []int) int {
	roads := make([][]int, n)
	for i:= 0; i < n; i++ {
		roads[i] = []int{}
	}
	for i:= 0; i < m; i++ {
		roads[a[i]-1] = append(roads[a[i]-1], b[i]-1)
		roads[b[i]-1] = append(roads[b[i]-1], a[i]-1)
	}
	peakCnt := 0
	for i:= 0; i < n; i++ {
		base := h[i]
		isPeak := true
		for _, v := range roads[i] {
			if base <= h[v] {
				isPeak = false
				break
			}
		}
		if isPeak {
			peakCnt++
		}
	}
	return peakCnt
}

Measured memory_bytes: 12484
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

string s;
vector<pii> v;
int n;

pii f(int now)
{
    if(v[now].first!=-2) return v[now];
    if(now==-1) return {0,0};
    if(now==n) return {n-1,n-1};
    if(now!=n-1 && s[now]=='R' && s[now+1]=='L'){
        v[now]={now,now+1};
        v[now+1]={now+1,now};
        return v[now];
    }
    v[now]=f(now+((s[now]=='R')?1:-1));
    swap(v[now].first,v[now].second);
    return v[now];
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    cin>>s;
    n=s.length();
    v.resize(n,{-2,-2});
    for(int i=0; i<n; i++) if(v[i].first==-2) f(i);
    vector<int> answer(n);
    for(int i=0; i<n; i++) answer[v[i].first]+=1;
    for(int ans : answer) cout<<ans<<" ";

    return 0;
}


Measured memory_bytes: 6480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N; cin >> N;
    if (N % 2 == 0) cout << 1.0/2.0 << endl;
    else cout << (N / 2 + 1.0) / N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n + 1, false);
    vector<int> wa(n + 1, 0);
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        if(ac[p]) continue;
        if(s == "AC") ac[p] = true;
        else wa[p]++;
    }
    int a = 0, w = 0; 
    rrep(i, n) {
        if(ac[i]) {
            a++;
            w += wa[i];
        }
    }
    cout << a << " " << w << endl;

    return 0;
}

Measured memory_bytes: 768
def judgeeven(lst):
	m = len(lst)
	for i in range(0, m):
		if lst[i] % 2 != 0: return False
	
	return True

n = int(raw_input())
inpt = map(int, raw_input().split())
cnt = 0

while judgeeven(inpt):
	for i in range(0, n):
		inpt[i] = inpt[i] / 2
	cnt = cnt + 1

print cnt


Measured memory_bytes: 2568
n, m = map(int,input().split())
ball = [1]*n
red_ball = [1] + [0]*(n-1)
for i in range(m):
  a,b = map(int,input().split())
  if red_ball[a-1] == 1:
    if ball[a-1] == 1:
      ball[a-1] -= 1
      ball[b-1] += 1
      red_ball[a-1] = 0
      red_ball[b-1] = 1
    else:
      ball[a-1] -= 1
      ball[b-1] += 1
      red_ball[b-1] = 1
  else:
    ball[a-1] -= 1
    ball[b-1] += 1
print(sum(red_ball))

Measured memory_bytes: 11048
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(const mat &A, const mat &B, ll mod) {
  mat C(A.size(), vec(B[0].size()));
  REP(i,A.size())
    REP(j,B[0].size())
    REP(k,B.size())
    C[i][j] = (C[i][j] + A[i][k]*B[k][j] % mod) % mod;
  return C;
}

mat pow(mat A, ll n, ll mod) {
  mat B(A.size(), vec(A.size()));
  REP(i,A.size())
    B[i][i] = 1;
  while(n) {
    if (n&1) B = mul(B, A, mod);
    A = mul(A,A, mod);
    n >>= 1;
  }
  return B;
}
int dx[] = {-1,-1,0,0,0,1,1};
int dy[] = {-1,0,1,0,-1,1,0};

int main() {
  int N,M,L;
  int T = 0;
  while(cin>>N>>M>>L,N) {
    map<pii, int> mp;
    int num = 0;
    vec b;
    REP(i,2*N-1) {
      REP(j,2*N-1-abs(N-i-1)) {
        //cout << j << endl;
        int a;cin >> a;
        b.push_back(a);
        int hoge = 0;
        if (i>=N) hoge = i-N+1;
        mp[pii(i,j+hoge)] = num++;
      }
    }
    mat A(num, vec(num));
    REP(i,2*N-1) {
      REP(j_,2*N-1-abs(N-i-1)) {
        int hoge = 0; if (i>=N) hoge = i-N+1;
        int j = j_+hoge;
        REP(k,7) {
          int ii=i+dy[k];
          int jj=j+dx[k];
          if (mp.count(pii(ii,jj)) == 0) continue;
          A[mp[pii(i,j)]][mp[pii(ii,jj)]] = 1;
        }
      }
    }
    A = pow(A, L, M);
    // REP(i,num) {
    //   REP(j,num) {
    //     cout << A[i][j] << " ";
    //   }cout << endl;
    // }
    // cout << endl;
    // REP(i,num) cout << b[i] << " ";cout<< endl;
    ll ans = 0;
    REP(i, num) {
      ll tmp = 0;
      REP(j, num) {
        tmp = (tmp + A[i][j]*b[j]%M) %M;
      }
      ans += tmp;
    }
    printf("Case %d: ",++T);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1224
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 1000000007
typedef long long ll;

int W[40],S[31000];

int main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;

  for(int i=0;i<=F/100/A;i++){
    for(int j=0;j<=(F/100-A*i)/B;j++){
      W[A*i+B*j]++;
    }
  }
  S[0]=1;
  for(int i=0;i<=((F/100)*E)/C;i++){
    for(int j=0;j<=((F/100)*E-C*i)/D;j++){
      S[i*C+j*D]++;
    }
  }
  int ans1,ans2;
  ll temp,ans=0;
  for(ll i=1;i<=F/100;i++){
    for(ll j=0;j<=(F/100)*E;j++){
      if(W[i]==0 || S[j]==0) continue;
      if(i*100+j>F) break;
      if(i*E<j) break;
      temp=(j*10000000)/(i*100+j);
      if(temp>=ans){
        ans=temp;
        ans1=j;
        ans2=i*100+j;
        
      }
    }
  }
  cout<<ans2<<" "<<ans1<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    string d[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
    string s;
    cin >> s;
    rep(i, 7)
    {
        if (s == d[i])
        {
            int ans = 7 - (i + 1);
            if (ans == 0)
                ans = 7;
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h[3], m[3], s[3];
	int h_end[3], m_end[3], s_end[3];
	int tmp[3];
	int i;
	
	for (i = 0; i < 3; i++){
		scanf("%d %d %d", &h[i], &m[i], &s[i]);
		scanf("%d %d %d", &h_end[i], &m_end[i], &s_end[i]);
		
		tmp[i] = (h_end[i] * 3600 + m_end[i] * 60 + s_end[i]) - (h[i] * 3600 + m[i] * 60 + s[i]);
		
	}
	
	for (i = 0; i < 3; i++){
		printf("%d %d %d\n", tmp[i] / 3600, tmp[i] % 3600 / 60, tmp[i] % 3600 % 60);
	}
	
	return (0);
}

Measured memory_bytes: 600
n=int(input())
ans=10**6
def calc(a,b):
  res=0
  for i in range(len(str(a))):
    res+=int(str(a)[i])
  for i in range(len(str(b))):
    res+=int(str(b)[i])
  return res
  
for i in range(1,n//2+1):
  a=i
  b=n-a
  ans=min(ans,calc(a,b))
print(ans)


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

map<ll,ll> prime_factor(ll n){
  map<ll,ll> res;
  for (ll i(2);i*i<=n;i++){
    while(n%i==0){
      ++res[i];
      n/=i;
    }
  }
  if (n!=1) res[n]=1;
  return res;
}

int main(){
  ll n,p;
  cin>>n>>p;
  map<ll,ll> res;
  res=prime_factor(p);
  ll ans(1);
  for (auto e: res) {
    ans*=(ll)pow(e.first,e.second/n); 
  }
  cout << ans << endl;
  return 0;
}


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

ll gcd(ll x, ll y){
	if(y == 0){
		return x;
	}
	return gcd(y, x%y);
}

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N){
		cin >> A.at(i);
	}
	
	vector<ll> R(N+1);
	vector<ll> L(N+1);
	
	L[0] = 0;
	R[N-1] = 0;
	
	rep(i,N){
		L[i+1] = gcd(L[i], A[i]);
	}
	
	for (int i = N-2; i >= 0 ; --i) {
		R[i] = gcd(R[i+1], A[i+1]);
	}
	
	ll ans = 0;
	
	rep(i,N){
		ans = max(ans, gcd(L[i], R[i]));
	}
	
	cout << ans << endl;
	
	
    return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int A,B,C,X;
		int count=0;
		Scanner sc = new Scanner(System.in);
		A=sc.nextInt();
		B=sc.nextInt();
		C=sc.nextInt();
		X=sc.nextInt();
		
		
		for(int i = 0; i <= A; i++)
			for(int j = 0; j <= B; j++)
				for(int k =0; k <=C; k++) 
					if( (500*i + 100*j+ 50*k) == X ) count++;
		
		System.out.println(count);
	}

}


Measured memory_bytes: 23252
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let r = n - k
let memo = Array.make_matrix 3000 3000 @@ -1
let rec comb n k =
  if memo.(n).(k) > -1 then memo.(n).(k)
  else
    (memo.(n).(k) <- if n < k then 0 else if n = k then 1 else if k = 0 then 1
      else (comb (n - 1) (k - 1) + comb (n - 1) k) mod 1_000_000_007;
    memo.(n).(k))
let h n k = comb (n + k - 1) k
let _ =
  for i = 1 to k do
    Printf.printf "%d\n" @@ comb (r + 1) i * h i (k - i) mod 1_000_000_007 done

Measured memory_bytes: 73724
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  deque<int> dq;
  rep(i,N) {
    int a;
    cin >> a;
    if(i % 2 == 1) {
      dq.push_back(a);
    } else {
      dq.push_front(a);
    }
  }
  if(N%2==0) {
    reverse(rng(dq));
  }
  rep(i,N) {
    cout << dq[i] << " ";
  }
  cout << endl;
  return 0;
}

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


#define REP(i, n) for(int i = 0; i < n ; i++)

using namespace std;

int main() {
    int a[3];
    int n = 3;
    REP(i, n) cin >> a[i];
    sort(a, a + n);
    int sum = 0;
    int obj = 3 * a[2];
    REP(i, n) sum += a[i];
    if (sum % 2 != (3 * a[2]) % 2) {
        obj++;
    } else {}
    if (obj % 3 == 1){
        obj += 2;
    } else if (obj % 3 == 2){
        obj++;
    } else {}
    int ans = (obj - sum) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int p[] = new int[N];
        Set<Integer> si = new HashSet<>();
        for(int i=0; i<N; i++) {
            p[i] = sc.nextInt();
            si.add(p[i]);
        }
        int result = 0;
        int mindiff = Math.abs(0-X);
        for(int t=0; t<=101; t++) {
            if(si.contains(t)) continue;
            if(mindiff > Math.abs(t-X)) {
                mindiff = Math.abs(t-X);
                result = t;
            }
        }
        System.out.println(result);
    }
}


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

class Program
{
    private static int count = 0;
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        MergeSort(ar, 0, ar.Length);
        WriteLine($"{string.Join(" ", ar)}\n{count}");
    }
    private static void MergeSort(int[] ar,int left,int right)
    {
        if (right <= left + 1) return;
        var mid = (right + left) / 2;
        MergeSort(ar, left, mid);
        MergeSort(ar, mid, right);
        Merge(ar, left, mid, right);
    }
    private static void Merge(int[] ar,int left,int mid,int right)
    {
        var num1 = mid - left;
        var num2 = right - mid;
        var le = new int[num1 + 1];
        var ri = new int[num2 + 1];
        for (var i = 0; i < num1; i++)
            le[i] = ar[left+i];
        for (var i = 0; i < num2; i++)
            ri[i] = ar[mid + i];
        le[num1] = int.MaxValue;
        ri[num2] = int.MaxValue;
        var ii = 0;
        var jj = 0;
        for(var k = left; k < right; k++)
        {
            if (le[ii] <= ri[jj])
            {
                ar[k] = le[ii];
                ii++;
            }
            else
            {
                ar[k] = ri[jj];
                jj++;
            }
            count++;
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 73540
#include <iostream>
#include <string>
#include <utility>
#include <queue>

using namespace std;

typedef pair<string, int> P;

int N, Q;
queue<P> RR;

void solve() {
    int t = 0;
    while (!RR.empty()) {
        P p = RR.front(); RR.pop();
        int r = p.second - Q;
        if (r <= 0) {
            t += p.second;
            cout << p.first << " " << t << endl;
        } else {
            t += Q;
            RR.push(P(p.first, r));
        }
    }
}

int main() {
    cin >> N >> Q;
    for (int i = 0; i < N; i++) {
        string name;
        int t;
        cin >> name >> t;
        RR.push(P(name, t));
    }
    solve();
    return 0;
}

Measured memory_bytes: 4404
# 2020/04/26
# AtCoder Beginner Contest 164 - B

# Input
a, b, c, d = map(int,input().split())

wa = a
wc = c

# Calc
while wa > 0 and wc > 0:
    wc = wc - b
    if wc <= 0:
        ans = 'Yes'
        break
        
    wa = wa - d
    if wa <= 0:
        ans = 'No'
        break

# Output
print(ans)


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

using namespace std;

#define int long long

int H, W, S, T;
bool fld[100][100];

int Count(int x, int y)
{
	int res = 0;
	for (int i = y; i < y + T; i++)
	{
		for (int j = x; j < x + S; j++)
		{
			res += fld[i][j];
		}
	}
	return res;
}

signed main()
{
	int N;
	while (cin >> N, N)
	{
		fill_n((bool*)fld, 100 * 100, false);
		cin >> W >> H;
		for (int i = 0; i < N; i++)
		{
			int X, Y;
			cin >> X >> Y;
			X--; Y--;
			fld[Y][X] = true;
		}
		cin >> S >> T;

		int ma = 0;
		for (int i = 0; i <= H - T; i++)
		{
			for (int j = 0; j <= W - S; j++)
			{
				ma = max(ma, Count(j, i));
			}
		}
		printf("%lld\n", ma);
	}
}

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

s = [0]*(H+2)

s[0] = ["."]*(W+2)

for i in range(1,H+1):
    s[i] = ["."]+list(str(input()))+["."]

s[H+1] = ["."]*(W+2)

#print(s)

det = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        #print(i,j,s[i][j],s[i][j-1],s[i][j+1],s[i-1][j],s[i+1][j])
        if s[i][j] == "#" and s[i][j-1] == "." and s[i][j+1] == "." and s[i-1][j] == "." and s[i+1][j] == ".":
            det = -1

if det == -1:
    print("No")
else:
    print("Yes")
        

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n,a,b;
   cin >> n >> a >> b;
   int ans = 0;
   for (int i = 1;i <= n;i++){
      int cnt = 0;
      string s = to_string(i);
      for (int j = 0;j < s.size();j++){
         cnt += stoi(s.substr(j,1));
      }
      if (cnt <= b && a <= cnt) ans+=i;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int Z = scan.nextInt();


		int temp = X;
		X = Y;
		Y = temp;

	    temp = X;
		X = Z;
		Z = temp;


		System.out.print(X + " " + Y + " " + Z);
		scan.close();

	}

}


Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

const ll delta[4][2] = {
    {-1, 0}, {1, 0}, {0, -1}, {0, 1}
};

int main(){
    ll H, W;
    cin >> H >> W;
    vector<string> m(H);
    REP(i, H){
        cin >> m.at(i);
    }

    ll ans = 0;
    REP(sy, H){
        REP(sx, W){
            if(m.at(sy).at(sx) == '#'){ continue; }

            vector<vector<ll>> dist(H, vector<ll>(W, -1));
            dist.at(sy).at(sx) = 0;
            queue<array<ll, 2>> que;
            que.push({sy, sx});
            while(!que.empty()){
                const auto p = que.front(); que.pop();
                REP(di, 4){
                    ll ny = p.at(0) + delta[di][0];
                    ll nx = p.at(1) + delta[di][1];
                    if(ny >= 0 && ny < H && nx >= 0 && nx < W && m.at(ny).at(nx) != '#' && dist.at(ny).at(nx) == -1){
                        dist.at(ny).at(nx) = dist.at(p.at(0)).at(p.at(1)) + 1;
                        que.push({ny, nx});
                    }
                }
            }

            REP(gy, H){
                REP(gx, W){
                    ans = max(ans, dist.at(gy).at(gx));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    ll n,h,w;
    cin>>n>>h>>w;
    int ans=0;
    rep(i,0,n){
        ll a,b;
        cin>>a>>b;
        if(a>=h&&b>=w)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];

  sort(all(a), greater<int>());

  int x = a[0];
  int ans = 0;
  int m = (x+1)/2;
  for (int i = 1; i < n; i++) {
    if(abs(a[i]-m) < abs(ans-m)) ans = a[i];
  }

  printf("%d %d\n", x, ans);
}


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

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = AB[0];
            int B = AB[1];

            
            int count = 0;
            for (int i = 0; i < 20; i++)
            {
                if (count * (A-1)+1 >= B)
                {
                    Console.WriteLine(count);
                    return;
                }
                else
                {
                    count++;
                }
            }

        }

    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
int main(){
  std::string s;
  std::cin >> s;
  int t,a[26],n = s.size();
  memset(a, 0, sizeof(a));
  for(int i = 0; i != n;  i++){
    t = s[i] - 97;
    a[t] += 1;
  }
  int i;
  char ch;
  for(i = 0; i < 26; i++){
    if(a[i] == 0){
      ch = i + 97;
      break;
    }
  }
	if(i == 26)
      std::cout << "None" << std::endl;
  	else
      std::cout << ch << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll h, w;
    cin >> h >> w;
    vector<string> board(h);
    REP(i, h) cin >> board.at(i);
    vector<string> ans(h * 2);
    REP(i, h * 2) {
        ans.at(i) = board.at(i / 2);
    }
    for (auto elem : ans) {
        cout << elem << endl;
    }
}

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

if '##' in S[A:C+1] or '##' in S[B:D+1]:
    print("No")
else:
    if C < D:
        print("Yes")
    elif '...' in S[B-2:D+1]:
        print("Yes")
    else:
        print("No")


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> cnt;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        A[i] = tmp;
        if (cnt.count(tmp) == 0) {
            cnt[tmp] = 1;
        } else cnt[tmp] += 1;
    }
    set<int> keys(A.begin(), A.end());
    ll sum = 0;
    for (auto key : keys) {
        ll tmp = cnt[key];
        sum += tmp*(tmp - 1)/2;
    }
    rep(i, N) {
        ll tmp = cnt[A[i]];
        tmp = sum - tmp*(tmp - 1)/2 + (tmp - 1)*(tmp - 2)/2;
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 16256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  ll n, a, b; cin >> n >> a >> b;
  if (n == 1) {
    if (a == b) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  if (a > b) {
    cout << 0 << endl;
    return 0;
  }

  ll mi = a*(n-1)+b;
  ll ma = a+b*(n-1);
  cout << ma-mi+1 << endl;
}


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

string shuffle(string a, int b){

	string s1= a, s2;
	int c1 = b;

	s2=s1.substr( 0, c1 );
	s1=s1.erase( 0, c1 );
	s1+=s2;

	return s1;
}

int main(){
	string str;
	int ct, ct2;

while(1){
	cin >> str;
	if(str=="-"){break;}
	cin >> ct;
	for(int i=0; i<ct; i++){ cin >> ct2; str=shuffle(str ,ct2);}	
	cout << str <<endl;
}

return 0;
}

Measured memory_bytes: 1216
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc091 {
    export class TaskB implements AtCoder.Paramable, AtCoder.Task {
        constructor(readonly args: string[][]) {
        }

        main(this: TaskB): void {
            const n: number = parseInt(this.args[0][0], 10);
            const m: number = parseInt(this.args[n + 1][0], 10);
            const map = new Map;

            for (let i = 0; i < n; i++) {
                const key: string = this.args[i + 1][0];
                if (!map.has(key)) {
                    map.set(key, 0);
                }
                map.set(key, 1 + map.get(key))
            }

            for (let i = 0; i < m; i++) {
                const key: string = this.args[n + i + 2][0];
                if (!map.has(key)) {
                    map.set(key, 0);
                }
                map.set(key, -1 + map.get(key));
            }

            const array: number[] = [];
            map.forEach((value) => {
                array.push(value);
            });

            const ans: number = Math.max(...array);
            console.log(ans > 0 ? ans : 0);
        } 
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
    const task: AtCoder.Task = new TaskB(args);
    task.main();
}

Measured memory_bytes: 7500
#include <stdio.h>          // printf(), scanf()

#define MAX_N 100
#define MAX_V 100 
#define min(a, b) ((a) < (b) ? (a) : (b))

static const int INF = 2000000000;

int n, W;
int v[MAX_N], w[MAX_N];
int dp[MAX_N + 1][MAX_N * MAX_V + 1];

int
solve()
{
	int i, j;

	for (j = 0; j <= MAX_N * MAX_V; ++j)
		dp[0][j] = INF;

	dp[0][0] = 0;
	for (i = 0; i < n; ++i)
	{
		for (j = 0; j <= MAX_N * MAX_V; ++j)
		{
			if (j < v[i])
				dp[i + 1][j] = dp[i][j];
			else
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
		}
	}

	int res = 0;
	for (i = 0; i <= MAX_N * MAX_V; ++i)
	{
		if (dp[n][i] <= W)
			res = i;
	}

	return res;
}

int
main(int argc, char** argv)
{
	int i;

	scanf("%d %d", &n, &W);
	for (i = 0; i < n; ++i)
		scanf("%d %d", &v[i], &w[i]);

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

Measured memory_bytes: 4540
#include<stdio.h>
#include<algorithm>
int main(){
	int i,height[10]={};
	for(i=0;i<=9;i++){
		scanf("%d",&height[i]);
	}
	std::sort(height,height+10);
	for(i=9;i>=7;i--){
		printf("%d\n",height[i]);
	}
	return 0;

}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


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

    int N, ans = 0;
    cin >> N;
    rep(i, N) {
        int a; cin >> a;
        ans += a - 1;
    }
    COUT(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;

int me[40000],enemy[40000];

void func(){

	for(int i = 0; i < N; i++)scanf("%d",&me[i]);
	for(int i = 0; i < N; i++)scanf("%d",&enemy[i]);

	sort(me,me+N,greater<int>() );
	sort(enemy,enemy+N,greater<int>());

	int me_index = 0,me_win_count = 0;
	int ans = BIG_NUM;


	for(int i = 0; i < N; i++){

		//while(me_index <= N-1){
		while(me_index <= N-2){
			if(enemy[i] >= me[me_index]){
				me_index++;
				break;
			}else{ //enemy[i] < me[me_index]
				me_win_count++;
				if(me_win_count >= (me_index+1)/2+1){
					ans = me_index+1;
					break;
				}
				me_index++;
			}
		}

		if(me_index >= N || ans != BIG_NUM)break;
	}

	if(ans == BIG_NUM){
		printf("NA\n");
	}else{
		printf("%d\n",ans);
	}
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3520
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

k = int(input())

intlist = []

intlist.append(a)
intlist.append(b)
intlist.append(c)
intlist.append(d)
intlist.append(e)


flag = 0

for i in range(len(intlist)):
	for j in range(i, len(intlist)):

		if i != j:
			if intlist[j] - intlist[i] > k:
				flag = 1
				break


	if flag == 1:
			break

if flag == 1:
	print(":(")

if flag == 0:
	print("Yay!")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(void){

    int K,X;
    cin>>K>>X;//入力
    
    int ans;//回答
    ans=X-K+1;
    for(int i=0;i<2*K-1;i++){
        if(ans>=-1000000&&ans<=1000000){
            cout<<ans<<endl;
        }
        ans++;
    }
   
    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
if(a>b):
    n=a
    a=b
    b=n
if(b>c):
    n=b
    b=c
    c=n
if(a>b):
    n=a
    a=b
    b=n
print(str(a)+" "+str(b)+" "+str(c))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main()
{
  init();
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vecll p(a,0),q(b,0),r(c,0);
  REP(i,a) cin >> p[i];
  REP(i,b) cin >> q[i];
  REP(i,c) cin >> r[i];
  sort(all(p), greater<ll>());
  sort(all(q), greater<ll>());
  sort(all(r), greater<ll>());
  priority_queue<int, vecint, greater<int> > quep, queq;
  ll sump = 0;
  ll sumq = 0;
  REP(i,x){ quep.push(p[i]);sump += p[i];}
  REP(i,y){ queq.push(q[i]);sumq += q[i];}
  ll ans = sump + sumq;
  int j = 0;
  bool ok = true;
  while(j < c&&ok){
    // cout << j << endl;
    ll tmp = r[j];
    ll nowp = quep.top();
    ll nowq = queq.top();
    // cout << nowp << " " << nowq << endl;
    ok = false;
    if(nowp < nowq){
      if(nowp <= tmp){
	quep.pop();
	quep.push(tmp);
	ok = true;
	sump = sump - nowp + tmp;
	// cout << sump << endl;
      }
    }else{
      if(nowq <= tmp){
	queq.pop();
	queq.push(tmp);
	ok = true;
	sumq = sumq - nowq + tmp;
	// cout << "q:" << sumq << endl;
      }
    }
    j++;
  }
  cout << sump + sumq << endl;
}


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

int main()
{
    int n;
    std::cin>>n;
    std::map<int,int> mp;
    for(int i=0;i<n;i++){
        int tmp;
        std::cin>>tmp;
        mp[tmp-1]++;
        mp[tmp]++;
        mp[tmp+1]++;
    }
    int max_el = 0;
    for(auto i : mp){
        max_el = std::max(i.second,max_el);
    }
    std::cout<<max_el<<std::endl;
}

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


int main() {
  int N,X,T;
  cin >> N >> X >>T;
  
  if(N%X==0){
    cout << N/X*T <<endl;
  }
  else{
    cout<< (N/X+1)*T <<endl;
  }
  
}


Measured memory_bytes: 3640