akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
	int n,k,h[200010];
	long long sum=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	sort(h,h+n);
	for(int i=0;i<n-k;i++){
		sum+=h[i];
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll k;
			string s;
			cin>>k>>s;
			if(s.size()<=k)
			cout<<s;
			else
			{
				s=s.substr(0,k);
				cout<<s<<"...";
			}
			
			
			return 0;
		 }	


Measured memory_bytes: 3640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M; cin >> N >> M;

    vector< vector<int> > G(N);
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    vector<int> dist(N, INF), dir(N);
    dist[0] = 0;
    queue<int> que;
    que.emplace(0);
    while(que.size()) {
        int u = que.front(); que.pop();
        for(auto v : G[u]) {
            if(dist[v] > dist[u] + 1) {
                dist[v] = dist[u] + 1;
                dir[v] = u;
                que.emplace(v);
            }
        }
    }

    puts("Yes");
    for(int i=1; i<N; i++) printf("%d\n", dir[i] + 1);
    return 0;
}


Measured memory_bytes: 10652
#include<iostream>
using namespace std;
#define m long long
#define d(s,i,n) for(m i=s;i<n;i++)
#define z else
m l[90][90],r[90][90];
int main(){m n;cin>>n;d(0,i,89){l[i][0]=1,r[i][0]=1;d(1,j,90){if(i==j)r[i][j]=r[i][j-1]*2+l[i][j-1];z r[i][j]=r[i][j-1]+l[i][j-1];l[i][j]=r[i][j-1];}}d(0,i,n){m a,b; cin>>a>>b;if(b>a)swap(a,b);m k=0;d(0,j,90)if(a>=r[0][j]&&b>=l[0][j])k=j;m g;if(k==0)k=1,g=1;z if(k==1)if(b==1)g=a;z g=4;z{g=1;if(b>=r[0][k]&&a>=l[0][k]&&l[0][k]!=r[0][k])g++;d(1,j,k+1)if(r[j][k]<=a&&l[j][k]<=b)g+=1+(a-r[j][k])/l[j][k];d(1,j,k+1)if(r[j][k]<=b&&l[j][k]<=a)g+=1+(b-r[j][k])/l[j][k];}cout<<k<<" "<<g%1000000007<<" ";}}	

Measured memory_bytes: 4448
#include <stdio.h>

int main()
{
  int h,i,j,d,K;

  scanf("%d",&h);

  int data[h];
  
  for(i=0; i<h; i++){
    scanf("%d",&data[i]);
  }

   for(i=1; i<h+1; i++){
     K= data[i];
     j = i-1;

     for(d=0; d<h-1; d++){
       printf("%d ",data[d]);
     }
     printf("%d",data[h-1]);
     printf("\n");

     while(j>=0 && data[j] >K){
       data[j+1]=data[j];
       j--;
       data[j+1]=K;
     }
   }
   return 0;
}
  



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

int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;

if(x+r<=H&&x-r>=0&&y+r<=H&&y-r>=0){
	cout<<"Yes"<<endl;
}
else{
	cout<<"No"<<endl;
}

return 0;
}


Measured memory_bytes: 3100
// abc132_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int div(int n)
{
    int i,c=1;
    for(i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            c++;

    }
    return c*2;


}
int main()
{
    int n,c,i;
    scanf("%d",&n);
    if(n<105)
    {
        printf("0\n");
    }
    else if(n==105)
        printf("1\n");
    else
    {
        c=1;
        for(i=107; i<=n; i+=2)
        {
            if(div(i)==8)
                c+=1;

        }
        printf("%d\n",c);


    }
    return 0;
}


Measured memory_bytes: 128
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool f = true;
    int ans = 0;
    int ct = 0;
    bool th = 0;
    while(f){
        if(ct%2 ==1){
            if(a>d) a-=d;
            else {
                f = false;
                th = 1;
            }
        }else{
            if(c>b) c-=b;
            else {
                f = false;
            }
        }
        ct++;
    }
    if(!th) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

long n,a,b,c,ans=999999999999999,aa,bb,cc;
vector<long> l(8);
vector<long> k(300);
vector<long> x(300,-1);

int main() {
  cin >> n >> a >> b >> c;
  for(long i=0;i<n;i++) cin >> l[i];

  for(long bit=1;bit<(1<<n);bit++) {
    for(long i=0;i<n;i++) {
      if(bit & (1<<i)) {
        k[bit]+=l[i];
        x[bit]++;
      }
    }
  }
  for(long i1=1;i1<(1<<n);i1++) {
    aa=labs(k[i1]-a)+x[i1]*10;
    for(long i2=1;i2<(1<<n);i2++) {
      if((i1&i2)>0) continue;
      bb=labs(k[i2]-b)+x[i2]*10;
      for(long i3=1;i3<(1<<n);i3++) {
        if((i1&i3)>0||(i2&i3)>0) continue;
        cc=labs(k[i3]-c)+x[i3]*10;
        ans=min(ans,aa+bb+cc);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
int x = N * (N - 1)/2;
int T = 0;
for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
        T+=(A.at(i)*A.at(j));
}
}
cout << T << endl;
}


Measured memory_bytes: 256
o = str(input().split())
e = str(input().split())

ans = ""

if len(o) == len(e):
    for i in range(len(o)):
        ans += o[i] + e[i]
else:
    for i in range(len(o)-1):
        ans += o[i] + e[i]
    
    ans += o[len(o)-1]

print(ans[4:-4])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}
ll const M=1e9+7;
ll const mx=2e3;
int main(){
	Speed_UP
  ll s;
  cin>>s;
  ll dp[s+1];
  fill(dp,dp+s+1,0);
  dp[0]=1;
  for(int i=1;i<=s;i++){
    for(int j=3;j<=mx;j++){
      if(i-j>=0){
        dp[i]+=(dp[i-j])%M;
        dp[i]%=M;
      }
    }
  }
  cout<<dp[s]%M;

}


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

int main()
{
  int N, K, S;
  cin >> N >> K >> S;
  vector<int> A(N);
  for (int i = 0; i < K; ++i)
    A[i] = S;
  for (int i = K; i < N; ++i)
    A[i] = ((1000000000 != S) ? S + 1 : 999999999);
  cout << A[0];
  for (int i = 1; i < N; ++i)
    cout << " " << A[i];
  return 0;
}


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

int main(){
    int x[5];
    for(int j=0;j<5;j++) cin >> x[j];
    for(int i=0;i<5;i++) if(x[i] != i+1) cout << i+1 << endl;
    return 0;
    
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  const double d = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  printf("%.8f\n", d);
  return 0;
}

Measured memory_bytes: 3240
n = int(input())
A = [int(i) for i in input().split()]

DP = [[0] * n for i in range(n)]
if n % 2 == 1:
    for i in range(n):
        DP[i][i] = A[i]
else:
    for i in range(n):
        DP[i][i] = -A[i]

for i in range(1, n):
    for l in range(n-i):
        if (n - i) % 2 == 1:
            DP[l][l+i] = max(DP[l+1][l+i] + A[l], DP[l][l+i-1] + A[l+i])
        else:
            DP[l][l+i] = min(DP[l+1][l+i] - A[l], DP[l][l+i-1] - A[l+i])

print(DP[0][n-1])

Measured memory_bytes: 112988
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n,s=0;
  cin>>n;
  vector<int> d(n);
  for(int i = 0;i<n;i++) cin>>d.at(i);

  for(int i=0;i<n-1;i++){
    for(int j = i+1;j<n;j++){
      s+=d.at(i)*d.at(j);
    }
  }
  cout<<s<<endl;
}

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

using namespace std;

int main(){

	char c;

	cin >> c ;

	if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')

		cout << "vowel"<< endl;
	

	else
		cout << "consonant" << endl;
}	

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

int main(void){
    vector<int> v;
    int n, a[200010];
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    cout << a[n-1];
    int i;
    for(i=n-3;i>=0;i = i-2){
        cout << " " << a[i];
    }
    int start = 1;
    if(i%2!=0) start = 0;
    for(int i=start;i<n;i = i+2){
        cout << " " << a[i];
    }
    cout << endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N;
	cin>>N;
	int A[MAX];
	int odd=0;
	rep(i,N){
		cin>>A[i];
		if(A[i]%2==1) odd++;
	}
	if(odd%2==0)cout<<"YES";
	else cout<<"NO";
}

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

int main(){
	int N,M;
	cin>>N>>M;
	int ans[50]={0};
	int point;
	for(int i=0;i<M;i++){
		cin>>point;
		ans[point]++;
		cin>>point;
		ans[point]++;
	}
	for(int i=1;i<=N;i++){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int ans=0;
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                for(int l=0;l<10;l++){
                    for(int m=0;m<10;m++){
                        if(j+k+l+m==n){
                            ans++;
                        }
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1172
h,w,n=map(int,input().split())
black=[tuple(map(int,input().split())) for _ in range(n)]
sblack=set(black)
ans=[0]*10
for a,b in black:
    for x in range(3):
        for y in range(3):
            cnt=0
            ok=True
            for nx,ny in [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]:
                dx,dy=nx-x,ny-y
                if 1<=a-dx<=h and 1<=b-dy<=w:
                    if (a-dx,b-dy) in sblack:
                        cnt+=1
                else:
                    ok=False
                    break
            if ok:
                ans[cnt]+=1
for i in range(1,10):
    ans[i]//=i
ans[0]=(h-2)*(w-2)-sum(ans[1:])
for num in ans:
    print(num)

Measured memory_bytes: 97812
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2], D = ip[3];
	ulong k;
	while(true) {
		if(k % 2 == 0) {
			if(C - B <= 0) {
				writeln("Yes");
				return;
			}
			C -= B;
		}
		else {
			if(A - D <= 0) {
				writeln("No");
				return;
			}
			A -= D;
		}
		k++;
	}	
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	lli n, k, pref[200005], ans = 0;
	map<lli, lli> peta;
	scanf("%lld %lld", &n, &k);
	peta[0] = 1;
	pref[0] = 0;
	for (lli i = 1; i <= n; i++) {
		if (i >= k)
			peta[pref[i - k]]--;
		scanf("%lld", &pref[i]);
		pref[i] = (pref[i] + pref[i - 1] - 1) % k;
		if (peta.count(pref[i]) > 0) {
			ans += peta[pref[i]];
			peta[pref[i]]++;
		}
		else
			peta[pref[i]] = 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 14336
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define pb(x)                   push_back((x))
#define pb2(x,y)                push_back({x,y})
#define pb3(x,y,z)              push_back({x,y,z})
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define dbg(a)                  cout<<#a <<" --> "<<(a)<<endl;
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace std;
using                           namespace __gnu_pbds;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;





main(){
//read;

ll a,b,c;
cin>>a>>b>>c;

ll x = c-a-b;
bool fl = 1;
if(x<=0)    fl = 0;
else if(4*a*b>=x*x) fl = 0;
puts(fl ? "Yes" : "No");


return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int solve(vector<int> a,int n){

    vector<int> dp(n+1);
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++)
    {
        int op1=abs(a[i]-a[i-1])+dp[i-1];
        int op2=abs(a[i]-a[i-2])+dp[i-2];
        dp[i]=min(op1,op2);
    }
    return dp[n];
}
 int main()
 {
 	#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// online submission
#endif


    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    cout<<solve(a,n)<<endl;


}
 	
 

Measured memory_bytes: 4560
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mk make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	a[0] = 0;
	FOR(i,1, n+1) {
		int c = INF;
		int i6=1;
		while (i6 <= i) {
			c = min(c, a[i - i6]);
			i6 *= 6;
		}
		int i9 = 1;
		while (i9 <= i) {
			c = min(c, a[i - i9]);
			i9 *= 9;
		}
		a[i] = c + 1;
	}
	cout << a[n] << endl;
	return 0;
}



Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int NUM_MAX = 200000;

int main()
{
	int n, m;
	cin >> n >> m;

	int num;
	if (m % 2 != 0) {
		if (n % 2 != 0) {
			num = n / 2;
		} else {
			num = n / 2 - 1;
		}
	} else {
		if (n % 2 != 0) {
			num = n / 2 - 1;
		} else {
			num = n / 2 - 1;
		}
	}

	int cnt = 0;
	int start = 0;
	int end = num;
	while (cnt < m) {
		cout << start + 1 << " " << end + 1 << endl;
		start++;
		end--;
		if (start >= end) {
			start = num + 1;
			if (n % 2 != 0) {
				end = n - 1;
			} else {
				end = n - 2;
			}
		}
		cnt++;
	}

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define lowbit(x) (x&-x)
using namespace std;
const int N = 57, p = 1e9+7;
int n;
ll a[N][N];
void mul(ll a[N][N], ll b[N][N])
{
	ll c[N][N];
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			c[i][j] = 0;
			for(int k = 1; k <= n; k++)
			{
				c[i][j] = (c[i][j]+a[i][k]*b[k][j])%p;
			}
		}
	}
	memcpy(a, c, sizeof(c));
	return;
}
ll qpow(ll x[N][N], ll k)
{
	ll ret = 0, res[N][N] = {0};
	for(int i = 1; i <= n; i++)
	{
		res[i][i] = 1;
	}
	while(k)
	{
		if(k&1)
		{
			mul(res, x);
		}
		k >>= 1;
		mul(x, x);
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			ret = (ret+res[i][j])%p;
		}
	}
	return ret;
}
int main()
{
	ll k;
	scanf("%d%lld", &n, &k);
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	printf("%lld\n", qpow(a, k));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

stack<int>s;
char ch[11];

int main()
{
    while(cin>>ch)
    {
        if(ch[0] != '+' && ch[0] != '-' && ch[0] != '*')
            s.push(atoi(ch));
        else if(ch[0] == '+')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a+b);
        }
        else if(ch[0] == '-')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(b-a);
        }
        else if(ch[0] == '*')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a*b);
        }
    }
    cout << s.top() << endl;
    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;
using  ull = unsigned long long int;

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


int main() {

	string str;
	cin >> str;

	bool flag = false;

	rep(i, 0, str.length()) {

		if (str[i] == '9')flag = true;

	}

	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,double,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,1,N)P[i]=(P[i]+P[i-1])/2;
  HpOut(P[N-1]);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int mod=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%mod;
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int n;
	string s[2*M];
	cin>>n;
	rep(i,0,n)cin>>s[i];
	sort(s,s+n);
	int ans=1;
	rep(i,1,n)
		if(s[i-1]!=s[i])ans++;
	print(ans);



}


Measured memory_bytes: 16240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() * sc.nextInt();
		int b = sc.nextInt() * sc.nextInt();
		if(a >= b) System.out.println(a);
		else System.out.println(b);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <string>
#include <queue>
using namespace std;
#pragma warning (disable: 4996)

int H, W, A[88][88], B[88][88], S[88][88];
bool dp[88][88][25601];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cin >> A[i][j];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cin >> B[i][j];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) S[i][j] = abs(A[i][j] - B[i][j]);
	}

	dp[0][0][12800 + S[0][0]] = true;
	dp[0][0][12800 - S[0][0]] = true;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k <= 25600; k++) {
				if (dp[i][j][k] == false) continue;

				if (i + 1 < H) {
					dp[i + 1][j][k + S[i + 1][j]] = true;
					dp[i + 1][j][k - S[i + 1][j]] = true;
				}
				if (j + 1 < W) {
					dp[i][j + 1][k + S[i][j + 1]] = true;
					dp[i][j + 1][k - S[i][j + 1]] = true;
				}
			}
		}
	}

	int ret = (1 << 30);
	for (int i = 0; i <= 25600; i++) {
		if (dp[H - 1][W - 1][i] == true) ret = min(ret, abs(12800 - i));
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 175232
N = int(input())
if N ==1 or N == 0:
    print(0)
else:
    ans = 0
    if N%2 == 1:
        print(0)
    else:
        i = 1
        while True:
            ans += N//(2*(5**i))
            i += 1
            if N//(2*(5**i)) == 0:
                break
        print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int L, R, D, ca, t;
    cin >> L >> R >> D;
    ca=R/D-L/D;
    t=L/D;
    t*=D;
    if(L==t)ca++;
    cout << ca << endl;
    // Your code here!
    
}


Measured memory_bytes: 3632
import math
S = input()
ans = 0
i = 0
while i < len(S):
    c = 1
    while i < len(S) -1 and S[i] == S[i+1]:
        c += 1
        i += 1
    if c % 3 == 2 and i < len(S) -1:
        c += 1
        i += 1
    ans += ( c // 3 ) * 2 + math.ceil( c % 3 / 3 )
    i += 1
print(ans)


Measured memory_bytes: 73988
#include<bits/stdc++.h>
using namespace  std;
void sieve(int spf[],int mx){
    spf[1] = 1;
    for(int i=2;i<=mx;i++){
        spf[i] = i ;
    }
    for(int i = 4;i<=mx;i+=2)
        spf[i] = 2;
    for(int i = 3;i*i<=mx;i++){
        
        if(spf[i]==i){
            for(int j = i*i;j<=mx;j+=i){
                if(spf[j] == j){
                    spf[j] = i;
                }
            }
        }
    }
}
int main(){
    int n;
    cin>>n;

    int a[n];
    int mx =0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        mx = max(mx,a[i]);
    }
    int spf[mx+1];
    sieve(spf,mx);
    map<int,int> mp;
    int f = 0;
    for(int i=0;i<n;i++){
        int x =a[i];
       // cout<<x<<endl;
        while(x!=1){
            if(mp[spf[x]]>0){
                
                f=1;
                break;
            }
            mp[spf[x]]++;
            int d =spf[x];
            while(x%d==0)
                x=x/d;
           
        }
        if(f==1)
        break;
    }
    
    int z = a[0];
    for(int i=1;i<n;i++)
        z= __gcd(z,a[i]);
    if(f==0)
    cout<<"pairwise coprime"<<endl;
    else if(z==1)
    cout<<"setwise coprime"<<endl;
    else{
        cout<<"not coprime"<<endl;
    }

}

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

//int from[1009];

int main()
{ 
  ll dp[100009];
  for(int i=1;i<=100005;i++)
    dp[i] = 10000000000000ll;
  ll w[109];
  int v[109];
  dp[0]= 0;
  int n;
  ll cap;
  ll sum = 0;
  cin >> n >> cap; 
  for(int i=0;i<n;i++){
    cin >> w[i] >> v[i];
    sum = sum + v[i]; 
  }
  //cout << sum << endl;
  for(int i=0;i<n;i++){

      int current = sum - v[i];
      for(int j = current; j>=0;j--){
        int index = j + v[i];
          //cout << j << " " << dp[index] << " " << dp[j]+w[i] << endl;
        dp[index] = min(dp[index],dp[j]+w[i]);
      
      }
      
      //cout << endl;
    
  }

  int ans = 0;
  for(int i=0;i<=sum;i++){
    if(dp[i]<=cap)
      ans = max(i,ans);
  }
  cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll f(ll n){
    if(n<0)return -1e9;
    return n - n%2;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a[7];for(ll i=0;i<7;i++)cin>>a[i];
    cout<<a[1] + max(f(a[0])+f(a[3])+f(a[4]) , f(a[0]-1) + f(a[3]-1) + f(a[4]-1) + 3);
}



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

char a[3][3];
int main() {
	while (cin >> a[0][0], a[0][0] != 48) {
		rep(i, 3)rep(j, 3)if (i || j)cin >> a[i][j];
		rep(i, 3) {
			if (a[i][0] == a[i][1] && a[i][1] == a[i][2] && a[i][0] != '+') {
				cout << a[i][0] << endl;
				goto p;
			}
			if (a[0][i] == a[1][i] && a[1][i] == a[2][i] && a[0][i] != '+') {
				cout << a[0][i] << endl;
				goto p;
			}
		}
		if (a[0][0] == a[1][1] && a[1][1] == a[2][2] && a[0][0] != '+') {
			cout << a[0][0] << endl;
			goto p;
		}
		if (a[0][2] == a[1][1] && a[1][1] == a[2][0] && a[0][2] != '+') {
			cout << a[0][2] << endl;
			goto p;
		}
		puts("NA");
	p:;
	}
}

Measured memory_bytes: 3040
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo 100000000000000000
const ll dx[]={-1,0,1, 0,-1,1, 1,-1};
const ll dy[]={ 0,1,0,-1, 1,1,-1,-1};
ll n;
ll a[81];

void solve(){
    cin>>n;
    fo(i,n)cin>>a[i];
    ll ans = 1000;
    fo(i,n){
        ll mini = a[i];
        ll j = i+1;
        while(j<n&&a[j]<=mini){
            mini = min(mini,a[j]);
            j++;
        }
        if(j==n)break;
        ll val = ans/mini;
        ll k = ans%mini;
        val = val*a[j];
        val+=k;
        ans = max(ans,val);
        i = j-1;
    }
    cout<<ans;
}

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


Measured memory_bytes: 3644
n,k=list(map(lambda x:int(x),input().split()))

a = [0] * n
for w in range(k):
    d = int(input())
    ds = list(map(lambda x:int(x),input().split()))
    for i in ds:
        a[i-1] = 1

print(len(list(filter(lambda x:x==0,a))))



Measured memory_bytes: 9192
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100], b[100], c[100];
    scanf("%s %s %s", a, b, c);
    int l1, l2, l3;
    l1 = strlen(a);
    l2 = strlen(b);
    l3 = strlen(c);
    if(a[l1-1] == b[0] && b[l2-1] == c[0])
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int H,A[MAX+1];

struct Node{int key;
Node *right, *left, *parent;};
Node *root, *NIL;

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

void maxHeapify(int i){
    int l,r,largest;
    l = 2*i;
    r = 2*i+1;
    
    if(l <= H && A[l] > A[i])largest = l;
    else largest = i;
    if(r <= H &&A[r] > A[largest])largest = r;
    
    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
};

int extract(){
    int mavx;
    if(H < 1)return -INFTY;
    mavx = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return mavx;
}

void increaseKey(int i, int key){
    if(key < A[i])return;
    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        swap(A[i],A[i/2]);
        i = i/2;
    }
}

void insert(int key){
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main(){
    int key;
    char com[10];
    while(1){
    cin >> com;
    if(com[0] == 'e' && com[1] == 'n')break;
    if(com[0] == 'i'){
        cin >> key;
        insert(key);
    }else cout << extract() << endl;
    }
    return 0;
}






Measured memory_bytes: 6912
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
    
    int n;
    cin >> n;
    unordered_map<size_t, size_t> mp;
    vector<size_t> a(n);
    for (size_t i = 0; i < n; ++i) {
        cin >> a[i];
        ++mp[a[i]];
    }
    size_t calc = 0;
    for (const auto& x : mp) {
        if (x.second > 1)
            calc += (x.second * (x.second - 1)) / 2;
    }

    for (size_t k = 0; k < n; ++k) {
        size_t res = calc - (mp[a[k]] * (mp[a[k]] - 1)) / 2;
        if (mp[a[k]] > 2) {
            res += ((mp[a[k]] - 1) * (mp[a[k]] - 2)) / 2;
        }
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 9644
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,k=MI()
    r,s,p=MI()
    t=S()
    ans=0
    ns=""
    for i in range(k):
        if t[i]=="r":
            ans+=p
            ns+="p"
        if t[i]=="p":
            ans+=s
            ns+="s"
        if t[i]=="s":
            ans+=r
            ns+="r"
    for i in range(k,n):
        if t[i]=="r" and ns[i-k]=="p":
            ns+="1"
            ans+=0
        if t[i]=="r" and ns[i-k]!="p":
            ns+="p"
            ans+=p
        if t[i]=="p" and ns[i-k]=="s":
            ns+="1"
            ans+=0
        if t[i]=="p" and ns[i-k]!="s":
            ns+="s"
            ans+=s
        if t[i]=="s" and ns[i-k]=="r":
            ns+="1"
            ans+=0
        if t[i]=="s" and ns[i-k]!="r":
            ns+="r"
            ans+=r
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 4336
#include<stdio.h>
int main(void){
	
	int m,f,r,sum;
	
	for(;;){
		
		scanf("%d %d %d",&m,&f,&r);
		
		sum=m+f;
		
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		else if(m==-1||f==-1){
			printf("F\n");
		}
		else if(sum>=80){
			printf("A\n");
		}
		else if(sum>=65&&sum<80){
			printf("B\n");
		}
		else if(sum>=50&&sum<65){
			printf("C\n");
		}
		else if(sum>=30&&sum<50){
			if(r>=50){
				printf("C\n");
			}
			else{
				printf("D\n");
			}
		}
		else{
			printf("F\n");
		}
		
	}
	
	return 0;
}


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

const int INF = 2147483647;
int dp[1001][10001];

int main() {

	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	rep(i, N + 1) {
		rep(j, H) {
			dp[i][j] = INF;
		}
	}

	rep(i, N){
		for (int j = H - 1; j >= 0; j--) {
			if(j + A[i] >= H )
			{
				dp[i + 1][j] = min(dp[i][j], B[i]);
			}
			else
			{
				dp[i + 1][j] = min(dp[i][j], dp[i + 1][j + A[i]] + B[i]);
			}

		}
	}
	cout << dp[N][0] << endl;


	return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
 
#define DEBUG(x)        do { std::cerr << #x << " = " << x << std::endl;  } while(0)
#define DEBUGV(x)       for(auto e : x) { std::cerr << e << " "; }; cout << endl;
#define INFO(msg)       do { std::cerr << msg << std::endl; } while(0)
#define ll              long long
#define vi              vector<int>
#define pii             pair<int, int>
#define fori(i, s, e)   for(int i = s; i < e; i++)
#define ford(i, s, e)   for(int i = s; i >= e; i--)
 
using namespace std;

const int N = 200010;
vi link(N + 1), sz(N + 1, 1);

void init() {
    iota(link.begin(), link.end(), 0);
    sz.resize(N + 1, 1);
}

int find(int x) {
    while(x != link[x]) x = link[x];
    return x;
}

bool same(int a, int b) {
    return find(a) == find(b);
}

void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(same(a, b)) return;
    if(sz[a] < sz[b]) swap(a, b);
    sz[a] += sz[b];
    link[b] = a;
}

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

    init();
    int n, m;
    cin >> n >> m;

    fori(i, 0, m) {
        int x, y;
        cin >> x >> y;
        unite(x, y);
    }

    int ans = 0;
    fori(i, 1, n + 1) ans = max(sz[i], ans);
    cout << ans << endl;

    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[3 * n];
        for (int i = 0 ; i < 3 * n ; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        long ans = 0;
        for (int i = 0 ; i < n ; i++) {
            ans += (long) a[i * 2 + n];
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 91616
from  fractions import gcd
N=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
ans=1
for i in range(N-1):
    R.append(gcd(R[-1], A[-1-i]))
    L.append(gcd(L[-1], A[i]))
print(max(gcd(l,r)for l,r in zip(L,R[::-1])))

Measured memory_bytes: 16112
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  alias T=long;
  const inf=1e9.to!(T);
  struct Edge{int to; T cost;}
  int n; rd(n);
  auto g=new Edge[][](n);
  foreach(i; 0..n){
    auto args=readln.split.to!(int[]);
    foreach(j; 0..args[1]){
      g[i]~=Edge(args[j*2+2], args[j*2+3]);
    }
  }
  T[] dijkstra(Edge[][] g, int s){
    auto d=new T[](n);
    fill(d, inf);
    struct P{int v; T d;}
    import std.container;
    // auto Q=new RedBlackTree!(P, "a.d<b.d", true);
    auto Q=new MyBinaryHeap!(P, "a.d<b.d");
    Q.insert(P(s, 0)); d[s]=0;
    while(Q.empty==false){
      auto cur=Q.front; Q.removeFront;
      foreach(e; g[cur.v]){
        if(d[e.to]<=d[cur.v]+e.cost) continue;
        d[e.to]=d[cur.v]+e.cost;
        Q.insert(P(e.to, d[e.to]));
      }
    }
    return d;
  }

  auto d=dijkstra(g, 0);
  foreach(i; 0..n) writeln(i, " ", d[i]);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}

import std.functional : binaryFun;
class MyBinaryHeap(T, alias less = "a<b") if(is(typeof(binaryFun!less(T.init, T.init))))
{
  import std.exception : enforce;
  import std.algorithm : each, swap;
  import std.functional : binaryFun;

  private T[] dat;
  private alias comp = binaryFun!(less);
  this()
  {
  }

  this(T[] arr)
  {
    arr.each!(x => insert(x));
  }

  void insert(T x)
  {
    size_t i = dat.length;
    dat ~= x;
    while (i > 0)
    {
      size_t p = (i - 1) / 2;
      if (comp(dat[i], dat[p]))
      {
        swap(dat[i], dat[p]);
        i = p;
      }
      else
      {
        break;
      }
    }
  }

  T front()
  {
    enforce(dat.length > 0, "Cannot call front on an empty heap."); // https://github.com/dlang/phobos/blob/master/std/container/binaryheap.d#L248
    return dat[0];
  }

  void removeFront()
  {
    enforce(dat.length > 0, "Cannot call removeFront on an empty heap."); // https://github.com/dlang/phobos/blob/master/std/container/binaryheap.d#L316
    swap(dat[0], dat[$ - 1]);
    dat = dat[0 .. ($ - 1)];
    size_t len = dat.length;
    size_t i = 0;
    while (i * 2 + 1 < len)
    {
      if (i * 2 + 2 < len)
      {
        size_t j = comp(dat[i * 2 + 1], dat[i * 2 + 2]) ? i * 2 + 1 : i * 2 + 2; // 左右で強いほうの子と比べる
        if (comp(dat[j], dat[i]))
        {
          swap(dat[j], dat[i]);
          i = j;
        }
        else
        {
          break;
        }
      }
      else
      { // 左の子しかない
        if (comp(dat[i * 2 + 1], dat[i]))
        {
          swap(dat[i * 2 + 1], dat[i]);
          i = i * 2 + 1;
        }
        else
        {
          break;
        }
      }
    }
  }
  bool empty(){
    return dat.length==0;
  }
}



Measured memory_bytes: 35392
n,a,b,c=map(int,input().split())
a=min(3,a)
b=min(3,b)
S=[input() for i in range(n)]
X=a+b+c
idx=0
log=[0]*n#0,1のいずれか,
plog=[(a,b)]*(n+1)

flag=False

while idx!=n:

    #3回以上戻ってたらもうダメ 0回目の時点でアウトでもダメ
    if idx<n-2 and log[idx+2]==2 and log[idx]==2:
        flag=True
        break
    if idx==0 and log[0]==2:
        flag=True
        break

    a,b=plog[idx]
    dx,dy=0,0
    if S[idx]=='AB':
        dx,dy=1,-1
    elif S[idx]=='BC':
        dx,dy=0,1
    else:#AC
        dx,dy=1,0

    if log[idx]==0:
        a+=dx
        b+=dy
    elif log[idx]==1:
        a-=dx
        b-=dy
    else:
        log[idx]=0
        idx-=1
        log[idx]+=1
        continue
    
    if a<0 or b<0 or X-(a+b)<0:
        log[idx]+=1
        continue
    else:
        idx+=1
        plog[idx]=(a,b)

if flag:
    print('No')
else:
    print('Yes')
    for i,s in zip(log,S):
        print(s[i])

Measured memory_bytes: 85760
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;
import core.bitop;

int f(int x)
{
	int ans = 0;
	while (x) {
		ans += x % 10;
		x /= 10;
	}
	return ans;
}

void main()
{
	int n = readln.chomp.to!int;
	int ans = int.max;
	for (int a = 1; a <= n - 1; ++a) {
		ans = min(ans, a.f + f(n - a));
	}
	ans.writeln;
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

ans = [0]*4
for i in range(n):
    if s[i] == 'AC':
        ans[0] += 1
    elif s[i] == 'WA':
        ans[1] += 1
    elif s[i] == 'TLE':
        ans[2] += 1
    elif s[i] == 'RE':
        ans[3] += 1

print('AC x ' + str(ans[0]))
print('WA x ' + str(ans[1]))
print('TLE x ' + str(ans[2]))
print('RE x ' + str(ans[3]))


Measured memory_bytes: 16248
// C - 100 to 105
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int X; cin>>X;
	vi dp(X+1, false); dp[0] = true;
	rp(i, 100, X+1) rp(y, 100, 105+1) if(0 <= i-y && dp[i-y]) dp[i] = true;
	puts(dp[X]? "1":"0");
}

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

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

const long INF = 1L << 60;

int h[110000];
long dp[110000];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	for(int i = 0; i <= n+100; i++) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 1; j <= k; j++) {
			chmin(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
		}
	}
	printf("%ld\n", dp[n-1]);
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main()
{
    int n,r,i;
    cin>>n>>r;
    if(n>=10)

    {
       cout<<r<<endl;
    }
    else
    {
        (r+((100)*(10-n)));
        cout<<(r+((100)*(10-n)))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s;
  cin>>s;
  bool flag = true;
  for(int i = 0; i < s.size(); i++)
  {
    int cnt = 0;
    for(int j = 0; j < s.size(); j++)
    {
      if(s[i] == s[j]) cnt++;
    }
    if(cnt % 2 == 1) flag = false;
  }
  if(flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256