akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
#define rep(i,n) for ( int i = 0; i < n; i++)
static const int MAX = 50;
static const int PMAX = 11;
static const string DT = "URDL";
static const int di[4] = {-1, 0, 1, 0};
static const int dj[4] = {0, 1, 0, -1};

int H, W, np;
char G[MAX][MAX];
string P[PMAX];

class State{
public:
  unsigned short pos;
  short M[PMAX], cost;
  string path;

  State(){
    rep(i, np) M[i] = -1;
    path = "";
    cost = 0;
  }

  bool shift(char ch){
    path += ch;
    rep(i, np){
      int p = -1;
      string s = P[i];
      for ( int k = 0; k < s.size(); k++ ){
	int st = path.size() -1 -k;
	if ( st < 0 ) continue;
	bool match = true;
	for ( int j = 0; j <= k; j++ ){
	  if ( path[st+j] != s[j] ) { match = false; break; }
	}
	if ( match ) p = k;
      }
      M[i] = p;
      if ( M[i] == P[i].size() -1 ) return false;
    }
    return true;
  }

  bool operator < ( const State &s ) const{
    if ( pos != s.pos ) return pos < s.pos;
    rep(i, np){
      if ( M[i] == s.M[i] ) continue;
      return M[i] < s.M[i];
    }
    return false;
  }
};

int bfs(int si, int sj, int gi, int gj){
  queue<State> Q;
  set<State> V;
  State s;
  s.pos = si*W + sj;
  V.insert(s);
  Q.push(s);
  State u, v;
  int ni, nj;
  while(!Q.empty()){
    u = Q.front(); Q.pop();
    if ( u.pos/W == gi && u.pos%W == gj ) return u.cost;

    rep(r, 4){
      ni = u.pos/W + di[r];
      nj = u.pos%W + dj[r];
      if ( ni < 0 || nj < 0 || ni >= H || nj >= W ) continue;
      if ( G[ni][nj] == '#' ) continue;
      v = u;
	   v.pos = ni*W + nj;
	         if (!v.shift(DT[r])) continue;
	   v.cost++;
      if ( V.find(v) == V.end() ){

	V.insert(v);
	Q.push(v);
      }
    }
  }
  return -1;
}

main(){
  int si, sj, gi, gj;
  while( cin >> H >> W && H){
    rep(i,H) rep(j, W){
      cin >> G[i][j];
      if ( G[i][j] == 'S' ){ si = i; sj = j; G[i][j] = '.'; }
      if ( G[i][j] == 'G' ){ gi = i; gj = j; G[i][j] = '.'; }
    }
    cin >> np;
    rep(i, np) cin >> P[i];
    cout << bfs(si, sj, gi, gj) << endl;
  }
}

Measured memory_bytes: 21000
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   int ichi = n%10;
   if(ichi == 2 || ichi == 4 || ichi == 5 || ichi == 7 || ichi == 9){
       cout << "hon" << endl;
   }else if(ichi == 3){
       cout << "bon" << endl;
   }else{
       cout << "pon" << endl;
   }
 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
bool checkprime(int n)
{
    for(int i=2;i<n/2;i++)
    {
        if(n%i ==0) 
          return false;
    }
    return true;
    
}
int main()
{
    int x,res;
    cin>>x;
    while(x)
    {
        if(checkprime(x))
           {
               cout<<x;
               break;
           }
        else
           x++;
            
    }
    return 0;
}


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

int main(){
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		ll num=n/i*i;
		ans+=(i+num)*(num/i)/2;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL s;

int main()
{
    cin >> s;
    printf("0 0 ");
    if(s / 2 <= 1e9)
    {
        if(s % 2 == 0)
        {
            cout << 2 << " 0 0 " << s / 2 << endl;
        }
        else
        {
            cout << 2 << " 1 1 " << (s + 1) / 2 << endl;
        }
    }
    else
    {
        LL t = 1e9;
        if(s == 1e18)
        {
            cout << t << " 0 0 " << t << endl;
            return 0;
        }
        cout << (LL)1e9 << " " << (LL)(s / (LL)t + 1) * t- s << " " << 1 << " " << s / (LL)t + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define mapitr(itr, mp) for(auto itr= mp.begin(); itr !=mp.end(); itr ++)
using namespace std;
int main(void){
    int n, m;
    int ans=0;
    string tmp;
    cin >> n;
    map<string, int>cards;
    rep(i, n){
        cin >> tmp;
        cards[tmp]+=1;
    } 
    cin >> m;
    rep(i, m){
        cin >> tmp;
        cards[tmp]-=1;
    }
    mapitr(itr, cards){
        if(itr->second>ans) ans = itr->second;
    } 
    cout << ans << endl;
}

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

p = list(map(int,input().split()))

cnt = 0
for i in range(1, n-1):
    tmp = [p[i-1], p[i], p[i+1]]
    if max(tmp) != p[i] and min(tmp) != p[i]:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
n = int(input())
odds = [i for i in range(1, n+1) if i%2 == 1]

ans = 0
for o in odds:
    cnt = 0
    for j in range(1, o+1):
        if o%j == 0:
            cnt+=1
    if cnt == 8:
        ans+=1
        
print(ans)

Measured memory_bytes: 3060
n, k = map(int, input().split())
d = list(map(str, input().split()))
for i in range(n, 10 ** 5 + 1):
    s = list(str(i))
    c = 0
    for j in s:
        if j in d:
            c = 1
            break
    if c == 0:
        print("".join(s))
        break

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int L = sc.nextInt();
        int[] p = new int[K];
        int[] q = new int[K];
        for (int i = 0; i < K; ++i) {
            p[i] = sc.nextInt() - 1;
            q[i] = sc.nextInt() - 1;
        }
        int[] r = new int[L];
        int[] s = new int[L];
        for (int i = 0; i < L; ++i) {
            r[i] = sc.nextInt() - 1;
            s[i] = sc.nextInt() - 1;
        }

        System.out.println(solve(N, p, q, r, s));

        sc.close();
    }

    static String solve(int N, int[] p, int[] q, int[] r, int[] s) {
        int[] roadRoots = buildRoots(N, p, q);
        int[] railwayRoots = buildRoots(N, r, s);

        Map<Element, Integer> elementToCount = new HashMap<>();
        for (int i = 0; i < N; ++i) {
            Element element = new Element(roadRoots[i], railwayRoots[i]);

            elementToCount.put(element, elementToCount.getOrDefault(element, 0) + 1);
        }

        return IntStream.range(0, N)
                .mapToObj(i -> String.valueOf(elementToCount.get(new Element(roadRoots[i], railwayRoots[i]))))
                .collect(Collectors.joining(" "));
    }

    static int[] buildRoots(int N, int[] x, int[] y) {
        int[] parents = new int[N];
        Arrays.fill(parents, -1);

        for (int i = 0; i < x.length; ++i) {
            int root1 = findRoot(parents, x[i]);
            int root2 = findRoot(parents, y[i]);

            if (root1 != root2) {
                parents[root2] = root1;
            }
        }

        return IntStream.range(0, N).map(i -> findRoot(parents, i)).toArray();
    }

    static int findRoot(int[] parents, int node) {
        int root = node;
        while (parents[root] != -1) {
            root = parents[root];
        }

        int p = node;
        while (p != root) {
            int next = parents[p];
            parents[p] = root;

            p = next;
        }

        return root;
    }
}

class Element {
    int roadRoot;
    int railwayRoot;

    Element(int roadRoot, int railwayRoot) {
        this.roadRoot = roadRoot;
        this.railwayRoot = railwayRoot;
    }

    @Override
    public int hashCode() {
        return Objects.hash(roadRoot, railwayRoot);
    }

    @Override
    public boolean equals(Object obj) {
        Element other = (Element) obj;

        return roadRoot == other.roadRoot && railwayRoot == other.railwayRoot;
    }
}

Measured memory_bytes: 144736
class Queue():
    def __init__(self):
        self.l = []
    
    def push(self, e):
        self.l.append(e)
        
    def pop(self):
        return self.l.pop(0)


queue = Queue()
n, q = tuple([int(x) for x in input().split()])
for _ in range(n):
    tmp = input().split()
    queue.push([tmp[0], int(tmp[1])])

time = 0
while queue.l:
    process = queue.pop()
    if process[1] <= q:
        time += process[1]
        print(' '.join([process[0], str(time)]))
    else:
        time += q
        queue.push([process[0], process[1]-q])

Measured memory_bytes: 13008
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int main(){
	while(true){
		int n,x[200],y[200];
		scanf("%d",&n);
		if(n==0) break;
		x[0]=0,y[0]=0;
		rep1(i,n-1){
			int ni,d;
			scanf("%d%d",&ni,&d);
			x[i]=x[ni]+dx[d],y[i]=y[ni]+dy[d];
		}
		int mxx=0,mxy=0,mnx=0,mny=0;
		rep(i,n){
			mxx=max(mxx,x[i]);
			mxy=max(mxy,y[i]);
			mnx=min(mnx,x[i]);
			mny=min(mny,y[i]);
		}
		printf("%d %d\n",mxx-mnx+1,mxy-mny+1);
	}
}

Measured memory_bytes: 1016
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            long sum = 0;
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            long tmp = 0, res = Integer.MAX_VALUE;
            for (int i = n - 1; i >= 1; --i) {
                tmp += a[i];
                long curSum = sum - tmp;
                res = Math.min(res, Math.abs(curSum - tmp));
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 46320
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
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
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b=mii()
print(a*b)



     



Measured memory_bytes: 77072
k, a, b = map(int, input().split())
first_k = k
bis = 1
if b - a >= 2:
    # 交換したほうが多い
    # 1回目
    k -= a - 1
    bis += a - 1
    change_count = k//2
    bis += change_count * (b - a)
    if bis >= 0:
        print(bis + (k % 2))
    else:
        print(first_k+1)

else:
    # たたいたほうが多い
    print(k+1)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toLong)
    val map = mutableMapOf<Long, Long>()
    aList.forEach {
        if (map.containsKey(it)) {
            map[it] = map[it]!! + 1L
        } else {
            map[it] = 1L
        }
    }
    val countMap = map.filterValues { it >= 2L }
    if (countMap.size < 2) {
        println(0)
        return
    }
    val (first, second) = countMap.keys.toList().sortedDescending().subList(0, 2)
    if (countMap[first]!! >= 4) {
        println(first * first)
    } else {
        println(first * second)
    }
}

Measured memory_bytes: 58124
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		br.close();

		int mod = 1000000007;
		NCR ncr = new NCR(n + 40, mod);
		Map<Integer, Integer> soinsu = bunkai(m);
		long ans = 1;
		for (int val : soinsu.values()) {
			long v = ncr.calc(n + val - 1, val);
			ans *= v;
			ans %= mod;
		}
		System.out.println(ans);
	}

	static Map<Integer, Integer> bunkai(int n) {
		Map<Integer, Integer> soinsu = new HashMap<>();
		int end = (int) Math.sqrt(n);
		int d = 2;
		while (n > 1) {
			if (n % d == 0) {
				n /= d;
				if (soinsu.containsKey(d)) {
					soinsu.put(d, soinsu.get(d) + 1);
				} else {
					soinsu.put(d, 1);
				}
				end = (int) Math.sqrt(n);
			} else {
				if (d > end) {
					d = n - 1;
				}
				d++;
			}
		}
		return soinsu;
	}

	static class NCR {
		long[] p, pi;
		int m;

		public NCR(int n, int mod) {
			n++;
			m = mod;
			p = new long[n];
			pi = new long[n];
			p[0] = 1;
			pi[0] = 1;
			for (int i = 1; i < n; i++) {
				p[i] = p[i - 1] * i % m;
			}
			pi[n - 1] = BigInteger.valueOf(p[n - 1])
					.modInverse(BigInteger.valueOf(m)).longValue();
			for (int i = n - 1; i > 1; i--) {
				pi[i - 1] = pi[i] * i % m;
			}
		}

		public long calc(int n, int r) {
			if (n < r) return 0;
			return p[n] * pi[r] % m * pi[n - r] % m;
		}
	}
}


Measured memory_bytes: 23636
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

template <typename T>
std::vector<int> sort_indexes(const std::vector<T> &v) {
  std::vector<int> idx(v.size());
  std::iota(idx.begin(), idx.end(), 0);
  std::sort(idx.begin(), idx.end(), [&v](int i1, int i2) {return v[i1] > v[i2];});
  return idx;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n/2);
	std::vector<int> b(n/2);
	rep(i,n) {
		if(i&1) std::cin >> a[i/2];
		else std::cin >> b[i/2];
	}

	int a1,a2,b1,b2;
	std::vector<int> mapa(1e5+7,0);
	for(auto i:a) mapa[i]++;
	{
		std::vector<int> idx = sort_indexes(mapa);
		a1 = idx[0];
		a2 = idx[1];
	}
	std::vector<int> mapb(1e5+7,0);
	for(auto i:b) mapb[i]++;
	{
		std::vector<int> idx = sort_indexes(mapb);
		b1 = idx[0];
		b2 = idx[1];
	}

	if(a1!=b1) {
		print(n-mapa[a1]-mapb[b1]);
		return 0;
	}
	print(std::min(n-mapa[a1]-mapb[b2],n-mapa[a2]-mapb[b1]));
	return 0;
}


Measured memory_bytes: 3440
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int counter;
		counter=in.nextInt();
		int seller,buyer,temp,diff;
		seller=0;
		int pri=0;
		diff=Integer.MIN_VALUE;
		buyer=Integer.MAX_VALUE;
		//long start=System.currentTimeMillis();
		for(int i=0;i<counter;i++) {
			temp=in.nextInt();
			if(i!=0 && diff<temp-pri)
				diff=temp-pri;
			if (temp< buyer && i<counter-1) {
				buyer = temp;
				seller = 0;
				pri=temp;
				continue;
			}
			if (temp>seller) {
				seller = temp;
			}
			if (seller !=0 && diff< seller-buyer) {
				diff= seller - buyer;
			}
			pri=temp;
		}
		System.out.println(diff);
	}
}


Measured memory_bytes: 69172
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int maxi = *max_element(all(l));
  int sum = accumulate(all(l), 0) - maxi;
  if (maxi < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
# -*- coding: utf-8 -*-

def main():
  A,B=map(int, input().split())
  num_max = max(A,B)
  num_min = min(A,B)
  res = ""
  for i in range(num_max):
    res = str(res) + str(num_min)
  print(res)


if __name__ == '__main__':
  main()

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

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define RREP(i, a, b) for(int i = (a); i >= (b); --i)
int L[5010][5010], R[5010][5010];
int a[5010];

int main() {
    int N; int K;
    scanf("%d %d", &N, &K);
    
    REP(i, 1, N + 1) scanf("%i", &a[i]);

    L[0][0] = 1;
    REP(i, 0, N) REP(j, 0, K) if(L[i][j]) {
        L[i+1][j] = 1;
        if(j + a[i+1] < K) L[i+1][j + a[i+1]] = 1;
    }

    R[N+1][0] = 1;
    RREP(i, N, 1) REP(j, 0, K) if(R[i+1][j]) {
        R[i][j] = 1;
        if(j + a[i] < K) R[i][j + a[i]] = 1;
    }

    REP(i, 0, N + 2) {
        REP(j, 1, K) R[i][j] += R[i][j-1];
    }

    int ans = 0;
    REP(i, 1, N + 1) {
        if(K <= a[i]) continue;

        bool ok = true;
        REP(j, 0, K) if(L[i-1][j]) {
            int lo = max(K - j - a[i], 0);
            int hi = min(K-1, K - j - 1);

            int sm = R[i+1][hi];
            if(0 < lo) sm -= R[i+1][lo-1];
            if(sm != 0) ok = false;
        }
        if(ok) ans++;
    }

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

Measured memory_bytes: 196224
using System;


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

        if (a > b)
        {
            Console.WriteLine(a - 1);
        }
        else
        {
            Console.WriteLine(a);
        }

        System.Threading.Thread.Sleep(1000);
    }
}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=305;
int mark[N],c[N],n,m,ans;
vi p[N];

int main(){
	read(n),read(m),ans=n;
	rep(i,1,n){
		p[i].resize(m);
		per(j,m-1,0) read(p[i][j]);
	}
	rep(i,1,m){
		fill(c+1,c+m+1,0);
		rep(j,1,n){
			while(mark[p[j].back()]) p[j].pop_back();
			c[p[j].back()]++;
		}
		int mx=0;
		rep(j,1,m) if(c[j]>c[mx]) mx=j;
		ans=min(ans,c[mx]);
		mark[mx]=1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <complex>
#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
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>M;
    priority_queue<ll> price;
    rep(i,N){
        cin>>A;
        price.push(A);
    }
    rep(i,M){
        ll temp = price.top();
        price.pop();
        price.push(temp/2);
    }
    ll ans = 0;
    rep(i,N){
        ll temp = price.top();
        price.pop();
        ans += temp;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#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;

int Abs(int x) { return max(x, -x); }

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

    int n;
    cin >> n;
    vector<int> x(n), y(n), z(n);
    rep(i, n) cin >> x[i] >> y[i] >> z[i];
    rep(X, 101) rep(Y, 101)
    {
        bool f = true;
        int H = -1;
        rep(i, n)
        {
            if (z[i] == 0)
                continue;
            int h = z[i] + abs(x[i] - X) + abs(y[i] - Y);
            if (H == -1)
                H = h;
            if (H != h)
                f = false;
        }
        if (f)
        {
            bool che = true;
            rep(i, n)
            {
                int h = max(H - abs(x[i] - X) - abs(y[i] - Y), 0LL);
                if (z[i] != h)
                    che = false;
            }
            if (che)
            {
                cout << X << " " << Y << " " << H << endl;
                return 0;
            }
        }
    }
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> height(n);
    for(int i=0;i<n;i++){
        cin >> height[i];
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        int jump = 0;
        while(i<n-1 && height[i]>=height[i+1]){jump++; i++;}
        ans = max(ans,jump); 
    }
    cout << ans << endl;
}

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

string name, type;

vector<string> split(string name) {
	vector<string> ret;
	string word;
	
	for (int i = 0; i < name.length(); i++) {
		if (name[i] == '_' || ('A' <= name[i] && name[i] <= 'Z')) {
			if (word.length() > 0) ret.push_back(word);
			word = "";
		}
		if ('A' <= name[i] && name[i] <= 'Z') word += name[i] + 32;
		else if (name[i] != '_') word += name[i];
	}
	ret.push_back(word);
	return ret;
}

int main() {
	while (cin >> name >> type) {
		char t = type[0];
		
		vector<string> names = split(name);
		
		if (t == 'X') break;
		
		if (t == 'U' || t == 'L') {
			for (int i = (t == 'L'); i < names.size(); i++) {
				if ('a' <= names[i][0] && names[i][0] <= 'z')
					names[i][0] = names[i][0] - 32;
			}
		}
		if (t == 'D') {
			for (int i = 0; i < (int)names.size() - 1; i++) {
				names[i] += '_';
			}
		}
		
		for (int i = 0; i < names.size(); i++) {
			cout << names[i];
		}
		cout << endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll a[n], sum[n], pre[n];
    rep(i, n) {
        cin >> a[i];
        if (i == 0) sum[i] = a[i], pre[i] = ((a[i] > 0) ? a[i] : 0);
        else sum[i] = a[i] + sum[i - 1], pre[i] = pre[i - 1] + ((a[i] > 0) ? a[i] : 0);
    }

    ll ans = max(sum[k - 1], 0LL) + pre[n - 1] - pre[k - 1];
    repl(i, k, n) {
        maxch(ans, max(sum[i] - sum[i - k], 0LL) + pre[i - k] + pre[n - 1] - pre[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
N = int(input())
a = [int(input()) for i in range(N)]
count = 0
tmp = 1
flag = 0
for i in range(len(a)):
    if tmp == 2:
        flag = 1
        break
    else:
        tmp = a[tmp-1]
    count += 1
if flag == 1:
    print(count)
else:
    print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    char ch,op,s1[110],s2[110],s3[110];
    int i,j,k;
    cin>>s1>>s2>>s3;
    ch=s1[0];
    i=1,j=k=0;
    while(ch)
    {
        if(ch=='a') ch=s1[i++],op='A';
        if(ch=='b') ch=s2[j++],op='B';
        if(ch=='c') ch=s3[k++],op='C';
    }
    cout<<op<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    let (n, m): (usize, usize) = read();
    let s: Vec<u8> = read::<String>().into_bytes();
    let lr: Vec<(usize, usize)> = readn(m);
    let mut imos: Vec<usize> = vec![0; n+1];
    for i in 0..n {
        let c = if s[i] == '1' as u8 { 1 } else { 0 };
        imos[i+1] = imos[i] + c;
    }

    let mut maxto: Vec<usize> = vec![0; n];
    for &(fr, to) in &lr {
        maxto[fr-1] = max(maxto[fr-1], to);
    }

    let mut dp: Vec<Vec<i64>> = vec![vec![0; n+1]; n+1];
    dp[0][0] = 1;

    let mut prev = vec![0; n+1];
    let mut to = 0;
    for i in 0..n {
        to = max(to, i);
        let mut h = 0;
        if to < maxto[i] {
            h += imos[maxto[i]] - imos[to];
        }
        to = max(to, maxto[i]);

        for j in 0..n+1 {
            if j >= h {
                prev[j] = dp[i][j-h];
            }  else {
                prev[j] = 0;
            }
        }

        let size = to - i;
        if size == 0 {
            for j in 0..n+1 {
                dp[i+1][j] = dp[i][j];
            }
        } else {
            for j in 0..n+1 {
                let left_zero = size - j;
                let left_one = j;
                let base = prev[j];
                if base >= 1 {
                    if left_zero >= 1 {
                        dp[i+1][j] += base;
                        dp[i+1][j] %= MOD;
                    }
                    if left_one >= 1 {
                        dp[i+1][j-1] += base;
                        dp[i+1][j-1] %= MOD;
                    }
                }
            }
        }
    }

    let mut ans = 0;
    for i in 0..n+1 {
        ans += dp[n][i];
    }
    println!("{}", ans % MOD);
}

Measured memory_bytes: 90364
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve
const (
	MAX   = 100
	INFTY = (1 << 21)
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

//V: グラフの頂点全体の集合
//T: MSTに属する頂点の集合
var (
	n     int
	M     [MAX][MAX]int //重みを記録する隣接行列
	color [MAX]int
	p     [MAX]int //MSTにおける頂点の親を記録
	d     [MAX]int //Tに属する頂点と、V−Tに属する頂点を繋ぐ辺の中で、重みが最小のものを記録
)

func prim() int {
	var u, minv int
	//初期化
	for i := 0; i < n; i++ {
		d[i] = INFTY
		p[i] = -1
		color[i] = WHITE
	}

	d[0] = 0

	for {
		//頂点uを決めていく
		//つまり、Tに属する頂点と、V−Tに属する頂点を繋ぐ辺の中で、重みが最小のものを決める
		minv = INFTY
		u = -1
		for i := 0; i < n; i++ {
			//未訪問かつ、辺の重みが最小となるuを選ぶ
			if minv > d[i] && color[i] != BLACK {
				u = i
				minv = d[i]
			}
		}

		if u == -1 {
			break
		}

		color[u] = BLACK
		for v := 0; v < n; v++ {
			//未訪問かつ、辺が存在するとき
			if color[v] != BLACK && M[u][v] != INFTY {
				if d[v] > M[u][v] {
					d[v] = M[u][v]
					p[v] = u
					color[v] = GRAY
				}
			}
		}
	}

	sum := 0
	for i := 0; i < n; i++ {
		if p[i] != -1 {
			sum += M[i][p[i]]
		}
	}
	return sum
}

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()

	for i := 0; i < n; i++ {

		for j := 0; j < n; j++ {
			tmp := nextInt()
			if tmp == -1 {
				tmp = INFTY
			}
			M[i][j] = tmp
		}

	}

	fmt.Println(prim())

}



Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, K;
	cin >> N >> K;
	ll ans = 0;
	if (K == 0) {
		ans += (ll)N * N;
	}
	else {
		for (int i = K + 1; i <= N; i++) {
			ans += max(0, (N % i) + 1 - K);
			ans += (N / i) * (i - K);
			//cout << ans << endl;
		}
	}
	cout << ans << endl;
}



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

int main(){
  int N, n, a, b;
  b = 0;
  cin >> N;
  n = N;
  for (int i = 0; i < 9; i++) {
    if (N >= pow(10, i) && N < pow(10, i + 1)) {
      for (int j = 0; j < i; j++) {
        a = N / pow(10, i - j);
        b += a;
        N -= a * pow(10, i - j);
      }
      if (n % (b + N) == 0)
        cout << " Yes" << endl;
      else
        cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int a, b, ans;
	cin >> a >> b;
	ans = max(0, a - 2 * b);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 888
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if(i * 500 + j * 100 + k * 50 == X):
                count += 1

print(count)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))


#Aだけのときのmax

s = 0
j = 0
for i in range(n):
    if s + a[i] > k:
        break
    else:
        s += a[i]
        j += 1


ans = [j]

for l in range(m):
    flag = True
    s += b[l]
    while s > k:
        s -= a[j-1]
        j -= 1
        if j < 0:
            flag = False
            break
    
    if not flag:
        break
    else:
        ans.append(l + 1 + j)
        #print(ans)

print(max(ans))


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

// 2個のボタンがあり、大きさはそれぞれ A,Bです。
// 大きさ Xのボタンを押すと、X枚のコインを獲得し、そのボタンの大きさが 1小さくなります。
// あなたは、いずれかのボタンを押すことを 2回行います。 同じボタンを 2回押しても構いません。
// 最大で何枚のコインを獲得できるでしょうか。
// 3<=A,B<=20

int main(){
    int a,b;
    cin >> a >> b;
    int sum = 0;
    sum += max(a, b);
    if(a>b){
        a--;
    }else{
        b--;
    }
    sum += max(a,b);
    cout << sum << endl;
    return 0;
}


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




int main()
{
  int N,M;
  cin >> N >> M;
  priority_queue<int> A;
  int64_t ans = 0;
  int a,now;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    A.push(a);
  }

  for (int i = 0; i < M; i++)
  {
    now = A.top() / 2;
    A.pop();
    A.push(now);
  }

  for (int i = 0; i < N; i++)
  {
    ans += A.top();
    A.pop();
  }

  cout << ans << endl;
}

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

const int32_t MAX_N = 1e5;
const int32_t MOD = 1e9 + 7;

class Tree {
public:
	struct Node {
		bool isVisited;
		int32_t id, dp[2];
		std::vector< Node* > v;
	};

	int32_t cntNodes;
	Node nodes[MAX_N + 5];

	void Init(int32_t pCntNodes) {
		cntNodes = pCntNodes;
		for(int32_t i = 1; i <= cntNodes; i++) {
			nodes[i].id = i;
		}
	}

	void AddEdge(Node *x, Node *y) {
        x->v.push_back(y);
        y->v.push_back(x);
	}

	void Dfs(Node *nd) {
		nd->isVisited = true;

		nd->dp[0] = 1;
		nd->dp[1] = 1;

		for(auto x : nd->v) {
			if(!x->isVisited) {
				Dfs(x);
				nd->dp[0] = ((int64_t) nd->dp[0] * x->dp[1]) % MOD;
				nd->dp[1] = ((int64_t) nd->dp[1] * (x->dp[0] + x->dp[1])) % MOD;
			}
		}
	}
};

Tree t;

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

	int32_t n;
	std::cin >> n;

	t.Init(n);

	for(int32_t i = 0; i < n - 1; i++) {
		int32_t x, y;
		std::cin >> x >> y;

		t.AddEdge(&t.nodes[x], &t.nodes[y]);
	}

	t.Dfs(&t.nodes[1]);

	std::cout << ((int64_t) t.nodes[1].dp[0] + t.nodes[1].dp[1]) % MOD << '\n';
}


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


int main(){
    int N; cin>>N;
    vector<int> h(N,0),f(N,0);
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    f[0]=0;
    f[1]=abs(h[0]-h[1]);
    for(int i=2;i<N;i++){
        f[i]=min(f[i-2]+abs(h[i]-h[i-2]),f[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<f[N-1];
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] ary = new int[3];
		ary[0] = sc.nextInt();
		ary[1] = sc.nextInt();
		ary[2] = sc.nextInt();
		Arrays.sort(ary);
		if (ary[0] + ary[1] == ary[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23380
e = input().split()
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

a = int(e[0])
b = int(e[1])
c = int(e[2])
d = int(e[3])

xmax = max(x)
ymax = min(y)

if xmax < ymax:
    if c < ymax:
        if xmax < d:
            print("No War")
        else:
            print("War")
    else:
        print("War")
else:
    print("War")


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

int main() {
	int a,b;
	cin>>a>>b;
	if(abs(a-b)%2==0) {
		if(a>b) cout<<a-abs(a-b)/2;
		else cout<<b-abs(a-b)/2;
	}
	else cout<<"IMPOSSIBLE";
	cout<<endl;
}

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

int main()
{
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<ll> red;
    priority_queue<ll> gr;
    priority_queue<ll> tra;
    priority_queue<ll, vector<ll>, greater<ll>> red1;
    priority_queue<ll, vector<ll>, greater<ll>> gr1;
    priority_queue<ll> tra1;
    rep(i, a)
    {
        ll q;
        cin >> q;
        red.push(q);
    }
    rep(i, b)
    {
        ll q;
        cin >> q;
        gr.push(q);
    }
    rep(i, c)
    {
        ll q;
        cin >> q;
        tra.push(q);
    }
    ll count = 0;
    rep(i, x)
    {
        count += red.top();
        red1.push(red.top());
        red.pop();
    }
    rep(i, y)
    {
        count += gr.top();
        gr1.push(gr.top());
        gr.pop();
    }
    //最小値を考えていきます。
    while (min(red1.top(), gr1.top()) < tra.top() && tra.empty() != 1)
    {
        count -= min(red1.top(), gr1.top());
        count += tra.top();

        ll o = tra.top();
        tra.pop();
        if (red1.top() == min(red1.top(), gr1.top()))
        {
            red1.pop();
            red1.push(o);
        }
        else if (gr1.top() == min(red1.top(), gr1.top()))
        {
            gr1.pop();
            gr1.push(o);
        }
    }
    cout << count;
}

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

int main(){
    int x, y, tmp;
    int i = 1;

    while(1){
        cin >> x >> y;
        
        if(0 == x && 0 == y){
            break;
        }

        if(x > y){
            tmp = x;
            x = y;
            y = tmp;
        }

        // cout << "Case " << i << ": " << n << endl;
        cout << x << " " << y << endl;

        i++;
    }

    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<int> A(N + 1);
  rep(i, N) cin >> A[i + 1];
  vector<int> B(N + 1);
  for (int i = N; i >= 1; i--) {
    int sum = 0;
    for (int j = 2 * i; j <= N; j += i) {
      sum += B[j];
    }
    if (sum % 2 != A[i]) {
      B[i] = 1;
    }
  }
  vector<int> ans;
  rep(i, N) {
    if (B[i + 1]) {
      ans.push_back(i + 1);
    }
  }
  cout << ans.size() << "\n";
  if (ans.size()) {
    rep(i, ans.size()) {
      if (i) cout << " ";
      cout << ans[i];
    }
    cout << "\n";
  }
}


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

int main()
{
    int w, n, num[31];
    int i;

    cin >> w;

    for (i = 1; i <= w; i++){
        num[i] = i;
    }

    cin >> n;
    for (i = 0; i < n; i++){
        char c;
        int a, b;
        cin >> a >> c >> b;
        swap(num[a], num[b]);
    }

    for (i = 1; i <= w; i++){
        cout << num[i] << endl;
    }
    return (0);
}

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

int main() {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0;i <= N;++i) {
		for (int j = 0;j <= N;++j) {
			if (Y - 10000 * i - 5000 * j == (N - i - j) * 1000 && N - i - j >= 0) {
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-09 20:13:20
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  set<int> st;

  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    st.insert(a);
  }

  if ((int) st.size() == n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

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

int main() {
  int X; cin >> X;
  vector<bool> expo(X+1);
  expo[1] = 1;
  for (int b = 2; b <= X; ++b) {
    int v = b * b;
    while (v <= X) {
      expo[v] = 1;
      v *= b;
    }
  }
  for (int i = X; i >= 1; i--) {
    if (expo[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}
int MOD = pow(10, 9) + 7;

//幅優先探索
//disは各座標への距離。行けない場合は-1にしている。
//chaは各座標の情報。文字で格納している。'.'はすすめる。'#'は壁(黒)。
//sはスタートの座標
//gはゴールの座標
vector<vector<int>> bfs(vector<vector<int>> dis,vector<vector<char>>cha,pair<int,int>s,pair<int,int>g){
    int h=dis.size();
    int w=dis.at(0).size();

    queue<pair<int,int>> Q;
    Q.push(s);
    dis.at(s.first).at(s.second)=0;
    if(cha[0][0]=='#') dis[0][0]=1;
    else dis[0][0]=0;

    while(!Q.empty()){
        int y,x;//今の座標
        y=Q.front().first; x=Q.front().second;
        Q.pop();

        //今回は後ろには戻らない。というか、0,0スタートなら戻る必要無さそう。
        int dy[4]={1,0,-1,0};
        int dx[4]={0,1,0,-1};
        for(int i=0;i<2;i++){
            //ey,exは変更後の座標。csは変える候補の値。
            int ey=y+dy[i];
            int ex=x+dx[i];
            int cs;
            //範囲外はスルー
            if(ex<0||ey<0||ex>=w||ey>=h) continue;
            //白から黒へ移るときにカウントが１増える
            if(cha[y][x]=='.' && cha[ey][ex]=='#') cs=dis[y][x]+1;
            else cs=dis[y][x];
            
            //未探索か、候補値の方が小さい場合、変更して変更先をキューに打ち込む
            if(dis[ey][ex]==-1 || cs<dis[ey][ex]){
                Q.push({ey,ex});
                dis[ey][ex]=cs;
            }
        }
    }

    return dis;
}

signed main() {
    int h,w; cin>>h>>w;
    vector<vector<char>> grid(h,vector<char>(w));
    vector<vector<int>> dis(h,vector<int>(w,-1));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>grid[i][j];
    }

    dis=bfs(dis,grid,make_pair(0,0),make_pair(h-1,w-1));

    cout<<dis[h-1][w-1]<<endl;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,a[2001],s[2001],t[2001];
long long k,k1,k2,d1=0,d2=0;

void nhap()
{
    scanf("%d %lld",&n,&k);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
    }
}

void process()
{
    k1=(k*(k+1))/2;
    k1%=MOD;
    k2=(k*(k-1))/2;
    k2%=MOD;
    for (int i=1;i<n;++i)
    {
        for (int j=i+1;j<=n;++j)
        {
            s[i]+=(a[i]>a[j]);
        }
    }
    for (int i=2;i<=n;++i)
    {
        for (int j=1;j<i;++j)
        {
            t[i]+=(a[i]>a[j]);
        }
    }
    for (int i=1;i<=n;++i)
    {
        d1=(d1+s[i])%MOD;
        d2=(d2+t[i])%MOD;
    }
    cout<<((k1*d1)%MOD+(k2*d2)%MOD)%MOD;
}

int main()
{
    nhap();
    process();
    return 0;
}


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

int main() {
	
	int a, b, h, m; cin >> a >> b >> h >> m;
	double angle;
	double ans;
	angle = 2 * M_PI * ((double)m / 60 - ((double)h / 12 + (double)m / 720));
	angle = abs(angle);
	ans = a * a + b * b - 2 * a * b * cos(angle);
	ans = sqrt(ans);
	cout << fixed << setprecision(11) << ans << endl;
	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a,b,k; cin >> a >> b >> k;
	if(a > b) swap(a,b); 
	vector<int> ans; int cek = -1;
	if(sqrt(a)*sqrt(a) == a) cek = sqrt(a);
	for(int i=1;i*i<=a;i++) if(a%i == 0 && b%i == 0) ans.push_back(i);
	for(int i=1;i*i<=a;i++) if((a)%(a/i) == 0 && i != cek && b%(a/i) == 0) ans.push_back(a/i);
	sort(ans.begin(), ans.end());
//	for(auto x: ans) cout << x << " ";
	cout << ans[ans.size()-k] << "\n";
	return 0;
}

Measured memory_bytes: 256