akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
long long int dp[1<<20];
long long int v[1<<20];
long long int rec(int st){
	if(st==0)return 0;
	if(dp[st]!=-1)return dp[st];
	for(int s=st;s>0;s=(s-1)&st){
		//dp[st]=max(dp[st],max(rec(s),v[s])+max(v[st-s],rec(st-s)));
		dp[st]=max(dp[st],rec(st-s)+v[s]);
	}
	return dp[st];
}
int main()
{
	int n;
	cin>>n;
	long long int a[n][n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	dp[0]=-1;
	for(int i=1;i<(1<<n);i++){
		dp[i]=-1;
		for(int j=0;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(i&(1<<j)&&i&(1<<k))v[i]+=a[j][k];
			}
		}
	}
	cout<<rec((1<<n)-1);
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, tl);
    int cmin = 10000;
    For(i, n){
        Cin(int, c);
        Cin(int, t);
        if(t > tl) continue;
        cmin = min(cmin, c);
    }
    if(cmin == 10000) Cout("TLE") else Cout(cmin);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
 
int n,x,ans,tmp,v[10000005];
int a[505],cnt1,b[505],cnt2;
int edge[505][505],r[505];
bool pri[10000005],vis[505];
 
void get_prime(int maxn){
    memset(pri,true,sizeof(pri));
    pri[0]=pri[1]=false;
    for(int i=2;i<=maxn;i++){
        if(!pri[i])continue;
        for(int j=2;i*j<=maxn;j++){
            pri[i*j]=false;
        }
    }
}
 
bool find(int x){
    for(int i=1;i<=cnt2;i++)
        if(edge[x][i]&&!vis[i]){
            vis[i]=true;
            if(!r[i]||find(r[i]))
                return r[i]=x,true;
        }
    return false;
}
 
int main(){
    scanf("%d",&n);
    int maxn=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        maxn=max(maxn,x);
        v[x]^=1,v[x+1]^=1;
    }
    for(int i=1;i<=maxn+1;i++)
        if(v[i]){
            if(i&1)a[++cnt1]=i;
            else b[++cnt2]=i;
        }
    get_prime(maxn);
    for(int i=1;i<=cnt1;i++)
    for(int j=1;j<=cnt2;j++){
        if(pri[abs(a[i]-b[j])])edge[i][j]=1;
    }
    for(int i=1;i<=cnt1;i++){
        memset(vis,0,sizeof(vis));
        if(find(i))tmp++;
    }
    ans+=tmp;
    cnt1-=tmp,cnt2-=tmp;
    ans+=2*(cnt1/2)+2*(cnt2/2);
    if(cnt1&1)ans+=3;
    printf("%d",ans);
}

Measured memory_bytes: 49408
dxy = [-1, 0, 1]
h, w = map(int, input().split())
s = [input() for i in range(h)]

def mines(y, x):
    around = [(y + i, x + j) for i in dxy for j in dxy]
    cnt = 0
    for (i, j) in around:
        if i < 0 or h <= i or j < 0 or w <= j:
            continue
        if s[i][j] == '#':
            cnt += 1
    return cnt

for i in range(h):
    for j in range(w):
        if s[i][j] != '#':
            print(mines(i, j), end = '')
        else:
            print('#', end = '')
    print()


Measured memory_bytes: 3444
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  n, r = map(int, readline().split())
  if n>=10:
    print(r)
  else:
    print(r+100*(10-n))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
import heapq
 
n,m = map(int, input().split())

items = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(items)
             
for i in range(m):
    pop = heapq.heappop(items)*(-1)//2
    heapq.heappush(items, pop*(-1))

print(-1*sum(items))

Measured memory_bytes: 14180
list1 = [int(a) for a in input().split()]
list1_0 = list1[0] #A
list1_1 = list1[1] #B

abc_0 = list1_0 * list1_1 * 1
abc_1 = list1_0 * list1_1 * 2
abc_2 = list1_0 * list1_1 * 3

if abc_0 in [3, 9, 15, 21, 27]:
    print("Yes")
elif abc_1 in [3, 9, 15, 21, 27]:
    print("Yes")
elif abc_2 in [3, 9, 15, 21, 27]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#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 sz(x) (int)(x).size()
#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 newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
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;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  v(string) ss(N);
  rep(i,N) {
    cin >> ss[i];
  }
  sort(rng(ss));
  uni(ss);
  cout << sz(ss) << endl;
  return 0;
}

Measured memory_bytes: 9596
#include<stdio.h>
int main()
{
int n,i,ans;
  ans=0;
scanf("%d",&n);
  
  int num[n];
  
  for(i=0;i<n;++i)
  {
  scanf("%d",&num[i]);
  if(num[i]==i+1) ans++;
  }
 if(ans==n-2 || ans==n) printf("YES");
 else printf("NO");

return 0;
}

Measured memory_bytes: 1712
N = int(input())
A1 = list(map(int,input().split(" ")))
A2 = list(map(int,input().split(" ")))
if N == 1:
    print(A1[0]+A2[0])
    exit()
B1 = [A1[0]]
B2 = [A2[0]]
for i in range(N-1):
    B1.append(B1[i]+A1[i+1])
for i in range(N-1):
    B2.append(B2[i]+A2[i+1])
for i in range(N):
    if i == 0:
        ans = B1[0]+B2[N-1]
    else:
        aaa = B1[i] + B2[N-1] - B2[i-1]
        ans = max(ans,aaa)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >>m;
  vector<int> ans(m);
  for(int i = 0;i<n;i++){
    int k;
    cin >> k;
    for(int j = 0 ;j<k;j++){
      int m1;
      cin >> m1;
      ans.at(m1-1) += 1;
    }
  }
  int num =0;
  for(int i = 0;i<m;i++){
    if(ans.at(i) == n){
      num += 1;
    }
  }
  cout << num;
}

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



int main() {
  int D,T,S; cin >> D >> T >> S;
  if(D<= T*S) cout << "Yes" << endl;
  else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

typedef struct node *NodePointer;

NodePointer root;
NodePointer nil;

void insert(int k){
  NodePointer y,x,z;
  y=nil;
  x=root;
  z=(NodePointer)malloc(sizeof(struct node));
  z->key=k;
  z->left=nil;
  z->right=nil;

  while(x!=nil){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  
  if(y==nil)root=z;
  else{
    if(z->key < y->key)y->left=z;
    else y->right=z;
  }
}

void inorder(NodePointer u){
  if(u==nil)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(NodePointer u){
  if(u==nil)return;
  printf(" %d",u->key);
  preorder(u->left);  
  preorder(u->right);
}

int main(){
  int n,i,x;
  char c[7];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(c,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    vector<int> v(n,0);
    v[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;i++)
    {
        v[i]+=min(v[i-1]+abs(ar[i]-ar[i-1]),v[i-2]+abs(ar[i]-ar[i-2]));
        //cout<<min(v[i-1]+abs(ar[i]-ar[i-1]),v[i-2]+abs(ar[i]-ar[i-2]))<<" ";
    }
    for(int i=0;i<n;i++)
    {
    }
    //cout<<endl;
    cout<<v[n-1];
}


Measured memory_bytes: 1024
import math
#a,bは短針、長針の長さでhは時間、mは分です。例えばh時m分のような
a,b,h,m = map(int, input().split())
#方針はstartで時刻によって短針と長針の間の角度を設定し、何分かによってstartから角度を引いていきます。180度より大きくならないようにdを置きました。
start = 30*h
d = min(abs(start - 5.5 * m),360-abs(start - 5.5 * m))
#短針と長針が重なった場合、三角形にならないのでelifにまわしました。90度の時も例外処理としました。
#if文では余弦定理を使って距離を出しています。:
c = math.cos(math.radians(d))
k = a**2+b**2-2*a*b*c
ans = math.sqrt(k) 
print(ans)


Measured memory_bytes: 9416
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr);
#define sz(x) ((int)x.size())

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
const int N = 1e5+5;
typedef vector<int> vi;

int f(vector<int> v, int n)
{
   int cnt = 0;
   for(int i = 0; i < v.size(); i++)
   {
      cnt += pow(v[i]-n, 2);
   }
   return cnt;
}

int32_t main()
{
   int n, cnt = 0;
   cin >> n;
   vector<int> v(n);
   for(auto &it : v)
   {   cin >> it;cnt += it;}
   int ans = min(f(v, cnt/n), f(v, (cnt/n) + 1));
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int A[100],i,j,k,l,N;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=N-1;i++){
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1)
	printf(" ");
    }
    printf("\n");
    l=A[i];
    j=i-1;
    while(j>=0&&A[j]>l){
      A[j+1]=A[j];
      j=j-1;
      A[j+1]=l;
    }
  }
  for(k=0;k<N;k++){
    printf("%d",A[k]);
    if(k!=N-1)
      printf(" ");
  }
  printf("\n");
  return 0;
} 

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,k;cin>>n>>k;
  long double ans=0;
  for(int i=1;i<=n;i++){
    int j=i;
    int cnt=0;
    while(j<k){
      j*=2;
      cnt++;
    }
    ans+=1.0/pow(2,cnt);
  }
  ans/=n;
  cout<<fixed<<setprecision(15)<<ans<<'\n';
}
    
    
    

Measured memory_bytes: 4128
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>a;
	rep(i,n){
	    int o;cin>>o;
	    if(o==0){int u;cin>>u;a.pb(u);}
	    else if(o==1){
	        int num;
	        cin>>num;
	        cout<<a[num]<<endl;
	    }
	else{a.pop_back(); 
    
}	    
	}
	
	return 0;
}


Measured memory_bytes: 3860
#include<stdio.h>
int main()
{
    int a[1000],i,j,k,b,c,d,s=0,t=0;
    scanf("%d %d %d",&b,&c,&d);
    for(i=1; i<=b; i++)
    {
        s=0;
        j=i;

        while(j!=0)
        {
            k=j%10;
            s=s+k;
            j=j/10;
        }
        if(s>=c && s<=d)
            t=t+i;
            // printf("%d\n",t);
    }
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
    llong abs ( llong n ) { return n < 0 ? -n : n; }
}

#define int long long

namespace Rlyeh {

    int dp[100100];
    int h[100100];

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
            dp[i+1] = INF;
            read h[i];
        }
        for ( int i = 0; i < n; i++ ) {
            dp[i+1] = std::min ( dp[i+1], dp[i] + abs(h[i]-h[i+1]));
            dp[i+2] = std::min ( dp[i+2], dp[i] + abs(h[i]-h[i+2]));
        }

        echo dp[n-1] fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 1792
n = int(input())
a=list(map(int,input().split()))
for i in range(n - 1, -1, -1):
    s = sum(a[i ::i + 1])
    if s % 2 != a[i]:
        a[i] = 1 - a[i] # 1 -> 0 , 0 -> 1
print(a.count(1))
print(*[i+1 for i,x in enumerate(a) if x])

Measured memory_bytes: 11700
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	dbt := 100000

	for i := 0; i < n; i++ {
		dbt = dbt * 105 / 100
		if dbt%1000 > 0 {
			dbt = dbt - (dbt % 1000) + 1000
		}
	}

	fmt.Println(dbt)
}



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

int main()
{
	string s, t, u, v;
	cin >> s >> t;

	for (int i = 0; i < s.size(); i++) {
		u = s.substr(0, i);
		v = s.substr(i, s.size());
		if (v + u == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

int main() {
	ll n,d;
	cin>>n>>d;
	ll c=0;
	for(ll i=0;i<n;i++)
	{
	    ll x,y;
	    cin>>x>>y;
	    int a=ceil(sqrt(pow(x,2)+pow(y,2)));
	    if(a<=d)
	       c++;
        //cout<<a<<" ";
	}
    cout<<c<<endl;
	return 0;
}

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

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int K, A, B;
    read(K, A, B);
    string ans = "NG";
    for(int i = A; i <= B; i++){
        if(i % K == 0) ans = "OK";
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
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;
    }
}
//

Measured memory_bytes: 3632
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;



int main()
{

	int N, Z, W;

	cin >> N >> Z >> W;

	if (N == 1)
	{
		int a;

		cin >> a;

		cout << abs(a - W) << endl;
	}

	else
	{
		int a1, a2;

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

			if (i == N - 2)a1 = a;
			if (i == N - 1)a2 = a;
		}

		cout << max(abs(a2 - W), abs(a1 - a2)) << endl;
	}

	return 0;

}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut c=0;
    for a in read::<String>().as_bytes().iter(){
    	if *a as char=='+'{c+=1}else{c-=1}
    }
    println!("{}",c)
}


Measured memory_bytes: 4352
#include <stdio.h>

int a,b;

int main(void) {
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
}
	if(a>b){
		printf("a > b\n");
}
	if(a==b){
		printf("a == b\n");
}

	return 0;
}



Measured memory_bytes: 2104
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  cs <- zip [1..] . map ((\[x,y] -> (x,(read :: String -> Int) y)) .words) <$> replicateM n getLine :: IO [(Int, (String, Int))]
  putStrLn $ unlines $ map (show . fst) $ sortBy (\(_,(y1,z1)) (_,(y2,z2)) -> case compare y1 y2 of
                                                                             LT -> LT
                                                                             GT -> GT
                                                                             EQ -> compare z2 z1) cs

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

def shiki(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

anli = [0] * 10100


for x in range(1,150):
    if shiki(x,1,1) > N:
        break

    for y in range(1, x+1):
        if shiki(x,y,1) > N:
            break

        for z in range(1, y+1):
            
            if shiki(x,y,z) > N:
                break
            if x == y and y == z:
                anli[shiki(x,y,z)] += 1
            elif x==y or y==z or z==x:
                anli[shiki(x,y,z)] += 3
            else:
                anli[shiki(x,y,z)] += 6

for i in range(1,N+1):
    print(anli[i])


Measured memory_bytes: 9156
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 2200
#define offset 
const ll MOD= 1e9+7;
ll dp[tam][tam];
int n;
ii val[tam];
ll func(int pos,int pbegin)
{
    if (pos==n)
    {
        return 0;
    }
    if (dp[pos][pbegin]!=-1)
        return dp[pos][pbegin];
    int x=pbegin,y=n-1-(pos-pbegin);
    int mipos=val[pos].se;
    ll res=func(pos+1,pbegin+1)+abs(mipos-x)*val[pos].fi;
    res=max(func(pos+1,pbegin)+abs(mipos-y)*val[pos].fi,res);
    return dp[pos][pbegin]=res;
}
int main()
{
    
    cin>>n;
    forr(i,0,n)
    {
        cin>>val[i].fi;
        val[i].se=i;
    }
    sort(val,val+n);
    reverse(val,val+n);
    memset(dp,-1,sizeof dp);
    
    cout<<func(0,0)<<endl;
}
// PLUS ULTRA!


Measured memory_bytes: 41628
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int A, B, C, X, ans = 0;
    cin >> A >> B >> C >> X;
    for (int i = 0; i < A + 1; i++) {
        for (int j = 0; j < B + 1; j++) {
            for (int k = 0; k < C + 1; k++) {
                if (500 * i + 100 * j + 50 * k == X) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        sc.close();
        int remainTank2 = Math.max(C - Math.max(A - B, 0), 0);
        System.out.println(remainTank2);
    }
}


Measured memory_bytes: 21716
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    string ss = s;
    reverse(all(ss));
    if (s == ss)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3576
import java.util.*;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		String x =sc.nextLine();
		
		char[] a = x.toCharArray();
		
		int p , q = 0;
		
		p = x.lastIndexOf('F');
		
		for (int i = p; i >= 0 ; i--){
			if(a[i] == 'C'){
				q++;
				break;
			}
		}
		if(q > 0){
			System.out.println("Yes");
		}
		if(q == 0){
			System.out.println("No");
		}	
		sc.close();
	}
}


Measured memory_bytes: 9684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 100000000;
const int MAX_N = 20;
int dis[MAX_N + 1][MAX_N + 1];
int main() {
	for (int i = 0; i < MAX_N + 1; i++) {
		for (int j = 0; j < MAX_N + 1; j++) {
			dis[i][j] = INF;
		}
	}
	int n, m;
	scanf("%d",&n);
  	scanf("%d",&m);
	for (int i = 0; i < m; i++) {
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		dis[a][b] = c;
		dis[b][a] = d;
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	int ans = y1 - y2 - dis[x1][x2] - dis[x2][x1];
	cout << ans << endl;
}



Measured memory_bytes: 3152
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = (char *)malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = (char *)malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = (int64 *)malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

typedef int64 simple_t;

int compare_simple(const void *a, const void *b)
{
  simple_t *x;
  simple_t *y;

  x = (simple_t *)a;
  y = (simple_t *)b;

  if (x > y) return 1;
  if (y < x) return -1;

  return 0;
}
void qsort_simple (simple_t *array, int size)
{
  qsort(array, size, sizeof(simple_t), compare_simple);
}

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

int compare_x(const void *a, const void *b)
{
  int64 *x;
  int64 *y;

  x = (int64 *)a;
  y = (int64 *)b;

  if (*x > *y) return 1;
  if (*x < *y) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}


int resolve1()
{
  int64 R;
  double pi=3.14159;
  double L;

  get_N(&R);

  L = pi*R*2;

  printf("%lf", L);
  return 0;
}

int resolve2()
{
  int64 N,K;
  int64 *P;
  int64 i;
  int64 total = 0;
  
  get_NK(&N, &K);
  P = get_NSeq(N);

  qsort(P, N, sizeof(int64), compare_x);

  for (i=0; i<K; i++) {
    total += P[i];
  }

  printf("%lld",total);
  return 0;
}


int main()
{

  resolve2();
  return 0;
}



Measured memory_bytes: 1752
#include <bits/stdc++.h>
#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() {
  string s, t;
  cin >> s >> t;
  ll count = 0;
  for(int i = 0; i < s.size(); ++i) {
    if(s.at(i) != t.at(i)) {
      t.at(i) = s.at(i);
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3872
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>

using namespace std;

const int mod = 1e9+7;

long long power(long long x, long long n) {
	long long res = 1;
	while(n>0) {
		if(n&1) res = res*x % mod;
		x = x*x % mod;
		n >>= 1;
	}
	return res;
}

long long nums[10010][100];

int main() {
	char s[10010];
	long long d;
	scanf("%s%lld", s, &d);
	int n = strlen(s);
	int a[n+1];
	for(int i=0; i<n; i++) {
		a[i] = s[i]-'0';
	}

	nums[0][0] = 1;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=9; j++) {
			for(int x=0; x<d; x++) {
				nums[i][(x+j)%d] += nums[i-1][x];
			}
		}
		for(int x=0; x<d; x++) {
			nums[i][x] %= mod;
		}
	}
	long long ans = 0;
	int rem = 0;
	for(int i=0; i<n; i++) {
		for(int j=0; j<a[i]; j++) {
			ans += nums[n-i-1][(10*d-(rem+j))%d];
		}
		rem = (rem+a[i])%d;
	}
	if(rem==0) ans++;
	ans = (ans+mod-1)%mod;
	printf("%lld\n", ans);
    return 0;
}

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

#define readv(v) for(auto& a : v) cin >> a;

using ll = long long int;
using vi = vector<ll>;
using vvi = vector<vi>;

const ll MOD = 1e9+7;

ll power(ll b, ll e){
  if (e == 1) return b;
  if (e % 2 == 0) return power((b*b)%MOD, e/2);
  return (b * power(b, e-1)) % MOD;
}

ll inverse(int i) {
  return power(i, MOD-2);
}

int main(){
  int N; cin >> N;
  vi x(N); readv(x);

  ll fact = 1; // (N-1)!
  for (int i = 2; i < N; i++) fact = (fact * i) % MOD;

  vi cum_sum(N, 0); // cum_sum[i] = /sum_{j=1}^{i} 1/j * (N-1)!
  for (int i = 1; i < N; i++) cum_sum[i] = (cum_sum[i-1] + fact * inverse(i)) % MOD;

  ll total = 0;
  for (int i = 0; i < N-1; i++) total = (total + ((x[i+1] - x[i]) * cum_sum[i+1]) % MOD) % MOD;

  cout << total << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF  1001001001;
#define PI  3.14159265358979323846;
 
int main(){
ll ans,H,W;
cin>>H>>W;
if((H==1)||(W==1)){
    cout<<1<<endl;
}
else{
cout<<(H*W-(H/2+H%2)*(W/2)-(H/2)*(W/2+W%2))<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
const int N = 2e5+5;
ll n, k, c;
string s;
ll dpf[N], dpb[N];
ll comp_front(ll i)
{
    if(i >= n) return 0;
    if(dpf[i] != -1) return dpf[i];
    ll ans = 0;
    //keep
    if(s[i] == 'o')
        ans = 1 + comp_front(i+c+1);
    //dont keep
    ans = MAX2(ans, comp_front(i+1));
    return dpf[i] = ans;
}
ll comp_back(ll i)
{
    if(i < 0) return 0;
    if(dpb[i] != -1) return dpb[i];
    ll ans = 0;
    //keep
    if(s[i] == 'o')
        ans = 1 + comp_back(i-c-1);
    // dont keep
    ans = MAX2(ans, comp_back(i-1));
    return dpb[i] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n>>k>>c;
    int i;
    cin>>s;
    if(c == 0)
    {
        vi out;
        FOR0(i, n) 
            if(s[i] == 'o')
                out.pb(i);
        if(out.size() <= k) 
        {
            int si = out.size();
            FOR0(i, si) cout<<out[i]+1<<endl;
        }
        else
            cout<<endl;
        return 0;
    }
    int num[n+5] = {};
    FOR0(i, n+2)
    {
        dpf[i] = -1;
        dpb[i] = -1;
    }
    FOR(i, 1-c, n)
    {
        ll l = 0, r = 0;
        if(i > 0) l = comp_back(i-1);
        if(i+c < n) r = comp_front(i+c);
        if(l + r >= k) 
        {
            int pos = MAX2(i, 0);
            num[pos]++;
            if(i+c < n)
                num[i+c]--;
        }
    }
    FOR(i, 1, n) 
        num[i] += num[i-1];
    FOR0(i, n) if(s[i] == 'x') num[i]++;
    FOR0(i, n)
    {
        if(!num[i]) cout<<i+1<<endl;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int[] NK = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int N = NK[0];
        int K = NK[1];

        if (N % K == 0)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(1);
        }
    }
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll k, c = 0;
    cin >> n >> k;
    pair<int, int> ab[101000];
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    
    sort(ab, ab + n);
    
    rep(i, n) {
        c += ab[i].second;
        
        if (c >= k) {
            cout << ab[i].first << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();

    int max = 0;
    int[] dp = new int[N + 1];
    for (int L = 1; L < N; L++) {
      Arrays.fill(dp, 0);
      for (int i = N - L; i >= 1; i--) {
        dp[i] = s[i - 1] == s[i + L - 1] ? dp[i + 1] + 1 : 0;
        max = Math.max(max, Math.min(dp[i], L));
      }
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 23636
c = int(input())
count = 0

d = [list(map(int,input().split())) for i in range(c)]
for i in range(c):
    a,b = d[i][0],d[i][1]
    
    if (a==b):
        count += 1
        if ( count == 3):
            break
    else : 
        count = 0

if (count >= 3):
        
    print("Yes")
else :
    print("No")


Measured memory_bytes: 9116
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        int a = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        if (a >= 3200)
        {
            Console.WriteLine(s);
        }
        else
        {
            Console.WriteLine("red");
        }
    }
}


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

int main() {
    int N, A, B, cnta=0, cntab=0, cntb=0;
    cin>>N>>A>>B;

    vector<int> p(N);
    for(int i=0; i<N; i++){
        cin>>p.at(i);
    }

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

    for(int i=0; i<N; i++){
        if(p.at(i)<=A) cnta++;
        else if(p.at(i)>=A+1 && p.at(i)<=B) cntab++;
        else if(p.at(i)>=B+1) cntb++;
    }

    cout<<min(cnta, min(cntab, cntb))<<endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    int mx =0;
    int sum =0;
    
    for(int i = 0; i < n; i++)
    {
        cin>>p[i];
        sum+=p[i];
        mx=max(mx,p[i]);
    }
    cout<<sum-mx/2<<endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class M {
  static void Main(string[] __) {
    var N = int.Parse(Console.ReadLine());
    var L = Console.ReadLine().Split(' ').Select( (v) => int.Parse(v) );
    
    int result = 0;
	while(true) {   
      if ( L.Any( (v) => v%2==1 ) ) {
        Console.Write(result);
        return;
      }
      L = L.Select( (v)=>v/2 );
      ++result;
    }
    
    Console.Write( ""+result ) ;
    
    
  }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
P x[55];
map<P, ll>mp;
signed main() {
	ll n, ans = 0;
	cin >> n;
	rep(i, n)cin >> x[i].first >> x[i].second;
	sort(x, x + n);
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			mp[P({ x[j].first - x[i].first,x[j].second - x[i].second })]++;
		}
	}
	for (auto x : mp) {
		ans = max(ans, x.second);
	}
	cout << n - ans << endl;
	ggr
}


Measured memory_bytes: 384
N=int(input())
C=[0]*(2*N + 1)
l=10**2
for i in range(l):
    for j in range(l):
        for k in range(l):
            x=i+1
            y=j+1
            z=k+1
            s=(x+y)*(x+y)+(x+z)*(x+z)+(z+y)*(z+y)
            if(s<(2*N+1)):
                C[s]+=1
for i in range(N):
    print(C[2*(i+1)])


Measured memory_bytes: 69464
#include <algorithm>
#include <iostream>
#define N 1500
using namespace std;
int Change(int);

int main(){
  int n,s,e,a,b,f,k,ans,cnt;
  bool d[N],t[N];
  while(1){
    cin>>n>>s>>e;
    if(!n&&!s&&!e) break;
    s=Change(s);
    e=Change(e);
    for(int i=s;i<e;i++) d[i]=t[i]=false;
    f=0;
    while(n--){
      cin>>k;
      while(k--){
	cin>>a>>b;
	a=Change(a);
	b=Change(b);
	if(!f)
	  for(int i=a;i<b;i++) d[i]=true;
	else
	  for(int i=a;i<b;i++) t[i]=true;
      }
      if(f)
	for(int i=s;i<e;i++) d[i]=d[i]&t[i];
      for(int i=s;i<e;i++) t[i]=false;
      f=1;
    }
    ans=cnt=0;
    for(int i=s;i<e;i++){
      if(!d[i]) cnt++;
      else ans=max(ans,cnt),cnt=0;
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
  }
  return 0;
}

int Change(int x){
  return (x/100)*60+x%100;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

void Main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  vector<int> bt(40, 0); 
  rep(i, n) rep(j, 40) bt[j] += (A[i] >> j) & 1;
  ll ans = 0;
  rep(i, 40) {
    if ((k >> i) & 1) ans += (1LL << i) * (n - bt[i]);
    else ans += (1LL << i) * bt[i];
  }
  rep(i, 40) {
    ll f = 0;
    if (!((k >> i) & 1)) continue;
    rep(j, i) {
      f += (1LL << j) * max(bt[j], n-bt[j]);
    }
    f += (1LL << i) * bt[i];
    REP(j, i+1, 40) {
      if ((k >> j) & 1) f += (1LL << j) * (n - bt[j]);
      else f += (1LL << j) * bt[j];
    }
    ans = max(ans, f);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

typedef long long ll;

ll H,W;

int main()
{
    scanf("%lld%lld",&H,&W);
    if(H > W)swap(H,W);
    if(H == 1)
    {
        if(W == 1)printf("1\n");
        else printf("%lld\n",W - 2);
    }
    else printf("%lld\n",(H - 2) * (W - 2));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int D, double E) {
    double ans = INF;
    REP(x, 101)REP(y, 101) {
        if (x + y != D) continue;
        double num = sqrt(x * x + y * y);
        ans = min(ans, abs(E - num));
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m, n) {
        solve(n, m);
        //return 0;
    }
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i,h) cin >> v[i];
  vector<vector<int>> ans(h, vector<int>(w));
  rep(i,h) {
    rep(j,w) {
      if (v[i][j] == '#') {
        continue;
      }
      int temp = 0;
      for (int k = -1; k <= 1; k++) {
        for (int l = -1; l <= 1; l++) {
          if (!(k == 0 && l == 0)) {
            int y = i + k;
            int x = j + l;
            if (0 <= y && y <= h - 1 && 0 <= x && x <=  w - 1) {
              if (v[y][x] == '#') temp++;
            }
          }
        }
      }
      ans[i][j] = temp;;
    }
  }
  rep(i,h) {
    rep(j,w) {
      if (v[i][j] == '#') cout << '#';
      else cout << ans[i][j];
    }
    cout << endl;
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll a,b,c,d;
int32_t main(){
CODE_START;
cin>>a>>b>>c>>d;
ll ans1=b*d;
ll ans2=a*c;
ll ans3=a*d;
ll ans4=b*c;
ans1=max(ans1,ans4);
ans1=max(ans1,ans3);
if(max(ans1,ans2)<0){
    if(a<=0&&b>=0){
        rc(0);
    }
    if(c<=0&&d>=0){
        rc(0);
    }
}
cout<<max(ans1,ans2)<<endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(){
  
   int x , y , tmp;
   while(1){
      scanf("%d%d" , &x , &y);
      if(x == 0 && y == 0){
        break;
      }
      if(x > y){
      tmp = x; x = y; y = tmp;
    }
      printf("%d %d\n" , x , y);   

   }

    return 0;


}



Measured memory_bytes: 1876
def main():
    inf=float("inf")
    v,e=map(int,input().split())
    con=[{} for _ in range(v)]
    for _ in range(e):
        s,t,d=map(int,input().split())
        con[s][t]=d

    #最終的に閉路が得られる場合、結果はスタート地点によらないので0→0を考えればよい
    #ij成分はiのbitで表現された頂点0を含まない部分集合のうち、j番目の頂点で終わるものの最短経路長
    dp=[[inf]*(v-1) for _ in range(2**(v-1))]
    #initialize
    for x in con[0]:
        dp[2**(x-1)][x-1]=con[0][x]
    
    for i in range(1,2**(v-1)):
        if bin(i).count("1")==1 : continue
        for j in range(v-1):
            if not i>>j &1:continue
            work=i-2**j
            mn=inf
            for k in range(v-1):
                if not work>>k &1 : continue
                if not j+1 in con[k+1] : continue
                if dp[work][k]==inf : continue
                if mn>dp[work][k]+con[k+1][j+1]:
                    mn=dp[work][k]+con[k+1][j+1]
            dp[i][j]=mn
    
    mn=inf
    #得られたグラフの終点と0をつなげられるか調べ最短距離を求める
    for i in range(v-1):
        if 0 in con[i+1]:
            if mn>con[i+1][0]+dp[2**(v-1)-1][i]:
                mn=con[i+1][0]+dp[2**(v-1)-1][i]



    if mn==inf : print(-1)
    else : print(mn)
    #print(dp)

main()



Measured memory_bytes: 12256