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

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

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

const ll mod = 1e9+7;

int main(){
    ll N; cin >> N;
    string s1, s2; cin >> s1 >> s2;
    ll prev = 0; ll ans = 1;
    REP(i, N){
        if(s1[i] == s2[i]){
            // x
            // x
            ans = ans * (3ll-prev) % mod;
            prev = 1;
        }
        else if(i < N-1 && s1[i] == s1[i+1]){
            // x x
            // y y
            ans = ans * (prev == 2ll ? 3 : (3ll-prev) * (2-prev)) % mod;
            prev = 2; i += 1;
        }
        else if(i < N-1 && s1[i+1] == s2[i+1]){
            // x z
            // y z
            // cout << "error" << endl;
        }
        else{
            // x z
            // y w
            // cout << "error" << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
L = [int(a) for a in input().split()]
count = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if(L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j] and L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]):
                count += 1

print(count)

Measured memory_bytes: 9200
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    x = 0
    for j in range(m):
        x += a[i][j]*b[j]
    if x + c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;

/**
 * B - Homework
 * 高橋君の夏休みは N 日間です。
 * 夏休みの宿題が M 個出されており、i 番目の宿題をやるには Ai 日間かかります。
 * 複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
 * 夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
 * ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 夏休みの日数
        int n = sc.nextInt();
        // 夏休みの宿題数
        int m = sc.nextInt();
        // それぞれの宿題にかかる日数
        int[] a = new int[m];

        // 宿題にかかる総日数
        int result = 0;
        for( int i = 0; i < m; i++ ) {
            a[i] = sc.nextInt();
            result += a[i];
        }

        System.out.println( result > n ? "-1" : n - result );

        sc.close();
    }
}

Measured memory_bytes: 46136
using namespace std;
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return pow(x * x % m, n / 2, m);
	else
		return x * pow(x, n - 1, m) % m;
}
int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	sort(all(a));
	int sum = 0;
	rip(i, k)sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 3596
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    println(join([readline()[1],readline()[2],readline()[3]]))
end
main()

Measured memory_bytes: 169596
#include<stdio.h>
int main()
{
    int h, w;
    scanf("%d %d", &h, &w);
    int i, j;
    char a[102][102];
    for (i = 0; i < h; i++)
        scanf("%s", a[i]);
    int k, x;
    for (i = 0; i < h; i++)
    {
        x = 0;
        for (j = 0; j < w; j++)
            if (a[i][j] == '#')
                x++;
        if (x == 0)
        {
            for (k = i + 1; k < h; k++)
                for (j = 0; j < w; j++)
                    a[k - 1][j] = a[k][j];
            h--;
            i--;
        }
    }
    for (i = 0; i < w; i++)
    {
        x = 0;
        for (j = 0; j < h; j++)
            if (a[j][i] == '#')
                x++;
        if (x == 0)
        {
            for (k = i + 1; k < w; k++)
                for (j = 0; j < h; j++)
                    a[j][k - 1] = a[j][k];
            w--;
            i--;
        }
    }
    for (i = 0; i < h; i++)
    {
        for (j = 0; j < w; j++)
            printf("%c", a[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

#問題数
n = int(arr_data[0][0])

#ドリンク数
m = int(arr_data[2][0])

arr01 = list(map(int, arr_data[1]))


#print(n, m, arr01)

for i in range(3, 3 + m):
    
    arr02 = arr01.copy()
    
    arr02.pop(int(arr_data[i][0])-1)
    
    #追加
    arr02.append(int(arr_data[i][1]))
    
    print(sum(arr02))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int main() {
	int n;
	cin >> n;
	
	int mi = INF, ma = -INF;
	REP(i, n) {
		int a;
		scanf("%d", &a);
		chmax(ma, a);
		chmin(mi, a);
	}
	cout << ma - mi << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N, T , A;
	scanf("%d%d%d",&N ,&T ,&A);
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d",&H[i]);
	}
	int x[N];
	int min = 0;
	for(int j=0;j<N;j++){
		x[j] = 1000*T - H[j]*6;
		if((x[j]>1000*A?x[j]-1000*A:1000*A-x[j]) < (x[min]>1000*A?x[min]-1000*A:1000*A-x[min])){
			min = j;
		}
	}
	printf("%d",min+1);
	return 0;
}	

Measured memory_bytes: 128
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def check(a,b,x):
    a=round(a)
    return a**5 - b**5 == x

def fifthroot(n):
    for i in range(int(n**(1/5)+1)) :
        if i**5==n:
            return i
    return -1

def main():
    x = int(input().strip())
    # b>=0 のとき
        # #
        # a=(x + b**5)**(1/5)
        # eprint('a ',end=':\n')
        # eprint(a)
        # if check(a,b,x):
        #     eprint("b>=0")
        #     print(int(a),b)
        #     return            

        #
        # if a.is_integer():
        #     eprint("b>=0")
        #     print(a,b)
        #     return
    
    # b<0の場合
    for a in range(1,10**9):
        if x - a**5 < 0:
            break
        # b=(x - a**5) ** (1/5)
        b=fifthroot(x - a**5)
        if b!=-1:
            eprint("b<0")
            print(a,-int(b))
            return

    for b in range(1,10**9):
        if fifthroot(x + b**5)!=-1:
            eprint("b>=0")
            a=fifthroot(x + b**5)
            print(a,b)
            return

if __name__ == '__main__':
    main()

Measured memory_bytes: 78340
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    c = np.array([0] * N)
    penalty = np.array([0] * N)

    pp = 0

    for i in range(M):
        if S[i]=='AC':
            if c[p[i]-1]==1:
                pass
            else:
                c[p[i]-1] = 1
                pp+=penalty[p[i]-1]
        else:
            if c[p[i]-1]:
                pass
            else:
                penalty[p[i]-1]+=1
    
    print(c.sum(), pp)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24592
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    List<String> lunlunList = new ArrayList<>();

    for (int i = 1; i <= 9; i++) {
      if (--k == 0) {
        System.out.println(String.valueOf(i));
        return;
      }
      lunlunList.add(String.valueOf(i));
    }

    while (true) {
      List<String> tmp;
      tmp = genLunlun(lunlunList.remove(0));
      while (!tmp.isEmpty()) {
        String s = tmp.remove(0);
        if (--k == 0) {
          System.out.println(s);
          return;
        } else {
          lunlunList.add(s);
        }
      }
    }
  }

  public static List<String> genLunlun(String s) {
    List <String> lunlunList = new ArrayList<>();
    switch (s.substring(s.length() - 1)) {
      case "0" :
        lunlunList.add(s.concat("0"));
        lunlunList.add(s.concat("1"));
        break;
      case "1" :
        lunlunList.add(s.concat("0"));
        lunlunList.add(s.concat("1"));
        lunlunList.add(s.concat("2"));
        break;
      case "2" :
        lunlunList.add(s.concat("1"));
        lunlunList.add(s.concat("2"));
        lunlunList.add(s.concat("3"));
        break;
      case "3" :
        lunlunList.add(s.concat("2"));
        lunlunList.add(s.concat("3"));
        lunlunList.add(s.concat("4"));
        break;
      case "4" :
        lunlunList.add(s.concat("3"));
        lunlunList.add(s.concat("4"));
        lunlunList.add(s.concat("5"));
        break;
      case "5" :
        lunlunList.add(s.concat("4"));
        lunlunList.add(s.concat("5"));
        lunlunList.add(s.concat("6"));
        break;
      case "6" :
        lunlunList.add(s.concat("5"));
        lunlunList.add(s.concat("6"));
        lunlunList.add(s.concat("7"));
        break;
      case "7" :
        lunlunList.add(s.concat("6"));
        lunlunList.add(s.concat("7"));
        lunlunList.add(s.concat("8"));
        break;
      case "8" :
        lunlunList.add(s.concat("7"));
        lunlunList.add(s.concat("8"));
        lunlunList.add(s.concat("9"));
        break;
      case "9" :
        lunlunList.add(s.concat("8"));
        lunlunList.add(s.concat("9"));
    }
    return lunlunList;
  }
}


Measured memory_bytes: 38436
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

int main() {
        string s;
        cin >> s;
        vector<int> cnt(26, 0);
        for (int i = 0; i < s.size(); i ++) cnt[s[i] - 'a'] ++;
        for (int i = 0; i < 26; i ++) if (cnt[i] == 0) return !printf("%c", 'a' + i);
        return !puts("None");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  a+=b;
  int k = stoi(a);
  for(int i = 0; i < 10000; i++){
	if(k == i*i){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
<?php

class Dice
{
  public $top = 0;
  public $bottom = 0;
  public $north = 0;
  public $east = 0;
  public $south = 0;
  public $west = 0;

  public function toNorth()
  {
    $t = $this->top;
    $this->top = $this->south;
    $this->south = $this->bottom;
    $this->bottom = $this->north;
    $this->north = $t;
  }

  public function toEast()
  {
    $t = $this->top;
    $this->top = $this->west;
    $this->west = $this->bottom;
    $this->bottom = $this->east;
    $this->east = $t;
  }

  public function toSouth()
  {
    $t = $this->top;
    $this->top = $this->north;
    $this->north = $this->bottom;
    $this->bottom = $this->south;
    $this->south = $t;
  }

  public function toWest()
  {
    $t = $this->top;
    $this->top = $this->east;
    $this->east = $this->bottom;
    $this->bottom = $this->west;
    $this->west = $t;
  }
}

$dice = new Dice();
$n = explode(" ", trim(fgets(STDIN)));
$dice->top = $n[0];
$dice->south = $n[1];
$dice->east = $n[2];
$dice->west = $n[3];
$dice->north = $n[4];
$dice->bottom = $n[5];

$order = str_split(trim(fgets(STDIN)));
foreach ($order as $o) {
  if ($o == "N") $dice->toNorth();
  elseif ($o == "E") $dice->toEast();
  elseif ($o == "S") $dice->toSouth();
  else $dice->toWest();
}

echo $dice->top . "\n";



Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll r,g,b,n;
    cin >> r >> g >> b >> n;
    ll ans=0;
    ll sum=0;
    while(sum<=n){
        ll copy=sum;
        while(copy<=n){
            if((n-copy)%b==0){
                ans++;
            }
            copy+=g;
        }
        sum+=r;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N1 1000
#define N2 100
int get,A[N1];

void push(int x){
  A[++get]=x;
}
 
int pop(){
  get--;
 
  return A[get+1];
}
 
int main()
{

  char a[N2];
  int x=0,y=0;
  get=0;
 
  while(scanf("%s",a)!=EOF){
    if(a[0]=='+'){
      x=pop();
      y=pop();
      push(y+x);
    }
    else if(a[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }
    else if(a[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else {
      push(atoi(a)); 
    }
  }
 
  printf("%d\n",pop());
 
  return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  if(a>b){
    cout << a+a-1 << endl;
  }
  
  if(a<b){
    cout << b+b-1 << endl;
  }
  
  if(a==b){
    cout << a+b << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#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__) << "] "
typedef long long ll;

void solve()
{
	int n;
	cin>>n;
	int mxn = 1e5+5;
	vector<ll> cnt(mxn);
	ll sum = 0;
	for (int i=0; i<n; i++) {
		int x;
		cin>>x;
		cnt[x]++;
		sum += x;
	}
	int q;
	cin>>q;
	vector<ll> ans;
	while (q--) {
		ll b,c;
		cin>>b>>c;
		sum = sum - cnt[b]*b + c*cnt[b];
		cnt[c] += cnt[b];	
		cnt[b] = 0;
		ans.push_back(sum);
	}
	for (ll a:ans) {
		cout << a << "\n";
	}
}

int main()
{
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5100
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列以外を出力する
    void write(){

    }
    template<typename First, typename... Rest>
    void write(First first, Rest... rest){
        cout << first << " ";
        write(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int H1, M1, H2, M2, K;
    io.read(H1, M1, H2, M2, K);
    int w = H1 * 60 + M1;
    int b = H2 * 60 + M2;
    int ans = b - w - K;
    io.write(ans);
    return 0;
}

Measured memory_bytes: 3636
/*input
100 600 200 300
*/

#include <iostream>

using namespace std;

int main()
{
	int a,b,c,d;

	cin >> a >> b >> c >> d;

	int s1 = a * b;
	int s2 = c * d;

	cout << max(s1, s2) << endl;

	return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
#define N 100005
#define ll long long
int t,n;
ll a[N];
int main()
{
	//freopen("circle.in","r",stdin);
    //freopen("circle.out","w",stdout);
    //scanf("%d",&t);
    //while(t--)
    //{
    	int k=0;
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++)
    		scanf("%lld",&a[i]),k^=a[i];
    	if(k!=0)
    	{
    		printf("No\n");
    		//continue;
		}
		//sort(a+1,a+n+1);
		else
		{
			printf("Yes\n");
		}
	//}
}

Measured memory_bytes: 896
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<bool> prime;
int main(){
int n,c;
cin>>n>>c;
vector<vector<ll>> d(c,vector<ll>(c)),a(3,vector<ll>(30,0));
for(int i=0;i<c;i++)for(int j=0;j<c;j++)cin>>d[i][j];
for(int i=0;i<n;i++)for(int j=0;j<n;j++){int m;cin>>m;a[(i+j)%3][m-1]++;}
int ans=INT_MAX;
for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
        if(i==j)continue;
        for(int k=0;k<c;k++){
            if(i==k||j==k)continue;
            int res=0;
            for(int l=0;l<c;l++)res+=d[l][i]*a[0][l];
            for(int l=0;l<c;l++)res+=d[l][j]*a[1][l];
            for(int l=0;l<c;l++)res+=d[l][k]*a[2][l];
            ans=min(ans,res);
        }
    }
}
cout<<ans<<endl;
}


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

int main(){
        char line[120];
        char str[120];
        char *p;
        int  len;
        int  flag = 0, i, flag2 = 0;

        fgets(line, sizeof(line), stdin);
        sscanf(line, "%s", &str );

        len = strlen(str);
        p = str;

        for(i=0; i<len; i++){
                if(*p == 'C') flag = 1;
                if(flag == 1 && *p == 'F' ) flag2 = 1;
                p++;
        }

        //printf("%s\n", str);
        if(flag2 == 1 ) printf("Yes\n");
        else printf("No\n");

        return 0;
}

Measured memory_bytes: 128
(defmacro dotimes-unroll ((var count size &optional result) &body body)
  "DOTIMES macro with loop-unrolling by SIZE."
  (let ((whole (gensym))
        (_count (gensym)))
    (check-type var symbol)
    (check-type size (integer 1 #.most-positive-fixnum))
    `(block ,whole
       (let ((,_count ,count)
             (,var 0))
         (declare ((integer 0 #.most-positive-fixnum) ,var ,_count))
         (loop
           (when (> ,var (- ,_count ,size))
             (do ((,var ,var (1+ ,var)))
                 ((>= ,var ,_count)
                  (return-from ,whole ,result))
               ,@body))
           ,@(loop for i from 0 below size
                   collect `(locally ,@body (setq ,var (+ ,var 1)))))))))

(defun main ()
  (declare (optimize (speed 3) (safety 0)))
  (let* ((n (read))
         (res 0))
    (declare ((unsigned-byte 62) res)
             ((unsigned-byte 32) n))
    (dotimes-unroll (i n 20)
      (incf res i))
    (princ res)
    (terpri)))

#-swank (main)


Measured memory_bytes: 11880
let rec print_array xs =
    let len = Array.length xs in
    if len = 0 then print_newline ()
    else if len = 1 then Printf.printf " %d\n" xs.(0)
    else (
        for i = 0 to len - 1 do
            Printf.printf " %d" xs.(i);
        done;
        print_newline ();
    )
;;
 
let make_house () = Array.make_matrix 3 10 0
 
let () = 
    let house = [| make_house (); make_house (); make_house (); make_house ();|] in
    let n = Scanf.scanf "%d\n" (fun x -> x) in
    for _ = 1 to n do
        let (b, f, r, v) = Scanf.scanf "%d %d %d %d\n" (fun a b c d -> (a - 1, b - 1, c - 1, d)) in
        house.(b).(f).(r) <- house.(b).(f).(r) + v;
    done;
    for i = 0 to 3 do
        for j = 0 to 2 do
            print_array house.(i).(j);
        done;
        if i < 3 then
        	print_endline "####################";
    done;
;;


Measured memory_bytes: 2568
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  map<int, map<int, int> > mp;  // P => (Yr, i)
  for (int i = 0; i < M; ++i) {
    int P, Y;
    cin >> P >> Y;
    mp[P][Y] = i;
  }

  map<int, string> res;
  for (const auto& e : mp) {
    string p = to_string(e.first);
    while (6 - p.length()) {
      p = '0' + p;
    }

    int cnt = 1;
    for (const auto& city : e.second) {
      int i = city.second;
      string order = to_string(cnt);
      while (6 - order.length()) {
        order = '0' + order;
      }

      res[i] = p + order;
      ++cnt;
    }
  }

  for (const auto& e : res) {
    cout << e.second << endl;
  }
  return 0;
}

Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int d, t, s;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> d >> t >> s;
    if(t * s >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3540
N, M, Q = map(int, input().split())
lists = [list(map(int, input().split())) for i in range(Q)]
ans = 0

def calc_score(A):
   score = 0
   for a, b, c, d in lists:
       if A[b - 1] - A[a - 1] == c:
           score += d
   return score

def dfs(A):
   global ans
   if len(A) == N:
       score = calc_score(A)
       ans = max(score, ans)
       return
   for n in range(A[-1], M + 1):
       dfs(A + [n])

dfs([1])
print(ans)

Measured memory_bytes: 9164
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	W := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &W[i])
	}
	min := 1000000000
	for t := 0; t < N; t++ {
		s1 := 0
		s2 := 0
		for i := 0; i < N; i++ {
			if i <= t {
				s1 += W[i]
			} else {
				s2 += W[i]
			}
		}
		diff := s1 - s2
		if diff < 0 {
			diff = -diff
		}
		if diff < min {
			min = diff
		}
	}
	fmt.Println(min)
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int n;
    cin >> n;
    n %= 1000;
    if (n == 0) {
        out(0);
    } else {
        out(1000 - n);
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <vector>

int main(void){
  int n;
  std::cin >> n;

  int ret = 0;
  char last = 0;
  for(int i=0; i<n; i++){
    char temp;
    std::cin >> temp;
    if(last != temp){
      ret++;
      last = temp;
    }
  }

  std::cout << ret << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <queue>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5 + 1;

int n, s, t;
int a[N + 1], b[N + 1];
int id[3][N + 1], cnt;
struct Edge {
	int	to, next, oppo;
	int	done, maxx;
} edge[(N << 3) + 1];
int tot, start[N + 1], cur[N + 1];
queue<int> q;
int vis[N + 1], dep[N + 1];
int ans, num;

inline void add(int u, int v, int flow)
{
	edge[++tot] = Edge{ v, start[u], tot + 1, 0, flow };
	start[u] = tot;
	edge[++tot] = Edge{ u, start[v], tot - 1, 0, 0 };
	start[v] = tot;
	return;
}
inline bool bfs()
{
	for (int i = s; i <= t; i++)
		vis[i] = dep[i] = 0;
	q.push(s);
	dep[s] = vis[s] = 1;
	while (q.size()) {
		int u = q.front();
		q.pop();
		for (int i = start[u]; i; i = edge[i].next) {
			int v = edge[i].to;
			if (!vis[v] && edge[i].done < edge[i].maxx) {
				dep[v] = dep[u] + 1;
				vis[v] = 1;
				q.push(v);
			}
		}
	}
	return dep[t];
}
inline int dfs(int u, int flow)
{
	if (u == t || !flow)
		return flow;
	int val = 0;

	for (int &i = cur[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (dep[v] == dep[u] + 1) {
			int w = dfs(v, min(flow, edge[i].maxx - edge[i].done));
			if (w > 0) {
				edge[i].done += w;
				edge[edge[i].oppo].done -= w;
				val += w;
				flow -= w;
				if (!flow)
					break;
			}
		}
	}
	return val;
}
inline void dinic()
{
	while (bfs()) {
		for (int i = s; i <= t; i++)
			cur[i] = start[i];
		ans += dfs(s, 2147483647);
	}
	return;
}
inline void number(int now, int opt)
{
	if (id[opt][now])
		return;
	id[opt][now] = cnt;
	if (opt == 1)
		number(a[now] + 1, opt);
	else
		number(b[now] + 1, opt);
	return;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	for (int i = 1; i <= n; i++)
		b[i] = read();
	for (int i = 1; i <= n; i++) {
		if (!id[1][i]) {
			cnt++;
			number(i, 1);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!id[2][i]) {
			cnt++;
			number(i, 2);
		}
	}
	s = 0;
	t = ++cnt;
	for (int i = 1; i <= n; i++) {
		if (a[i] == b[i]) {
			if (a[i] == i - 1) {
				num++;
			} else {
				add(id[1][i], id[2][i], 1);
				add(id[2][i], id[1][i], 1);
			}
		} else {
			if (a[i] != i - 1 && b[i] == i - 1)
				add(s, id[1][i], 1);
			if (a[i] == i - 1 && b[i] != i - 1)
				add(id[2][i], t, 1);
			if (a[i] != i - 1 && b[i] != i - 1)
				add(id[2][i], id[1][i], 1);
		}
	}

	dinic();

	printf("%d\n", n - num - ans);
	return 0;
}


Measured memory_bytes: 15632
#include <iostream>
#include <string>

using namespace std;

int main(){
  int s;
  cin >> s;
  int a = s / 100;
  int b = s % 100;

  if(1 <= a && a <= 12){ // MM** or YY**
    if(1 <= b && b <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else { // YY** or NA
    if(1 <= b && b <= 12){
      cout << "YYMM" << endl; 
    }
    else cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def dfs(r):
    global l
    if len(r) == 11:
        return
    l.append(int(r))
    for i in range(-1, 2):
        tmp = int(r[-1]) + i
        if 0 <= tmp <= 9:
            dfs(r + str(tmp))


k = int(input())
l = []
for i in range(1, 10):
    dfs(str(i))
print(sorted(l)[k - 1])

Measured memory_bytes: 12856
#include <iostream>
#include <set>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      for(int l = 0; l <= k; l++){
        if(i + j + l == k){
          if(c * pow(2, i) > b * pow(2, j) && b * pow(2, j) > a * pow(2, l)){
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

lli dp[404][404];
lli summ[404+1];
void solve(){
	lli n;
	cin>>n;
	lli arr[n+1];
	rep(i,1,n){cin>>arr[i];summ[i]=summ[i-1]+arr[i];}
	rep(len,1,n){
		for(int st=1;st+len-1<=n;st++){
			int en=st+len-1;
			if(st==en){
				dp[st][en]=0;
			}else{
				dp[st][en]=MOD*MOD;
				for(int i=st;i<en;i++){
					remin(dp[st][en],dp[st][i]+dp[i+1][en]+summ[en]-summ[st-1]);
				}
			}
		}
	}
	cout<<dp[1][n]<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }

    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);

    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+ abs(a[i]-a[i-1]) ,dp[i-2]+ abs(a[i]-a[i-2]) );
    }
    cout<<dp[n-1]<<"\n";
    
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
// disjoint-set data structure represented on a single array
// each element points to parent element in the same set and forms tree,
// whose root indicates tree size multipled by -1

class DSU {
	private:
		int *data;
	public:
		DSU(int n) {
			data = new int[n];
			for(int i = 0; i < n; i++) {
				data[i] = -1;
			}
		}

		~DSU() {delete[] data;}

		DSU& operator=(DSU&& rval) {
			auto t = rval.data;
			rval.data = data;
			data = t;
			return *this;
		}
		
		// path compression without recursion
		int find(int i) {
			int parent;
			int back_to = -1;
			for(; (parent = data[i]) >= 0; i = parent) {
				data[i] = back_to;
				back_to = i;
			}
			int root = i;
			while(back_to != -1) {
				i = back_to;
				back_to = data[i];
				data[i] = root;
			}
			return root;
		}

		// union by size
		// returns 0 if union not performed
		// note that 'union' is reserved word
		int merge(int i, int j) {
			int ri = find(i), rj = find(j);
			if (ri == rj)
				return 0;
			if (data[ri] > data[rj]) {
				int t = ri;
				ri = rj;
				rj = t;
			}
			data[ri] += data[rj];
			data[rj] = ri;
			return 1;
		}

		int get_size(int i) {
			return -data[find(i)];
		}
};

int main() {
    int n, m;
    cin >> n >> m;
    DSU d(n);
    rep(_, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        d.merge(a, b);
    }
    int ans = 0;
    rep(i, n) {
        chmax(ans, d.get_size(i));    }
    cout << ans << endl;
}


Measured memory_bytes: 4032
#include<stdio.h> 
 #include<limits.h> 
   
 
int A[2000000]; 
int n; 
 
int parent(int i) 
{ 
  return i/2; 
}  
int left(int i) 
{ 
   return 2*i; 
} 
 
int right(int i) 
{ 
   return 2*i+1; 
}  
 
 
void maxHeapify(int i) 
{ 
  int l = left(i); 
  int r = right(i); 
  int largest,temp; 
  if( l <= n && A[l] > A[i]) 
    { 
      largest = l; 
    } 
  else 
    { 
      largest = i; 
    } 
  if(r <= n && A[r] > A[largest]) 
    { 
      largest = r; 
    } 
  if (largest != i) 
    { 
      temp = A[i]; 
      A[i] = A[largest]; 
      A[largest] = temp; 
      maxHeapify(largest); 
    } 
} 
 
void buildMaxHeap() 
{ 
  int i; 
  for( i = n/2;i>0;i--) 
    { 
      maxHeapify(i); 
    } 
} 
 
void maxHeapInsert(int key) 
{ 
  n = n + 1; 
  A[n] = INT_MIN; 
  heapIncreaseKey(n,key); 
} 
 
void heapIncreaseKey(int i,int key) 
{ 
  int tmp; 
  if (key < A[i]) 
    { 
      return; 
    } 
  A[i] = key; 
  while (i > 1 && A[parent(i)] < A[i]) 
    { 
      tmp = A[i]; 
      A[i] = A[parent(i)]; 
      A[parent(i)]= tmp; 
      i = parent(i); 
    } 
} 
 
int heapExtractMax() 
{ 
  int max; 
  if ( n < 1) 
    { 
      return; 
    } 
  max = A[1]; 
  A[1] = A[n]; 
  n = n - 1; 
  maxHeapify(1); 
  return max; 
} 
 
 
int main() 
{ 
  int t; 
  char s[10]; 
  while(1){ 
    scanf("%s",s); 
    if(s[2]=='s') 
      { 
scanf("%d",&t); 
maxHeapInsert(t); 
      } 
    if(s[2]=='t') 
      { 
printf("%d\n",heapExtractMax()); 
      } 
    if(s[2]=='d') 
      { 
break; 
      } 
  } 
  return 0; 
} 


Measured memory_bytes: 5640
# -*- coding: utf-8 -*-
import math

N, M = map(int , input().split() )

if(N==2) :
  n = 1
elif(N<=1) :
  n = 0
else :
  n = math.factorial(N) // ( math.factorial(2) * math.factorial(N - 2) )
  
if(M==2) :
  m = 1
elif(M<=1) :
  m = 0
else :
  m = math.factorial(M) // ( math.factorial(2) * math.factorial(M - 2) )

print(n + m)


Measured memory_bytes: 3060
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 1048577;
int a[11][N], b[N], cntt[N];
int n, m, k, cnt;

int popc(int x) {
  if (x == 0) return 0;
  else return __builtin_popcountll(x);
}
bool chk() {
  for (rint i = 0; i < cnt; i++) {
    if (cntt[i] > k) {
      return false;
    }
  }
  return true;
}

signed main() {
  scanf("%lld%lld%lld", &n, &m, &k);
  for (rint i = 0; i < n; i++) {
    for (rint j = 0; j < m; j++) {
      scanf("%1lld", &a[i][j]);
    }
  }  
  int all = 1 << (n - 1), _ans = 1e18;
  for (rint st = 0; st < all; st++) {
    int ned = popc(st), ans = 0;
    cnt = 0;
    for (rint i = 0; i < n - 1; i++) {
      if (st >> i & 1) {
        b[cnt++] = i;
      }
    } 
    b[cnt++] = n - 1;
    int fake = 1;
    for (rint p = 0; p < cnt; p++) cntt[p] = 0;
    for (rint j = 0; j < m; j++) {
      int cur = 0;
      for (rint i = 0; i < n; i++) {
        cntt[cur] += a[i][j];
        if (i == b[cur]) cur++; 
      }
      if (!chk()) {
        ans++;
        for (rint p = 0; p < cnt; p++) cntt[p] = 0;
        cur = 0;
        for (rint i = 0; i < n; i++) {
          cntt[cur] += a[i][j];
          if (i == b[cur]) cur++; 
        }
        if (!chk()) {
          fake = 0;
        }
      }
    }
    if (fake) _ans = min(_ans, ned + ans);
  }
  printf("%lld\n", _ans);
  return 0;
}

Measured memory_bytes: 22784
#include <stdio.h>
#define K 10000
int numbers[2000005];
int sortedNums[2000005];
void printArray(int *array, int n){
  for(int i = 0; i < n; ++i){
    printf("array[%d]: %d\n", i, array[i]);
  }
}
void countingSort(int n){
  int C[K];
  for(int i = 0; i <= K; ++i){
    C[i] = 0;
  }
  for(int i = 0; i < n; ++i){
    ++C[numbers[i]];
  }
  for(int i = 1; i <= K; ++i){
    C[i] = C[i] + C[i - 1];
  }
  for(int i = 0; i < n; ++i){
    sortedNums[C[numbers[i]] - 1] = numbers[i];
    --C[numbers[i]];
  }
}
int main(){
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i){
    scanf("%d", &numbers[i]);
  }
  countingSort(n);

  for(int i = 0; i < n; ++i){
    printf("%d", sortedNums[i]);
    if(i != n - 1)
      printf(" ");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 17424
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);


ll soinsu(ll k,ll i){
    if(k%i!=0){
        return k;
    }else{
        return soinsu(k/i,i);
    }
}


std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
ll gcd(ll a,ll b){
    if(a==0||b==0)return max(a,b);
    if(b>a)swap(a,b);
    while(1){
        if(a%b!=0){
            ll tmp=b;b=a%b;
            a=tmp;
        }else{
            return b;
        }
    }
}

int main() {
    sieve(1000000);
    ll a,b;
    cin>>a>>b;

    if(b>a)swap(a,b);
    ll ab = gcd(a,b);

    ll ans=0;

    bool f = false;
    // cout<<ab<<endl;

    ll k = ab;

    for(ll i=2;i<=1000000;i++){
        if(k==1)break;
        if(IsPrime[i]&&k%i==0){
            ans++;
            k=soinsu(k,i);
            

        }
        
    }
    if(k!=1)ans++;



    cout<<ans+1<<endl;

    return 0;
}


Measured memory_bytes: 384
def main():
    a, b, c = map(int, input().split())
    add = a
    mods = [0]*b
    i = a % b
    while mods[i] == 0:
        mods[i] = 1
        if i == c:
            print('YES')
            exit()
        a = a+add
        i = a % b
    print('NO')


if __name__ == "__main__":
    main()


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

int main() {
    int d;
    while (cin >> d) {
        int area = 0;
        for (int i=0; i+d<=600; i+=d) {
            area += d * i * i;
        }
        cout << area << endl;
    }
    return 0;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B, N;
    cin >> A >> B >> N;
    if (B <= N) {
        cout << (A * (B - 1)) / B << endl;
    } else {
        cout << (A * N) / B << endl;
    }
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int man_distance(int x_1, int y_1, int x_2, int y_2);

int main() {
	int n, m;
	vector<int> a, b;
	vector<int> c, d;
	int temp1, temp2;
	int min_dis = pow(10, 8);
	int now_dis = -1;
	int min_p;

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> temp1 >> temp2;
		a.push_back(temp1);
		b.push_back(temp2);
	}

	for (int i = 0; i < m; i++) {
		cin >> temp1 >> temp2;
		c.push_back(temp1);
		d.push_back(temp2);
	}

	for (int i = 0; i < n; i++) {
		min_p = 1;
		min_dis  = man_distance(a[i],b[i],c[0],d[0]);
		for (int now_p = 1; now_p < m; now_p++) {
			now_dis = man_distance(a[i], b[i], c[now_p], d[now_p]);
			if (min_dis > now_dis) {
				min_dis = now_dis;
				min_p = now_p + 1;
			}
		}
		cout << min_p << endl;
	}
}

int man_distance(int x_1, int y_1, int x_2, int y_2) {

	return (abs(x_1 - x_2) + abs(y_1 - y_2));
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    for(ll i=0;i<a;i++) cin >> p[i];
    for(ll i=0;i<b;i++) cin >> q[i];
    for(ll i=0;i<c;i++) cin >> r[i];
    sort(ALL(p),greater<ll>());
    sort(ALL(q),greater<ll>());
    sort(ALL(r),greater<ll>());

    priority_queue<ll> que;
    for(ll i=0;i<x;i++) que.push(p[i]);
    for(ll i=0;i<y;i++) que.push(q[i]);
    for(ll i=0;i<c;i++) que.push(r[i]);

    ll ans = 0;
    for(ll i=0;i<x+y;i++){
        ll cur = que.top();
        ans += cur;
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9752
n, c, k = map(int, input().split())
T = [0] * n
for i in range(n):
    T[i] = int(input())
 
T.sort()
ans, s, m = 0, 0, 0

for t in T:
    if m == 0:
        s = t
        m = 1
        ans += 1
    else:
        if t <= s + k:
            m += 1
        else:
            s = t
            m = 1
            ans += 1
    if m == c:
        m = 0
 
print(ans)

Measured memory_bytes: 13288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		String str = BR.readLine();
		String [] arr = str.split("\\s+");
		int an = Integer.parseInt(arr[0]);
		int mw = Integer.parseInt(arr[1]);
		
		int[] values = new int[an];
		int[] weights = new int[an];
		for (int i = 0;i<an;i++){
			String temp = BR.readLine();
			String [] temparr = temp.split("\\s+");
			int tv = Integer.parseInt(temparr[0]);
			int tw = Integer.parseInt(temparr[1]);
			values[i] = tv;
			weights[i] = tw;
		}
		
		int[][] Vtable = new int[an+1][mw+1];
		for (int i=1;i<an+1;i++){
			for (int j=1;j<mw+1;j++){
				if (j<weights[i-1]){
					Vtable[i][j] = Vtable[i-1][j];
				}else {
					Vtable[i][j] = Math.max(Vtable[i-1][j-weights[i-1]]+values[i-1],Vtable[i-1][j]);
				}
			}
		}
		System.out.println(Vtable[an][mw]);
		BR.close();
	}
}

Measured memory_bytes: 29256