akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int mx=0;
    vector<string>ans;
    map<string,int>mm;
    int n;
    cin>>n;
    string str;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        mm[str]++;
        if(mm[str]>mx)
        {
            mx=mm[str];
            ans.clear();
            ans.push_back(str);
        }
        else if(mm[str]==mx)
        {
            ans.push_back(str);
        }
    }
    sort(ans.begin(),ans.end());
    for(auto i:ans)
        cout<<i<<'\n';

        
} 



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

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

    int N;
    cin >> N;

    string s;
    int cnt = 0, ba = 0, bx = 0, xa = 0;
    for (int i=0; i<N; ++i) {
        cin >> s;
        if (s[0] == 'B' && s[(int)s.size()-1] == 'A') {
            ba ++;
        } else if (s[0] == 'B') {
            bx ++;
        } else if (s[(int)s.size()-1] == 'A') {
            xa ++;
        }

        for (int i=0; i<(int)s.size()-1; ++i) {
            if (s[i] == 'A' && s[i+1] == 'B') cnt ++;
        }
    }

    cnt += min(xa, bx);
    if (xa > 0 && bx > 0) {
        cnt += ba;
    } else if (xa > 0 || bx > 0) {
        cnt += ba;
    } else {
        cnt += max(0, ba - 1);
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


struct v_t
{
	set<int> m;
	int s;
};


using vv_t=vector<v_t>;


void calc(vv_t&v)
{
	deque<int> q;

	q.push_back(1);
	while(!q.empty())
	{
		int c=q.front();
		q.pop_front();

		for(int mc:v[c].m)
		{
			v[mc].s+=v[c].s;
			v[mc].m.erase(c);
			q.push_back(mc);
		}
	}
}


int main(void)
{
	int n, q;

	while(scanf("%d%d", &n, &q)==2)
	{
		vv_t v(n+1);

		for(int i=0;i<n-1;i++)
		{
			int a, b;

			scanf("%d%d", &a, &b);
			v[a].m.insert(b);
			v[b].m.insert(a);
		}
		for(int i=0;i<q;i++)
		{
			int p, x;

			scanf("%d%d", &p, &x);
			v[p].s+=x;
		}
		calc(v);

		for(int i=1;i<=n-1;i++)
		{
			printf("%d ", v[i].s);
		}
		printf("%d\n", v[n].s);
	}
	return 0;
}


Measured memory_bytes: 32128
while True:
    M,F,R = map(int,input().split())
    if M == -1 and F == -1 and R == -1:
        break
    if M == -1 or F == -1:
        print('F')
    elif M + F >= 80:
        print('A')
    elif M + F >= 65:
        print('B')
    elif M + F >= 50:
        print('C')
    elif M + F >= 30:
        if R>= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, t;
	scanf("%d%d%d", &a, &b, &t);
	int p = a;
	int count = 0;
	while (t - p >= 0) {
		p += a;
		count += b;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>

int main(){
   int a, b, d, r;
   double f;
   scanf("%d %d", &a, &b);
   d = a / b;
   r = a % b;
   f = 1.0 * a / b;
   printf("%d %d %.8lf\n", d, r, f);
   return 0;


}


Measured memory_bytes: 2080
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

int main(void){
    string s;
    cin >> s;

    sort(s.begin(),s.end());
    if(s=="abc"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
from typing import List


def bubble_sort(elems: List[str]) -> List[str]:
    for i in range(0, len(elems)):
        for j in range(len(elems) - 1, i, -1):
            if int(elems[j][1]) < int(elems[j - 1][1]):
                elems[j], elems[j - 1] = elems[j - 1], elems[j]
    return elems


def selection_sort(elems: List[str]) -> List[str]:
    for i in range(0, len(elems)):
        mini = i
        for j in range(i + 1, len(elems)):
            if int(elems[j][1]) < int(elems[mini][1]):
                mini = j
        if i != mini:
            elems[i], elems[mini] = elems[mini], elems[i]
    return elems


def is_stable(input_elems: List[str], elems: List[str]) -> bool:
    for card1, card2 in zip(elems[:-1], elems[1:]):
        if (int(card1[1]) == int(card2[1])) and (
           input_elems.index(card1) > input_elems.index(card2)):
            return False
    return True


if __name__ == "__main__":
    elem_num = int(input())
    elems = list(input().split())

    elems_bubble_sort = elems.copy()
    elems_bubble_sort = bubble_sort(elems_bubble_sort)
    print(" ".join(elems_bubble_sort))
    if is_stable(elems, elems_bubble_sort):
        print("Stable")
    else:
        print("Not stable")

    elems_selection_sort = elems.copy()
    elems_selection_sort = selection_sort(elems_selection_sort)
    print(" ".join(elems_selection_sort))
    if is_stable(elems, elems_selection_sort):
        print("Stable")
    else:
        print("Not stable")



Measured memory_bytes: 7164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BigDecimal one = new BigDecimal("1.00");
		int[] abo = {0,0,0,0};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		int cup = 0;
		int mun = 0;
		int ter = 0;
		String[] rrr;
		int st = 0,sr = 0;
		int mon = 0;
		int syo=0,hisi=0;
		long aaaa = 1;
		
		
		while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			
			if(tmp.equals("")){
				break;
			}
			
			mon = Integer.parseInt(tmp);
			
			
			int abc = 2;
			for(int i=2;i<mon+1;i++){
				abc = abc + i;
			}
			if(mon == 0){
				abc = 1;
			}
			System.out.println(abc);
			
		}
	}

}

Measured memory_bytes: 17816
#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>

using namespace std;

#define OUT cout <<
#define IN cin >>
#define E << endl;
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define RFOR(i, a, b) for(int i = a;i >= b;i--)

string str;
int sum;

int check;

void input(){
	IN str;
}

int main(){
	while(IN str){
		RFOR(i, str.size() - 1, 0){
			if(isdigit(str[i]) > 0){
				if(check > 0){
					sum += ((int)str[i] - '0') * pow(10, check);	
				}
				else{
					sum += ((int)str[i] - '0');		
				}
				check++;
			}
			else{
				check = 0;
			}
		}
		check = 0;
	}
	
	OUT sum E
}

Measured memory_bytes: 3252
#include <iostream>
#include <stdint.h>
using namespace std;

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

	int64_t num = 0;
	for (int64_t i = 1; i <= A; i++) {
		if (A%i == 0 && B%i == 0) {
			num = i;
		}
	}
	if (num>1) {
		cout << A / num * B;
	}
	else {
		cout << A * B;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m 1000000007 
#define endl "\n"    
#define int long long

int modpow(int x, int n) 
{ 
    if (n == 0) 
    return 1%m; 
    long long u = modpow(x,n/2); 
    u = (u*u)%m; 
    if (n%2 == 1) 
    u = (u*x)%m; 
    return u; 
}


int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(9);
  int t;
  cin>>t;
  multiset<double> s;
  for(int i=1;i<=t;i++)
  {
      int x;
      cin>>x;
      s.insert(x);
  }

    while(s.size() > 1)
    {
        auto it1 = s.begin();
        auto it2 = s.begin();
        ++ it2;
        double val = (*it1 + *it2) / 2.0;
        s.erase(it1);
        s.erase(it2);
        s.insert(val);
    }
    for(auto x:s)
    cout<<x;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

signed main()
{
   int N; cin >> N;
   V<int> a(3*N);
   REP(i, 3*N) {
      cin >> a[i];
   }

   V<int> dp0(N+1), dp1(N+1);
   priority_queue<int, vector<int>, greater<int>> que0;
   priority_queue<int> que1;
   REP(i, N) {
      dp0[0] += a[i];
      que0.push(a[i]);
   }
   REP(i, N) {
      que0.push(a[i+N]);
      dp0[i+1] = dp0[i] + a[i+N] - que0.top();
      que0.pop();
   }
   REP(i, N) {
      dp1[0] += a[3*N-1-i];
      que1.push(a[3*N-1-i]);
   }
   REP(i, N) {
      que1.push(a[2*N-1-i]);
      dp1[i+1] = dp1[i] + a[2*N-1-i] - que1.top();
      que1.pop();
   }

   int ans = -INF;
   REP(i, N+1) {
      ans = max(ans, dp0[i] - dp1[N-i]);
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 6516
#include <stdio.h>
#define ll long long int
#include <queue>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>

using namespace std;
static int nums;
int palin(char *k,char*palinn,int num,int tot,int counter,int len){
counter++;

if(*k=='\0')
return num;
else 
{palin(++k,palinn,num,tot,counter,len);

if(len-counter<=tot && *((palinn+len-counter))!=k[0])
++nums;

return nums;

}

}

int main(){
char* k=(char*)malloc(sizeof(char)*100);
char*palinn=(char*)malloc(sizeof(char)*100);
scanf("%s",k);
palinn=k;
int tot=(strlen(k)/2)-1;
int num=0;
int ctr=0;
int len=strlen(k)-1;
num=palin(k,palinn,num,tot,ctr,len);
cout<<num;

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
//#include "Header.h"
//#include "Math.h"

using namespace std;

int main(int argc, const char * argv[]) {
    string S;
    cin>>S;
    
    if(S.find('a')==string::npos)printf("a");
    else if(S.find('b')==string::npos)printf("b");
    else if(S.find('c')==string::npos)printf("c");
    else if(S.find('d')==string::npos)printf("d");
    else if(S.find('e')==string::npos)printf("e");
    else if(S.find('f')==string::npos)printf("f");
    else if(S.find('g')==string::npos)printf("g");
    else if(S.find('h')==string::npos)printf("h");
    else if(S.find('i')==string::npos)printf("i");
    else if(S.find('j')==string::npos)printf("j");
    else if(S.find('k')==string::npos)printf("k");
    else if(S.find('l')==string::npos)printf("l");
    else if(S.find('m')==string::npos)printf("m");
    else if(S.find('n')==string::npos)printf("n");
    else if(S.find('o')==string::npos)printf("o");
    else if(S.find('p')==string::npos)printf("p");
    else if(S.find('q')==string::npos)printf("q");
    else if(S.find('r')==string::npos)printf("r");
    else if(S.find('s')==string::npos)printf("s");
    else if(S.find('t')==string::npos)printf("t");
    else if(S.find('u')==string::npos)printf("u");
    else if(S.find('v')==string::npos)printf("v");
    else if(S.find('w')==string::npos)printf("w");
    else if(S.find('x')==string::npos)printf("x");
    else if(S.find('y')==string::npos)printf("y");
    else if(S.find('z')==string::npos)printf("z");
    else printf("None");
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
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 vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

const int mod = 998244353;

vector<int> mat[400];
void XOR(vi &A, vi &B){
  int n = A.size();
  rep(i,n)A[i] ^= B[i];
}

int Pow(int x, int n){
  if(n < 0)n += mod-1;
  int ans = 1;
  while(n > 0){
    if(n & 1)ans = (ans*x)%mod;
    x = (x*x)%mod;
    n >>= 1;
  }
  return ans;
}

int calc_rank(int h, int w){
  int r = 0;
  rep(j,w){
    int pivot = -1;
    repi(i,r,h)if(mat[i][j]){
      pivot = i;break;
    }
    if(pivot == -1)continue;
    swap(mat[pivot], mat[r]);
    rep(i,h)if(i != r){
      if(mat[i][j])XOR(mat[i], mat[r]);
    }
    r++;
    if(r >= h)break;
  }
  return r;
}

signed main(){
  int h, w;
  scanf("%lld%lld", &h, &w);
  rep(i,h)rep(j,w){
    int tmp;scanf("%lld", &tmp);
    mat[i].pb(tmp);
  }
  int r = calc_rank(h, w);
  int ans = mod+Pow(2, h)-Pow(2, h-r);
  ans = (ans%mod)*Pow(2, w-1);
  printf("%lld\n", ans%mod);
  return 0;
}






Measured memory_bytes: 1408
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}



int main() {
    ll n ; cin>>n;
    vi arr(n);
    ll ans = 0,sum=0;
    rep(i,0,n)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    for(ll i=0;i<n;i++)
    {
        ans+=(arr[i]*(sum-arr[i]));
        sum-=arr[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  long long int N,M;
  long long int sum = 0;
  cin >> N >> M;
  vector<int> a(M);
  for( int i= 0 ; i < M ; i++ ){
    cin >> a.at(i);
    sum += a.at(i);
  }
  if(sum <= N ){
    cout << N - sum <<endl;
  }else{
    cout << -1 <<endl;
  }
}

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

ll a[314159274];
int x=0;
void DFS(ll i,ll c)
{
	a[++x]=i;
	if(c==10) return;
	for(ll j=max(ll(0),(i%10)-1);j<=min(ll(9),(i%10)+1);j++)
		{	
			DFS(i*10+j,c+1);
		}
}
int main()
{
	for(size_t i =1;i<=9;i++)
		{
			DFS(i,1);

		}
	sort(a,a+x);
	ll k;cin >> k;cout << a[k];
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

struct gotiusa_t {
	int idx;
	int score;
};

int kinnmoza(const void* x, const void* y) {
	struct gotiusa_t a = *(const struct gotiusa_t*)x, b = *(const struct gotiusa_t*)y;
	return a.score > b.score ? -1 : a.score < b.score;
}

int N;
int A[114514], B[114514];

signed char dotti[114514];

struct gotiusa_t takahasikunn[114514], aokikunn[114514];

int main(void) {
	int i, j;
	int64_t kotae = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &A[i], &B[i]) != 2) return 1;
		takahasikunn[i].idx = i;
		takahasikunn[i].score = A[i] + B[i];
		aokikunn[i].idx = i;
		aokikunn[i].score = B[i] + A[i];
	}
	qsort(takahasikunn, N, sizeof(*takahasikunn), kinnmoza);
	qsort(aokikunn, N, sizeof(*aokikunn), kinnmoza);
	for (i = j = 0; i < N || j < N; ) {
		while (i < N && dotti[takahasikunn[i].idx] != 0) i++;
		if (i < N) dotti[takahasikunn[i].idx] = 1;
		while (j < N && dotti[aokikunn[j].idx] != 0) j++;
		if (j < N) dotti[aokikunn[j].idx] = -1;
	}
	for (i = 0; i < N; i++) {
		kotae += dotti[i] > 0 ? A[i] : -B[i];
	}
	printf("%" PRId64 "\n", kotae);
	return 0;
}


Measured memory_bytes: 4968
import java.io.*;
import java.util.*;


public class Main{
	static void main() throws Exception{
		double a=sc.nextInt(),b=sc.nextInt(),h=sc.nextInt()*5,m=sc.nextInt();
		h+=m/(12);
		double dif=Math.min(Math.abs(h-m), 60-Math.abs(h-m));
//		System.out.println(dif);
		double cosa=Math.cos(dif*2*Math.PI/60);
		pw.println(Math.sqrt(a*a+b*b-2*cosa*a*b));
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0)main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 33188
N,K = map(int,input().split())
nums = list(map(int,input().split()))
center = nums.index(min(nums))
leftrem = center+1
rightrem = N-center

def g(n,k):
  ii = 0
  while True:
    if k<=(n+(n-1)*ii):
      return ii+1
    ii += 1

if N==K:
  print(1)
else:
  print(g(K,N))

Measured memory_bytes: 14008
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
#define PI 3.141592653589

int main(){
    int n, a, b, c, d;
    int num[4][3][10]={0};
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a >> b >> c >> d;
		num[a-1][b-1][c-1] += d;
	}
	for(int i = 0;i < 4;i++){
		for(int j = 0;j < 3;j++){
			for(int k = 0;k < 10;k++){
				cout << " " << num[i][j][k];
			}
			cout << endl;
		}
		if(i != 3)cout << "####################" << endl;
	}

    cin>>n;
    return 0;
}

Measured memory_bytes: 3084
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
l = []
for i in range(h):
    a[i].insert(0,'#')
    a[i].insert(w+1,'#')

for j in range(h+2):
    if j == 0 or j == h+1:
        l.append('#'*(w+2))
    else:
        l.append(a[j-1])
        
for i in range(h+2):
    print(''.join(l[i]))

Measured memory_bytes: 63144
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;
//int i, j, k;
long long ans = 0;

long long gcd(long long a, long long b) {
	long long tmp,r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main() {
	long long A, B, C;
	cin >> A >> B;
	C = gcd(A, B);
  	ans++;
  	long long N = C;
	for(long long i=2;i*i<=N;i++){
		if (C % i != 0)continue;
		ans++;
		while (C % i == 0)C /= i;
	}
  	ans +=(C==1 ? 0 : 1);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

/*
	GgXelXÉw×I n < 2^15@¾©çÅ«½±ÆBÅ©¢ÆÊ
*/
//public class Problem1200_GoldbachsConjecture {
public class Main {
	private PrimeMaster primeMaster;
	public static void main(String[] args) {
		try {
		//	Problem1200_GoldbachsConjecture test = new Problem1200_GoldbachsConjecture();
			Main test = new Main();
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String line;
			while((line = reader.readLine()) != null) {
				int target = Integer.parseInt(line);
				if(target < 4) {
					break;
				} else {
					test.showAnswer(target);
				}
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
//	Problem1200_GoldbachsConjecture() {
	Main() {
		primeMaster = new PrimeMaster();
	}
	void showAnswer(int number) {
		int answerNumber = 0;
		
		int counterpart = number-2;
		if(primeMaster.isPrime(counterpart)) {
			answerNumber++;
		}
		for(int i = 3; i <= number/2; i += 2) {
			counterpart = number - i;
			if(primeMaster.isPrime(i) && primeMaster.isPrime(counterpart)) {
				answerNumber++;
			//	System.out.println(i + " + " + counterpart);
			}
		}
		
		System.out.println(answerNumber);
	}
	private class PrimeMaster {
		final private boolean[] SIEVE;	//RÈãÌïÉÂ¢ÄA(n-1)/2 Å¾çêélÌêªtrueÈçfBfalseÈçï
		
		PrimeMaster() {
			SIEVE = createSieve();
		}
		private boolean[] createSieve() {
			boolean[] sieve = new boolean[(int)(Math.pow(2,14))];
			Arrays.fill(sieve, true);
			
			for(int i = 1; i < sieve.length/2; i++) {
				if(sieve[i] == true) {	//sieve[1] = true@ÈçRªfÅRÌ{Í [1+3a] ÌÊuÉ¶Ý·é
										/*
										n1 = (x-1)/2	n1 = (3-1)/2 = 1
										na = (ax-1)/2	n5 = (3*5-1)/2 = 7
										
										na - n1 = ((a-1)*x)/2	:n5-n1 = 6 = 3*((5-1)/2)
										a = 1,3,5,7c ÌÆ«
										na-n1 = 0,x,2x,3x,4xc Æ±­
										sieve[a] Ì{ÌlÌ b{(bÍï)Í sieve[a + bx] Ì{Ìl
										*/
					int trueNumber = i*2 + 1;
					for(int j = i + trueNumber; j < sieve.length; j += trueNumber) {
						sieve[j] = false;
					}
				}
			}
			
			return sieve;
		}
		private boolean isPrime(int number) {
			if(number == 2) {
				return true;
			}
			if(number % 2 == 0 || number == 1) {
				return false;
			}
			return SIEVE[(number-1)/2];
		}
	}
}

Measured memory_bytes: 0
//
// Created by reiji kobayashi on 2019/11/18.
//

#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

typedef long long ll;



int main() {
    int N,K;
    cin >> N >> K;
    vector<int> l(N);
    REP(i,N) cin >> l[i];
    sort(ALL(l));
    reverse(ALL(l));
    int sum=0;
    REP(i,K) sum+=l[i];
    cout << sum << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		long n=sc.nextLong();
		long k=sc.nextLong();
		if(n<k) {
			System.out.println((long)Math.min(n, k-n));
		}else if(n%k==0)System.out.println(0);
		else {
			System.out.println(k-(n%k));
		}
		
		sc.close();
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif

	ll n;
	cin>>n;
	vector<ll> a(n+1);

	for(int i=1;i<=sqrt(n);i++)
	{
		for(int j=i;j<=sqrt(n);j++)
		{
			for(int k=j;k<=sqrt(n);k++)
			{
				ll temp=i*i+j*j+k*k+i*j+i*k+j*k;
				if(temp>n)
					break;
				map<int,int> mp;
				mp[i]++;
				mp[j]++;
				mp[k]++;
				ll toadd=mp.size();
				if(mp.size()==2)
					toadd=3;
				else if(mp.size()==3)
					toadd=6;
				a[temp]+=toadd;
			}
		}
	}

	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3636
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0
for i in range(N-1, 0, -1):
    if H[i] <= H[i-1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))


Measured memory_bytes: 14252
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int s = 1;
		
		for(int i = 0; i < N; i++){
			int s1 = 2 * s;
			int s2 = s + K;
			if(s1 < s2) s = s1;
			else s = s2;
		}
		
		System.out.println(s);
	}
}

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

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

    vector<int> cnt(m, 0);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int food;
            cin >> food;
            food -= 1;
            cnt[food] += 1;
        }
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (cnt[i] == n) {
            ans += 1;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

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

  int n;
  cin >> n;
  cout << n * n * n << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    for (_ <- 0 until N) {
      val c, a, n = sc.nextInt
      val ans1 = math.min(c, math.min(a, n))
      val ans2 = math.min(((c - ans1) / 2): Int, a - ans1)
      val ans3 = ((c - ans1 - ans2 * 2) / 3): Int
      println(ans1 + ans2 + ans3)
    }
  }


  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 45428
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int main(){
	ll n;
	cin >> n;

	ll a,b;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			a = i;
			b = n/i;
		}
	}

	cout << (a+b-2) << endl;

	return 0;
}


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

using namespace std;

typedef pair<double, double> P;
typedef long long ll;

int N;
int visited[9] = {0};
vector<P> d;


void solve(){
    double sum = 0.0;
    int n = 0;
    double dx, dy;
    do{
        for (int i = 0; i < N - 1; i++)
        {
            dx = d[i].first - d[i + 1].first;
            dy = d[i].second - d[i + 1].second;
            sum += sqrt(dx * dx + dy * dy);
        }
        n++;
    }while(next_permutation(d.begin(), d.end()));
    printf("%.8f\n", sum / (double)n );
}


int main(){
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        P p;
        cin >> p.first >> p.second;
        d.push_back(p);

    }
    sort(d.begin(), d.end());
    solve();

    return 0;

}

Measured memory_bytes: 256
mod = 10**9+7
n = int(input())
A = list(map(int,input().split()))

ans = 0
wa = 0
for i in range(n):
    wa = wa + A[i]

wa = wa%mod
wa -= A[0]    

for i in range(n-1):
    tmp = A[i]*wa%mod
    ans = tmp+ans
    wa -= A[i+1]

print(ans%mod)

Measured memory_bytes: 31540
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    cin>> a;
    ll have = 1000;
    for(int i=1;i<n;i++){
        if(a[i-1]<a[i]){
            ll num = have/a[i-1];
            have = have + a[i] * num - num*a[i-1];
        }
    }
    cout << have <<endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = INF;
    for (int i = 1; i < n; i++)
    {
        ll a = i;
        ll b = n - i;
        ll tmp = 0;
        while(a != 0){
            tmp += a%10;
            a/=10;
        }
        while(b!=0){
            tmp += b%10;
            b/=10;
        }
        ans = min(ans,tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
S = input()
S = list(map(int, S))

r = 0
pow10 = 1
counter = [0] * 2019
counter[0] = 1
for i in range(1, len(S) + 1):
    r = (r + pow10 * S[-i]) % 2019
    counter[r] += 1
    pow10 *= 10
    pow10 %= 2019

ans = 0
for count in counter:
    if count >= 2:
        ans += count * (count - 1) // 2

print(ans)


Measured memory_bytes: 75760
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int min = 100000;
        for(int i=0; i<n; i++) {
            a[i] = Integer.parseInt(sc.next());
            if(min > a[i]) min = a[i];
        }
        int count = 0;
        for(int i=0; i<n; i++) {
            if(min == a[i]) count++;
        }
        if((n-count) % (k-1) == 0) System.out.println((n-count)/(k-1));
        else System.out.println(((n-count)/(k-1)) +1);
    }
}


Measured memory_bytes: 46908
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  string s; cin>>s;
  reverse(all(s));
  map<LL,LL> c;
  LL k = 1;
  LL z = 0;
  c[z]++;
  for(auto i:s){
  	z  = (z + (i-'0')*k)%2019;
  	k = k*10%2019;
  	c[z]++;
  }
  LL an = 0;
  for(auto i:c)
  	an += i.se*(i.se-1)/2;
  cout<<an<<endl;

  return 0;
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,k;
  cin >> n >> k;
  int ans=0;
  int h[n];
  rep(i,n) cin >> h[i];
  rep(i,n){
    if(h[i]>=k) ans++;
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 640
a=[[10*[0]for _ in[0]*3]for _ in[0]*4]
for _ in[0]*int(input()):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i<3:print('#'*20)


Measured memory_bytes: 5616
#include<stdio.h>
 
int main(void){
    int w, h, x, y;
    if(scanf("%d %d %d %d", &w, &h, &x, &y));
    printf("%lf %d\n", (double)h * w / 2.0, 2 * x == w && 2 * y == h);
    return 0;
}

Measured memory_bytes: 128
k, n = map(int, input().split())
li = list(map(int,input().split()))

m = n

max_dist = 0
while n >= 1:
    if max_dist < li[n -1] - li[n -2]:
        max_dist = li[n -1] - li[n -2]
    n -= 1

x = 0
while m >= 2:
    x += li[m -1] - li[m -2]
    m -= 1

print(min([k - max_dist, x]))


Measured memory_bytes: 26436
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  int n;cin>>n;
  double ans = 0;
  rep(i,n){
    double x;string u;cin>>x>>u;
    if(u[0] == 'J'){
      ans += x;
    }else{
      ans += 380000.0 * x;
    }
  }
  cout << fixed << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    int N;
    ArrayList<ArrayList<Pair>> G = new ArrayList<>();
    int[][] dp = new int[1 << 15][15];

    int INF = 1 << 20;

    void solve() throws IOException {
        N = ni();
        int M = ni();

        for (int i = 0; i < N; i++) {
            G.add(new ArrayList<>());
        }

        for (int i = 0; i < M; i++) {
            int s = ni();
            int t = ni();
            int d = ni();

            G.get(s).add(new Pair(t, d));
        }

        for (int[] a : dp) Arrays.fill(a, -1);
        int ans = rec(0, 0);
        out.println(ans >= INF ? -1 : ans);
    }

    int rec(int S, int v) {
        if (dp[S][v] >= 0) return dp[S][v];

        if (S == (1 << N) - 1 && v == 0) {
            return 0;
        }

        int ans = INF;
        for (Pair p : G.get(v)) {
            if (((S >> p.x) & 1) == 0) {
                ans = Math.min(ans, rec(S | (1 << p.x), p.x) + p.y);
            }
        }
        return dp[S][v] = ans;
    }

    public class Pair {
        int x, y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main(){
  int n; cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
    }
    int ans=1;
    int a = h[0];
    for(int i=1; i<n; i++){
      a = max(a,h[i]);
      if(a==h[i]){
        ans++;
      }
    }
    cout << ans << endl;
  }


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

int d[2][100010];

vector <int> v[100010];

void dfs(int a, int x, int depth) {
    if (d[a][x] != -1) return;
    d[a][x] = depth;
    for(auto i : v[x]) {
        dfs(a, i, depth+1);
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a, b;
    rep(i, N-1) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    rep(i, 2) rep(j, N+1) d[i][j] = -1;
    int cnt = 0, cnt2 = 0;
    dfs(0, 1, 0); dfs(1, N, 0);
    rep(i, N) {
        if (d[0][i+1] <= d[1][i+1]) cnt++;
        else cnt2++;
    }
    if (cnt > cnt2) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }

    return 0;
}


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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;
  int input[101][101];
  int graph[101][101];
  rep(i, 101) rep(j, 101) input[i][j] = graph[i][j] = inf;
  rep(i, 101) input[i][i] = graph[i][i] = 0;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    input[a][b] = input[b][a] = graph[a][b] = graph[b][a] = c;
  }
  rep(i, N) rep(j, N) rep(k, N) {
    graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
  }
  int ans = 0;
  rep(i, N) reps(j, i+1, N) {
    if(input[i][j] == inf) continue;
    if(input[i][j] != graph[i][j]) ans++;
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 512
N = int(input())
H_array = map(int,input().split())

count = 0
ans = 0
now_h = 10 ** 10
for h in H_array:
    if now_h >= h:
        now_h = h
        count += 1
        ans = max(ans,count)
    else:
        now_h = h
        count = 1

print(ans-1)

Measured memory_bytes: 64240
#include <iostream>

using namespace std;

int main(){
    char c[3];
    cin >> c[0] >> c[1] >> c[2];

    int sum=700;

    if(c[0] == 'o') sum += 100;
    if(c[1] == 'o') sum += 100;
    if(c[2] == 'o') sum += 100;

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

struct sct
{
	char t;
	int r1[11];
	int win;
	int lose;
	int drow;
	int input;
};

int main()
{
	while(true)
	{
		int n = 0;
		sct team[11];
		sct cl = {0, 0, 0, 0, 0, 0}; 

		cin >> n;

		if(n == 0)
		{
			return false;
		}

		for(int i= 0; i < n; i++)
		{
			team[i] = cl;
			team[i].input = i;
			
			cin >> team[i].t;

			for(int j = 0; j < n - 1; j++)
			{
				cin >> team[i].r1[j];
			}
		}

		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < n - 1; j++)
			{
				if(team[i].r1[j] == 0)
				{
					team[i].win++;	
				}
				
				else if(team[i].r1[j] == 1)
				{
					team[i].lose++;
				}
				else if (team[i].r1[j] == 2)
				{
					team[i].drow++;
				}				
			}
		}

		for(int i = 0; i < n; i++)
		{
			for(int j = i; j < n; j++)
			{
				if(team[i].win < team[j].win)
				{
					sct tmp = team[i];
					team[i] = team[j];
					team[j] = tmp;
				}
				else if(team[i].win == team[j].win)
				{
					if(team[i].lose > team[j].lose)
					{
						sct tmp = team[i];
						team[i] = team[j];
						team[j] = tmp;
					}
					else if(team[i].lose == team[j].lose)
					{
						if(team[i].input > team[j].input)
						{
							sct tmp = team[i];
							team[i] = team[j];
							team[j] = tmp;
						} 	
					}
				}
			}
		}

		for(int i = 0; i < n; i++)
		{
			cout << team[i].t << endl;
		}
	}
}

Measured memory_bytes: 1148
import sys
N = int(input())
S = input()
if N == 1:
    print("1")
    sys.exit()
ans = 0
for i in range(N - 1):
    if S[i] != S[i + 1]:
        ans += 1
    if i == N - 2:
        ans += 1

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main (){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
  }
  map<int,int> mp;
  for(int i=0;i<m;i++){
    if(a[i]==1){
      mp[b[i]]=1;
    }
  }
  bool ans = false;
  for(int i=0;i<m;i++){
    if(b[i]==n){
     if(mp[a[i]]>=1)
      ans = true;
    }
  }
  if(ans){
    cout<<"POSSIBLE"<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}


Measured memory_bytes: 11136