akhauriyash/Code-Regression huggingface dataset:
import sys
bbn=1000000007
	
#+++++

		
def main():
	sx,sy,tx,ty = map(int, input().split())
	cx=tx-sx
	cy=ty-sy
	
	u='U'
	d='D'
	l='L'
	r='R'
	
	ret=''
	ret+=u*cy
	ret+=r*cx
	ret+=d*cy
	ret+=l*(cx+1)
	ret+=u*(cy+1)
	ret+=r*(cx+1)
	ret+=d
	ret+=r
	ret+=d*(cy+1)
	ret+=l*(cx+1)
	ret+=u
	
	
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define inv(x) power(x,Mod-2)
#define cle(a) memset(a,0,sizeof(a))
#define upd(a,b) a=add(a,b)
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
typedef long long ll;
int add(int a,const int b){a+=b;if(a>=Mod)a-=Mod;return a;}
int sub(int a,const int b){a-=b;if(a<0)a+=Mod;return a;}
int mul(const int a,const int b){return (ll)a*b%Mod;}
int power(int x,int cs)
{
	int ras=1;
	while(cs)
	{
		if(cs&1) ras=mul(ras,x);
		x=mul(x,x);cs>>=1;
	}
	return ras;
}
const int N=620,P=310;
int n,ans;
int a[N],dp[2][P][P];
int main()
{
	int c,i,j,k,pos,num;
	scanf("%d",&n);
	for(i=0;i<(n<<1);i++) 
	{
		scanf("%d",&a[i]);
		if(a[i]!=-1) a[i]--;
	}
	c=0;dp[0][0][0]=1;
	for(i=(n<<1)-1;i>=0;i--)
	{
		
		pos=-1;
		for(j=0;j<(n<<1);j++)
		{
			if(a[j]==i) pos=j;
		}
		if(pos!=-1&&a[pos^1]!=-1) continue;
		c^=1;
		cle(dp[c]);
		//puts("OK");
		if(pos!=-1)
		{
			//puts("A");
			for(j=0;j<=n;j++)
			{
				for(k=0;k<=n;k++)
				{
					upd(dp[c][j][k],dp[c^1][j][k+1]);
					if(j>0) upd(dp[c][j][k],dp[c^1][j-1][k]);
				}
			}
			//puts("end");
		}
		else
		{
			//puts("B");
			for(j=0;j<=n;j++)
			{
				for(k=0;k<=n;k++)
				{
					upd(dp[c][j][k],mul(j+1,dp[c^1][j+1][k]));
					upd(dp[c][j][k],dp[c^1][j][k+1]);
					if(k>0) upd(dp[c][j][k],dp[c^1][j][k-1]);
				}
			}
			//puts("end");
		}
		/*
		for(j=0;j<=n;j++)
		{
			for(k=0;k<=n;k++)
			{
				printf("#%d %d %d %d\n",i,j,k,dp[c][j][k]);
			}
		}
		*/
	}
	ans=dp[c][0][0];
	//printf("P%d\n",ans);
	num=0;
	for(i=0;i<n;i++)
	{
		if(a[i<<1]==-1&&a[(i<<1)+1]==-1)
		{
			num++;
			ans=mul(ans,num);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n=in.nextInt();
        int b=in.nextInt();
        if(Math.sqrt(Integer.parseInt(n+""+b))==(int)Math.sqrt(Integer.parseInt(n+""+b))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}






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

using namespace std;

const int N = 100010;

int K;

struct node
{
	int to, len;

	node (int a, int b)
	{
		to = a, len = b;
	}
	node () { }
};
vector <node > link[N];

int dis[N], in[N];
deque <int > q;

void SPFA()
{
	memset(dis, 0x3f, sizeof(dis));
	in[1] = 1, q.push_back(1) , dis[1] = 1;

	while(!q.empty())
	{
		int wz = q.front();
		q.pop_front(), in[wz] = 0;

		for(int k = 0; k < (int )link[wz].size(); k++)
		{
			int to = link[wz][k].to;
			int len = link[wz][k].len;

			if(dis[to] > dis[wz] + len)
			{
				dis[to] = dis[wz] + len;

				if(!in[to])
				{
					in[to] = 1;

					if(q.empty() || dis[to] < dis[q.front()])
						q.push_front(to);
					else
						q.push_back(to);
				}
			}
		}
	}

	printf("%lld", dis[0]);
}

signed main()
{
	scanf("%lld", &K);
	for(int k = 1; k <= K; k++)
		link[k].push_back(node(k + 1, 1)), link[k].push_back(node(k * 10 % K, 0));

	SPFA();

	return 0;
}

Measured memory_bytes: 9088
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    b = [sum(a) - sum(a[1::2]) * 2]
    for i in range(len(a)-1):
        b.append((a[i] - b[i] // 2) * 2)
    print(*b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef long long ll;
typedef priority_queue<int> pq;

int keta(int x){
    int ret = 0;
    while(1){
        if(x==0)break;
        x/=10;
        ret++;
    }
    return ret;
}
string _keta(int a){
    string ret = "";
    for(int i = keta(a); i < 6; i++){
        ret+="0";
    }
    ret += to_string(a);
    return ret;
}

string makeStr(int a, int b){
    string ret = _keta(a) + _keta(b);
    return ret;
}


int main(void) {
    int N, M;
    cin >> N >> M;
    vector<PP> maps;
    for(int i = 0; i < M; i++){
        int p, y;
        cin >> p >> y;
        maps.push_back(PP(P(p,y),i));
    }
    sort(maps.begin(), maps.end());
    string s[100001];
    int before = -1;
    int now = -1;
    for(int i = 0; i < M; i++){
        if(before != maps[i].first.first){
            now = 1;
            before = maps[i].first.first;
        }
        s[maps[i].second] = makeStr(maps[i].first.first, now);
        now++;
    }
    for(int i = 0; i < M; i++){
        cout << s[i] << endl;
    }
}

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

struct Card {
    char suit, value;
};

void bubble(struct Card A[], int N ){
    for ( int i = 0; i < N; i++ ){
        for ( int j = N-1; j >= i + 1; j-- ){
            if ( A[j].value < A[ j-1 ].value){
                Card t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i = 0; i < N; i++ ){
        int minj = i;
        for ( int j = i; j < N; j++ ){
            if ( A[j].value < A[minj].value ) minj = j;
        }
        Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for ( int i = 0; i < N; i++ ){
        if ( i > 0 ) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for ( int i = 0; i < N; i++ ){
        if ( C1[i].suit != C2[i].suit ) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for ( int i =  0; i < N; i++ ) cin >> C1[i].suit >> C1[i].value;
    
    for ( int i = 0; i < N; i++ ) C2[i] = C1[i];
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if ( isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }
    else cout << "Not stable" << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>

int main(){
  
  //Declarations of variables
  int a,b,c,x;
  int count=0;

  //Taking Inputs
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&x);

  for(int i =0; i<=a; i++)
    for(int j=0; j<=b; j++)
      for(int k=0; k<=c; k++)
        if(500*i + 100*j + 50*k == x)
          count++;

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


Measured memory_bytes: 128
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val k = sc.nextInt()
    val lun = mutableListOf<Long>()
    val stack = Stack<Long>()
    for (i in 1..9) {
        stack.add(i.toLong())
    }
    while (stack.count() > 0) {
        val n = stack.pop()
        val r = n % 10
        lun.add(n)
        if (n.toString().length < 10) {
            val n1 = 10 * n + r
            stack.add(n1)
            if (r != 0L) {
                val n2 = 10 * n + r - 1
                stack.add(n2)
            }
            if (r != 9L) {
                val n3 = 10 * n + r + 1
                stack.add(n3)
            }
        }
    }
    lun.sort()
    println(lun[k - 1])
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 47884
// ABC088A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int N,A;
	cin >> N >> A;
	int res;
	res = N % 500;
	if(res<=A) cout <<"Yes" <<endl;
	else cout << "No" << endl;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
x = int(input())

l = [1]
for b in range(2, 32):
    p = 2
    while b ** p <= 1000:
        l.append(b ** p)
        p += 1
l.sort()
l.append(10**5)

for i in range(len(l)):
    if l[i] > x:
        print(l[i-1])
        exit()
print(l)

Measured memory_bytes: 38384
h,w,a,b,=map(int,input().split())
ans='No'
if h==1 and b==0:
        ans=['1']*a+['0']*(w-a)
        print(''.join(ans))
elif w==1 and a==0:
        ans=['1']*b+['0']*(h-b)
        for i in ans:
                print(i)
else:
    ans1='0'*a+'1'*(w-a)
    ans2='1'*a+'0'*(w-a)
    for i in range(h):
        if i<=b-1:
            print(ans1)
        else:
            print(ans2)

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  int p, q;
  string str, buf;
  vector<string> vec;

  while(!cin.eof()){
    p = q = 0;
    buf = "";

    while(getline(cin, str) && str != "END_OF_TEXT") vec.push_back(str);
    while(getline(cin, str) && str != "-"){
      if(str == "a") q = 0;

      if(str == "e") q = vec[p].size();

      if(str == "p"){
	if(p > 0) --p;
	q = 0;
      }

      if(str == "n"){
	if(p < vec.size()-1) ++p;
	q = 0;
      }

      if(str == "f"){
	if(q < vec[p].size()) ++q;
	else if(q == vec[p].size() && p < vec.size()-1){
	  ++p;
	  q = 0;
	}
      }

      if(str == "b"){
	if(q > 0) --q;
	else if(q == 0 && p > 0){
	  --p;
	  q = vec[p].size();
	}
      }

      if(str == "d"){
	if(q == vec[p].size()){
	  if(vec.size()-1 > p){
	    vec[p] += vec[p+1];
	    vec.erase(vec.begin()+(p+1));
	  }
	} else if(q < vec[p].size()){
	  vec[p].erase(vec[p].begin()+q);
	}
      }

      if(str == "k"){
	if(q == vec[p].size()){
	  if(vec.size()-1 > p){
	    vec[p] += vec[p+1];
	    vec.erase(vec.begin()+(p+1));
	    buf = "\n";
	  }
	} else if(q < vec[p].size()){
	  buf = vec[p].substr(q);
	  vec[p] = vec[p].substr(0, q);
	}
      }

      if(str == "y" && buf.size()){
	if(buf == "\n"){
	  string s1 = vec[p].substr(0, q), s2 = vec[p].substr(q);
	  vec[p++] = s1;
	  vec.insert(vec.begin()+(p), s2);
	  q = 0;
	} else {
	  vec[p].insert(q, buf);
	  q += buf.size();
	}
      }
    }

    for(int i = 0; i < vec.size(); ++i)
      cout << vec[i] << endl;
    
    buf.clear();
    vec.clear();
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long a,b,x;
	cin >> a >> b >> x;
	if(a == 0)
	{
		cout << b/x - a/x + 1<< endl; 
	}
	else
	{
		a--;
		cout << b/x - a/x << endl;
	}
	 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

struct BIT{
 int n;
 int MAX;
 vector<int> bit;
 BIT(){}
 BIT(int _n){
   n = _n;
   MAX = n +2;
   bit.resize(n+10,0);
 }
 
 int query(int x){
   int r=0;
   while(x>0){
     r+=bit[x];
     x-=(x&-x);
   }
   return r;
 }
 
 int query(int l,int r){
   return query(r) - query(l-1);
 }
 
 void update(int x,int val){
   while(x<MAX){
     bit[x]+=val;
     x+=(x&-x);
   }
 }
 
 int find_kth(int k){
   int sum=0;
   int pos=0;
   // 30 == log -> trocar conforme necessario
   for(int i=30;i>=0;i--){
     if(pos+(1LL<<i)>n)continue;
     int atual = bit[pos+(1LL<<i)];
     if(sum+atual<k){
       sum+=atual;
       pos+=(1LL<<i);
     }
     
   }
   
   //acha a maior pos com <k;
   return pos+1;
 }
  
};

struct qry{
  int op,a,b;
  qry(){}
  qry(int x,int y=0,int z=0){
    op =x;
    a = y;
    b = z;
  }
};

const int N = 200100;
int rev[N];

int32_t main(){
  fastio;
  int Q;
  cin>>Q;
  map<int,int> mp;
  vector<qry> q;
  for(int i=0;i<Q;i++){
    int op;
    cin>>op;
    if(op == 1){
      int a,b;
      cin>>a>>b;
      q.pb(qry(op,a,b));
      mp[a];
    }else q.pb(qry(op,0,0));
  }

  int k=0;
  for(auto& it : mp){
    it.ss = ++k;
    rev[k] = it.ff;
  }
  BIT sum(N),median(N);
  int tot=0;
  int f=0;
  int tam=0;
  for(int i=0;i<Q;i++){
    if(q[i].op==2){
      if(tam==0)cout<<0<<endl;
      else{
        int best = median.find_kth((tam+1)/2);
        int small = median.query(best);
        int high = tam - small;
        int sum_down = rev[best]*small - sum.query(best);
        int sum_up = sum.query(best+1,N-10) - rev[best]*high;
      //  cout << small<<" "<<high<<" "<<sum_up<<" "<<sum_down<<endl;
        cout << rev[best] <<" "<<sum_up + sum_down + tot << endl;

      }

    }else{
      tam++;
      median.update(mp[q[i].a],1);
      sum.update(mp[q[i].a],q[i].a);
      tot+=q[i].b;
    }
  }




  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
int a[201];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<2*n;i++)scanf("%d",&a[i]);
    sort(a,a+2*n);
    int ans=0;
    for(int i=0;i<2*n;i+=2)ans+=a[i];
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }



void solve() {
    string s;
    cin>>s;
    ll n = s.size();
    ll ans=0;
    rep(i,n) ans+=s[i]-'0';
    if(ans%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}







signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

using namespace std;
double dp[3010][3010];

int main(){
    ll n;
    cin >> n;
    double p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    for(int i = 0; i < 3010; i++){
        for(int j = 0; j < 3010; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    double one = 1.000000000;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            dp[i+1][j] += dp[i][j]*(one-p[i]);
            dp[i+1][j+1] += dp[i][j]*p[i];
        }
    }

    double ans = 0.000000000;
    for(int i = n/2+1; i <= n; i++){
        ans += dp[n][i];
    }
    cout << fixed;
    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 71040
N, L = map(int, input().split())
S = {int(x) for x in input().split()}
flag = False
while 1:
    if N%10 in S:
        N += 1
        continue
    if int((N%100-N%10)/10) in S and N >= 10:
        N += 1
        continue
    if int((N%1000-N%100)/100) in S and N >= 100:
        N += 1
        continue
    if int((N%10000-N%1000)/1000) in S and N >= 1000:
        N += 1
        continue
    if int((N%100000-N%10000)/10000) in S and N >= 10000:
        N += 1
        continue
    break
print(N)


Measured memory_bytes: 9100
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n, max = -1000000, min = 1000000, input;
    long sum = 0;

    Scanner in = new Scanner(System.in);
    n = in.nextInt();

    for(int i=0; i<n; i++){
        input = in.nextInt();
        if(input > max){
            max = input;
        }
        if( input < min){
            min = input;
        }
        sum += input;
    }
    
    System.out.println(min + " " + max + " " + sum);
  }
}

Measured memory_bytes: 42064
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var a = int.Parse(inputs[0]);
        var b = int.Parse(inputs[1]);

        if (a < 10 && b < 10)
        {
            Console.WriteLine(a * b);
        }
        else
        {
            Console.WriteLine("-1");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    string ans;
    REP(i,len){
        if(S[i] == '0'){
            ans += '0';
        }
        else if(S[i] == '1'){
            ans += '1';
        }
        else{
            int t = ans.length();
            if(t != 0){
                ans.erase(t-1,1);
            }
        }
    }
    cout << ans << endl;

}


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

ll N, K, h[100010];

int main()
{
  cin >> N >> K;
  for(int i = 1; i <= N; i++) cin >> h[i];
  
  sort(h+1,h+N+1,greater<ll>());
  
  ll maxMin = INF;
  for(ll i = 1; i <= N-K+1; i++)
  {
    if(h[i]-h[i+K-1] < maxMin)
      maxMin = h[i]-h[i+K-1];
  }
  cout << maxMin << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
vi Digit(ll x){
	vi res ;
	while(x){
		res.pb(x % 10) ;
		x /= 10 ;
	}
	return res ;
}
		

int main(){
	IOS;
	cout.precision(30) ;
	int n ; cin >> n ;
	vll x(n),y(n), h(n);
	for(int i = 0 ; i < n ; i++) cin >> x[i] >> y[i] >> h[i] ;
	for(int cx = 0 ; cx <= 100 ; cx++){
		for(int cy = 0 ; cy <= 100 ; cy++){
			bool b = true ;
			int d = 0 ;
			ll H = 0;
			while(d < n && h[d] == 0) d++ ;
			if(d < n) H = h[d] + abs(x[d] - cx) + abs(y[d] - cy) ;
			else{
				ll m = 1e9 ;
				for(int i = 0 ; i < n ; i++){
					m = min(abs(x[i] - cx) + abs(y[i] - cy) , m) ;
				}
				H = m ;
			}
			for(int i = 0 ; i < n ; i++){
				if(h[i] == 0 && H > abs(x[i] - cx) + abs(y[i] - cy)) {b = false ; break;}
				else if(h[i] > 0 && h[i] + abs(x[i] - cx) + abs(y[i] - cy) != H){b = false ; break; }
			}
			if(b && H) return cout << cx << " " << cy << " " << H << endl , 0 ;
		}
	}
				
	return 0;
}


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

#define mpr make_pair

typedef pair<int,int> pii;

const int MX=1000006;
char s[MX];
int l[MX];
pair <pii,int> a[MX];

int main()
{
    int n;
    scanf("%d",&n);
    l[0]=0;
    for(int i=0;i<n;i++){
        scanf("%s",s+l[i]);
        int len=strlen(s+l[i]);
        l[i+1]=l[i]+len;
        int x=0,y=INT_MAX;
        for(int j=l[i];j<l[i+1];j++){
            x+=(s[j]=='(')?1:-1;
            y=min(x,y);
        }
        if(x<0){
            x=0,y=INT_MAX;
            for(int j=l[i+1]-1;j>=l[i];j--){
                x+=(s[j]==')')?1:-1;
                y=min(y,x);
            }
            a[i]=mpr(mpr(1,y),i);
        }
        else a[i]=mpr(mpr(0,-y),i);
    }
    sort(a,a+n);
    int x=0;
    bool f=true;
    for(int i=0;i<n;i++){
        int p=a[i].second;
        for(int j=l[p];j<l[p+1];j++){
            x+=(s[j]=='(')?1:-1;
            if(x<0 || (i==n-1 && j==l[p+1]-1 && x)){
                f=false;
                break;
            }
        }
    }
    puts(f?"Yes":"No");
    return 0;
}

Measured memory_bytes: 20272
x = int(input())
c = 1
if x < 600:
    c = 8
elif x < 800:
    c = 7
elif x < 1000:
    c = 6
elif x < 1200:
    c = 5
elif x < 1400:
    c = 4
elif x < 1600:
    c = 3
elif x < 1800:
    c = 2
print(c)

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	rep(i,1000){
		int tmp = i;
		string t = "";
		t = char('0'+tmp%10) + t;tmp /= 10;
		t = char('0'+tmp%10) + t;tmp /= 10;
		t = char('0'+tmp%10) + t;tmp /= 10;
		int num = 0;
		rep(j,s.size())if(num < 3){
			if(s[j] == t[num])num++;
		}
		if(num == 3)ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 3268
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


K = I()
num = 7
for i in range(10 ** 6):
    if num % K == 0:
        print(i + 1)
        exit()
    num = (num * 10 + 7) % K
print(-1)

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

int main(){
	long X;
	cin>>X;
	long ans;
	long state=0;
	for(long i=0;i<X;++i){
		state+=i+1;
		if(X<=state){
			ans=i+1;
			break;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import math

N, M, K = map(int, input().split())

if N == 1:
    print(M)
    exit(0)

mod = 998244353

fac = [0] * N
finv = [0] * N
inv = [0] * N

fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, N):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod

def com(n, k):
    global fac, finv, mod
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod

ans = pow(M, N, mod)
for L in range(K + 1, N):
    result = (M * pow(M - 1, N - L - 1, mod) * com(N - 1, N - L - 1)) % mod
    ans -= result

print(ans % mod)


Measured memory_bytes: 32604
#include<iostream>
using namespace std;
int main()
{
	unsigned long int n;
	int k;
	cin>>n>>k;
	int tmp,count = 0;
	for(int i=0;i<n;i++)
	{
		cin>>tmp;
		if(tmp >= k)
			count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
const int N=1e+5;
int n,a[N],b[N],c[N];
int memo[N][4];
int dp(int i,int t)
{
    if(i==n)
        return 0;
    int &ret=memo[i][t];
    if(~ret)
        return ret;
    ret=0;
    if(t!=0)
        ret=max(ret,dp(i+1,0)+a[i]);
    if(t!=1)
        ret=max(ret,dp(i+1,1)+b[i]);
    if(t!=2)
        ret=max(ret,dp(i+1,2)+c[i]);
    return ret;


}
int main()
{
    memset(memo,-1,sizeof memo);
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
         scanf("%d %d %d",a+i,b+i,c+i);
    }
    printf("%d\n",dp(0,3));
    return 0;
}


Measured memory_bytes: 12736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> X(n);
  int k;
  for(int i=0;i<n;i++){
  for(int j=0;j<3;j++){
  	cin>>k;
    X[i].push_back(k);
  }
  }
  vector<int> a(3,0);
  vector<vector<int>>result(n,a);
  result[0][0]=X[0][0];
  result[0][1]=X[0][1];
  result[0][2]=X[0][2];
  
  for(int i=1;i<n;i++){
  for(int j=0;j<3;j++){
  if(j==0){
  result[i][j]=X[i][j]+max(result[i-1][1],result[i-1][2]);
  }
    else if(j==1){
       result[i][j]=X[i][j]+max(result[i-1][0],result[i-1][2]);
    }
    else{
       result[i][j]=X[i][j]+max(result[i-1][0],result[i-1][1]);
    }
  }
  }
  cout<<max(result[n-1][0],max(result[n-1][1],result[n-1][2]))<<"\n";
  
}

Measured memory_bytes: 14092
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
class FF
{
public:
  struct edge{ll to,cap,rev;};
  vector<vector<edge>>G;
  vector<bool> used;
  FF(ll maxv)
  {
    G.resize(maxv);
    used.resize(maxv);
  }
  void add_edge(ll from,ll to,ll cap,bool directed=1)
  {
    G[from].push_back({to,cap,(ll)G[to].size()});
    G[to].push_back({from,cap*(!directed),(ll)G[from].size()-1});
  }
  ll dfs(ll v,ll t,ll f)
  {
    if(v==t)return f;
    used[v]=1;
    for(auto &nv:G[v])
    {
      if(!used[nv.to] && nv.cap>0)
      {
        ll d=dfs(nv.to,t,min(f,nv.cap));
        if(d>0)
        {
          nv.cap-=d;
          G[nv.to][nv.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
  ll solve(ll s,ll t)
  {
    ll res=0;
    while(1)
    {
      for(ll i=0;i<used.size();i++)used[i]=0;
      ll f=dfs(s,t,(1<<30)-1);
      if(f==0)break;
      res+=f;
    }
    return res;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin>>n;
  FF ff(n+2);
  ll s=0,t=n+1;
  ll sum=0;
  rep(i,n)
  {
    ll a;
    cin>>a;
    if(a<0)
    {
      ff.add_edge(s,i+1,-a);
    }
    else
    {
      ff.add_edge(i+1,t,a);
      sum+=a;
    }
  }
  repi(i,1,n+1)
  {
    ll ti=i*2;
    while (ti<n+1)
    {
      ff.add_edge(i,ti,2e9);
      ti+=i;
    }
  }
  cout<<sum-ff.solve(s,t)<<endl;

  return 0;

}


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

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

    int n;
    int ans;
    for (int i=0;i<5;i++) {
        cin >> n;
        if (n == 0)
            ans = i+1;
    }
    cout << ans;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1000001],x;
bool ch(int mid){
  int res=1,now=0;
  for(int i=0;i<n;i++){
    now+=a[i];
    if(now>mid)res++,now=a[i];
    if(a[i]>mid)return 0;
  }
  return res<=x;
}
int main(){
  cin>>n>>x;
  for(int i=0;i<n;i++)cin>>a[i];
  int l=0,r=1e9;
  while(l<r){
    int mid=(l+r)/2;
    if(ch(mid))r=mid;
    else l=mid+1;
  }
  cout<<l<<endl;
}



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

int main() {
  int N,D,i,j,k,c=0;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));

  for(i=0; i<N; i++)
    for(j=0; j<D; j++)
      cin >> X.at(i).at(j);

  for(i=0; i<N; i++)
    for(j=i+1; j<N; j++) {
      int ds=0;
      for(k=0; k<D; k++)
        ds += pow((X.at(i).at(k)-X.at(j).at(k)),2);
      float dsf = sqrt(ds);
      if(dsf == (float)(int)dsf)
        c++;
    }
    
  cout << c << endl;
}


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

using namespace std;

struct WeatherList {
    string value;
    WeatherList* next;
    WeatherList(string s) : value(s), next(NULL) {}
};

int main() {
    // create list
    struct WeatherList* sunny = new WeatherList("Sunny");
    struct WeatherList* cloudy = new WeatherList("Cloudy");
    struct WeatherList* rainy = new WeatherList("Rainy");

    sunny->next = cloudy;
    cloudy->next = rainy;
    rainy->next = sunny;

    // input
    string in;
    cin >> in;

    WeatherList* target = sunny;
    while (true) {
        if (in == target->value) {
            cout << target->next->value << endl;
            break;
        }
        target = target->next;
    }

    return 0;
}

Measured memory_bytes: 256
import sys

s = sorted(input())
t = sorted(input(), reverse=True)
l = len(s)
m = len(t)
n = min(l,m)

for i in range(n):
    if ord(s[i]) < ord(t[i]):
        print('Yes')
        sys.exit()
    if ord(s[i]) > ord(t[i]):
        print('No')
        sys.exit()

if l < m:
    print('Yes')
if l >= m:
    print('No')

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

int main(){
 string s,t;
    cin >> s >> t;
    
    int count = 0;
    
    for(int i = 0; i < s.size();i++){
     if(s.at(i) != t.at(i)) {
     count++;
     }
    }
    cout <<count;
    
}

Measured memory_bytes: 3860
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#include <iomanip>
#include <cmath>
#define PI acos(-1)
typedef long long ll;
const long long mod = 998244353;
const long long maxn = 1e9 + 5; 
using namespace std;

int main()
{
	ll a, b, c, k;
	scanf("%lld %lld %lld %lld",&a, &b, &c, &k);
	ll sum = 0;
	
	if (k < a)
	{
		sum += k;
	}
	else if (k >= a && k <= a + b)
	{
		sum += a;
	}
	else if (k >= a && k > a + b && k <= a + b + c)
	{
		sum += a;
		sum -= (k - a - b);
	}
	printf("%lld\n", sum);
	return 0;	
} 

Measured memory_bytes: 3248
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 1
mod = 10**9 + 7
c = 0
z = 0
for i in a:
    if i < 0:
        c += 1
    elif i == 0:
        z += 1
if c == n and k & 1:
    a.reverse()
    for i in range(k):
        ans *= -a[i]
        ans %= mod
    print(-ans % mod)
elif c == n:
    for i in range(k):
        ans *= -a[i]
        ans %= mod
    print(ans)
elif k == n:
    for i in a:
        ans *= abs(i)
        ans %= mod
    print(((-1)**c * ans) % mod)
else:
    plus = [i for i in a if i > 0]
    minus = [i for i in a if i <= 0]
    plus.sort(reverse=1)
    minus.sort()
    x = len(plus)
    y = len(minus)
    plus += [0] * z
    p, m = 0, 0
    for i in range(k // 2):
        if x - 1 <= p:
            ans *= minus[m] * minus[m + 1]
            m += 2
        elif y - 1 <= m:
            ans *= plus[p] * plus[p + 1]
            p += 2
        else:
            if minus[m] * minus[m + 1] >= plus[p] * plus[p + 1]:
                ans *= minus[m] * minus[m + 1]
                m += 2
            else:
                ans *= plus[p] * plus[p + 1]
                p += 2
        ans %= mod
    if k & 1:
        if p < x:
            ans *= plus[p]
        else:
            ans *= minus[-1]
        ans %= mod

    print(ans % mod)


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int n, m, pic[110][110], pat[55][55], sub[55][55];

typedef pair< int, int > pii;

void rot() {
	for_(i,0,m) for_(j,0,m) sub[m - j - 1][i] = pat[i][j];
	for_(i,0,m) for_(j,0,m) pat[i][j] = sub[i][j];
}

int main() {
	while (cin >> n >> m, n) {
		for_(i,0,n) for_(j,0,n) cin >> pic[i][j];
		for_(i,0,m) for_(j,0,m) cin >> pat[i][j];
		
		pii ans(n, n);
		
		for_(r,0,4) {
			pii p(n, n);
			
			for (int i = 0; i < n - m + 1 && p.first == n; ++i) {
				for (int j = 0; j < n - m + 1 && p.first == n; ++j) {
					bool flag = true;
					
					for (int ii = 0; ii < m && flag; ++ii) for (int jj = 0; jj < m && flag; ++jj) {
						if (pat[ii][jj] == -1) continue;
						flag &= (pic[i + ii][j + jj] == pat[ii][jj]);
						if (flag && p.first == n) p = pii(i + ii, j + jj);
					}
					
					if (!flag) p = pii(n, n);
				}
			}
			
			ans = min(ans, p);
			
			rot();
		}
		
		if (ans.first == n) cout << "NA" << endl;
		else cout << ans.second + 1 << " " << ans.first + 1 << endl;
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    while (1)
    {
        int n, m;
        cin >> n >> m;
        if (n == 0)
            break;
        vector<int> a(m, 0);
        rep(i, n)
        {
            int d, v;
            cin >> d >> v;
            d--;
            a[d] = max(a[d], v);
        }
        int ans = 0;
        rep(i, m) ans += a[i];
        cout << ans << endl;
    }
}



Measured memory_bytes: 3228
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=int):
    return list(map(cast_func, input().split()))


def get_input(cast_func=int):
    return cast_func(input())


def main():
    N, M = get_inputs()
    A = get_inputs()

    max_heap = [-a for a in A]
    heapq.heapify(max_heap)
    while M > 0:
        a_max = -heapq.heappop(max_heap)
        a_max //= 2
        heapq.heappush(max_heap, -a_max)
        M -= 1

    ans = -sum(max_heap)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23136
n,k = map(int, input().split())
a =[0] + list(map(int, input().split()))

count_dict = {i+1:0 for i in range(n)}
count_dict[1] = 1

anow = 1
if k <= n+1:
  for i in range(k):
    anow = a[anow]
  print(anow)
else:
  for i in range(2, n+3):
    anow = a[anow]
    cnow = count_dict[anow]
    if cnow != 0:
      cycle = i-cnow
      amari = (k-i+1)%cycle
      if amari==0:
        print(anow)
      else:
        for nokori in range(amari):
          anow = a[anow]
        print(anow)
      exit()
    else:
      count_dict[anow] = i

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int n, m, x, c[12], a[12][12];
    cin >> n >> m >> x;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for (int t = 0; t < (1 << n); ++t) {
        int sum = 0, b[12] = { 0 };
        for (int i = 0; i < n; ++i) {
            if (t & (1 << i)) {
                sum += c[i];
                for (int j = 0; j < m; ++j) {
                    b[j] += a[i][j];
                }
            }
        }
        bool f = true;
        for (int i = 0; i < m; ++i) {
            if (b[i] < x)
                f = false;
        }
        if (f) {
            ans = min(ans, sum);
        }
    }
    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}

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

using namespace std;

int n, ans;
vector< pair<int, int> > red, blue;

bool comp(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}

int main(){
	cin >> n;
	red.resize(n); blue.resize(n);
	for(int i = 0; i < n; ++i) cin >> red[i].first >> red[i].second;
	for(int i = 0; i < n; ++i) cin >> blue[i].first >> blue[i].second;

	sort(blue.begin(), blue.end());
	sort(red.begin(), red.end(), comp);
	reverse(red.begin(), red.end());

	while(blue.size() > 0){
		auto bml = blue.begin();
		for(auto itr = red.begin(); itr != red.end(); itr++){
			if(itr->first < bml->first && itr->second < bml->second){
				ans++;
				red.erase(itr);
				break;
			}
		}
		blue.erase(bml);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long t,x;
    scanf("%ld%ld", &t, &x);

    printf("%.5f\n", (double)t/x);

    return 0;
}


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

using namespace std;

int n, W;
vector<int> w, v;
vector< unordered_map<int, int> > dp;

int knap(int i, int j) {
    if (dp[i].find(j) != dp[i].end()) {
        return dp[i][j];
    }
    int res;
    if (i == n) {
        res = 0;
    } else if (j < w[i]) {
        res = knap(i + 1, j);
    } else {
        res = max(knap(i + 1, j), knap(i + 1, j - w[i]) + v[i]);
    }
    dp[i][j] = res;

    return res;
}

int main() {
    cin >> n >> W;
    w = vector<int>(n);
    v = vector<int>(n);
    dp = vector< unordered_map<int, int> >(n + 1, unordered_map<int, int>());
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    cout << knap(0, W) << endl;

    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

ll a,b,k;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a;
  a.push_back(0);
  rep(i,n){
    ll b; cin>>b;
    a.push_back(b);
  }
  a.push_back(0);
  ll sum=0;
  rep(i,n+1){
    sum+=abs(a[i]-a[i+1]);
  }
  
  rep(i,n){
    cout<<sum-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i]-a[i+2])<<endl;
  }
  
  
  
}


Measured memory_bytes: 2164
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int k=0; k<10000; k++){
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a == 0 && b == 0){
            break;
        }
        for(int i=0; i<a; i++){
            for(int j=0; j<b; j++){
                System.out.printf("#");
            }
            System.out.println();
        }
        System.out.println();
    }
}
}


Measured memory_bytes: 58636
n,t=map(int,input().split())
k=[int(i) for i in input().split()]
ans=[0]*3
for i in k:
    if i<=ans[1]:
        ans[1]=i+t
    else:
        ans[2]+=ans[1]-ans[0]
        ans[0]=i
        ans[1]=ans[0]+t

print(ans[2]+(ans[1]-ans[0]))

Measured memory_bytes: 85328