akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define maxn 1000006
int spf[maxn];
void seive(){
	for(int i = 0; i<maxn; i++){
		spf[i] = i;
	}
	for(int i = 2; i<=sqrt(maxn); i++){
		if(spf[i]==i){
			for(int j = i*i; j<maxn; j+=i){
				spf[j] = i;
			}
		}
	}
}
void solve(){
	int n;
	cin>>n;
	int a[n];
	map<int,int> m;
	for(int i = 0; i<n; i++){
		cin>>a[i];
		if(a[i]>1){
			int d = a[i];
			while(d>1){
				int s = spf[d];
				m[s]++;
				while(d%s==0) d/=s;
			}
		}
	}
	bool f = true;
	for(auto kvp : m){
		if(kvp.ss != 1){
			f = false;
			break;
		}
	}
	if(f){
		cout<<"pairwise coprime\n";
		return;
	}
	int g = a[0];
	for(int i = 1; i<n; i++){
		g = gcd(g,a[i]);
	}
	if(g==1){
		cout<<"setwise coprime\n";
	}
	else cout<<"not coprime\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	seive();
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


Measured memory_bytes: 24044
#include<bits/stdc++.h>
#define ll                    long long int
#define ull                   unsigned long long int
#define vll                   vector<long long int>
#define loop(i,a,b) 		  for(ll i=(ll)a;i<(ll)b;++i)
#define pb                    push_back
#define ii					  pair<int, int> 
#define vii					  vector<ii>
#define vvi					  vector<vector<int>> 
#define pi                    acos(-1.0)
#define MOD                   1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void f_io(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
struct Interval 
{ 
    int val, idx; 
}; 
  
// Compares two intervals according to staring times. 
bool compareInterval(Interval i1, Interval i2) 
{ 
    return (i1.val < i2.val); 
}


int main(){ 
    f_io();
        ll t,n,w,a,k,x,m;
 
    cin>>n>>m>>k;
    set <pair<int,int>> s,s1;
    map <int,int>r,c;
    int arr[k][2];
    for(int i=0;i<k;i++){
        cin>>arr[i][0]>>arr[i][1];
        r[arr[i][0]]++;
        s.insert(make_pair(arr[i][0],arr[i][1]));

    }
    for(int i=0;i<k;i++){
        c[arr[i][1]]++;
        s1.insert(make_pair(arr[i][0],arr[i][1]));
    }
    int mx=0,left;
    for(auto it=r.begin();it!=r.end();it++){
        if(mx<it->second)
            {mx=it->second;
                left=it->first;
            }
    }
    int ans=0;
    for(auto it=c.begin();it!=c.end();it++){
        if(s.find(make_pair(left,it->first))==s.end()){
            ans=max(mx+it->second,ans);
        }
        else{
              ans=max(mx+it->second-1,ans);
        }
    }
     mx=0;
     int right;
    for(auto it=c.begin();it!=c.end();it++){
        if(mx<it->second)
            {mx=it->second;
                right=it->first;
            }
    }

    for(auto it=r.begin();it!=r.end();it++){
        if(s1.find(make_pair(it->first,right))==s1.end()){
            ans=max(mx+it->second,ans);
        }
        else{
              ans=max(mx+it->second-1,ans);
        }
    }




    cout<<ans;


   

}



    
    
    

        




    




      







   





         
    

Measured memory_bytes: 62212
Q = int(input())
mod = 10**6+3
arr = []
for i in range(Q):
    arr.append(list(map(int, input().split())))

P = [1]*(mod+1)
for i in range(mod):
    P[i+1] = P[i]*(i+1)%mod

def rev(a):
    return pow(a,mod-2,mod)

def f(x, d, n):
    if d == 0:
        return pow(x, n, mod)
    else:
        d_r = rev(d)
        xdr = d_r * x % mod 
        if xdr == 0:
            return 0
        elif (xdr+n-1) >= mod:
            return 0
        else:
            return (P[xdr+n-1] * rev(P[xdr-1])%mod) * pow(d,n,mod)%mod

for i in range(Q):
    print(f(arr[i][0], arr[i][1], arr[i][2]))

Measured memory_bytes: 72924
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    int n,m;
    
    cin>>n>>m;
    
    int r;
    int s=1;
   for(int i=0;i<m;i++){
         s=s*2;
   }
   cout<<(100*(n-m)+1900*m )*s<<endl;    
  
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    int a,b;
    scanf("%d%d",&a,&b);
    if(a+b==15)
		puts("+");
	else if(a*b==15)
		puts("*");
	else
		puts("x");
	return 0;
}
 

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.math.BigDecimal;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        int D=sc.nextInt();
        int E=sc.nextInt();

        if(A==0){
            System.out.println("1");
        }else if(B==0){
            System.out.println("2");
        }else if(C==0){
            System.out.println("3");
        }else if(D==0){
            System.out.println("4");
        }else{
            System.out.println("5");
        }




        //END
    }
}




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

int H,W,px,py,dp[45][45][45][45],sum[45][45];
char S[45][45];

void upd(int &x,int y){
	if(x>y)x=y;
}

int calc(int a,int b,int c,int d){
	if(a>c||b>d)return 0;
	return sum[c][d]-sum[a-1][d]-sum[c][b-1]+sum[a-1][b-1];
}

int main(){
	scanf("%d%d",&H,&W);
	for(int i=1;i<=H;++i){
		scanf("%s",S[i]+1);
		for(int j=1;j<=W;++j){
			sum[i][j]=sum[i][j-1]+(S[i][j]=='#');
			if(S[i][j]=='P')
				px=i,py=j;
		}
	}
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
			sum[i][j]+=sum[i-1][j];
	memset(dp,0x3f,sizeof dp);
	dp[1][1][H][W]=0;
	int ans=H*W;
	for(int a=1;a<=px;++a)
	for(int b=1;b<=py;++b)
	for(int c=H;c>=px;--c)
	for(int d=W;d>=py;--d){
		if(dp[a][b][c][d]>H*W)continue;
		upd(ans,dp[a][b][c][d]+min({calc(a,b,px,py),calc(a,py,px,d),calc(px,b,c,py),calc(px,py,c,d)}));
		for(int x=px;x<=c;++x)
			for(int y=py;y<=d;++y)
				upd(dp[a][b][x][y],dp[a][b][c][d]+calc(x+1,b,c,y)+calc(a,y+1,x,d));
		for(int x=a;x<=px;++x)
			for(int y=b;y<=py;++y)
				upd(dp[x][y][c][d],dp[a][b][c][d]+calc(x,b,c,y-1)+calc(a,y,x-1,d));
		for(int x=px;x<=c;++x)
			for(int y=b;y<=py;++y)
				upd(dp[a][y][x][d],dp[a][b][c][d]+calc(a,b,x,y-1)+calc(x+1,y,c,d));
		for(int x=a;x<=px;++x)
			for(int y=py;y<=d;++y)
				upd(dp[x][b][c][y],dp[a][b][c][d]+calc(a,b,x-1,y)+calc(x,y+1,c,d));
	}
	printf("%d\n",ans);
	return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
  out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
  return print_tuple(out, t, int_<Pos-1>());
}

template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
  return out << get<tuple_size<Tuple>::value-1>(t);
}

template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
  return print_tuple(out, t, int_<sizeof...(Args)>());
}

#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";

//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

//OUTN
void OUTN() {}
template<class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

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

  VAR(i64, n, k);

  vector<i64> vec(100010);
  rep(i, n) {
    VAR(i64, a, b);
    vec[a] += b;
  }

  reps(i, 1, 100010) {
    k -= vec[i];
    if (k <= 0) {
      OUTL(i);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+')
	{
		cout<<a+b;
		return 0;
	}
	else
	{
		cout<<a-b;
		return 0;
	}
	return 0;
}

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

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(long long n, long long a, long long b)
{
    long long all = 0;
    long long num = n / (a + b);

    all = num * a;
    if(n - num * (a + b) > a) {
        all += a;
    } else {
        all += (n - num * (a + b));
    }

    printf("%lld\n", all);
}

int
main(int argc, char *argv[])
{
    long long N, A, B;
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    scanf("%lld%lld%lld", &N, &A, &B);
    solver(N, A, B);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int h,ans = 0,num = 1;
	cin >> h;
	while(h){
		ans += num;
		h /= 2;
		num *= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,x,y,z;
    scanf("%d %d",&A,&B);
    x=(A+B);
    y=(A-B);
    z=(A*B);
    if (x>=y&&x>=z)
    {
        printf("%d\n",x);
    }
    else if (y>=x&&y>=z)
        {
        printf("%d\n",y);
        }
    else
        {
        printf("%d\n",z);
        }
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;


template<int Modulus> 
struct ModInt {
    long long x;
    ModInt(long long x = 0) :x((x%Modulus + Modulus)%Modulus) {}
    constexpr ModInt &operator+=(const ModInt a) {if ((x += a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator-=(const ModInt a) {if ((x += Modulus - a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator*=(const ModInt a) {(x *= a.x) %= Modulus; return *this;}
    constexpr ModInt &operator/=(const ModInt a) {return *this *= a.inverse();}

    constexpr ModInt operator+(const ModInt a) const {return ModInt(*this) += a.x;}
    constexpr ModInt operator-(const ModInt a) const {return ModInt(*this) -= a.x;}
    constexpr ModInt operator*(const ModInt a) const {return ModInt(*this) *= a.x;}
    constexpr ModInt operator/(const ModInt a) const {return ModInt(*this) /= a.x;}
    
    friend constexpr ostream& operator<<(ostream& os,const ModInt<Modulus>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<Modulus>& a) {return is >> a.x;}
    
    ModInt inverse() const {// x ^ (-1) 
        long long a = x,b = Modulus,p = 1,q = 0;
        while (b) {long long d = a/b; a -= d*b; swap(a,b); p -= d*q; swap(p,q);}
        return ModInt(p);
    }
    ModInt pow(long long N) {// x ^ N 
        ModInt a = 1;
        while (N) {
            if (N&1) a *= *this;
            *this *= *this;
            N >>= 1;
        }
        return a;
    }
};

using mint = ModInt<1000000007>;

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

    string s; cin >> s;
    int N = s.size();
    vector<vector<mint>> dp(N + 1,vector<mint>(13,0));
    dp[0][0] = 1;
    rep(i,N) {
        rep(j,13) {
            if (s[i] == '?') {
                rep(k,10) {
                    dp[i + 1][(j*10 + k)%13] += dp[i][j];
                } 
            } else dp[i + 1][(j*10 + s[i] - '0')%13] += dp[i][j];
        }
    }
    cout << dp[N][5] << '\n';
    return 0;
}

Measured memory_bytes: 16660
#include <iostream>

using namespace std;

void func(){
	int A[100];
	int N, temp;
	int count = 0;
	bool flag = 1;

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];

	for (int j =0; flag; j++) {
		flag = 0;

		for (int i = N - 1; i >= j + 1; i--) {
			if (A[i] < A[i - 1]) {
				swap(A[i], A[i - 1]);
				flag = 1;
				count++;
			}
		}
	}

	for (int i = 0; i < N; i++){
if(i) cout << " ";
		cout << A[i];
}
	cout << endl;
	cout << count << endl;
}

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


Measured memory_bytes: 3096
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

class City implements Comparable<City>{
    int p;
    int y;
    String id;

    City(int p, int y) {
        this.p = p;
        this.y = y;
    }

	@Override
	public int compareTo(City o) {
		return this.y - o.y;
	}

    
}

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        HashMap<Integer, ArrayList<City>> map = new HashMap<Integer, ArrayList<City>>();
        ArrayList<City> ansList = new ArrayList<City>();

        for (int i = 0; i < M; i++ ) {
            int p = sc.nextInt();
            int y = sc.nextInt();
            City c = new City(p, y);
            map.putIfAbsent(p, new ArrayList<City>());
            map.get(p).add(c);
            ansList.add(c);
        }

        for (int i = 0; i <= N; i++ ) {
            if (map.containsKey(i)) {
                ArrayList<City> list = map.get(i);
                list.sort(Comparator.naturalOrder());
                for (int j = 0; j < list.size(); j++ ) {
                    list.get(j).id = String.format("%06d%06d", i, j + 1);
                }
            }
        }

        ansList.stream().forEach(c -> System.out.println(c.id));

        sc.close();
    }

}

Measured memory_bytes: 181912
N,M=map(int,input().split())
H=list(map(int,input().split()))
HL=[1]*N
ML=[list(map(int, input().split())) for _ in range(M)]
for m in ML:
    a=m[0]
    b=m[1]
    ah=H[a-1]
    bh=H[b-1]
    if ah > bh:
        HL[b-1]=0
    elif bh > ah:
        HL[a-1]=0
    else:
        HL[a-1]=0
        HL[b-1]=0
print(HL.count(1))

Measured memory_bytes: 31856
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

LL change_div_mul_mod(LL divisor, LL mod_minus_2, LL mod){
    if(mod_minus_2 == 0) return 1;
    else if(mod_minus_2 % 2 == 0){
        LL d = change_div_mul_mod(divisor, mod_minus_2/2, mod);
        return (d * d) % mod;
    }else{
        return (divisor * change_div_mul_mod(divisor, mod_minus_2-1, mod)) % mod;
    }
}

//#define int long long

/*************** using variables ***************/
int n, t;
vector<LL> a, sa, max_num;
/**********************************************/

signed main(){
    cin >> n >> t;
    a.resize(n); sa.resize(n); max_num.resize(n);

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

    t = t - t%2;
    
    max_num[n-1] = a[n-1];
    for(int i = n-2; i >= 0; i--){
        max_num[i] = max(max_num[i+1], a[i]);
    }
/*
    REP(i, n){
        cout << max_num[i] << " ";
    }
    cout << endl;
*/
    REP(i, n-1){
        sa[i] = max_num[i] - a[i];
    }
    LL max_sa = 0;
    REP(i, n-1){
        max_sa = max(max_sa, sa[i]);
    }

    int cnt = 0;
    REP(i, n-1){
        if(max_sa == sa[i]) cnt++;
    }

    cout << cnt << endl;

}


Measured memory_bytes: 2560
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')




# for _ in range(ii()):
    





n,k=mi()
a=li()
a.sort()
print(sum(a[:k]))














Measured memory_bytes: 67436
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N;
    int a[3333];
    cin >> N;
    int i;
    for(i=0;i<=N-1;i++)
        cin >> a[i];
    int sum = 0;
    for(i=0;i<=N-1;i++)
        sum = sum + a[i];
    sum -= N;
    cout << sum << endl;
}


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

int main(){
    int N;
    int K;
    int h[100000];

    int c[100000];

    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        c[i] = INT_MAX;
    }
    c[0] = 0;

    for(int i = 1; i < N; i++){
        for(int j = 1; j <= K; j++){
            if(i - j >= 0){
                c[i] = min(c[i], c[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }

    cout << c[N - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>

using namespace std;

int main(){
  string s = "arrows";
  string AI;
  map<string,bool> judge;

  judge[s] = true;

  while(true){
    cout << "?" << s << endl;
    cin >> AI;

    if(s[s.size()-1] != AI[0] || judge[AI]){
      cout << "!OUT" << endl;
      break;
    }
    judge[AI] = true;

    s[0] = AI[AI.size()-1];
   
    for(int i = 1 ; i < (int)s.size() ; i++){
      if(s[i] < 'z'){
	s[i]++;
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1256
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
struct L
{
    int x, y, p, ans;
    bool operator<(const L &__Val) const
    {
        return x < __Val.x;
    }
} a[200005];
int n, fa[200005], mex, siz[200005];
bool vis[200005];
int find(int now)
{
    return now == fa[now] ? now : fa[now] = find(fa[now]);
}
bool cmpp(const L &A, const L &B)
{
    return A.p < B.p;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i].x >> a[i].y;
        a[i].p = i;
        fa[i] = i;
    }
    sort(a + 1, a + 1 + n);
    mex = n;
    for (int i = 1; i <= n; ++i)
    {
        while (vis[mex])
        {
            --mex;
        }
        vis[a[i].y] = true;
        if (mex == n - i + 1)
        {
            continue;
        }
        fa[i] = find(i - 1);
    }
    for (int i = 1; i <= n; ++i)
    {
        ++siz[find(i)];
    }
    for (int i = 1; i <= n; ++i)
    {
        a[i].ans = siz[find(i)];
    }
    sort(a + 1, a + 1 + n, cmpp);
    for (int i = 1; i <= n; ++i)
    {
        cout << a[i].ans << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 13172
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
 
using ll = long long int;
 
int main(){
    vector<int> a(3);
    in_arr(int, a, 3);
    int ret = 0;
    repi(i, a) {
        ret += *i;
    }
    if(ret <= 21){
        cout << "win" << endl;
    } else{
        cout << "bust" << endl;
    }
    return 0;
}


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

map < long long, int > m;

int main(){
	int n; cin >> n;
	m[0]++;
	long long res = 0, now = 0;
	for(int i = 0 ; i < n ; i++){
		int x; cin >> x;
		now += x;
		res += m[now];
		m[now]++;
	}
	cout << res << endl;
}
/*
6
1 3 -4 2 2 -2
*/

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

vector<vi> al;

void search(vi a, int lef) {
    if (lef == 0) {
        al.pb(a);
        return;
    }
    FOR(i,1,lef+1) {
        vi A = a; A.pb(i);
        search(A,lef-i);
    }
}

vector<vi> get(int sum) {
    al.clear();
    search({},sum);
    return al;
}

array<int,33808> cur, tmp;
map<vi,int> m;
bool done[33808];
int nex[33808][11];

ll ad(ll a, ll b) { return (a+b)%MOD; }
ll mul(ll a, ll b) { return a*b%MOD; }

int N,X,Y,Z; 
    
void solve() {
    F0R(i,sz(m)) FOR(j,1,11) tmp[nex[i][j]] = ad(tmp[nex[i][j]],cur[i]);
    F0R(i,sz(m)) {  cur[i] = tmp[i]; tmp[i] = 0; }
}

void gen() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> X >> Y >> Z;
    vector<vi> a = get(X), b = get(Y), c = get(Z);
    vector<vi> al;
    for (auto x: a) for (auto y: b) for (auto z: c) {
        vi res = {}; 
        res.insert(res.end(),all(x));
        res.insert(res.end(),all(y));
        res.insert(res.end(),all(z));
        al.pb(res);
    }
    for (auto t: al) {
        vi T;
        F0R(i,sz(t)+1) {
            if (!m.count(T)) {
                int z = sz(m);
                m[T] = z;
            }
            if (i != sz(t)) T.pb(t[i]);
        }
        done[m[T]] = 1;
    }
    for (auto& a: m) {
        if (done[a.s]) {
            FOR(i,1,11) nex[a.s][i] = a.s;
        } else {
            FOR(i,1,11) {
                vi A = a.f; A.pb(i);
                while (!m.count(A)) A.erase(A.begin());
                nex[a.s][i] = m[A];
                // cout << nex[a.s][i] << "\n";
            }
        }
    }
    // cout << sz(m) << "\n";
}

int main() {
    gen();
    cur[0] = 1;
    F0R(i,N) solve();
    int ans = 0;
    F0R(i,sz(m)) if (done[i]) ans = ad(ans,cur[i]);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 7356
#include<stdio.h>
#define MAX 100000

int partition(int ,int);
int A[MAX];
int main(){
  int i,n,q;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  q=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }
  printf("\n");

  
  return 0;
}

int partition(int p,int r){
  int i,j,x,k;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
    i++;
    k=A[i];
    A[i]=A[j];
    A[j]=k;
  }
}
k=A[i+1];
A[i+1]=A[r];
A[r]=k;
return i+1;
}



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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (bit & (1LL << i))

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

    int M, N;
    cin >> M >> N;
    V<int> P(M), C(N), E(N);
    FOR(i, 0, M) {
        cin >> P[i];
    }
    sort(RALL(P));

    FOR(i, 0, N) {
        cin >> C[i] >> E[i];
    }

    VV<int> dp(M + 1, V<int>(N + 1, 0));
    FOR(i, 0, M) {
        FOR(j, 0, N) {

            int c = C[j];
            int e = E[j];

            // not use
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);

            // use
            int m = 0;
            FOR(k, i, min(M, i + c)) {
                m += P[k];
            }
            dp[min(M, i + c)][j + 1] = max(dp[min(M, i + c)][j + 1], dp[i][j] - e + m);
        }
    }

    int ans = 0;
    FOR(i, 0, dp.size()) {
        FOR(j, 0, dp[0].size()) {
            ans = max(ans, dp[i][j]);
        }
    }
    print(ans);


}


Measured memory_bytes: 22920
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0006
	Reverse Sequence
*/

#include <stdio.h>
int main(void)
{
	char str[30];
	scanf("%s",str);

	/* ????????????????????¢??? */
	int i = 0;
	while(str[i] != '\0'){
			i++;
	}

	int j;
	for (j = i - 1; j >= 0; j--){
		printf("%c", str[j]);
	}

	printf("\n");
	return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, c;

	cin >> n >> c;

	vector<vector<ll>> d(c, vector<ll>(c));
	vector<vector<ll>> v(n, vector<ll>(n));
	vector<vector<ll>> vv(3, vector<ll>(c, 0));

	REP(i, c) {
		REP(j, c) {
			cin >> d[i][j];
		}
	}

	REP(i, n) {
		REP(j, n) {
			cin >> v[i][j];
			vv[(i + j) % 3][v[i][j] - 1]++;
		}
	}

	ll now;
	ll ans = INF;

	REP(i, c) {
		REP(j, c) {
			REP(k, c) {
				if (i == j || j == k || k == i) {
					continue;
				}

				now = 0;

				REP(l, c) {
					now += d[l][i] * vv[0][l];
					now += d[l][j] * vv[1][l];
					now += d[l][k] * vv[2][l];
				}

				ans = min(ans, now);
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	String a=scan.next();
	String b=scan.next();
	String ans="";
	for(int i=0;i!=a.length()+b.length();i++) {
		char ch=' ';
		if(i%2==0) {
			ch=a.charAt(i/2);
		}
		else {
			ch=b.charAt(i/2);
		}
		ans+=ch;
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  // ABC113B - Palace
  // pairの一要素で並び替え、他方の要素を表示する場合はこれ
  double T, A; cin >> T >> A;
  vector<pair<double, int> > t;
  REP(i, N){
    int tmp; cin >> tmp;
    t.push_back({abs(A-(T-tmp*0.006)), i});
  }
  sort(t.begin(), t.end()); // sortはfirstで判断される
  cout << t[0].second + 1 << endl; // 表示はsecond
}


Measured memory_bytes: 256
# Code for B - Tag
# Use input() to fetch data from STDIN
[A, V] = map(int, input().split())
[B, W] = map(int, input().split())
T = int(input())

if B > A:
    if ( A + V * T ) >= ( B + W * T ):
        print("YES")
    else:
        print("NO")
else:
    if ( A - V * T ) <= ( B - W * T ):
        print("YES")
    else:
        print("NO")


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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N);
  
  long long x=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    x ^= A[i];
  }
  
  for(int i=0;i<N;i++) cout << (x^A[i]) << " ";
  return 0;
}


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

using namespace std;

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> a(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    
    long long count = 0;
    for (size_t i = 0; i < N; i+=2)
    {
        if (a[i]%2 == 1)
        {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  char s[101];
  scanf("%s",s);
  int c=0,m=strlen(s);
  qsort(s,m,sizeof(s[0]),strcmp);
  for(int i=0;i<m-1;i++){
    if(s[i]==s[i+1])c++;
    else if(c%2)c=0;
    else {
      puts("No");
      return 0;
    }
  }
  if(m==1)puts("No");
  else puts("Yes");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> v[n];
    for(int i = 0; i < n; i++){
        int m;  cin >> m;
        while(m-- > 0){
            int x;  cin >> x;
            v[i].push_back(x);
        }
    }
    priority_queue<int> q;
    ll ans = 0;
    for(int i = n-1; i >= 0; i--){
        for(int x : v[i])   q.push(x);
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19400
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]

T.sort()

cur = T[0]
p = 0
cnt = 1

for t in T:
    p += 1
    if t > cur + K or p > C:
        cur = t
        p = 1
        cnt += 1
        
print(cnt)

Measured memory_bytes: 7384
S = input()
if ord(S[0]) != 65:
    print("WA")
    exit()
num = 0
for i in range(2,len(S)-1):
    if S[i] == "C":
        num = i
if not num:
    print("WA")
    exit()
else:
    for j in range(1,len(S)):
        if j != num:
            if 97 <= ord(S[j]) <= 122:
                continue
            else:
                print("WA")
                exit()
print("AC")

Measured memory_bytes: 9140
S = input()
T = input()
L = []

for i in range(len(S)-len(T)+1) :
    for j in range(len(T)) :
        if S[i+j] not in ("?", T[j]) :
            break
    else :
        l = S[:i]+T+S[i+len(T):]
        l = l.replace("?","a")
        L.append(l)
if L :
    print(min(L))
else :
    print("UNRESTORABLE")


Measured memory_bytes: 3060
import java.io.*;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    void solve() {
        int X = in.nextInt();
        int Y = in.nextInt();
        int Z = in.nextInt();
        int useful = X - Z;
        int block = Y + Z;
        out.println(useful/block);

    }

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
#define NODE (100)
#define INF (100000000)

int U[NODE];
int dist[NODE];
int prev[NODE];
int cost[NODE][NODE];
int V;

void dijkstra(int s)
{
	int i, j;
	int v;
	
	dist[s] = 0;
	prev[s] = 0;
	
	for (i = 0; i < V; i++){
		U[i] = 1;
	}
	
	for (i = 0; i < V; i++){
		v = -1;
		
		for (j = 0; j < V; j++){
			if (U[j] == 1 && (v == -1 || dist[v] > dist[j])){
				v = j;
			}
		}
		
		if (v == -1){
			break;
		}
		
		U[v] = 0;
		
		for (j = 0; j < V; j++){
			if ((dist[j] > dist[v] + cost[v][j]) && U[j] == 1){
				dist[j] = dist[v] + cost[v][j];
				prev[j] = v;
			}
		}
	}
}

int main(void)
{
	int i, j;
	int n;
	int from, to, m;
	int max, min, min_t, sum;
    char defined[20][20];
	while (1){
		scanf("%d", &n);
		if (n == 0){
            break;
		}
        max = 0;
        memset(defined, 0, sizeof(defined));
		while (n-- != 0){
			scanf("%d%d%d", &from, &to, &m);
            if (from > max){
                max = from;
            }
            if (to > max){
                max = to;
            }
			cost[from][to] = cost[to][from] = m;
            defined[from][to] = defined[to][from] = 1;
		}
        V = max + 1;
        
        for (i = 0; i < V; i++){
			for (j = 0; j < V; j++){
                if (!defined[i][j]){
                    cost[i][j] = INF;
                }
			}
			dist[i] = INF;
		}
        
        min = INF;
        for (i = 0; i < V; i++){
    		dijkstra(i);
            sum = 0;
            for (j = 0; j < V; j++){
                sum += dist[j];
                dist[j] = INF;
            }
            if (sum < min){
                min = sum;
                min_t = i;
            }
        }
		
		printf("%d %d\n", min_t, min);
	}
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n, s[334], sum = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> s[i];
		sum += s[i];
	}
	sort(s, s + n);
	if (sum % 10 != 0)cout << sum << endl;
	else for (int i = 0;i < n;i++) {
		if (s[i] % 10 != 0) {
			cout << sum - s[i] << endl;
          	break;
		}
      	if(i==n-1)cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    cout << N * (N - 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

parent = [i + 1 for i in range(n)]
rank = [0 for i in range(n)]
size = [1 for i in range(n)]

def find(x):
    if parent[x - 1] == x:
        return x
    else:
        parent[x - 1] = find(parent[x - 1])
        return parent[x - 1]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x - 1] < rank[y - 1]:
        parent[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        parent[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1

for i in range(m):
    a, b = map(int, input().split())
    unite(a, b)
print(max(size))

Measured memory_bytes: 94292
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

int main(void) {
    LL N;
    cin >> N;

    vector<LL> A(N);
    rep(i, N) cin >> A[i];

    map<LL, LL> stick_length_num_hash;
    rep(i, N) { stick_length_num_hash[A[i]]++; }

    vector<LL> length_of_usable_stick;
    for(auto kv : stick_length_num_hash) {
        if(kv.second >= 2) {
            length_of_usable_stick.push_back(kv.first);
        }
        if(kv.second >= 4){
            length_of_usable_stick.push_back(kv.first);
        }
    }

    sort(RALL(length_of_usable_stick));

    if(length_of_usable_stick.size() < 2) {
        cout << 0 << endl;
    } else {
        cout << length_of_usable_stick[0] * length_of_usable_stick[1] << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  // cerr << fixed << setprecision(10);

  int n, d;
  cin >> n >> d;

  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> x[i][j];
    }
  }

  int cnt = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      double dist = 0.0;
      for (int k = 0; k < d; ++k) {
        dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      dist = sqrt(dist);
      // cerr << floor(dist) << "=" << dist << ", ";
      if (floor(dist) == dist) {
        ++cnt;
      }
    }
    // cerr << '\n';
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string s;cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  

Measured memory_bytes: 256
import sys

def main():
    N, M, X = map(int, input().split())
    C_A_list = [[int(_) for _ in input().split()] for i in range(N)]

    bit = 1 << N
    INF = float('inf')
    min_price = INF
    for i_bit in range(bit):
        price = 0
        understand_list = [0] * M
        for j_N in range(N):
            if i_bit & (1 << j_N) == 0:
                continue

            price += C_A_list[j_N][0]
            for i, i_A in enumerate(C_A_list[j_N][1:]):
                understand_list[i] += i_A

        for i_understand in understand_list:
            if i_understand < X:
                break
        else:
            min_price = min(min_price, price)

    if min_price == INF:
        print(-1)
    else:
        print(min_price)  

    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 68800