akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		long n = Integer.parseInt(sa[0]);
		long a = Integer.parseInt(sa[1]);
		long b = Integer.parseInt(sa[2]);
		long c = Integer.parseInt(sa[3]);
		long d = Integer.parseInt(sa[4]);
		br.close();

		long ba = b - a;

		for (int i = 0; i < n; i++) {
			if (c * i - d * (n - 1 - i) <= ba
					&& ba <= d * i - c * (n - 1 - i)) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e3 + 5;
long double p[N];
int n;
long double dp[N][N];

void solve()
{
    cin >> n;

    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);

    for (int i = 1; i <= n; i++)
        cin >> p[i];
    mem0(dp);

    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for (int i = 2; i <= n; i++)
    {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int j = 1; j <= i; j++)
        {
            dp[i][j] = dp[i - 1][j] * (1.00 - p[i]) + dp[i - 1][j - 1] * p[i];
        }
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++)
        ans += dp[n][i];
    cout << ans << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 141440
using System;

namespace Circle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			double sq, l, r;
			r = double.Parse (Console.ReadLine ());
			sq = r * r * Math.PI;
			l = 2 * r * Math.PI;

			Console.WriteLine("{0:f6} {1:f6}", sq, l);

		}
	}
}

Measured memory_bytes: 5776
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ELeague {
public:
    int N;
    vc<int> used, deg;
    vvc<int> G;
    queue<int> que;

    int bfs(){
        int ans = 1;
        unordered_set<int> S;
        while(not que.empty()){
            int u = que.front();
            used[u] = 1;
            que.pop();
            if(S.count(u/N) or S.count(u%N)){
                S.clear();
                ++ans;
            }
            for(int& v : G[u]){
                deg[v]--;
                if(deg[v]==0){
                    que.push(v);
                    used[v] = 1;
                    S.insert(v/N), S.insert(v%N);
                }
            }
        }
        return ans;
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        in>>N;
        G.resize(N*N);
        deg.resize(N*N, 0);
        used.resize(N*N, 0);
        vc<int> A(N-1);
        REP(i, N){
            REP(j, N-1) in>>A[j], A[j]--;
            REP(j, N-2){
                int cur = i < A[j] ? i * N + A[j] : A[j] * N + i;
                int nxt = i < A[j+1] ? i * N + A[j+1] : A[j+1] * N + i;
                G[cur].pb(nxt);
                deg[nxt]++;
            }
        }
        REP(i, N) FOR(j, i+1, N){
            if(deg[i*N+j]==0) que.push(i*N+j);
        }
        int ans = bfs();
        REP(i, N) FOR(j, i+1, N){
            if(not used[i*N+j]) ans = -1;
        }
        out<<ans<<'\n';
    }
};


int main() {
	ELeague solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;


void _main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    REP (i, H) cin >> s[i];
    int ans = 0;
    REP (bit1, 1 << H) REP (bit2, 1 << W) {
        vector<string> t = s;
        REP (i, H) if (bit1 >> i & 1) {
            REP (j, W) t[i][j] = '.';
        }
        REP (j, W) if (bit2 >> j & 1) {
            REP (i, H) t[i][j] = '.';
        }
        int num = 0;
        REP (i, H) REP (j, W) {
            num += (t[i][j] == '#');
        }
        ans += (num == K);
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




int cnt[2005];
int dist[2005];
V<int>adj[2005];
PQ<PII,V<PII>,greater<PII> >pq;

void runBFS()
{
    int x,y;
    while(!pq.EM)
    {
        x=pq.T.SE;
        y=pq.T.FI;
        pq.PP;
        for(int bal : adj[x])
        {
            if(dist[bal] > y+1)
            {
                dist[bal]=y+1;
                pq.PS({y+1,bal});
            }
        }
    }
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,j,k,n,x,y;
    cin >> n >> x >> y;
    for(i=2;i<=n;i++)
    {
        adj[i-1].emplace_back(i);
        adj[i].emplace_back(i-1);
    }
    adj[x].emplace_back(y);
    adj[y].emplace_back(x);
    runBFS();
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)dist[j]=INT_MAX;
        dist[i]=0;
        pq.PS({0,i});
        runBFS();
        for(j=1;j<=n;j++)cnt[dist[j]]++;
    }
    for(i=1;i<n;i++)cout << cnt[i]/2 << '\n';
    return 0;
}


Measured memory_bytes: 384
/*


                 """Bismillahir Rahmanur Rahim"""

*/
#include<bits/stdc++.h>
using namespace std;
#define pi 2*acos(0.0)
#define ll long long int
#define inf 922337203470075000
#define pb push_back
#define pf push_front
const ll sz = 1000001;
#define ek(x) __builtin_popcount(x)
#define ses '\n'
#define in(x) scanf("%lld",&x);
#define out(x) printf("%lld\n",x);
#define stm istringstream
#define all(x) x.begin(),x.end()
#define ghora ios_base::sync_with_stdio(0);cin.tie(0);
#define gcd __gcd
ll lcm(ll x,ll y){return (x*y)/gcd(x,y);}
#define tin ll T;cin>>T; for(ll o=1;o<=T;o++)
#define tout cout<<"Case "<<o<<": ";
#define spc printf(" ");
std::vector<ll> v;
ll n;
ll dp[100000];
ll f(ll i)
{
    if(i>=n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll x,y;
    if(i+1<n)
    x=abs(v[i]-v[i+1])+f(i+1);
     if(i+2<n)
    y=abs(v[i]-v[i+2])+f(i+2);
return dp[i]=min(x,y);
}
int main()
{
   
     ll p;
     memset(dp,-1,sizeof(dp));
     cin>>n;
     for(ll i=0;i<n;i++)
     {
        cin>>p;
        v.pb(p);
     }
     ll x=f(0);
     cout<<x<<ses;
    return 0;
}
/*   --------------------
    |      ~SOHAN~       |
    |   ~Chandler68~     |
     --------------------
    || VALAR MORGULIS||==|| ALL MEN MUST DIE ||
    \\ Power Is Power//
    || I Can Do This All day ||
    // We are on a Break \\ // How you doin'? \\
    || Say My Name || ~~ || I Am The Who Knocks ||
    // I Am Ted Mosby Architect \\
    || It Is Legen --wait for it -- dary ,Legendary ||
    \\ Penny - Penny - Penny // -- Bazinga

*/

Measured memory_bytes: 5108
import { readFileSync } from 'fs'

function main(input: string) {
  const [N, ...list] = input.trim().split(/\s/).map(Number)

  const result = list
    .map((v, i, self) => [self[i - 1], v, self[i + 1]])
    .filter(([a, b, c]) => (a < b && b < c) || (a > b && b > c))

  console.log(result.length)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <list>
#include <map>
using namespace std;

struct C
{
  string s;
  int x1;
  int y1;
  int x2;
  int y2;
  C ( int x1, int y1, int x2, int y2, const char *s )
  {
    this->x1 = x1;
    this->y1 = y1;
    this->x2 = x2;
    this->y2 = y2;
    this->s = s;
  }
};

int
main (
  int   argc,
  char *argv[ ]
  )
{
  list<C>::iterator it;
  int i;

  for ( ; ; )
  {
    map<string,list<C> > lis;
    list<string> buf;
    list<string> cont;
    int w, h;
    int n;

    scanf ( " %d", &n );
    if ( n == 0 ) break ;

    scanf ( " %d %d", &w, &h );
    while ( n-- )
    {
      list<C> r;
      char s[ 32 ];
      int c;

      scanf ( " %s %d", s, &c );
      if ( buf.empty ( ) )
        buf.push_back ( s );
      for ( i = 0; i < c; ++i )
      {
        int x1, y1, x2, y2;
        char t[ 32 ];

        scanf ( " %d %d %d %d %s", &x1, &y1, &x2, &y2, t );
        r.push_back ( C ( x1, y1, x2, y2, t ) );
      }
      lis[ s ] = r;
    }

    scanf ( " %d", &n );
    while ( n-- )
    {
      char cmd[ 32 ];

      scanf ( " %s", cmd );

      if ( strcmp ( "show", cmd ) == 0 )
      {
        puts ( buf.back ( ).c_str ( ) );
        continue ;
      }
      if ( strcmp ( "click", cmd ) == 0 )
      {
        list<C> *p;
        int x, y;

        scanf ( " %d %d", &x, &y );

        p = &lis[ buf.back ( ) ];
        for ( it = p->begin ( ); it != p->end ( ); ++it )
        {
          if ( x >= it->x1 && x <= it->x2
            && y >= it->y1 && y <= it->y2 )
          {
            buf.push_back ( it->s );
            cont.clear ( );
            break ;
          }
        }

        continue ;
      }
      if ( strcmp ( "back", cmd ) == 0 )
      {
        if ( buf.size ( ) >= 2 )
        {
          cont.push_front ( buf.back ( ) );
          buf.pop_back ( );
        }
        continue ;
      }
      if ( strcmp ( "forward", cmd ) == 0 )
      {
        if ( cont.size ( ) >= 1 )
        {
          buf.push_back ( cont.front ( ) );
          cont.pop_front ( );
        }
        continue ;
      }
    }
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 1124
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    int a[3];
    for (int i=0; i < 3; i++) scanf("%d", &a[i]);

    if (22 <= a[0]+a[1]+a[2]) printf("bust\n");
    else printf("win\n");



    return 0;
} 



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

int main() {
  int n, q;
  // int time[100000];
  // string name[100000];

  cin >> n >> q;
  string name[n];
  int time[n];
  queue<int> timeq;
  queue<string> nameq;
  pair<string, int> x;
  for(int i = 0; i < n; i++ ){
    cin >> name[i] >> time[i];
    //x = make_pair(name[i], time[i]);
    nameq.push(name[i]); // {0, 1, 2, ...}
    timeq.push(time[i]);
    // cout << s.top() << endl;
  }
  // cout << nameq.front() << timeq.front() << endl;

  bool flag = true;
  int t = 0, i = 0;
  while(nameq.size()){
    // cout << t << endl;
    if ( timeq.front() <= q ) { // 完了！
      t += timeq.front();
      cout << nameq.front() << " " << t << endl;
      timeq.pop(); // 最初が消える
      nameq.pop(); // 最初が消える
    } else { // 完了しない場合
      t += q;
      string tmp_n = nameq.front();
      int tmp_t = timeq.front() - q;
      nameq.push(tmp_n);
      timeq.push(tmp_t);
      nameq.pop();
      timeq.pop();
    }

  }

  return 0;
}



Measured memory_bytes: 6724
n,m,q=map(int,input().split())
ans=[[0 for _ in range(n+1)] for _ in range(n+1)]
for _ in range(m):
    l,r=map(int,input().split())
    ans[l][r]+=1
#print(ans)
for l in range(2,n+1):
    for i in range(1,n+1):
        j=i+l-1
        if j>n or i+1>n:
            continue
        if i+1<=j-1:
            ans[i][j]+=ans[i][j-1]+ans[i+1][j]-ans[i+1][j-1]
        else:
            ans[i][j]+=ans[i][j-1]+ans[i+1][j]
#print(ans)
for _ in range(q):
    p,q=map(int,input().split())
    print(ans[p][q])



Measured memory_bytes: 9440
#include <iostream>

using namespace std;

int main(){
  int a[3], b[3], i, flag=0;
  int count[5];
  for(i=1; i<5; i++) count[i] = 0;
  for(i=0; i<3; i++){
    cin >> a[i] >> b[i];
  }
  for(i=0; i<3; i++){
    count[a[i]]++;
    count[b[i]]++;

  }

  for(i=1; i<=4; i++){
    //cout << count[i]<<"\n";
    if(count[i] == 3) flag = 1;
  }
  if(flag == 1) cout << "NO\n";
  else cout << "YES\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void makeoneg(vec &ve, mat a){
    rep(s,1<<N){
        bool first = true;
        ll ls;
        ll &ndp = ve.at(s);
        rep(j,N){
            if((s>>j)&1){
                if(first) {
                    ls = j;
                    first = false;
                }else{
                    ndp += a.at(j).at(ls);
                }
            }
        }
        if(!first) ndp += ve.at(s^(s&-s));
    }
}

int main() {
    cin>>N;
    mat a(N,vec(N));
    rep(i,N) rep(j,N) cin>>a[i][j];
    vec oneg(1<<N);
    makeoneg(oneg,a);
    vec dp(1<<N,0);
    rep(s,1<<N) {
        vec rab(0);
        rep(i, N) if (s >> i & 1) rab.push_back(i);
        ll rsize = rab.size();
        ll ans = 0;
        rep(i, 1 << rsize) {//iはsの1の部分だけ抜き出したイメージ
            ll ns = 0;
            rep(j, rsize) if ((i >> j) & 1) ns =ns | (1 << rab.at(j));
            ans = max(ans, dp.at(ns) + oneg.at(s ^ ns));
        }
        dp.at(s) = ans;
    }
    cout<<dp.at((1<<N)-1)<<endl;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{

	public static void main(String[] args)  {

		Scanner sc = new Scanner(System.in);
		int numN = sc.nextInt();
		int numM = sc.nextInt();
		int numL = sc.nextInt();
		long[][] arrA = new long[numN][numM];
		long[][] arrB = new long[numM][numL];
		long[][] arrTot = new long[numN][numL];

		for (int i = 0; i < numN; i++) {
			for (int j = 0; j < numM; j++) {
				arrA[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < numM; i++) {
			for (int j = 0; j < numL; j++) {
				arrB[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < numN; i++) {
			for (int j = 0; j < numL; j++) {
				for (int k = 0; k < numM; k++) {
					arrTot[i][j] += arrA[i][k] * arrB[k][j];
				}
			}
		}
		for (int i = 0; i < numN; i++) {
			System.out.print(arrTot[i][0]);
			for (int j = 1; j < numL; j++) {
				System.out.print(" " + arrTot[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 52948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;


int main() {


	int N = 0;
	cin >> N;

	vector<int> a(N);
	vector<int> b(N);
	ll n = 0;
	ll p = 0;

	FOR(i, 0, N)
		cin >> a[i];
	FOR(i, 0, N)
		cin >> b[i];
	FOR(i, 0, N) {
		int xx = a[i] - b[i];
		if (xx > 0)
			p += xx;
		else if (xx < 0) {
			n += (2 * int(-xx/2));
		}
	}

	if (n >= 2 * p)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 512
import heapq
n , m = map(int, input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i]*=-1
heapq.heapify(a)

for i in range(m):
    t = (heapq.heappop(a)*(-1)//2)*(-1)
    heapq.heappush(a,t)

print(sum(a)*(-1))

Measured memory_bytes: 20328
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 100010;
ll a[N], sum[N];
int main(){
	int n;
	read(n);
	for (int i = 0; i <= n; i++) read(a[i]);
	for (int i = n; i >= 0; i--) sum[i] = a[i] + sum[i + 1];
	ll ans = 0, now = 1;
	for (int i = 0; i <= n; i++){
		ans = ans + min(now, sum[i]);
		now = now - a[i];
		if (now < 0){
			puts("-1");
			return 0;
		}
		now = now * 2;
		now = min(now, infll);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n,m,u,v,dp[1007][1007];
bool vis[1007];
pair <int,int> ed[200007];
vector <int> edge[1007];
void dfs(int u,int par,int from){
	if(u==from) return;
	if(dp[from][u]==2) return;
	if(dp[from][u]==1 && vis[u]) return;
	dp[from][u]++, vis[u]=true;
	for(int v:edge[u]){
		if(v==par) continue;
		dfs(v,u,from);
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		edge[u].pb(v);
		ed[i]=mp(u,v);
	}
	for(int i=1;i<=n;i++){
		for(int x:edge[i]){
			memset(vis,false,sizeof(vis));
			dfs(x,i,i);
		}
	}
	for(int i=1;i<=m;i++){
		u=ed[i].fi;
		v=ed[i].se;
		bool ok=true;
		if(dp[u][v]>=2){
			if(dp[v][u]==0) ok=true;
			else ok=false;
		}
		else{
			if(dp[v][u]>=1) ok=true;
			else ok=false;
		}
		if(ok) cout<<"diff\n";
		else cout<<"same\n";
	}
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli N=1e5+5;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli n,w;
    cin>>n>>w;
    lli i,j,dp[n+1][N],weight[n+1],value[n+1],ans=0;
    
    for(i=0;i<=n;i++)
    {
        for(j=0;j<N;j++)
        {
            if(j==0)
            dp[i][j]=0;
            else
            dp[i][j]=1e10;
        }
    }
    
    for(i=1;i<=n;i++) cin>>weight[i]>>value[i];
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<N;j++)
        {
            if(j-value[i]>=0)
            {
                dp[i][j]=min(dp[i][j],weight[i]+dp[i-1][j-value[i]]);
            }
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    
    for(i=1;i<=n;i++) for(j=1;j<N;j++) if(dp[i][j]<=w) ans=max(ans,j);
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 79232
read N
digit1=`echo $N | rev | cut -c 1 | rev`
if [ "$digit1" = "3" ]; then
echo bon
elif [ "$digit1" = "0" ] || [ "$digit1" = "1" ] || [ "$digit1" = "6" ] || [ "$digit1" = "8" ]; then
echo pon
else
echo hon
fi

Measured memory_bytes: 3828
N, K = map(int, input().split())
S = list(input())
S = list(map(int, S))
nums = []

now = 1
cnt = 0
for i in range(N):
    if S[i] == now:
        cnt += 1
    else:
        nums.append(cnt)
        cnt = 1
        now = 1 - now
if cnt != 0:
    nums.append(cnt)
    
if S[N-1] == 0:
    nums.append(0)

sums = [0] * (len(nums) + 1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]

Add = 2 * K + 1
res = 0
for left in range(0, len(nums), 2):
    right = left + Add
    if right >= len(sums):
        right = len(sums) - 1
    res = max(res, sums[right] - sums[left])

print(res)


Measured memory_bytes: 8432
#include <iostream>
#include <cstdio>
using namespace std;
int n, k, x, y, s, mx, a[2005][2005];
char c;
int main() {
	int i, j, t;
	cin>>n>>k;
	for(i=0; i<n; i++) {
		scanf("%d%d%s\n", &x, &y, &c);
		t = c=='W' ? 0:1;
		t = (t + x/k + y/k) % 2;
		x = x%k + 1;
		y = y%k + 1;
		if(t==0) a[x][y]++, a[x+k][y+k]++;
		else a[x+k][y]++, a[x][y+k]++;
	}
	for(i=1; i<=2*k; i++) for(j=1; j<=2*k; j++)
		a[i][j] += a[i-1][j] + a[i][j-1] - a[i-1][j-1];
	for(i=0; i<k; i++) for(j=0; j<k; j++) {
		s = a[i][j] + a[i+k][j+k] - a[i+k][j] - a[i][j+k];
		mx = max(mx, max(s, n-s));
	}
	printf("%d", mx);
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  scanf("%d", &n);

  int paper = n / 2 + (n % 2);

  printf("%d\n", paper);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 1e5 + 5;

int n;
int a[N];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);
    int mx = 0;
    for(int i = 0 ; i < n ; ++i){
        int cnt = 0;
        while(i + 1 < n && a[i] >= a[i + 1])++i, ++cnt;
        mx = max(mx, cnt);
    }
    printf("%d\n", mx);
}

Measured memory_bytes: 640
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    AB = LLIN(N)
    CD = LLIN(M)
    for a,b in AB:
        mini = inf
        mini_idx = -1
        for i,(c,d) in enumerate(CD,start=1):
            d = abs(c-a) + abs(d-b)
            if mini>d:
                mini = d
                mini_idx = i
        print(mini_idx)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def _cmb(N, mod):
    N1 = N + 1
    fact = [1] * N1
    inv = [1] * N1

    for i in range(2, N1):
        fact[i] = fact[i-1] * i % mod

    inv[N] = pow(fact[N], mod-2, mod)
    for i in range(N-1, 1, -1):
        inv[i] = inv[i+1]*(i+1) % mod

    def cmb(a, b):
        return fact[a] * inv[b] % mod * inv[a-b] % mod
    return cmb

def resolve():
    K = int(input())
    s = input()
    ls = len(s) - 1
    mod = 10**9+7

    cmb = _cmb(ls+K, mod)

    ans = 0
    p25 = 1
    p26 = pow(26, K, mod)
    p26inv = 576923081 #pow(26,  mod-2, mod)
    for i in range(K+1):
        ans = (ans + cmb(ls+i, ls) * p25 % mod * p26 % mod) % mod
        p25 = p25 * 25 % mod
        p26 = p26 * p26inv % mod
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 102972
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)

//C++で提出



// string s="AAA";    s.size() =3    (sのサイズ) ...1
// vector <int> a;    配列a(サイズは0) ...2
// a.push_back(10);   配列のサイズが一つ増えて一番後ろに10を代入 ...2
// A.pop_back();   最後の要素が消去される
// sort(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)より前までを小さい順に並び替えてa[0]から代入していく...3
// reverse(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)までを逆の順にしてa[0]から代入していく
// s.substr(3,2)   配列s[3]から2個の文字を抜き出した文字列 (s[3]とs[4]) ...4
// strcmp(s1,s2)  文字列が等しければ0を出力　s1>s2なら1 s1<s2なら-1を出力　C言語用なので配列は、s1[100]にする...5





int main()
{
	char s[6];
	int Ans = 0;
	int i;
	scanf("%s",s);
	rep(i, 0, 6) {


		if (s[i] == '1') Ans++;
	}
	
	cout << Ans;

	
}

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

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> P;
    vector<vector<int>> City(n+1);
    for(int i = 0; i < m; i++) {
        int p, y;
        cin >> p >> y;
        City[p].push_back(y);
        P.push_back(make_pair(p, y));
    }
    for(int i = 1; i <= n; i++) {
        sort(City[i].begin(), City[i].end());
    }
    for(auto au : P) {
        string ans = "";
        string a = to_string(au.first);
        for(int i = 0; i < (6-a.size()); i++) {
            ans += '0';
        }
        ans += a;
        int it = lower_bound(City[au.first].begin(), City[au.first].end(), au.second) - City[au.first].begin();
        it++;
        string b = to_string(it);
        for(int i = 0; i < (6-b.size()); i++) {
            ans += '0';
        }
        ans += b;
        cout << ans << "\n";
    }
    return 0;
}

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

int main() {
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    double m=w;
    m *= h;
    m/=2;

    cout << fixed << setprecision(10);
    cout << m << ' ';

    if(2*x==w && 2*y==h) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>

int a(int,int);
int S[100000];

int main()
{

  int count, n, q, i;

  count = 0;

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

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

  for(i=0;i<q;i++){
    if(a(n,T[i]) != -1){
      count++;
    }
  }

  printf("%d\n",count);

  return 0;

}


int a(int n,int key)
{

  int left, right, mid;

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



Measured memory_bytes: 2284
import java.util.Scanner;

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

    System.out.println(calcDebt(n));
  }

  static int calcDebt(int a) {
    int debt = 100000;

    for (int i = 0; i < a; i++) {
      debt *= 1.05;
      debt = (int)Math.ceil((debt / 1000.0)) * 1000;
    }

    return debt;
  }
}

Measured memory_bytes: 17164
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int x; cin >> x;

	if(x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;


	return 0;

}


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

using namespace std;

typedef struct {
  int x;
  int y;
} pos_t;

int isin(int);
int icos(int);

int main(void) {
  int H, W; cin >> H >> W;

  bool MAP[H+2][W+2];
  for (int i = 1; i <= H+1; i++) {
    MAP[i][0]     = false;
    MAP[i-1][W+1] = false; 
  }
  for (int i = 1; i <= W+1; i++) {
    MAP[0][i-1]   = false;
    MAP[H+1][i]   = false; 
  }

  for (int y = 1; y <= H; y++) {
    string line; cin >> line;
    for (int x = 1; x <= W; x++) {
      if (line[x-1] == '.') {
        MAP[y][x] = true;
      } else {
        MAP[y][x] = false;
      }
    }
  }
  
  int ans = 0;
  for (int y = 1; y <= H; y++) {
    for (int x = 1; x <= W; x++) {

      if (!MAP[y][x]) continue;

      vector<pos_t> curr, next;
      bool canPass[H+2][W+2];
      memcpy(canPass, MAP, sizeof(canPass));

      pos_t S; S.x = x; S.y = y;
      canPass[S.y][S.x] = false;
      next.push_back(S);

      int move = 0;
      while (!next.empty()) {
        curr = next;
        next.clear();
        for (auto it = curr.begin(); it != curr.end(); it++) {

          for (int th = 0; th < 4; th++) {
            int dy, dx;
            dy = isin(th);
            dx = icos(th);

            if (canPass[it->y + dy][it->x + dx]) {
              pos_t ne;
              ne.y = it->y + dy;
              ne.x = it->x + dx;
              canPass[ne.y][ne.x] = false;
              next.push_back(ne);
            }
          }
        }
        if (!next.empty()) move++;
      }

      if (move > ans) ans = move;
    }
  }
  
  cout << ans << endl;
  return 0;
}

int isin(int th) {
  return ((th&1) == 0 ? 0 : 1) * ((th&2) == 0 ? 1 : -1);
}
int icos(int th) {
  return ((th&1) == 0 ? 1 : 0) * ((th&2) == 0 ? 1 : -1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
 
int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n)   cin >> a[i];
 
    priority_queue<ll, vector<ll>, greater<ll>> q;
    rep(i, n) q.push(a[i]);
 
    map<ll, int> m;
    rep(i, n){
        m[q.top()] = i+1;
        q.pop();
    }
 
    ll sum = 0;
    rep(i, n){
        if((i+1) % 2 == 1 && m[a[i]] % 2 == 0){
            sum++;
        }
        else if((i+1) % 2 == 0 && m[a[i]] % 2 == 1){
            sum++;
        }
    }
    cout << sum/2 << endl;
 
 
    return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  string s;
  cin >> s;
  int op = 0;
  
  for(int i=0;i<=7;i++){
    string equStr = "";
    equStr += s[0];
    int ans = s[0]-'0';
    for(int j=0;j<3;j++){
      if((i>>j)%2==0){
        equStr += "+"; 
        ans += s[j+1]-'0';
      }
      else{
        equStr += "-"; 
        ans -= s[j+1]-'0';
      }
      equStr += s[j+1]; 
    }
    if(ans==7){
      cout << equStr << "=7" << endl;
      return 0;
    }
  }
  
  
  return 0;
}



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

#define MAX(a, b) (((a)>(b)) ? (a) : (b))
#define MIN(a, b) (((a)<(b)) ? (a) : (b))

int main()
{
    int n;
    int array_a[101];
    int array_b[101];
    long long int a = 0;

    scanf("%d", &n);

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

    a += array_b[1];

    for (int i = 2; i<n; i++)
    {
        a += MIN(array_b[i], array_b[i-1]);
    }

    a += array_b[n-1];

    printf("%lld", a);

    return 0;
}

Measured memory_bytes: 1720
n = int(input())
l = sorted([int(i) for i in input().split(' ')])

if len(l) < 3:
    print(0)
    exit()

count = 0

for i in range(0, (n - 2)):
    for j in range((i + 1), (n - 1)):
        if l[i] == l[j]:
            continue
        for k in range((j + 1), n):
            if l[j] == l[k]:
                continue

            if l[i] + l[j] > l[k]:
                count += 1

print(count)

Measured memory_bytes: 9184
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//abc176A
int main(void) {
  int n, x, t, k, i, cou=0, tmp;
  scanf("%d %d %d", &n, &x, &t);
  printf("%d", ((n-1)/x+1)*t);
  return 0;
}


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

int main(){
    ll a,b;
    cin >> a >> b;
    vector<ll> a_prime;
    a_prime.push_back(1);
    ll c=a;
    for(ll i=2; i*i<=a; i++){
        if(c%i == 0){
            a_prime.push_back(i);
            while(c%i==0){
                c  /= i;
            }
        }
    }
    if(c != 1){
        a_prime.push_back(c);
    }
    int count=0;
    for(int i=0; i<a_prime.size(); i++){
        ll k=a_prime.at(i);
        if(b%k==0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3536
#include <cstdio>

using namespace std;

int main( void )
{

	int hand_list[5];
	int hands;
	while( 1 )
	{
		hands = 0;

		for( int i = 0; i < 5; ++i )
		{
			scanf( "%d", &hand_list[i] );
			if( hand_list[0] == 0 )
				goto end_0205;
			hands |= 1 << (hand_list[i] - 1);
		}

		for( int i = 0; i < 5; ++i )
		{
			if( hands == 0x0001 || hands == 0x0002 || hands == 0x0004 || hands == 0x0007 )
			{
				puts( "3" );
			}
			else
			{
				if( hands == 0x0003 )
				{
					if( hand_list[i] == 2 ) puts( "2" );
					else puts( "1" );
				}
				else if( hands == 0x0006 )
				{
					if( hand_list[i] == 3 ) puts( "2" );
					else puts( "1" );
				}
				else if( hands == 0x0005 )
				{
					if( hand_list[i] == 1 ) puts( "2" );
					else puts( "1" );
				}
			}
		}
	}

end_0205:
	return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
//using mint = modint1000000007;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1 << 30) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-9;
constexpr double pi = acos(-1.0);
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {each(in, v) is >> in; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) os << v[i] << (i + 1 != sz(v) ? " " : ""); return os;}
template<typename T> constexpr void print(const T& t) {cout << t << "\n";}
template<typename Head, typename... Tail> constexpr void print(const Head& head, const Tail&... tail) {print(head); print(tail...);}
template<typename T, typename U> constexpr bool chmax(T& a, const U& b) {if (a < b) a = b; return a < b;}
template<typename T, typename U> constexpr bool chmin(T& a, const U& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    int n, k;
    cin >> n >> k;
    vi p(n);
    cin >> p;
    sort(all(p));
    int sum = 0;
    rep(i, k) sum += p[i];
    print(sum);
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MAXN 200002

 

int n, k, c;
char s[2000005];
stack <int> sta;

 

int main () {
    cin >> n >> k >> c ;
    scanf("%s",s);
    for (int i = n - 1, j = 0; i >= 0 && j < k; i --) {
        if (s[i] == 'o') {
            sta.push (i);
            j ++; i -= c;
        }
    }
    for (int i = 0, j = 0; i < n && j < k; i ++) {
        if (s[i] == 'o') {
            if (sta.top () == i) cout << (i + 1) << endl;
            sta.pop ();
            j ++; i += c;
        }
    }
    return 0;
}

Measured memory_bytes: 2332
#define FOR(i, min, max) for(int (i) = (min); (i) < (max); (i)++)

#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

int main()
{
	int n, c = 0;
	cin >> n;
	FOR(i, 0, n)
	{
		int r;
		cin >> r;
		if (r == 2 || r == 3)
		{
			c++;
			continue;
		}
		if (r > 1 && (r % 6 == 5 || r % 6 == 1))
		{
			bool ch = true;
			FOR(j, 2, (int)sqrt(r) + 1)
			{
				if (r % j == 0)
				{
					ch = false;
					break;
				}
					
			}
			if (ch)	c++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    ll N; cin >> N;
    ll A[N], B[N], C[N];
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N-1) cin >> C[i];

    ll ans = 0;
    ll last = -1;
    REP(i, N) {
        ans += B[A[i]-1];
        if (i>0 && last == A[i]-1) {
            ans += C[last-1];
        }
        last = A[i];
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> p(n);
    vector<long long> o(n);
    for(long long i = 0; i < n; i++){
        cin >> p[i];
        o[i] = i + 1;
    }

    long long cnt = 0;
    for(long long i = 0; i < n; i++){
        if(p[i] != o[i]) cnt++;
    }

    if(cnt == 0 || cnt == 2) printf("YES\n");
    else printf("NO\n");
    
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	double sum = 0;
	FOR(i,0,n) {
		double x; cin >> x;
		sum += 1/x;
	}
	cout << fixed << setprecision(20) << 1/sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;

    if(S == U){
        cout << A-1 << ' ' << B;
    }else{
        cout << A << ' ' << B-1;
    }

    return 0;    
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

ll n, m;
//ll a[1000100];

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

  cin >> n >> m;
  priority_queue<ll> q;

  REP(i,n) {
    ll tmp;
    cin >> tmp;    
    q.push(tmp);
  }

  REP(i,m) {
    ll tmp = q.top();
    q.pop();
    tmp /= 2;
    q.push(tmp);
  }    

  ll sum = 0LL;
  while (!q.empty()) {
    sum += q.top();
    q.pop();
  }  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define FOR(i,s,n) for(ll (i)=(s);(i)<=(n);(i)++)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
   ll n;
   int count = 0;
   cin >> n;
   vector<string> s(n);
   rep(i,0,n){
     cin >> s[i];  
   } 
   sort(all(s));

   FOR(i,1,n){
       if(s[i]!=s[i-1]){
           count++;
       }
   }
       
   
  cout << count << endl;     

   return 0;
}


Measured memory_bytes: 9600
import java.util.*;

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

  private void run() {
    while(sc.hasNext()) {
      int id = sc.nextInt();

      if(id == 0) System.out.println(dq.pop());
      else dq.push(id);
    }
  }

  private final Scanner sc = new Scanner(System.in);
  private final Deque<Integer> dq = new ArrayDeque<Integer>();
}

Measured memory_bytes: 12000
fn main() {
    let div = 1000000000 + 7;
    let n = read::<u64>();
    let mut ans = 1;
    for i in 1..n + 1 {
        ans *= i;
        ans %= div;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352