akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

from math import gcd

k = int(readline())
cnt = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcd_ans = gcd(i, j)
        for l in range(1, k + 1):
            cnt += gcd(l, gcd_ans)
print(cnt)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
 
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e2+7;
const ll inf = 1e9+7;
int main() {
	fastio;
	ll cont=0;
	string s,t;
	cin>>s>>t;
	f(i,0,sz(s)){
		if(s[i]!=t[i]) cont++;
	}
	cout<<cont<<"\n";
	return 0;
}

Measured memory_bytes: 3736
#include "cstdio"
#include <algorithm>

using namespace std;

int main (){
    int n,mx=-1000000,mn=1000000,a;
    long sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        mx = max(mx,a);
        mn = min(mn,a);
        sum += a;
    }
    printf("%d %d %ld\n",mn,mx,sum);
}

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

    int main(){
        int n,ans;
        cin >> n;
        int number[10][10];

        for(int i = 0 ; i < 10 ; i++){
            for(int j = 0 ; j < 10 ; j++){
                number[i][j] = 0;
            }
        }

        //最初の一桁と最後の一桁が同じ数字をひとまとめにして個数を格納
        for(int i = 1 ; i <= n ; i++){
            int v = static_cast<int>(log10(i)); //最初の一桁
            int max = i / pow(10,v); //桁数計算
            int min = i % 10; //最後の一桁
            number[min][max]++;
        }

        //ペアの総数計算
        for(int i = 0 ; i < 10 ; i++){
            for(int j = 0 ; j < 10 ; j++){
                ans += number[i][j] * number[j][i]; //組み合わせ
            }
        }

        cout << ans;
        return 0;
    }

Measured memory_bytes: 512
import itertools

N = input()
if len(N)==1:
    print(N)
    exit()


gen = (1,2,3,4,5,6,7,8,9)
A = list(itertools.product(gen,gen))
count =0

mem = [[0 for i in range(0,10,1)]for j in range(0,10,1)]

for a,b in A:
    tmp = 0
    if a < int(N[0]):
        for i in range(0,len(N)-1,1):
            tmp+= pow(10,i)
    elif a > int(N[0]):
        for i in range(0,len(N)-2,1):
            tmp+= pow(10,i)
    else:
        tmp +=1
        for i in range(1,len(N)-2,1):
            tmp+= pow(10,i)
        if len(N) > 2:
            tmp+=int(N[1:len(N)-1])+1
            if int(N[len(N)-1]) < b:
                tmp-=1
    if a==b:
        tmp+=1
    mem[a][b]=tmp

for a,b in A:
    count+=mem[a][b]*mem[b][a]

print(count)



Measured memory_bytes: 3064
using System;

class Program
{
    static void Main(string[] args)
    {
        var str = Console.ReadLine();
        var str2 = Console.ReadLine();

        var reverse = "";
        for(var i = 0; i < str.Length; i++)
        {
            reverse += str.Substring(2 - i, 1);
        }
        if (str2 == reverse) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}


Measured memory_bytes: 13140
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();
		// 出力
		
		if(b%2==0) {
			if ( a>=0 && a<6 )  {
				System.out.println(0);
			} else if ( a>=6 && a<13 ){
				System.out.println(b/2);
			} else if ( a>=13 && a<= 100){
				System.out.println(b);
			} else {
			}
		}
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		int p;
		int i=0;
        sc =new Scanner(System.in);  
		int count[] = new int[26];
		String str;
		char c;
		
	    
		while(sc.hasNext()){
			str=sc.next();
			for(int j=0;j<str.length();j++) {
				c=str.charAt(j);
				if(c>='A'&&c<='Z') {
					c+=32;
				}else if(c>='a'&&c<='z') {
					
				}else {
					continue;
				}
				p= c-'a';
				count[p]++;
			}
		}
		for(i=0;i<26;i++) {
			System.out.printf("%c : %d\n",i+'a',count[i]);
		}
	}
	
}



Measured memory_bytes: 26048
#include <stdio.h>

int main(void) {
    int a[3], i;
    for(i = 0; i < 3; ++i) { scanf("%d", &a[i]); }
    if(a[0] == a[1] && a[1] == a[2]) { printf("Yes\n"); }
    else { printf("No\n"); }
    return 0;
}

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

int main() {
  long long a, b, temp;
  long long c, d;
  cin >> a >> b;
  c = a;
  d = b;
  if(a < b){
    temp = a;
    a = b;
    b = temp;
  }
  
  while(a % b != 0){ /* calc gcd(a,b) */
    temp = b;
    b = a % b;
    a = temp;
  }
  long long lcm = c*d / b; /* lcm(a,b) == a*b/gcd(a,b) */
  cout << lcm << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int m=in.nextInt();
			int tmp=m;
			int ans=0;
			if((n|m)==0)
				return;
			boolean[] a=new boolean[n+1];
			Arrays.fill(a, true);
			a[tmp]=false;
			for(;;)
			{
				int cn=0;
				int j=0;

				for(;;)
				{
					if(tmp+1>n)
						tmp=0;
					if(a[++tmp])
						cn++;
					if(cn==m)
						break;
				}
				a[tmp]=false;
				ans=tmp;
				
				for(int k=1;k<a.length;k++)
				{

					if(a[k])
					{
						j=0;
						break;
					}
					j=1;
				}		
				if(j==1)
					break;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAXN 10005
#define MAXM 1000005
int n,m;
struct Edge
{
	int id;
	double val;
	Edge *nxt;
	Edge(){nxt=NULL;}
	Edge(int i,double v){id=i;val=v;nxt=NULL;}
}E[MAXM],*V[MAXN],*cur;
void add_edge(int x,int y,double val)
{
	*cur=Edge(y,val);
	cur->nxt=V[x];
	V[x]=cur++;
	*cur=Edge(x,val);
	cur->nxt=V[y];
	V[y]=cur++;
}
struct cmp
{
	bool operator () (Edge *a,Edge *b)
	{return a->val<b->val;}
};
bool used[MAXN];
double Prim(int s)
{
	double ans=0;
	priority_queue<Edge*,vector<Edge*>,cmp>Q;
	used[s]=1;
	for(Edge *p=V[s];p;p=p->nxt)
		if(!used[p->id])
			Q.push(p);
	while(!Q.empty())
	{
		Edge *t=Q.top();
		Q.pop();
		if(used[t->id])
			continue;
		ans+=t->val;
		used[t->id]=1;
		for(Edge *p=V[t->id];p;p=p->nxt)
			if(!used[p->id])
				Q.push(p);
	}
	return ans;
}
pair<int,int>pile[MAXN];
double dis(int a,int b)
{
	return sqrt((pile[a].first-pile[b].first)*(pile[a].first-pile[b].first)+
	(pile[a].second-pile[b].second)*(pile[a].second-pile[b].second));
}
int main()
{
	int N,M;
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)
		scanf("%d%d",&pile[i].first,&pile[i].second);
	cur=E;
	double sum=0;
	for(int j=1,p,q;j<=M;j++)
	{
		scanf("%d%d",&p,&q);
		double tmp=dis(p,q);
		add_edge(p,q,tmp);
		sum+=tmp;
	}
	for(int i=1;i<=N;i++)
		if(!used[i])
			sum-=Prim(i);
	printf("%.3lf\n",sum);
	return 0;
}

Measured memory_bytes: 26432
// https://atcoder.jp/contests/abc082/tasks/abc082_b
// B - Two Anagrams
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

// 文字列の比較
int comp_s(char a[], char b[]) {
    int i = 0;
    while (a[i] != '\0' || b[i] != '\0') {
        if (a[i] != b[i]) {
            return a[i] - b[i];
        }
        i++;
    }
    return 0;
}

// charバブルソート
void sort_c(char a[], int num) {
    int i, j, b;
    for (i = 0; i < num-1; i++) {
        for (j = 0; j < num-i-1; j++) {
            if (a[j] > a[j+1]) {
                b = a[j];
                a[j] = a[j+1];
                a[j+1] = b;
            }
        }
    }
}

// 逆ソート
void sort_c_r(char a[], int num) {
    int i, j, b;
    for (i = 0; i < num-1; i++) {
        for (j = 0; j < num-i-1; j++) {
            if (a[j] < a[j+1]) {
                b = a[j];
                a[j] = a[j+1];
                a[j+1] = b;
            }
        }
    }
}

int strlen_(char a[]) {
    int i = 0;
    while(a[i] != '\0') {
        i++;
    }
    return i;
}

int main(void) {
    char s[101];
    char t[101];
    int tn, sn;
    scanf("%s", s);
    scanf("%s", t);
    sn = strlen_(s);
    tn = strlen_(t);

    sort_c(s, sn);
    sort_c_r(t, tn);

    if (comp_s(s, t) < 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}


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

int main()
{
	ll n,d;
	cin >> n >> d;
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		ll x,y;
		cin >> x >> y;
		if(x*x+y*y<=d*d)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
ll n, m;
int main() {
	cin>>n>>m;
	if (m >= 2 * n) {
		ll det = m - 2 * n;
		cout<<n + det/4<<endl;
	} else {
		cout<<m/2<<endl;
	}
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = max({a+b, a-b, a*b});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#72c
import collections

N = int(input())
a_list = [int(e) for e in input().split()]

c = collections.Counter(a_list)

ans = 1

for number in sorted(c.items(), reverse=False):
    #print("######################")
    #print(number[0],":",number[1])
    #print(number[0]+1,":",c[number[0]+1])
    #print(number[0]-1,":",c[number[0]-1])
    if ans < c[number[0]-1] + number[1] + c[number[0]+1]:
        ans = c[number[0]-1] + number[1] + c[number[0]+1]
        
print(ans)

Measured memory_bytes: 16096
#include <stdio.h>

int main(void){

    int N = 0;
    scanf("%d", &N);
    N %= 10;

    if (N == 3){
        puts("bon");
    } else if (N == 0 || N == 1 || N == 6 || N == 8){
        puts("pon");
    } else {
        puts("hon");
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
/*
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
 */
    speed();
    ll x; cin >> x;
    ll p = 100, year = 0;
    while (p < x) {
        p += p / 100;
        year++;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
int gcd( int m, int n )
{
    // 引数に０がある場合は０を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    
    // ユークリッドの方法
    while( m != n )
    {
        if ( m > n ) m = m - n;
        else         n = n - m;
    }
    return m;
}
int main(){
    int n,k;
    cin>>n>>k;
    int a[100005];
    int mini=1000000000;
    int maxi=-1;
    for(int i=0; i<n; i++){
        cin>>a[i];
        mini=min(mini,a[i]);
        maxi=max(maxi,a[i]);
        if(a[i]==k){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    if(maxi<k){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    int key=a[0];
    if(n>1){
        key=gcd(a[0],a[1]);
        for(int i=2; i<n; i++){
            if(a[i]%key!=0){
                key=gcd(key,a[i]);
            }
        }
    }
        if(k%key!=0)cout<<"IMPOSSIBLE"<<endl;
    else cout<<"POSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 640
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long valid(long long n) {
	int geko = 0;
	while (n != 0) {
		if (n % 10 == 3) geko |= 1;
		if (n % 10 == 5) geko |= 2;
		if (n % 10 == 7) geko |= 4;
		n /= 10;
	}
	if (geko == 7) return 1;
	return 0;
}
int main() {
	queue<long long> hoget;
	hoget.push(0);
	long long n;
	cin >> n;
	long long ans = 0;
	while (hoget.empty() == false) {
		long long nya = hoget.front();
		hoget.pop();
		if (nya <= n) {
			ans += valid(nya);
			nya *= 10;
			for (int i = 3; i <= 7; i += 2) {
				hoget.push(nya + i);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,m;
int dis[100010];
int dp[100010];
int sum=0;
int ans=0x7fffffff;
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&dis[i]),dp[i]=abs(dis[i]);
	for(int i=0;i<=n;i++) if(dis[i]<0&&dis[i+1]>=0) {sum=i;break;}
	if(dis[n]<0) sum=n;
	for(int i=0;i<m;i++){
		if(sum<i) break;
		if(sum-i+m>n) continue;
		ans=min(ans,dp[sum-i+1]*2+dp[sum+m-i]);
		ans=min(ans,dp[sum-i+1]+dp[sum+m-i]*2);
	}
	if(sum>=m) ans=min(ans,dp[sum-m+1]);
	if(m+sum<=n) ans=min(ans,dp[m+sum]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		List<Integer> list = new ArrayList<>();
		Set<String> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}

		for (int a  : list) {
			if (a < 400) set.add("灰色");
			else if (a < 800) set.add("茶色");
			else if (a < 1200) set.add("緑色");
			else if (a < 1600) set.add("水色");
			else if (a < 2000) set.add("青色");
			else if (a < 2400) set.add("黄色");
			else if (a < 2800) set.add("橙色");
			else if (a < 3200) set.add("赤色");
			else if (a >= 3200) max++;
 		}

		max += set.size();

		if (set.size() == 0) {
			System.out.print(1 + " ");
			System.out.println(max);
		}else {
			System.out.print(set.size() + " ");
			System.out.println(max);
		}
		sc.close();
	}

}

Measured memory_bytes: 21716
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        Sieve sieve = new Sieve(n);
        
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += (long)sieve.factorCount[i] * i;
        }
        System.out.println(ans);
    }
}

class Sieve {
    int[] minFactor;    // 最小の素因数
    int[] factorCount;  // 約数の個数

    Sieve(int n) {
        minFactor = new int[n + 1];
        Arrays.fill(minFactor, -1);
        factorCount = new int[n + 1];
        Arrays.fill(factorCount, 1);
        
        for (int i = 2; i <= n; i++) {
            // // 素数でないなら篩をかけない
            // if (minFactor[i] != -1) continue;
            
            factorCount[i]++;
            
            // 自分の倍数の最小の素因数を自分とする
            // (但し未確定の数に限る)
            for (int j = 2; i * j <= n; j++) {
                factorCount[i * j]++;
            }
        }
    }
    
    boolean isPrime(int x) {
        if (minFactor[x] == x) {
            return true;
        }
        
        return false;
    }
    
    // nの素因数のリスト (60 => [2, 2, 3, 5])
    List<Integer> factorList(int x) {
        List<Integer> res = new ArrayList<Integer>();
        
        while (x != 1) {
            res.add(minFactor[x]);
            x /= minFactor[x];
        }
        
        return res;
    }
    
    // nの素因数の頻度 (60 => (2 => 2, 3 => 1, 5 => 1)
    Map<Integer, Integer> factorMap(int x) {
        Map<Integer, Integer> res = new HashMap<Integer, Integer>();
        
        List<Integer> factorList = factorList(x);
        
        for (Integer f : factorList) {
            int count = res.getOrDefault(f, 0);
            res.put(f, ++count);
        }
        
        // for (int i = 1; i <= x; i++) {
        //     if (!res.containsKey(i)) {
        //         res.put(i, 0);
        //     }
        // }
        
        return res;
    }
}

Measured memory_bytes: 116116
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	rep(snip_i, n) cin >> l.at(snip_i);
	sort(l.begin(), l.end());
	
	ll ans = 0;
	rrep(i, n){
		int a = l.at(i);
		for(int j = i-1; j > 0; j--){
			int b = l.at(j);
			int cc = a - b;
			int n_c = upper_bound(l.begin(), l.end(), cc) - l.begin();
			// cerr << a << " " << b << " " << n_c << endl;
			if(n_c == n) continue;
			if(n_c < j){
				ans += (j-n_c);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

X=input().split()

for i in range(M):
	X[i] = int(X[i])

X.sort()

kyori = []
for i in range(M-1):
	kyori += [0]

for i in range(M-1):
	kyori[i] = X[i+1] - X[i]

kyori.sort()


sumkyori=0
for i in range(M-N):
	sumkyori += kyori[i]

print(sumkyori)

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int n,m; cin >> n >> m;
  vector<string> a(n),b(m);
  for(int i=0; i<n; ++i) cin >> a.at(i);
  for(int i=0; i<m; ++i) cin >> b.at(i);

  for(int i=0; i<n-m+1; ++i) {
    for(int j=0; j<n-m+1; ++j) {
      if(a[i][j]==b[0][0]) {
      //if(i+m-1>=n || j+m-1>=n) continue;
        int ok=1;
        for(int k=0; k<m; ++k) {
          for(int l=0; l<m; ++l) {
            if(a[i+k][j+l]!=b[k][l]) {
              ok=0;
            }
          }
        }
        if(ok) drop("Yes");
      }
    }
  }
  cout << "No" << endl;

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3696
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right)/2;
    if (key == A[mid])return 1;
    if(key > A[mid])left = mid + 1;
    else if (key < A[mid])right = mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum =0;

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

  scanf("%d",&q);
  for (i=0;i<q;i++){
    scanf("%d", &k);
    if(binarySearch(k))sum++;
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2124
#include <cstdio>
#include <algorithm>

using namespace std;

int calc(int n) {
	int ans = 0;
	while(n >= 1) {
		ans += n%10;
		n/=10;
	}
	return ans;
}

int main() {
	int n;
	scanf("%d", &n);
	int j = 0;
	int mn = 0x3f3f3f3f;
	for (int i = 1; i < n; ++i) {
		j = n - i;
		mn = min(mn, calc(i)+calc(j));
	}
	printf("%d\n", mn);
	
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (s[s.length() - 1] == 's') {
            cout << s << "es" << "\n";
            break;
        } else {
            cout << s << "s" << "\n";
            break;
        }


    }


}




















Measured memory_bytes: 3652
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int i = 0;
        while(a > 0){
            a = a / b;
            i++;
        }
        System.out.println(i);

    }
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    int N; cin >> N;
    vector<int> h(N);
    rep (i, 0, N) {
        cin >> h[i];
    }

    vector<int> dp(N+1, INF);
    dp[0] = 0;
    for (int now = 0; now < N; ++now) {
        for (int next = now+1; next <= min(N, now+2); ++next) {
            dp[next] = min(dp[next], abs(h[now] - h[next])+dp[now]);
        }
    }

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 202000;
int T;
int n,l[MAXN],r[MAXN],k[MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> T;
  while(T--){
    cin >> n;
    int ans = 0;
    priority_queue<pair<int,int>> q;
    set<int> s,s1;
    int ll = 0, rr = 0;
    for(int i=1;i<=n;i++){
      cin >> k[i] >> l[i] >> r[i];
      ans+=min(l[i],r[i]);
      q.push({abs(l[i]-r[i]),i});
      // s.insert(i);
      if(l[i]>r[i])ll++;
      else if(r[i]>l[i])rr++;
    }
    for(int i=1;i<=ll;i++){
      s.insert(i);
    }
    for(int i=1;i<=rr;i++){
      s1.insert(n-i+1);
    }
    while(!q.empty()){
      pi cur = q.top();q.pop();
      if(!cur.fs)break;
      int i = cur.sc;
      if(l[i]>r[i]){
        auto it  = s.upper_bound(k[i]);
        if(it==s.begin())continue;
        it--;
        ans+=cur.fs;
        s.erase(it);
      }
      else {
        auto it = s1.upper_bound(k[i]);
        if(it==s1.end())continue;
        ans+=cur.fs;
        s1.erase(it);        
      }
    }
    cout<<ans<<endl;
  }


return 0;
}
///....


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

int main(){
  char word[1001][33];
  int cnt[1001],l[1001];
  char tmp[33];
  int len,num,i,j;
  int mod,max;

  num = 0;
  while(scanf(" %s ",tmp)!=EOF){
    len = strlen(tmp);

    for(i=0;i<num;i++){
      if(len!=l[i])continue;
      for(j=0;j<l[i];j++)
	if(tmp[j]!=word[i][j])break;
      if(j==l[i]){
	cnt[i]++;
	break;
      }
    }
    if(i==num){
      for(j=0;j<=len;j++)word[num][j] = tmp[j];
      l[num] = len;
      cnt[num] = 1;
      num++;
    }
  }
  mod = 0;
  max = 0;
  for(i=1;i<num;i++){
    if(cnt[mod]<cnt[i])mod = i;
    if(l[max]<l[i])max = i;
  }
  printf("%s %s\n",word[mod],word[max]);
  
  return 0;
}

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

int main(){
  int N,count;
  string A,B,C;
  cin >>N>>A>>B>>C;
  count = 0;
  
  for(int i=0;i<N;i++){
    if(A[i]==B[i] && B[i]==C[i]){
      count = count;
    }
    else if(A[i]!=B[i] && B[i]!=C[i] && C[i]!=A[i]){
      count = count+2;
    }
    else{
      count = count+1;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
import math

n = int(input())
theta = math.pi / 3
p1 = [0, 0]
p2 = [100, 0]


def kock(d, p1, p2):
    if d == 0:
        return

    sx = (2*p1[0] + p2[0]) / 3
    tx = (p1[0] + 2 * p2[0]) / 3
    sy = (2 * p1[1] + p2[1]) / 3
    ty = (p1[1] + 2 * p2[1]) / 3
    s = [sx, sy]
    t = [tx, ty]

    ux = (t[0] - s[0]) * math.cos(theta) - (t[1] - s[1]) * math.sin(theta) + sx
    uy = (t[1] - s[1]) * math.cos(theta) + (t[0] - s[0]) * math.sin(theta) + sy
    u = [ux, uy]

    kock(d - 1, p1, s)
    print("{0:.8f} {1:.8f}".format(*s))
    kock(d - 1, s, u)
    print("{0:.8f} {1:.8f}".format(*u))
    kock(d -1 ,u, t)
    print("{0:.08f} {1:.8f}".format(*t))
    kock(d - 1, t, p2)

if __name__ == '__main__':
    print("0.00000000 0.00000000")
    kock(n, p1, p2)
    print("100.00000000 0.00000000")

Measured memory_bytes: 7996
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int A, B, C, D;

int main()
{
	scanf("%d %d %d %d", &A, &B, &C, &D);
	int ans1 = A + B;
	int ans2 = C + D;

	if(ans1 > ans2)
	{
		printf("Left");
	}
	else if (ans1 < ans2)
	{
		printf("Right");
	}
	else
	{
		printf("Balanced");
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((c - a) * (c - b) < 0) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main()
{
    int A,B,C,X,Y,a,b,c;
    cin>>A>>B>>C>>X>>Y;
    int ans=(1<<31)-1;
    for(c=0;c<=200000;++c)
    {
        a=max(0,X-c/2);
        b=max(0,Y-c/2);
        ans=min(ans,a*A+b*B+c*C);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int a,b;
  int c,d;
  int e,f;
  e=1;f=a;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>c>>d;
    e=max(c,e);
    f=min(d,f);
  }
  cout<<max(0,f-e+1);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char op;
    int a,b;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }else if(op=='-'){
            printf("%d\n",a-b);
        }else if(op=='*'){
            printf("%d\n",a*b);
        }else if(op=='/'){
            printf("%d\n",a/b);
        }else{
        break;
        }
    }
    return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<string.h>
#include<vector>

using namespace std;

int main(){
	int n,m,q;
	cin >> n >> m >> q;
	
	int lr[500][500];
	memset(lr,0,sizeof(lr));
	for(int i = 0;i < m;i++){
		int l,r;
		cin >> l >> r;
		lr[l-1][r-1]++;
	}
	
	int cum[500][500];
	memset(cum,0,sizeof(cum));
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(j == 0){
				cum[i][j] = lr[i][j];
			}else{
				cum[i][j] = cum[i][j-1] + lr[i][j];
			}
		}
	}
	
	vector<int> ql,qr;
	for(int i = 0;i<q;i++){
		int l,r;
		cin >> l >> r;
		ql.push_back(l-1);
		qr.push_back(r-1);
	}
	
	for(int i = 0;i < q;i++){
		int ans = 0;
		for(int j = ql[i];j <= qr[i];j++){
			if(ql[i] == 0){
				ans += cum[j][qr[i]];
			}else{
				ans += cum[j][qr[i]] - cum[j][ql[i] - 1];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int h,n;
  cin >> h >> n;
  rep(i,n){
    int a;
    cin >> a;
    h-=a;
  }
  if(h<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

#define sz(x) int(x.size())
#define rep(i,x) for(int i=0; i<x; i++) 

typedef long long ll;

struct Edge {
  int from;
  int to;
  ll cost;
};

typedef std::vector<std::vector<Edge>> List;
typedef std::vector<Edge> Graph;


void check( List &G , std::vector<bool> &used, int start ) {
  used[start] = true;
  for(auto&& e : G[start]) {
    int n = e.to;
    if ( used[n] == true ) continue;
    used[n] = true;
    check( G , used, n );
  }
  return;
}


int main (void) {

  int N, M, P; std::cin >> N >> M >> P;

  List G(N), UG(N);

  rep(i, M) {
    int A, B, C; std::cin >> A >> B >> C;
    A--, B--; C -= P;
    G [A].push_back( {A, B, -C} );
    UG[B].push_back( {B, A, -C} );
  }

  std::vector<bool> list1(N, false), list2(N, false);
  check(  G, list1, 0   );
  check( UG, list2, N-1 );

  Graph Gr;
  rep(i, N) rep(j, sz(G[i]) ) {
    auto e = G[i][j];
    if ( list1[i] == true && list2[i] == true && 
         list1[e.to] == true && list2[e.to] == true ) {
      Gr.push_back( e );
    }
  }

  std::vector<ll> d(N, (1LL<<60));
  d[0] = 0;
  rep(i, N) rep(j, sz(Gr)) {
    auto e = Gr[j];
    if ( d[e.to] > d[e.from] + e.cost ) { 
      d[e.to] = d[e.from] + e.cost;
      if (i == N-1) {        
        std::cout << -1 << std::endl;
        return 0;
      }
    }
  }

  std::cout << std::max(0LL, -d[N-1]) << std::endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll ans = 0;
  if(a + b > c * 2){
    int minVal = min(x, y);
    ans += minVal * c * 2;
    x -= minVal;
    y -= minVal;
    if(a && a > c * 2){
      ans += c * x * 2;
    }else ans += x * a;
    if(b && b > c * 2){
      ans += c * y * 2;
    }else ans += y * b;
    cout << ans << endl;
  }else{
    ans += x * a;
    ans += y * b;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
// atcoder/abc148/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  string s, t;
  while (cin >> n >> s >> t) {
    for (int i = 0; i < n; ++i) {
      cout << s[i] << t[i];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            var H = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var links = new List<int>[N + 1];
            for (int i = 0; i < N + 1; i++) links[i] = new List<int>();
            for (int i = 0; i < M; i++)
            {
                var AB = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                links[AB[0]].Add(AB[1]);
                links[AB[1]].Add(AB[0]);
            }
            var result = 0;
            for (int i = 1; i < N + 1; i++)
            {
                var isHighest = true;
                var currentHeight = H[i-1];
                foreach (int h in links[i]) if (H[h - 1] >= currentHeight) isHighest = false;
                if (isHighest) result++;
            }
            Console.WriteLine(result);
        }
    }
}


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

#define ll long long
// const int mod = 1e9 + 7;
ll int INF = 1e17;



int mod;
vector<int> adj[100005];
ll int dp1[100005];
ll int dp2[100005];
vector<ll int> pre[100005];
vector<ll int> suf[100005];

void dfs1(int node, int pn)
{
  dp1[node] = 1;
  for(int i=0;i<adj[node].size();i++)
    if(adj[node][i] != pn)
    {
      dfs1(adj[node][i], node);
      dp1[node] = (dp1[node] * (1 + dp1[adj[node][i]])) % mod;
    }
  ll int prev=1, front=1;

  pre[node].resize(adj[node].size());
  suf[node].resize(adj[node].size());

  for(int i=0;i<adj[node].size();i++)
  {
    if(adj[node][i] != pn)
    {
      pre[node][i] = (prev * (1+dp1[adj[node][i]])) % mod;
      prev = pre[node][i];
    }
    pre[node][i] = prev;
  }

  for(int i=adj[node].size()-1;i>=0;i--)
  {
    if(adj[node][i] != pn)
    {
      suf[node][i] = (front * (1+dp1[adj[node][i]])) % mod;
      front = suf[node][i];
    }
    suf[node][i] = front;

  }
  return;
}


void dfs2(int node, int pn, int up)
{
  dp2[node] = (1 + up) % mod;

  for(int i=0;i<adj[node].size();i++)
    if(adj[node][i] != pn)
    {
      ll int mul = dp2[node];
      if(i != 0)
        mul = (mul * pre[node][i-1]) % mod;
      if(i != adj[node].size()-1)
        mul = (mul * suf[node][i+1]) % mod;

      dfs2(adj[node][i], node, mul);
    }
  return;
}


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

  int n, x, y;
  cin>>n>>mod;

  for(int i=0;i<n-1;i++)
  {
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  dfs1(1, -1);
  dfs2(1, -1, 0);

  for(int i=1;i<=n;i++)
    cout<<(dp2[i] * dp1[i]) % mod<<endl;

  return 0;
}


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

int main() {
	long N, M, x[100010], y[100010], mod=1000000007; cin >> N >> M;
	for(int i=0; i<N; ++i) cin >> x[i];
	for(int i=0; i<M; ++i) cin >> y[i];
	long XSUM=0, YSUM=0, mul, Int;
	for(int i=1; i<N; ++i){
	    mul=(i*(N-i))%mod, Int=(x[i]-x[i-1])%mod;
	    XSUM=(XSUM+Int*mul)%mod;
	}
	for(int i=1; i<M; ++i){
	    mul=(i*(M-i))%mod, Int=(y[i]-y[i-1])%mod;
	    YSUM=(YSUM+Int*mul)%mod;
	}
	cout << (XSUM*YSUM)%mod << endl;
	return 0;
}


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

int main() {
    int N, M;

    cin >> N >> M;

    int a[M], b[M];
    for (int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }

    
    for (int i = 1; i <= N; i++){
        int s = 0;
        for (int j = 0; j <= M; j++){
            if (a[j] == i){
                s++;
            }
            if (b[j] == i){
                s++;
            }
        }
        cout << s << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;

int main(){
    ios;
    int n; cin >> n;
    map<string,int> mp;
    mp["AC"] = 0; mp["WA"] = 0; mp["TLE"] = 0; mp["RE"] = 0;
    rep(i,n){
        string s; cin >> s;
        ++mp[s];
    }
    cout <<"AC x " << mp["AC"] << '\n';
    cout <<"WA x " << mp["WA"] << '\n';
    cout <<"TLE x " << mp["TLE"] << '\n';
    cout <<"RE x " << mp["RE"] << '\n';
    return 0;
}


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

int main(){
  string N;
  cin >> N;
  int Nsize = N.size();
  int ans = 0;
  if (Nsize<3){
    cout << 0 << endl;
    return 0;
  }
  for (int i=1; i<=Nsize-2; i++){
    for (int j=1; j<=Nsize-i-1; j++){
      for (int k=1; k<=Nsize-i-j; k++){
        // cout << i << ' ' << j << ' ' << k << endl;
        string S = "";
        for (int I=0; I<i; I++) S += '3';
        for (int J=0; J<j; J++) S += '5';
        for (int K=0; K<k; K++) S += '7';
        do {
          // cout << S << endl;
          if (S.size() < Nsize) ans++;
          else {
            int s = stoi(S);
            int n = stoi(N);
            if (n>=s) ans++;
          }
        } while(next_permutation(S.begin(), S.end()));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k;
int a[5000];
int sum;
int c;

int main(){

  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>a[i];

  sort(a,a+n);
  reverse(a,a+n);
  c = n;
  for(int i=0;i<n;i++){
    if(sum+a[i]<k) sum+=a[i];
    else
      c=n-i-1;
  }

  cout<<c<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,x,sum=0;
    cin>>n;
    vector<ll>v;
    for(i=0; i<n; i++)
    {
        cin>>x;
        if(x%10!=0) v.push_back(x);
        sum+=x;
    }
    if(v.size()==0&&sum%10==0)
   return  cout<<0<<endl,0;
   if(sum%10==0)
   sum-=*min_element(v.begin(),v.end());

    cout<<sum<<endl;
    return 0;
}





Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc, char *argv[])
{
    int values[100];
    int n;
    scanf("%d", &n);
    for (int *elm = values, *const end = elm + n; elm != end; ++elm)
    {
        scanf("%d", elm);
    }
    for (int *elm = values + n - 1, *const end = values - 1; elm != end; --elm)
    {
        printf("%d%c", *elm, elm == values ? '\n' : ' ');
    }
    return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if(N >= 3 && M >= 3) ans = (N - 2) * (M - 2);
    else if(N == 2 || M == 2) ans = 0;
    else if(N == 1 || M == 1){
        ll a = min(N, M);
        ll b = max(N, M);
        ans = fabs(b - 2);
    }
    cout << ans << endl;
    return 0;

}

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

int main() {

    int N,K;
    cin >> N >>K;
    vector<int>A(N),dp(N+1,INF),jump(K,0);
    for (int i = 0; i < N; i++) { cin >> A[i]; }
    dp[0]=0;
    dp[1]=max(A[0],A[1])-min(A[1],A[0]);
    for(int i=0;i<N;i++){
      for(int j=1;j<=K;j++){
        if(i+j<=N){
        jump[j]=max(A[i],A[i+j])-min(A[i],A[i+j]);
        if(dp[i+j]>dp[i]+jump[j]) dp[i+j]=dp[i]+jump[j];
        }
      }
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a[10000];
int main()
{
	long long n,m=1000,g=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<n;i++)
	{
		if(a[i+1]>a[i])
		{
			g+=m/a[i];
			m%=a[i];
		}
		if(a[i+1]<a[i])
		{
			m+=g*a[i];
			g=0;
		}
	}
	cout<<m+g*a[n];
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int N;
string s;
string t;
int main() {
  cin >> N;
  cin >> s >> t;
  int k = 0;
  for (int i=0; i<s.length(); i++) {
    bool f = true;
    for (int j=0; j<min(s.length() - i, t.length()); j++) {
      if (s[i+j] != t[j]) {
        f = false;
        break;
      }
    }
    if (f) {
      k = s.length() - i;
      break;
    }
  }
  cout << max(N, (int)(s.length() + t.length()) - k) << "\n";
  return 0;
}



Measured memory_bytes: 256
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));

		while (true) {
			String line = br.readLine();
			int N = Integer.parseInt(line);
			if (N == 0) {
				return;
			}

			int myScore = 0;
			int yourScore = 0;

			for (int i = 0; i < N; i++) {
				String readLine = br.readLine();
				readLine = readLine.trim();
				String[] readLineArray = readLine.split(" ");
				int mine = Integer.parseInt(readLineArray[0]);
				int yours = Integer.parseInt(readLineArray[1]);

				if (mine < yours) {
					// you win
					yourScore += mine + yours;
				} else if (mine > yours) {
					// i win
					myScore += mine + yours;
				} else {
					// draw
					myScore += mine;
					yourScore += yours;
				}
			}
			System.out.printf("%d %d\n", myScore, yourScore);
		}
	}
}

Measured memory_bytes: 43572
#include<bits/stdc++.h>
using namespace std;
int m;
int arr[1<<20];
int memo[1<<20];
int solve(int n){
    if(memo[n]!=-1)return memo[n];
    if(n==0)return 0;
    int ans=INT_MAX;
    for(int i=1;i<=m;++i){
       if(n-arr[i]>=0) ans=min(ans,1+solve(n-arr[i]));
    }
    return memo[n]=ans;
}
int main(){
    int n;cin>>n>>m;
    for(int i=1;i<=m;++i)
        cin>>arr[i];
    memset(memo,-1,sizeof memo);
    cout<<solve(n)<<endl;
    return 0;
}

Measured memory_bytes: 9652
#include <stdio.h>

int main()
{
    int H,W;
    for (;;) {
        scanf("%d %d", &H, &W);

        if ((H == 0)&&(W == 0))
            break;

        int i,j,check;
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                check = (i + j) % 2;
                if (check == 0) {
                    printf("#");
                } else if (check == 1) {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return(0);
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end() 
#define MOD 1000000007
#define N 200005
#define pll pair<ll,ll>
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll dp1[N][3],dp2[N][2],a[N],n;
ll solve1(ll id,ll taken)
{
     if(id==n+1 && taken==0)
     {
          return -1e18;
     }
     if(id==n+2 && taken==1)
     {
          return -1e18;
     }
     if(id>=n)    return 0;
     ll ans = dp1[id][taken];
     if(ans!=-1)    return ans;
     ans = -1e18;
     if(taken<=1)
     {
          ans = max(ans,a[id]+solve1(id+3,taken+1));
     }
     ans = max(ans,a[id]+solve1(id+2,taken));
     return dp1[id][taken] = ans;
}
ll solve2(ll id,ll taken)
{
     if(id>=n)   return 0;
     ll ans = dp2[id][taken];
     if(ans!=-1)    return ans;
     ans = -1e18;
     if(taken==0)
     {
          ans = max(ans,a[id]+solve2(id+3,1));
     }
     ans = max(ans,a[id]+solve2(id+2,taken));
     return dp2[id][taken] = ans;
}
void solve()
{ 
     cin >> n;
     for(ll i=0;i<n;i++)   cin >> a[i];
     if(n%2)
     {
          memset(dp1,-1,sizeof(dp1));
          memset(dp2,-1,sizeof(dp2));
          ll ans = solve2(1,0);
          ll sum = 0;
          for(ll i=2;i<n;i+=2)    sum += a[i];
          ans = max(ans,sum);
          sum = 0;
          ll ele = 0;
          for(ll i=0;i<n;i+=2)
          {
               ele++;
               sum += a[i];
               if(ele==n/2)     break;
          }
          ans = max(ans,sum);
          ll ans1 = solve1(0,0);
          ans = max(ans,ans1);
          cout<<ans;
     }
     else
     {
          memset(dp2,-1,sizeof(dp2));
          ll ans = solve2(0,0);
          ll sum = 0;
          for(ll i=1;i<n;i+=2)     sum += a[i];
          ans = max(ans,sum);
          cout<<ans;
     }
}
int main()
{
     FAST;
     ll t = 1;
  ///   cin >> t;
     while(t--)
     {     
          solve();
     }
}

Measured memory_bytes: 19232
n = int( input() )
a = list( map( int, input().split() ) )

cnt = [ 0 ] + [ 0 ] * n

for a_i in  a:
    cnt[a_i] += 1

all_combi = 0
for m in cnt:
    all_combi += m * ( m - 1 ) // 2

for k in range( 1, n+1 ):
    print( all_combi - ( cnt[a[k-1]] - 1 ) )

Measured memory_bytes: 25644