akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll t,d,l;

void solve(){
    vector<ll> x(t+10,0);

    vector<int> imos(t+d+10,0);
    rep(i,t){
        int x; cin >> x;
        if(x>=l){
            int ti = i+1;
            imos[ti]++;
            imos[ti+d]--;
        }
    }
    rep(i,t) imos[i+1] += imos[i];
    int ans = 0;
    for(int i=1;i<t;i++){
        if(imos[i]>0) ans++;
    }
    cout << ans << endl;
}

int main(){
    while(cin>>t>>d>>l){
        if(!t && !d && !l) break;
        solve();
    }
}



Measured memory_bytes: 4800
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
struct Card { 
    char suit; 
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) { 
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for ( i = 0; i < n1; i++ ) L[i] = A[left + i]; 
    for ( i = 0; i < n2; i++ ) R[i] = A[mid + i]; 
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for ( k = left; k < right; k++ ) { 
        if ( L[i].value <= R[j].value ) {
            A[k] = L[i++]; 
        }else {
            A[k] = R[j++]; 
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) { 
    int mid;
    if ( left + 1 < right ) {
        mid = (left + right) / 2; 
        mergeSort(A, n, left, mid); 
        mergeSort(A, n, mid, right); 
        merge(A, n, left, mid, right);
    } 
}

int partition(struct Card A[], int n, int p, int r) { 
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for ( j = p; j < r; j++ ) {
        if ( A[j].value <= x.value ) { 
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t; 
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) { 
    int q;
    if ( p < r ) {
        q = partition(A, n, p, r); 
        quickSort(A, n, p, q - 1); 
        quickSort(A, n, q + 1, r);
    }
}

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX]; char S[10];
    int stable = 1;
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) { 
        scanf("%s %d", S, &v); A[i].suit = B[i].suit = S[0]; 
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n); 
    quickSort(B, n, 0, n - 1);
    for ( i = 0; i < n; i++ ) {
        if ( A[i].suit != B[i].suit ) stable = 0;
    }
    
    if ( stable == 1 ) printf("Stable\n"); 
    else printf("Not stable\n");
    for ( i = 0; i < n; i++ ) {
        printf("%c %d\n", B[i].suit, B[i].value); 
    }

    return 0; 
}


Measured memory_bytes: 4884
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
 
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans = 0;
    string s;
    cin >> s;
    if(s[0] == '1') ans++;
    if(s[1] == '1') ans++;
    if(s[2] == '1') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    for i in range(1, 10):
        for j in range(1, 10):
            if i * j == n:
                print("Yes")
                exit()
    print("No")

    
            
    

    

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 5884
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 1000
int main()
{
  string str;
  cin >> str;
  
  int min = INF;
  for(int i = 0; i < str.size()-2; i++){
    string tmp = str.substr(i, 3);
    int x = atoi(tmp.c_str());
    if(min > abs(753 - x))
      min = abs(753 - x);
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(j = 2; j <= n; j++) {
    key = A[j];
    i = j - 1;

    while(i > 0 && A[i] > key) 
      {
	A[i+1] = A[i];
	i = i-1;
      }

    A[i + 1] = key;
    trace(A, n);
  }

  return 0;
  
}

Measured memory_bytes: 608
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def kaijou(n):
    s = 1
    for i in range(n):
        s *= i+1
    return s

def jisyo(L):
    l = 0
    k = len(L)
    for i in range(k):
        n = L.pop(0)
        l += kaijou(len(L))*(n-1)
        for m in range(len(L)):
            if L[m] > n:
                L[m] -= 1
    return l+1

print(abs(jisyo(P)-jisyo(Q)))






Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  string s;
  int k;
  cin>>s>>k;
  int n=s.size();
  vector<vector<ll>>dp0(101,vector<ll>(4));
  vector<vector<ll>>dp1(101,vector<ll>(4));
  dp0[0][0]=1;
  dp0[0][1]=max(0,(s[0]-'0')-1);
  dp0[0][2]=0;
  dp0[0][3]=0;
  dp1[0][0]=0;
  dp1[0][1]=1;
  dp1[0][2]=0;
  dp1[0][3]=0;
  for(int i=1;i<n;i++){
    for(int j=0;j<=k;j++){
      if(j-1>=0) dp0[i][j]=dp0[i-1][j]+9*dp0[i-1][j-1];
      else dp0[i][j]=dp0[i-1][j];
      if(s[i]!='0') dp0[i][j]+=dp1[i-1][j];
      if(j-1>=0) dp0[i][j]+=(max((s[i]-'0')-1,0))*dp1[i-1][j-1];
      if(s[i]=='0') dp1[i][j]+=dp1[i-1][j];
      if(j-1>=0 && s[i]!='0') dp1[i][j]+=dp1[i-1][j-1];
    }
  }
  cout<<dp0[n-1][k]+dp1[n-1][k]<<endl;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3

S = input()
is_ok = True
for i, ch in enumerate(list(S)):
    if i % 2 == 0:
        if ch not in "RUD":
            is_ok = False
    else:
        if ch not in "LUD":
            is_ok = False

ans = "Yes" if is_ok else "No"

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n; 
    cin>>n; 
    ll a[n],s=0;
    for(ll i=0;i<n;i++){
      cin>>a[i];
    }
    map<ll,ll>mp;
    for(ll i=0;i<n;i++){
      mp[a[i]]++;
      s+=a[i];
    }
    ll q; 
    cin>>q; 
    while(q--){
      ll b,c;
      cin>>b>>c;
      s+=(-mp[b]*b+mp[b]*c);
      //cout<<mp[b]<<" # "<<c<<endl; 
      mp[c]+=mp[b];
      mp[b]=0;
      cout<<s<<endl;
    }
    //printclock;
    return 0;
}
    

Measured memory_bytes: 10304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double C = sc.nextDouble();

		double radC = Math.PI * 2.0 * C / 360.0;

		double h = b * Math.sin(radC);

		double S = a * h / 2.0;

		double d = a - b * Math.cos(radC);
		double cc = h*h + d*d;
		double c = Math.sqrt(cc); // ????§???¢????????????????????????c

		double L = a + b + c;

		System.out.printf("%.5f\n", S);
		System.out.printf("%.5f\n", L);
		System.out.printf("%.5f\n", h);
	}

}

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

int partition(int,int);

int A[MAX];

int main(){
  int n,i,s;

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

  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    if(i==s) printf("[");
    printf("%d",A[i]);
    if(i==s) printf("]");
  }
  printf("\n");
  return 0;
}

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

Measured memory_bytes: 988
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe





vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}
int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int n;
cin >> n;
for(int i=0;i<30;i++){
	for(int j=0;j<30;j++){
		if(4*i+7*j==n){
			cout << "Yes" << endl;
			return 0;
		}
	}
}   
cout << "No" << endl;
 
///////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n, m; cin >> n >> m;
  int left = 0, right = n;
  for(int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    left = max(left, u);
    right = min(right, v);
  }
  cout << max(right - left + 1, 0) << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int num[3005];
int dp[3005][3005];
string sa;
priority_queue<P,vector<P>,greater<P> > q1;

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n>>m;
    cin>>sa;
    for(i=0;i<n;i++){
        if(sa[i]=='1')num[i]++;
        if(i!=0)num[i]+=num[i-1];
    }
    for(i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        q1.push(make_pair(a,b));
    }
    int en=0;
    dp[0][0]=1;
    for(i=0;i<n;i++){
        en=max(en,i);
        while(!q1.empty() && q1.top().first==i){
            en=max(en,q1.top().second),q1.pop();
        }
        for(j=max(i-(en-num[en]+1),0);j<=num[en];j++){
            if(dp[i][j]>=MAX)dp[i][j]%=MAX;
            if(j<num[en])dp[i+1][j+1]+=dp[i][j];
            if(j!=i-(en-num[en]+1))dp[i+1][j]+=dp[i][j];
        }
    }
    cout<<dp[n][num[n-1]]%MAX<<endl;
}

Measured memory_bytes: 33920
// AtCoder ABC122: B - ATCoder
// 2019.9.9 bal4u

#include <stdio.h>

char p[128];
char S[15];

int main()
{
	int w, ans; char *s;
		
	p['A'] = p['T'] = p['C'] = p['G'] = 1;
	scanf("%s", s=S);
	w = ans = 0; while (*s) {
		if (p[*s]) w++;
		else if (w > ans) ans = w, w = 0;
		s++;
	}
	if (w > ans) ans = w;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
s = gets.chomp
Q = gets.to_i
Qvery = Q.times.map{gets.split.map(&:to_s)}
cnt = 0
pre = []

Qvery.each do |n|
  if n[0] == "1"
    cnt += 1
    cnt
  else
    if n[1] == "1" && cnt%2 == 0
      pre << n[2]
    end
    if n[1] == "2" && cnt%2 == 0
      s << n[2]
    end
    if n[1] =="2" && cnt%2 == 1
      pre << n[2]
    end
    if n[1] == "1" && cnt%2 == 1
      s << n[2]
    end
  end
end

s = pre.join.reverse + s

if cnt%2 == 0 
  puts s
else
  puts s.reverse
end

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


int main() {
	int N;
	int a[110] = {};
	int i,k;
	int A=0, B=0;

	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a, a + N, greater<int>());
	
	for (i = 0; i < N; i++) {
		if (i % 2 == 0) A += a[i];
		else B += a[i];
	}
	cout << A - B << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP std::make_pair
#define FI first
#define SE second
#define M 1000005
#define INF 1000000000
int n,m,t,X[M],Y[M],num[M],ed[M];
std::bitset <50005> Bitset[50005];
bool flag[M];
char ans[M];
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(int x){
	if (x<10) putchar(x+'0');
	else Write(x/10),putchar(x%10+'0');
	return;
}
int main(){
	n=read(),m=read(),t=read();
	for (int i=1;i<=m;i++) X[i]=read(),Y[i]=read();
	if (t==1){
		for (int i=1;i<=n;i++) Bitset[i][i]=Bitset[0][i]=1;
		for (int i=m;i;i--)
			Bitset[X[i]]|=Bitset[Y[i]],Bitset[Y[i]]=Bitset[X[i]];
		for (int i=1;i<=n;i++) Bitset[0]&=Bitset[i];
		if (Bitset[0].count()>0){
			int pos=-1;
			for (int i=1;i<=n;i++)
				if (Bitset[0][i]) pos=i;
			flag[pos]=1;
			for (int i=m;i;i--)
				if (flag[X[i]]==flag[Y[i]]) ans[i]='v';
				else {
					if (flag[X[i]]) ans[i]='^',flag[Y[i]]=1;
					else ans[i]='v',flag[X[i]]=1;
				}
			for (int i=1;i<=m;i++) putchar(ans[i]);
		}
		else printf("-1");
	}
	else {
		if (n==2) printf("-1");
		else {
			for (int i=1;i<=n;i++) ed[i]=i,num[i]=1;
			for (int i=m;i;i--)
				if (ed[X[i]]==ed[Y[i]]) ans[i]='v';
				else {
					if (num[ed[X[i]]]<num[ed[Y[i]]]) num[ed[X[i]]]++,num[ed[Y[i]]]--,ed[Y[i]]=ed[X[i]],ans[i]='^';
					else num[ed[Y[i]]]++,num[ed[X[i]]]--,ed[X[i]]=ed[Y[i]],ans[i]='v';
				}
			for (int i=1;i<=m;i++) putchar(ans[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 310048
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int solve(vector<int>& v) {
    int ans = 1;
    v.push_back(v.back());
    bool inc;
    bool init = true;
    for (int i = 0; i < v.size() - 1; i++) {
        if (v[i] == v[i + 1])
            continue;
        if (init) {
            inc = v[i] < v[i + 1];
            init = false;
        }
        if ((inc && v[i] > v[i + 1]) || (!inc && v[i] < v[i + 1])) {
            ans++;
            inc = v[i + 1] < v[i + 2];
            init = true;
        }
    }
    return ans;
}

signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    cout << solve(v) << "\n";
}

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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            if (n == 1)
            {
                Console.WriteLine(1);
                Console.Out.Flush();
                return;
            }
            // 整数配列の入力
            long ni = 1;
            while (true)
            {
                if (n < ni)
                {
                    break;
                }
                ni = ni * 2;
            }

            Console.WriteLine(ni/2);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13140
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, x, y = map(int, input().split())
#print(a, b, c, x, y)
ab = math.floor((x+y)/2)
#print('ab', ab)
p1 = a*x+b*y
max_x = max(x, y)
p2 = c*max_x+c*max_x
min_x = min(x, y)
p3 = a*(x-min_x)+b*(y-min_x)+c*((min_x)*2)
ans = min(p1, p2, p3)
print(ans)


Measured memory_bytes: 60012
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int r;
  cin >> r;
  if (r < 1200) cout << "ABC" << endl;
  else if (r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES";
  else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
 
using namespace std;
typedef long long ll;


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main()
{
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	
	mint ans = 0;
	
	mint twon = 2;
	twon = twon.pow(n);
	
	mint afact = 1;
	for(int i = a; i > 0; i--){
		afact *= i;
	}
	mint bfact = 1;
	for(int i = b; i > 0; i--){
		bfact *= i;
	}
	
	mint nca = 1;
	for(int i = n-a+1; i <= n; i++){
		nca *= i;
	}
	nca = nca / afact;
	
	mint ncb = 1;
	for(int i = n-b+1; i <= n; i++){
		ncb *= i;
	}
	ncb = ncb / bfact;
	
	ans = twon - 1 - nca - ncb;
	//printf("%lld %lld %lld\n", twon.x, nca.x, ncb.x);
	
	printf("%lld\n", ans.x);
	
	return 0;
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

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


int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    const int w = 52;
    const int h = 100;
    char field[h][w];
    int a, b;
    cin >> a >> b;
    a--, b--;

    rep(i, h / 2)
    {
        rep(j, w)
            field[i][j] = '.';
    }
    rep(i, h / 2)
    {
        rep(j, w)
            field[i + h / 2][j] = '#';
    }

    rep(i, 20)
    {
        if (b == 0)
            break;
        else
        {
            rep(j, 25)
            {
                if (b == 0)
                    break;
                else
                {
                    field[2 * i + 1][2 * j + 1] = '#';
                    b--;
                }
            }
        }
    }

    rep(i, 20)
    {
        if (a == 0)
            break;
        else
        {
            rep(j, 25)
            {
                if (a == 0)
                    break;
                else
                {
                    field[2 * i + h / 2 + 1][2 * j + 1] = '.';
                    a--;
                }
            }
        }
    }

    cout << h << " " << w << endl;
    rep(i, h)
    {
        rep(j, w)
                cout
            << field[i][j];
        cout << endl;
    }

    return 0;
}

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

int main(){
    int N; cin >> N;
    vector <float> A(N);
    vector <string> B(N);
    rep(i,N) cin >> A[i] >> B[i];
    
    double ans=0;
    rep(i,N){
        if (B[i]=="JPY") ans+=A[i];
        else ans+=A[i]*380000;
    }
    cout << fixed << setprecision(5) << ans;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  int n, cn;
  cin >> n >> cn;
  vector<vector<int>> d(cn, vector<int>(cn,0));
  vector<vector<int>> c(n, vector<int>(n,0));

  rep(i, cn) rep(j,cn){
    cin >> d[i][j];
  }
  rep(i, n) rep(j,n){
    cin >> c[i][j];
  }
  int amari;
  vector<vector<ll>> iwakan(cn, vector<ll>(cn,0));
  rep(i, n) rep(j,n){
    rep(k, cn){
      amari = (i+j)%3;
      amari = c[i][j];
      iwakan[k][(i+j)%3] += d[c[i][j]-1][k];
    }
  }
  ll sum=1e9;
  rep(i, cn) {
    rep(j, cn){
      rep(k, cn){
        if(i!=j && j!=k && i!=k && iwakan[i][0]+iwakan[j][1]+iwakan[k][2]<sum)
          sum = iwakan[i][0]+iwakan[j][1]+iwakan[k][2];
      }
    }
  }
  cout << sum << endl;
  return 0;
}

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

double dist(int x1, int y1, int x2, int y2) {
	double dx = x1 - x2, dy = y1 - y2;
	return sqrt(dx * dx + dy * dy);
}

int main() {
	int n; cin >> n;
	int x[n], y[n], a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
		a[i] = i;
	}

	double res = 0;
	do
	{
		for (int i = 1; i < n; i++)
		{
			res += dist(x[a[i-1]], y[a[i-1]], x[a[i]], y[a[i]]);
		}
	} while (next_permutation(a, a + n));

	for (int i = 2; i <= n; i++)
	{
		res /= i;
	}

	cout << fixed << setprecision(10) << res << endl;

	return 0;
}


Measured memory_bytes: 256
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,c,d = map(int,input().split())
i = 0
cnt1 = 0
while True:
    if a<=0:
        break
    cnt1+=1
    a -= d
cnt2 = 0
while True:
    if c<=0:
        break
    cnt2+=1
    c -= b
if cnt1<cnt2:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 27092
# 点数計算
def scoring(last, c, s, t, d, score):
    # score += s[d][t[d]-1]
    score = s[d][t]
    for i in range(len(c)):
        #score -= c[i] * (d+1 - last[d][i])
        score -= c[i] * (d + 1 - last[i])
    return score


# input
score = 0
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(i) for i in input().split()])
# t = []
# for i in range(D):
#     t.append(int(input()))
last = [[0 for i in range(len(c))] for j in range(D+1)] # last[d][i]

ans = []
for d in range(D):
    # last[d][t[d]-1] = d+1
    last_dummy = last[d][:]
    score = 0
    t_d = 0
    for t in range(len(c)):
        last_dummy2 = last_dummy[:]
        last_dummy2[t] = d+1
        if score < scoring(last_dummy2, c, s, t, d, score):
            score = scoring(last_dummy2, c, s, t, d, score)
            t_d = t
    ans.append(t_d)
    last[d][t_d] = d+1


    # last更新
    for i in range(len(c)):
        last[d+1][i] = last[d][i]


[print(ans[i]+1) for i in range(D)]





Measured memory_bytes: 9688
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  ll n;
  cin >> n;
  ll a[210];
  map <int,ll> ans;
  rep (i,201){
    a[i]=pow(i,5);
    ans[i] = a[i];
  }
  ll cnt1,cnt2;
  bool flag = false;
  for (int i = 0;i <=200;i++){
    ll t = n,s=n;
    //t -= a[i];
    for (int j = 0;j <=200;j++){
      if (a[i] - a[j] == n){        
        //cout << a[i] << " " << a[j] << endl;
        cnt1 = i;
        cnt2 = j;
        flag = true;
        break;
      }
      if (a[i] + a[j] == n){
        //cout << 2 << endl;
        cnt1 = i;
        cnt2 = -j;
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
  cout << cnt1 << " "<< cnt2 << endl;
}

Measured memory_bytes: 4124
S = input()
S = S.replace("BC", "X")
ans = 0
lo = 0
while True:
    while lo < len(S) and (S[lo] == "B" or S[lo] == "C"): lo += 1
    if lo == len(S): break
    hi = lo
    X = 0
    while hi < len(S) and S[hi] != "B" and S[hi] != "C":
        if S[hi] == "X": 
            ans += hi - lo
            lo += 1 
        hi += 1
    lo = hi
print(ans)
    


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

using namespace std;

const int INF = 1e9;

int n, k, a[55], dp[105][55][55];

int solve(int step, int l, int r) {
	if (step == 0 || l > r) return 0LL;
	if (dp[step][l][r] != -INF) return dp[step][l][r];
	
	int best = -INF;
	
	best = max(best, solve(step - 1, l + 1, r) + a[l]);
	if (step - 2 >= 0) best = max(best, solve(step - 2, l + 1, r));

	best = max(best, solve(step - 1, l, r - 1) + a[r]);
	if (step - 2 >= 0) best = max(best, solve(step - 2, l, r - 1));
	
	return dp[step][l][r] = best;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) dp[i][j][k] = -INF;
		}
	}
	
	int res = 0;
	
	for (int i = 0; i <= k; i++) {
		res = max(res, solve(i, 0, n - 1));
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
	int N = 0;
	cin >> N;

	int* W = NULL;
	W = new int[N];

	int sum = 0;
	for (int ii = 0; ii < N; ii++) {
		cin >> W[ii];
		sum = sum + W[ii];
	}

	int S1 = 0;
	int S2 = sum;
	int tmpSa = 0;
	int absTmpSa = 0;
	int sa = 0;
	for (int ii = 0; ii < N; ii++) {
		S1 = S1 + W[ii];
		S2 = S2 - W[ii];

		tmpSa = S2 - S1;
		absTmpSa = abs(tmpSa);

		if (ii == 0) {
			sa = absTmpSa;
		}
		else {
			if (sa > absTmpSa) {
				sa = absTmpSa;
			}
		}

	}

	cout << sa;
	
	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int>price(N);
  for(int i = 0; i <N; i++){
    cin >> price[i];
  }
  sort(price.begin(),price.end());
  ll ans = 0;
  for(int i = 0; i < K; i++){
    ans += price[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>

using i64 = long long;

const int N = 100000 + 7;

int n;
int s[N], e[N];
i64 d[N], t;
int u[N], v[N];

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", d + i), e[i] = i, s[i] = 1;
	std::sort(e + 1, e + n + 1, [](int a, int b) {
		return d[a] < d[b];
	});
	for (int i = n; i > 1; --i) {
		int j = std::lower_bound(e + 1, e + n + 1, d[e[i]] - n + s[e[i]] * 2, [](int a, i64 b) {
			return d[a] < b;
		}) - e;
		if (d[e[j]] != d[e[i]] - n + s[e[i]] * 2) return printf("-1"), 0;
		s[e[j]] += s[e[i]], t += s[e[i]];
		u[i] = e[i], v[i] = e[j];
	}
	if (d[e[1]] != t) return printf("-1"), 0;
	for(int i = 2; i <= n; i++)
		printf("%d %d\n", u[i], v[i]);
	return 0;
}

Measured memory_bytes: 6152
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/22/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string s; cin>>s;
  auto n = s.size();
  auto solve = [&](int l, int r) {
    while (l <= r and s[l] == s[r]) {
      l++, r--;
    }
    return l > r;
  };
  auto ans = solve(0, (n-1)/2-1) and solve((n+3)/2-1, n-1) and solve(0, n-1);
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


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

int main(){
    char a,b;
    cin>>a>>b;
    string sa="";
    string sb="";

    for(int i=0; i<b-'0'; i++){
        sa+=a;
    }
    for(int i=0; i<a-'0'; i++){
        sb.push_back(b);
    }

    if(sa<=sb) cout<<sa<<endl;
    else     cout<<sb<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string S;
string T;

int main()
{
	cin >> S >> T;
	int len = S.size();
	char tmp;
	for(int i=0; i<len; ++i){
		tmp = S.front();
		S.erase(S.begin());
		S.push_back(tmp);
		if(S == T){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main(void) {
	string s, t;
	cin >> s >> t;
	ll mi = inf;
	ll count = 0;
	if (s.size() > t.size()) {
		for (int i = 0; i < s.size() - t.size(); i++) {
			count = 0;
			for (int j = 0; j < t.size(); j++) {
				if (s[i + j] != t[j]) {
					count++;
				}
			}

			mi = min(mi, count);
		}
		cout << mi << endl;
	}
	else {
		ll count = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != t[i]) {
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
int n;
char s[30010];
int f[30010][15];
int ans=0;
bool find(int a,int b,int c)
{
	bool x,y,z;
	x=y=z=0;
	for(int i=1;i<=n;i++)
	if(s[i]-'0'==a&&!x) x=1;
	else if(s[i]-'0'==b&&!y&&x) y=1;
	else if(s[i]-'0'==c&&!z&&y) z=1;
	if(z) return 1;
	else return 0; 
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=0;i<=9;i++)
	for(int j=0;j<=9;j++)
	for(int k=0;k<=9;k++)
	if(find(i,j,k)) ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
a = [[0 for j in range(3)] for w in range(3)]
s = [[0 for h in range(3)] for t in range(3)]
ans = 'No'

for i in range(3):
    a[i][0],a[i][1],a[i][2] = map(int,input().split())

n = int(input())

for k in range(n):
    b = int(input())
    for x in range(0,3,1):
        for y in range(0,3,1):
            if a[x][y] == b:
                s[x][y] = 1

if s[0][0] == 1 and s[0][1] == 1 and s[0][2] == 1:
    ans = 'Yes'
if s[1][0] == 1 and s[1][1] == 1 and s[1][2] == 1:
    ans = 'Yes'
if s[2][0] == 1 and s[2][1] == 1 and s[2][2] == 1:
    ans = 'Yes'
if s[0][0] == 1 and s[1][0] == 1 and s[2][0] == 1:
    ans = 'Yes'
if s[0][1] == 1 and s[1][1] == 1 and s[2][1] == 1:
    ans = 'Yes'
if s[0][2] == 1 and s[1][2] == 1 and s[2][2] == 1:
    ans = 'Yes'
if s[0][0] == 1 and s[1][1] == 1 and s[2][2] == 1:
    ans = 'Yes'
if s[2][0] == 1 and s[1][1] == 1 and s[0][2] == 1:
    ans = 'Yes'

print(ans)

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

int main()
{
  string s1,s2,s3;
  int n;
  int x = 0;
  cin>>n;
  cin>>s1>>s2>>s3;
  for(int i=0;i<n;i++){
    if(s1[i] == s2[i] && s2[i] == s3[i]) continue;
    if(s1[i] != s2[i] && s1[i] != s3[i] && s2[i] != s3[i]) x += 2;
    if(s1[i] == s2[i] || s1[i] == s3[i] || s2[i] == s3[i]) x ++;
  }
  printf("%d\n", x);
  return 0;
}


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

using namespace std;

int x, n;
bool vis[105];

int main()
{
    cin >> x >> n;
    for (int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        vis[a] = 1;
    }
    for (int d = 0; d <= 50; d++)
    {
        if (!vis[x - d])
        {
            cout << x - d << endl;
            return 0;
        }
        if (!vis[x + d])
        {
            cout << x + d << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  
  int max=0;
  for(int i=0; i<=X/500; i++){
    int y= (X-500*i)/5;
    int z= 1000*i + 5*y;
    if(z > max) max = z;
  }
  
  cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

struct edge{
    int to;
    long cost;
};

vector<edge> G[300];

typedef pair<int, long> P;
typedef pair<P, int> P_;

P dist[300][300];

const long INF = 50000;
int N, M;
long L;

void dijkstra(long s, P d[]){
    priority_queue<P_, vector<P_>, greater<P_>> que;
    fill(d, d+N, P(INF, 0));
    d[s] = P(0, -L);
    que.push(P_(P(0, -L), s));
    while(!que.empty()){
        P_ p = que.top();que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(long i = 0; i < G[v].size(); i++){
            edge e = G[v][i]; 
            P next;
            if(d[v].second + e.cost > 0){
                next = P(d[v].first+1, -L+e.cost);
            }else{
                next = P(d[v].first, e.cost+d[v].second);
            }
            if(next.second > 0) continue;
            if(next < d[e.to]){
                d[e.to] = next;
                que.push(P_(next, e.to));
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    
    cin >> N >> M >> L;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) dist[i][j] = P(0, -L);
            else dist[i][j] = P(500, 0);
        }
    }
    for(int i = 0; i < M; i++){
        int A, B;
        long C;
        cin >> A >> B >> C;
        A--; B--;
        G[A].push_back((edge){B, C});
        G[B].push_back((edge){A, C});
    }
    for(int i = 0; i < N; i++){
        dijkstra(i, dist[i]);
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int s, t;
        cin >> s >> t;
        s--; t--;
        if(dist[s][t].first == INF){
            cout << -1 << endl;
        }else{
            cout << dist[s][t].first << endl;
        }
    }
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        Arrays.sort(p);
        int sum = 0;
        for (int i = 0; i < k; i++) {
            sum += p[i];
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 38776
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    map<char, int> mp;
    REP(i, s.size()) mp[s[i]]++;
    if(mp['N'] > 0 && mp['S'] == 0){
        cout << "No" << endl;
        return 0;
    }
    if(mp['S'] > 0 && mp['N'] == 0){
        cout << "No" << endl;
        return 0;
    }
    if(mp['W'] > 0 && mp['E'] == 0){
        cout << "No" << endl;
        return 0;
    }
    if(mp['E'] > 0 && mp['W'] == 0){
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N);
    ll sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    if (H <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
	var keys = new Set();
	for(var i = 0; i < N; i++){
		var tmp = next();
		keys.add(tmp);
	}
	myout(keys.size);
	myerr(keys);
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;

  for (int i = 0; i < B; i++) {
    if((A*i)%B==C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


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

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 100010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/

int main()
{
    string s;
    cin >> s;
    if(s == "ABC")
        cout << "ARC";
    else
    {
        cout << "ABC";
    }
    cout << "\n";
    
    return 0;
}


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

int main() {

  int N;
  cin >> N;

  set<string> st;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    st.insert(S);
  }

  cout << st.size() << endl;

  return 0;
}

Measured memory_bytes: 19132
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a;
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        a.push_back(temp);
    }
    sort(a.begin(),a.end());
    int np=n/2;
    cout<<a[np]-a[np-1];
}


Measured memory_bytes: 892
n = int(input())
s = input()
mod = 1000000007
alphacnt = [0]*26
ans = 0
for c in s:
    idx = ord(c)-ord("a")
    alphacnt[idx] += 1
    cnt = 1
    for i in range(26):
        if i == idx: continue
        cnt = (cnt*(alphacnt[i]+1))%mod
    ans = (ans+cnt)%mod
print(ans)

Measured memory_bytes: 9300
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let vec: Vec<i32> = read_line();
    let (a, b) = (vec[0], vec[1]);
    let plus = a + b;
    let minus = a - b;
    let by = a * b;
    let p_m = cmp::max(plus, minus);
    println!("{}", cmp::max(by, p_m));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int64_t F(int64_t A, int64_t B){
    int64_t C = max(A, B);
    int64_t counter = 0;
    while(C > 0) {
        C /= 10;
        counter++;
    }
    return counter;
}

int main() {
    int64_t N;
    cin >> N;

    int64_t ans = 10000000;
    vector<int64_t> A = divisor(N);

    rep(a, A.size()) {
        int64_t b = N / A.at(a);
        ans = min(ans, F(b, A.at(a)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256