akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<vector<ll>> dp(c+1,vector<ll>(d+1));
    const ll MOD=998244353;
    dp[a][b] = 1;
    rep(i,a,c+1) rep(j,b,d+1) {
        if(i>a) dp[i][j]=(dp[i-1][j]*j)%MOD;
        if(j>b) dp[i][j]=(dp[i][j]+dp[i][j-1]*i)%MOD;
        if(i>a && j>b) {
            ll x = (dp[i-1][j-1]*(i-1))%MOD;
            x = (x*(j-1))%MOD;
            dp[i][j]=(dp[i][j]+MOD-x)%MOD;
        }
    }
    // rep(i,1,c+1) {
    //     rep(j,1,d+1) cerr<<dp[i][j]<<" ";
    //     cerr<<endl;
    // }
    cout<<dp[c][d]<<endl;
}


Measured memory_bytes: 73656
N = int(input())
A = [int(i) for i in input().split()]
tmp_A = []
tmp_A.append(A[N-1])
for i in range(N-2):
    A0 = tmp_A[i]+A[N-2-i]
    tmp_A.append(A0)
tmp_A.reverse()
sum_A = 0
for i in range(N-1):
    sum_A += A[i]*tmp_A[i]
print(sum_A%(1000000007))

Measured memory_bytes: 31572
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n; 
  vector<ll> sum(n, 0);
  for(int i = 1; i < n; ++i){
  	int a;
  	cin >> a;
  	--a;
  	++sum[a];
  }

  for(int i = 0; i < n; ++i)cout << sum[i] << endl;
  return 0;
}


Measured memory_bytes: 4840
/*(c) nupetan 2017*/
#include<stdio.h>
int main(){
	struct {
		short int width, height;
	}rectangle;
	struct {
		short int x_coordinate, y_coordinate,radius;
	}circle;
	scanf("%hd %hd", &rectangle.width, &rectangle.height);
	scanf("%hd %hd %hd", &circle.x_coordinate, &circle.y_coordinate, &circle.radius);

	if(rectangle.width >= circle.x_coordinate + circle.radius
	&& rectangle.height >= circle.y_coordinate + circle.radius
	&& 0 <= circle.x_coordinate - circle.radius
	&& 0 <= circle.y_coordinate - circle.radius)
	puts("Yes");
	else
	puts("No");
}

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

int main(){
  char s[11];
  cin >>s;
  int m=0;
  int count=0;
  for(int i=0;i<10;i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      count++;
    }else{
      count = 0;
    }
    m = max(m,count);
  }
  cout<<m<<endl;
}

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

int main(){
  int n,k,i;
  string s;
  cin >> n >> s >> k;
  for(i=0;i<n;i++){
    if(s.at(i)!=s.at(k-1)){
      s.at(i)='*';
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3592
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int H = 20;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int w = sc.nextInt(), d = sc.nextInt();
			if((w|d) == 0) break;
			
			int[] ws = new int[w], ds = new int[d];
			for(int i=0;i<w;i++) ws[i] = sc.nextInt();
			for(int i=0;i<d;i++) ds[i] = sc.nextInt();
			sort(ws); sort(ds);
			int i, j, cnt = 0;
			for(i=j=0;i!=w&&j!=d;) {
				if(ws[i] == ds[j])     {cnt+=ws[i]; i++; j++; }
				else if(ws[i] < ds[j]) {cnt+=ws[i]; i++;}
				else                   {cnt+=ds[j]; j++;}
			}
			for(;i<w;i++) cnt+=ws[i];
			for(;j<d;j++) cnt+=ds[j];
			System.out.println(cnt);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 23268
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			int num = scan.nextInt();
			
			int[] primeList = new int[num+1];
			int cnt = 0;
			
			// 2以上の自然数をすべて1（素数）にする
			for(int i = 2; i <= num; i++) {
				primeList[i] = 1;
			}
			
			for(int i = 2; i <= num; i++) {
				if(primeList[i] == 0);
				else {
					cnt++;
					for(int j = i + i; j <= num; j += i) {
						primeList[j] = 0;
					}
				}
			}
			
			System.out.println(cnt);
			
		}
	}
}

Measured memory_bytes: 54304
import math

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

if N < 2:
  even =0
else:
  even = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))

if M < 2:
  odd = 0
else:
  odd = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))

#print(even, odd)
print(even + odd)


Measured memory_bytes: 3060
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
set<pair<int,string> > t;
string s[200010];
map<string,int> mp;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		mp[s[i]]++;
	}
	for(int i=0;i<n;i++){
		t.insert(make_pair(-mp[s[i]],s[i]));
	}
	pair<int,string> st=*t.begin();
	int last=st.first;
	for(set<pair<int,string> >::iterator it=t.begin();it!=t.end();it++){
		pair<int,string> p=*it;
		if(p.first!=last)break;
		else cout<<p.second<<endl;
		last=p.first;
	}
	return 0;
	return 0;
}


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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(8);
    int n; cin >> n;
    vector<int> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    auto dist = [&](int i, int j){
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx * dx + dy * dy);
    };
    vector<int> p(n);
    rep(i,n) p[i] = i;
    double len = 0;
    int cnt = 0;
    do {
        rep(i,n-1){
            len += dist(p[i],p[i+1]);
        }
        cnt++;
    } while (next_permutation(p.begin(),p.end()));
    double ans = len / cnt;
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	int k[m], p[m];
	vector< vector<int> > s(m);
	for (int i = 0; i < m; i++) {
		cin >> k[i];
		s[i].resize(k[i]);
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	long ans = 0;
	bool flag[n] = {};
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}
	int tmp = 0;
	int max = 1 << n;
	while (tmp < max) {
		int cmp = tmp;
		vector<int> vec(n);
		int cnt = 0;
		while (cmp) {
			vec[cnt] = cmp % 2;
			cmp = cmp / 2, cnt++;
		}
		bool FLAG = true;
		for (int i = 0; i < m; i++) {
			int CNT = 0;
			for (int j = 0; j < k[i]; j++) {
				if (vec[s[i][j] - 1]) CNT++;
			}
			if (CNT % 2 != p[i]) {
				FLAG = false;
				break;
			}
		}
		if (FLAG) ans++;
		// while (cmp) {
		// 	cout << cmp % 2;
		// 	cmp = cmp / 2;
		// }
		// cout << endl;
		tmp++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

bool can(ll x, ll p) {
  while(x % p == 0) {
    x /= p;
  }
  return x % p == 1;
}

double getSum(double x) {
  return x * (x + 1.0) / 2.0;
}

int main() {
  int n, k; cin >> n >> k;
  vector <double> prefix(n + 1, 0);
  double sum = 0;
  for(int i = 1; i <= n; i++) {
    double x; cin >> x;
    sum += getSum(x) / x;
    prefix[i] = sum;
  }
  double ans = 0;
  for(int i = 1; i + k - 1 <= n; i++) {
    ans = max(ans, prefix[i + k - 1] - prefix[i - 1]);
  }
  printf("%0.8lf\n", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
int n,m;
int ar[105];
int mem[55][55][105];

int solve(int l,int r,int rm){
    if(rm==0||l>r){
        return 0;
    }
    if(mem[l][r][rm]!=-1){
        return mem[l][r][rm];
    }
    int ch1=solve(l+1,r,rm-1)+ar[l];
    int ch2=solve(l,r-1,rm-1)+ar[r];
    int ch3=0,ch4=0;
    if(rm>=2){
        ch3=solve(l+1,r,rm-2);
        ch4=solve(l,r-1,rm-2);
    }
    return mem[l][r][rm]=max(ch1,max(ch2,max(ch3,ch4)));
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof mem);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cout<<solve(0,n-1,m)<<endl;
    return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner) = {
    val N = sc.nextInt
    val S = sc.next
    var count = 0
    for (_ <- Range(0, N)) {
      val s = sc.next
      var flag = true
      for (i <- Range(0, math.max(0, s.length - S.length) + 1)) {
        if (flag) {
          for (j <- Range(1, 200)) {
            if (flag) {
              if (i + j * (S.length - 1) < s.length) {
                //println(i, j)
                var f = true

                for (k <- Range(0, S.length)) {
                  if (s(i + j * k) != S(k)) (f = false)
                }

                if (f) {
                  count += 1
                  flag = false
                }
              }
            }
          }
        }
      }
    }
    println(count)
  }

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




Measured memory_bytes: 55604
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print()



Measured memory_bytes: 7000
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef int ss;
#define int long long

typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll A[4];

ss main()
{
  rep(i,4) cin>>A[i];
  sort(A,A+4);
  puts( (A[0]==1&&A[1]==4&&A[2]==7&&A[3]==9)?"YES":"NO"   );
}


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

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

using namespace std;

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  int sr, sc;
  cin >> sr >> sc;
  string s,t;
  cin >> s >> t;

  // yoko W
  int l = 0, r = w+1;
  for (int i = n-1; i > -1; i--) {
    if(t[i] == 'R' && 1 <= l && l < w) {
      l--;
    }
    if(t[i] == 'L' && 1 < r && r <= w) {
      r++;
    }

    if(s[i] == 'L') {
      l++;
    }
    if(s[i] == 'R') {
      r--;
    }
  }

  // tate H
  int u = 0, d = h+1;
  for (int i = n-1; i > -1; i--) {
    if(t[i] == 'D' && 1 <= u && u < h) {
      u--;
    }
    if(t[i] == 'U' && 1 < d && d <= h) {
      d++;
    }

    if(s[i] == 'U') {
      u++;
    }
    if(s[i] == 'D') {
      d--;
    }
  }

  if ((l < sc && sc < r) && (u < sr && sr < d)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}


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

const double EPS=1e-6;

int main() {
	double a,b,c,d,e,f;
	double x,y;
	while(cin>>a>>b>>c>>d>>e>>f)
	{
		x=(c*e-b*f)/(a*e-b*d);
		y=(a*f-c*d)/(a*e-b*d);
		if(x>-EPS)x=abs(x);
		if(y>-EPS)y=abs(y);
		cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
	}
	return 0;
}

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

int main()
{
    // 入力
    // a,b,cの入力
    int a, b;
    cin >> a >> b;

    cout << a*b ;

    return 0;

}


Measured memory_bytes: 3596
fun main(args: Array<String>) {

    var list = readLine()!!.split(" ").map { it.toInt() }
    val mokuhyo = list[1]

    var numList = readLine()!!.split(" ").map { it.toInt() }
    // group byの戻り値ってなんだろう？ペアリストかな？mutableListじゃないとgroup byできない？
    val groupMap = numList.groupBy { it }
    // LOOK mapのソートってどうなっている？keyソート、valueソート
    // key sort
    //    groupMap.toSortedMap()
    // value sort
    // LOOK ソート処理結果はmutableであっても変数入れ直し必要。3回目くらいなのでOK
    // Maoの値を変更する場合はtoMutableMapしておく toMap().toMutableMap()??
    // atCoderでtoMutableMapが使えないのだが・・・filterなど高級関数で無理やり対応する
    var sortedGroupMap = groupMap.toList().sortedByDescending { it.second.count() }.toMap()

    // Mapのキー数がNになるまで、末尾のオブジェクトをカウントして消去していたけれど、性能的にNGだった
    // キー集合N以降の数値については、全て書き換える必要があって、それをカウントすれば良いだけ
    var result = 0

    // Mapでインデックスな処理はできない、何番目のオブジェクトといったような。なのでリストに変換する
    val sortedGroupList = sortedGroupMap.toList()
    // LOOK rangeで末端がItarableのサイズであれば、untilにすること
    for (i in mokuhyo until sortedGroupMap.size)
        result += sortedGroupList[i].second.count()

    println(result)
//    while (mokuhyo < sortedGroupMap.count()) {
//        // 種類が多いので、変換処理を実施
//        // LOOK Mapの先頭、末尾のオブジェクトって取れる？
//        val last = sortedGroupMap.toList().last()
////        val first = sortedGroupMap.toList().first()
//        result += last.second.count()
//        // LOOK Mapの要素を削除したい
////        sortedGroupMap.remove(last.first)
//        sortedGroupMap = sortedGroupMap.filter { it.key != last.first }
//
//    }
//    println(result)
}

Measured memory_bytes: 113396
#include "bits/stdc++.h"
using namespace std;
int P, Q, A, N;
int DFS(int k, int prev,int p,int q) {
	if (k == N) return 0;
	int sum = 0;
	for (int i = prev; q*i <= A; i++) {
		sum += DFS(k + 1, i, p*i + q, q*i);
		if ((p*i + q)*Q == q*i*P) sum++;
	}
	return sum;
}
int main() {
	while (cin >> P >> Q >> A >> N, P) {
		cout << DFS(0, 1, 0, 1) << endl;
	}

}

Measured memory_bytes: 3088
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            if (n <= 999)
                Console.WriteLine("ABC");
            else
                Console.WriteLine("ABD");
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		Set<String> set = new HashSet<>();
		for(int i=1;i<=n;i++)
		{
			String s=fs.next();
			set.add(s);
		}
		System.out.println(set.size());
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 62388
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a==1&&b==1&&c==1){
		cout<<0;
		return 0;
	}
	if(a==b&&b==c){
		cout<<-1;
		return 0;
	}
	long long count=0,m,n,q;
	while(1){
		if(a%2!=0||b%2!=0||c%2!=0){
			break;
		}
		m=a;
		n=b;
		q=c;
		a=n/2+q/2;
		b=m/2+q/2;
		c=m/2+n/2;
		count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[5], i, sum = 0;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &a[i]);
		if (a[i] < 40){
			a[i] = 40;
		}
		sum += a[i];
	}
	
	printf("%d\n", sum / 5);
	
	return (0);
}

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

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a > b && c > b && a > c)
        cout << "Yes" << endl;
    else if (a < b && c < b && a < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
ll A,B,C,K;
int main(){
	cin >> A >> B >> C >> K;
	ll D[3] = {A,B,C};
	sort(D,D+3);
	for(int i=0;i<K;i++){
		D[2] *= 2;
	}
	cout << D[0] + D[1] + D[2] << endl;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << '\n';
			return 0;
		}
	}
	long long prod = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] <= 1000000000000000000 / prod) {
			// This condition is equivalent to prod * a[i] <= 10^18
			prod *= a[i];
		} else {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << prod << '\n';
	
	return 0;
}


Measured memory_bytes: 3972
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int K = scanner.nextInt();
        if(K<=A){
            System.out.print(K);
        }
        else if(K<=A+B){
            System.out.print(A);
        }
        else{
            System.out.print(A-(K-A-B));
        }

    }
}

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

using namespace std;
int main(){
  int r,c;
  int sum,sum2;
  cin >> r >>c;
  int row[r+1][c+1];
  int r_num, c_num;
  for(r_num=0;r_num<r;r_num++){

    for(c_num=0;c_num<c;c_num++){

      cin >>row[r_num][c_num];
    }
  }


  for(r_num=0;r_num<r;r_num++){
    sum = 0;
    for(c_num=0;c_num<c;c_num++){
      cout <<row[r_num][c_num]<<" ";
      sum += row[r_num][c_num];
    }

    cout<<sum<<endl;
  }
  sum2 = 0;
  for(c_num=0;c_num<c;c_num++){
    sum = 0;
    for(r_num=0;r_num<r;r_num++){
      sum += row[r_num][c_num];
    }

    cout<<sum<<" ";
    sum2 += sum;
  }
  cout <<sum2 <<endl;

}



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

using namespace std;
const int MAXN=3100;
string s, t;
int N, M;
int mat[MAXN][MAXN];
deque<char> ris;
string LCS(){
	s = '?'+s;
	t = '!'+t;
	for(int i=1;i<=M;i++)
		for(int j=1;j<=N;j++){
			if(s[j]==t[i])
				mat[i][j]=mat[i-1][j-1]+1;
			else
				mat[i][j]=max(mat[i-1][j],mat[i][j-1]);
		}
	int i=M, j=N;
	while(mat[i][j]!=0){
		if(mat[i-1][j]==mat[i][j])
			i--;
		else if(mat[i][j-1]==mat[i][j])
			j--;
		else{
			ris.push_front(s[j]);
			i--;
			j--;
		}
	}
	string finale ="";
	for(auto adj : ris)
		finale+=adj;
	return finale;
}

int main(){
	cin>>s>>t;
	N=s.length();
	M=t.length();
	cout<<LCS();
}

Measured memory_bytes: 37120
import math
x = int(input())
res=[x]
for n in range(1000000):
  if len(res)!=1:
    if res.count(res[n])>1:
      break
  if res[n]%2==0:
    res.append(math.floor(res[n]/2))
  else:
    res.append(3*res[n]+1)

print(n+1) 

Measured memory_bytes: 3060
#include <iostream>


using namespace std;

int main()
{
	int h, m, s;
	cin >> s;
	h = s / 3600;
	s %= 3600;
	m = s / 60;
	s %= 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3084
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
a = 0
sum = 0
for i in range(N):
    for j in range(M):
        sum += A[i][j] * B[j]
    if sum + C > 0:
        a += 1
        sum = 0
    else :
        sum = 0
print(a)

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

using namespace std;

const int N = 1e6 + 10;

struct node{
	int l, r, id;
	bool operator < (const node &W) const
	{
		return r < W.r;
	}
}e[N];

int n, q;
int a[N];
int last[N];
int c[N];
int st[N];
int lowbit(int x) {return x &-x;}
int ans[N];

void add(int x, int y)
{
	for (; x <= n; x += lowbit(x))
	c[x] += y;
}

int ask(int x)
{
	int res = 0;
	for (;x; x -= lowbit(x))
	res += c[x];
	return res;
}



int main()
{
	scanf("%d", &n);	scanf("%d", &q);
	for (int i = 1; i <= n; i ++)
	{
		int x;
		scanf("%d", &x);
		a[i] = x;
	}
	for (int i = 1; i <= q; i ++)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		e[i].id = i, e[i].l = l, e[i].r = r;
	}
	sort(e + 1, e + q + 1);
	int cnt = 1;
	for (int i = 1; i <= q; i ++)
	{
		for (int j = cnt; j <= e[i].r; j ++)
		{
			if(last[a[j]])
			{
				add(last[a[j]], -1);
			}
			add(j, 1);
			last[a[j]] = j;
		}
		cnt = e[i].r + 1;
		ans[e[i].id] = ask(e[i].r) - ask(e[i].l - 1);
	 }
	 for (int i = 1; i <= q; i ++)
	  printf("%d\n", ans[i]);
 }

Measured memory_bytes: 17464
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n,k;cin >> n >> k;
    int p[n];rep{
        cin >> p[i];
    }
    int dp[n];rep{
        dp[i] = MOD;
    }
    dp[0] = 0;
    for(int i = 1;i<n;i++){
        for(int j = 1;j<=min(k,i);j++){
            dp[i] = min(dp[i], dp[i-j]+abs(p[i]-p[i-j]));
            //cout << dp[i] << " ";
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;

int n,m,blocked[305],a[305][305],ans=10000000000;

void solve(int cnt){
	if(cnt<=0)return ;
	int fav[305],mx=0;
	for(int i=0;i<=m;i++){
		fav[i]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(!blocked[a[i][j]]){
				fav[a[i][j]]++;
				break;
			}
		}
	}
	for(int i=1;i<=m;i++){
		if(fav[i]>fav[mx] && !blocked[i]){
			mx = i;
		}
	}
	blocked[mx]=1;
	ans = min(ans,fav[mx]);
	solve(cnt-1);
}

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

#ifndef ONLINE_JUDGE
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif


cin >> n >> m;
for(int i=1;i<=n;i++){
	for (int j = 1; j <= m; ++j)
	{
		cin >> a[i][j];
	}
}

solve(m);

cout << ans << endl;


return 0;}
///....


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ret = 0;
    for(int i=0; i<=n; ++i){
        if(s[i] == '0')
            continue;
        int a = atoi(s.substr(0, i).c_str());
        int b = atoi(s.substr(i).c_str());
        if(b - a >= 0 && (a + b) % 2 == 0)
            ++ ret;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1200
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

class edge {
public:
    int from, to;
    ll cost;

    edge(int t, ll c) : from(-1), to(t), cost(c) {}

    edge(int f, int t, ll c) : from(f), to(t), cost(c) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }

    bool operator>(const edge &e) const {
        return cost > e.cost;
    }
};

const int Maxn = 100010;
int color[Maxn];

vector<vector<edge>> g;

void dfs(int v, int p, int c) {
    color[v] = c;
    for (auto &e : g[v]) {
        if (e.to == p) continue;
        if (e.cost % 2 == 0) {
            dfs(e.to, v, c);
        } else {
            dfs(e.to, v, 1 - c);
        }
    }
}

int n;

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
    */
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        ll z;
        cin >> x >> y >> z;
        --x, --y;
        g[x].emplace_back(y, z);
        g[y].emplace_back(x, z);
    }

    dfs(0, -1, 0);
    for (int i = 0; i < n; ++i) {
        cout << color[i] << "\n";
    }
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

const lli mod = 1e9 + 7;
int main()
{
    fastio;
    int n;
    cin>>n;
    vinput(a,n);

    vlli suf(n,0);
    suf[n - 1] = a[n - 1]%mod;

    for(int i = n - 2; i >= 0;i--)suf[i] = (suf[i+1]+a[i])%mod;

    lli ans = 0;

    rep(i,n-1,0)ans=(ans + a[i]*suf[i+1]%mod)%mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 6364
N,K,Q = map(int,(input().split()))
A = []
H = []
for i in range(Q):
  A.append(int(input()))
for i in range(N):
  H.append(0)
for i in A:
  H[i-1] += 1
sumA = sum(H)
for i in range(N):
  if K - sumA + H[i] > 0:
    print("Yes")
  else:
    print("No")
  
  

Measured memory_bytes: 8680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N; //A 1円の枚数  N 払いたい額
  cin >> N >> A;
 
  if (A >= 499) {
    cout << "Yes" << endl;
  }
  
   else if(N%500 <= A){
     cout << "Yes" << endl;
   }
  else{
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 256
import java.util.*;

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

        int K = S.nextInt();
        int X = S.nextInt();

        if(K*500 >= X){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

total_a = sum(a_list)
#約数の列挙
candidates = set()
for i in range(1, total_a):
    if i * i > total_a:
        break
    if total_a % i == 0:
        candidates.add(i)
        candidates.add(total_a // i)

ans = 1
for x in candidates:
    remainders = sorted(map(lambda a: a % x, a_list))
    total_r = sum(remainders)
    border = total_r // x
    need = sum(remainders[:(N - border)])
    if need <= K:
        ans = max(ans, x)
print(ans)


Measured memory_bytes: 42588
//テスト
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;


int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }
      ll sum=0;
      vector<int> last(26);
    //答え入れる配列
     vector<int> ans(d);
    //減少

    for(int i=0;i<d;i++){
        ll nax=-INF;
        ll nax_i;
        rep(j,26){
            ll now_sum=0;
            now_sum+=s[i][j];
            last[j]=i+1;
            ll minus=0;
            rep(k,26){
                if(k!=j)
                    minus+=c[k]*(i+1-last[k]);
            }
            now_sum-=minus;
            if(nax<now_sum){
                nax_i = j;
                nax = now_sum;
            }
        }
        ans[i] = nax_i+1;
        last[nax_i] = i+1;
    }  
    rep(i,d){
        cout << ans[i] << endl;
    }
	return 0;   
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;

int main() {
	
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	set<int> xc, yc;
	xc.insert(x); yc.insert(y);
	for (int i=0; i<n; i++) {
		int ux;
		cin >> ux;
		xc.insert(ux);
	}
	for (int i=0; i<m; i++) {
		int ux;
		cin >> ux;
		yc.insert(ux);
	}
	
	if (*--xc.end() < *yc.begin()) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
	
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
m=10**9+7
s=r=1
for i in range(b):
 r=r*(n-i)*pow(i+1,m-2,m)%m
 if i+1in[a,b]:s+=r
print((pow(2,n,m)-s)%m)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main(){
  char g;
  cin >>g;
  if(g=='A'){cout << 'T' << endl;}
  if(g=='T'){cout << 'A' << endl;}
  if(g=='G'){cout << 'C' << endl;}
  if(g=='C'){cout << 'G' << endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

int K,N;
int A[SIZE];

int main(){

	scanf("%d %d",&K,&N);

	for(int i = 0; i < N; i++){

		scanf("%d",&A[i]);
	}
	sort(A,A+N);

	int ans = K-((K-A[N-1])+A[0]);

	for(int i = 1; i < N; i++){

		ans = min(ans,K-(A[i]-A[i-1]));
	}

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

	return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int K;
  string S;

  cin >> K >> S;
  if (S.length() <= K) cout << S << endl;
  else {
    for (int i = 0; i < K; i++) cout << S[i];
    cout << "..." << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3616
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	// 各桁をとるのにstrconvなんて要らねぇ
	cnt, tmp := 0, 0
	tmp = n
	for 0 < tmp {
		cnt += tmp % 10
		tmp /= 10
	}
	if n%cnt == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int a,p;
    cin>>a>>p;
    int sum=a*3+p;
    cout<<sum/2<<endl;


    return 0;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

const int _n = 1e6 + 10;
vector<int> Fact(_n), Inv(_n);
const int kmod = 1000000007;

int mul(int a, int b, int mod = kmod)
{
    return (long long)a * b % mod;
}

int add(int a, int b, int mod = kmod)
{
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b, int mod = kmod)
{
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int power(int base, int index, int mod = kmod)
{
    if (index == 0)
        return 1;
    int temp = power(base, index / 2, mod);
    temp = mul(temp, temp, mod);
    if (index & 1)
        temp = mul(temp, base, mod);
    return temp;
}

int mod_inv(int x, int mod = kmod)
{
    return power(x, mod - 2, mod);
}

void pre()
{
    Fact[0] = 1;
    for (int i = 1; i < _n; ++i)
        Fact[i] = mul(Fact[i - 1], i);
    Inv[_n - 1] = mod_inv(Fact[_n - 1]);
    for (int i = _n - 2; i >= 0; --i)
        Inv[i] = mul(Inv[i + 1], (1 + i));
}

int ncr(int n, int r)
{
    if (n < 0 || r < 0 || n - r < 0)
        return 0;
    return mul(Fact[n], mul(Inv[r], Inv[n - r]));
}

int npr(int n, int r)
{
    if (n < 0 || r < 0 || n - r < 0)
        return 0;
    return mul(Fact[n], Inv[n - r]);
}

void Solution::solveCase()
{
    pre();
    int n;
    cin >> n;
    int res = 0;
    for (size_t i = 2; i <= n; i++)
    {
        ll temp = mul(sub(power(2, i), 2), ncr(n, i));
        temp = mul(temp, power(8, n - i));
        res = add(res, temp);
    }
    cout << res << '\n';
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 11028
#include<stdio.h>
#include<math.h>
int main(Void){
    double x=0.0,y=0.0;
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    x=pow(x2-x1,2.0);
    y=pow(y2-y1,2.0);
    printf("%f\n",sqrt(x+y));
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    sort(begin(a), end(a));
    long long ans = 0;
    for (int i = 0; i < n; i++) ans += abs(a[i] - a[n / 2]) * 2;
    if (n & 1) ans -= min(a[n / 2 + 1] - a[n / 2], a[n / 2] - a[n / 2 - 1]);
    else ans -= a[n / 2] - a[n / 2 - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
mod = 998244353

class FenwickTree:
    def __init__(self, n, init_list=None):
        self.n = n
        self.data = [0] * n
        if init_list:
            assert n == len(init_list)
            for i in range(n):
                self.add(i, init_list[i])
        
    def add(self, i, val):
        assert 0 <= i < self.n
        i += 1
        while i <= self.n:
            self.data[i - 1] = (val + self.data[i - 1]) % mod
            i += i & -i #LSBを加算して上の層へ
            
    def update(self, i, val):
        self.add(i, val - self.sum(i, i+1))

    def sum(self, l, r): #[l, r)
        assert  0 <= l <= r <= self.n
        if l != 0:
            return (self.sum(0, r) - self.sum(0, l)) % mod
        ret = 0
        while r > 0:
            ret = (ret + self.data[r - 1]) % mod
            r -= r & -r #LSB減算して上の層へ
        return ret

n, k = map(int, input().split())

s = []
for _ in range(k):
    l, r = map(int, input().split())
    s.append((l, r))

ft = FenwickTree(n)
ft.add(0, 1)
for i in range(1, n):
    for l, r in s:
        jl = i - l
        jr = max(i - r, 0)
        if jl < 0:
            continue
        ft.add(i, ft.sum(jr, jl+1) % mod)
print(ft.sum(n-1, n) % mod)

Measured memory_bytes: 71344
n, k, q = map(int,input().split())
a = [int(input()) for _ in range(q)]

points = [k]*n
for i in range(q):
    points[a[i]-1] += 1

for i in range(n):
    if points[i] < q+1:
        print("No")
    else:
        print("Yes")

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

main()
{
    int n, k, a[100000], h[100000], i;
    cin >> n >> k;
    for (i = 0; i < n; i++){cin >> h[i];}
    a[0] = 0;
    for (i = 1; i < n; i++){
        a[i] = a[i-1] + abs(h[i]-h[i-1]);
        if (i <= k){
            for (int j = 0; j<i; j++){
            a[i] = min(a[i], a[j] + abs(h[i]-h[j]));
            }
        }
        else {
            for (int j = i-k; j < i; j++){
            a[i] = min(a[i], a[j] + abs(h[i]-h[j]));
            }
        }
    }
    cout << a[n-1];
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    long long int a,b;
    cin>>a>>b;
    if(a<=(((a*2)+b)/4))
    {
        cout<<((a*2)+b)/4<<endl;
    }
    else
    {
        cout<<b/2<<endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(int argc, char const *argv[]) {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  REP(x, K + 1) {
    REP(y, K + 1) {
      if (x + y <= S&&S-(x+y)<=K) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll x,n; cin >> x >> n;
    vl p(n);
    set<int> s;
    rep(i,n){
        cin>>p[i];
        s.insert(p[i]);
    }
    ll dif = L_INF;
    ll idx = 0;
    for(int i=-200;i<=200;i++){
        if(s.find(i) == s.end()){
            ll num = abs(x-i);
            if(num < dif){
                dif = num;
                idx = i;
            }
        }
    }
    out(idx);
}


Measured memory_bytes: 3668
#include<iostream>
#include<string>
using namespace std;
void dfs(int x, int y);
int d[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int f[14][14]={0};
int main(){
  string s;
  while(cin >>s){
    for(int i=0; i<12; i++){
      if(i>0) cin >>s;
      for(int j=0; j<s.size(); j++) f[j+1][i+1] = s[j]-'0';
    }
    int ans = 0;
    for(int i=1; i<13; i++){
      for(int j=1; j<13; j++){
	if(f[j][i] == 1){
	  ans++;
	  dfs(j,i);
	}
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}
void dfs(int x, int y){
  f[x][y] = 0;
  for(int i=0; i<4; i++) if(f[x+d[i][0]][y+d[i][1]] == 1) dfs(x+d[i][0],y+d[i][1]);
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=300+10;
inline bool chkmax(int &x,int y){return (y>x)?(x=y,1):0;}
char s[maxn];
int dp[maxn][maxn][maxn];
int main(){
	scanf("%s",s+1);
	int m=read(),n=strlen(s+1);
	REP(i,1,n)
		DREP(j,n,i)
			REP(k,0,m){
				dp[i][j][k]=max(dp[i-1][j][k],dp[i][j+1][k]);
				if(s[i]==s[j]) chkmax(dp[i][j][k],dp[i-1][j+1][k]+1);
				else if(k>0) chkmax(dp[i][j][k],dp[i-1][j+1][k-1]+1);
			}
	int ans=0;
	REP(i,1,n){
		chkmax(ans,dp[i][i][m]*2-1);
		REP(j,i+1,n) chkmax(ans,dp[i][j][m]*2);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 114560
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> E_left(N+1,0);
  vector<int> W_left(N+1,0);
  vector<int> E_right(N+1,0);
  vector<int> w_right(N+1,0);

  rep(i,N){
    if(S.at(i) == 'E'){
      E_left.at(i+1) = E_left.at(i) + 1;
    }
    else{
      E_left.at(i+1) = E_left.at(i);
    }
  }

  rep(i,N){
    if(S.at(i) == 'W'){
      W_left.at(i+1) = W_left.at(i) + 1;
    }
    else{
      W_left.at(i+1) = W_left.at(i);
    }
  }

/*
  for(int i = N-1;i >= 0;i--){
    if(S.at(i) == 'W'){
      W_right.at(i+1) = W_right.at(i) + 1;
    }
    else{
      W_right.at(i+1) = W_right.at(i);
    }
  }

  rep(i,N){
    if(S.at(i) == 'W'){
      E_right.at(i+1) = E_right.at(i) + 1;
    }
    else{
      E_right.at(i+1) = E_right.at(i);
    }
  }
*/
  int sum = MOD;
  for(int i = 0;i < N;i++){
    if(S.at(i) == 'E'){
      if(sum > W_left.at(i) + E_left.at(N) - E_left.at(i+1)){
        sum = W_left.at(i) + E_left.at(N) - E_left.at(i+1);
      }
    }
    else{
      if(sum > W_left.at(i) + E_left.at(N) - E_left.at(i+1)){
        sum = W_left.at(i) + E_left.at(N) - E_left.at(i+1);
      }
    }
  }

  cout << sum <<endl;
  /*
  rep(i,N+1){
    cout << W_left.at(i)<<endl;
  }
  */



}


Measured memory_bytes: 5380
N = int(input())
b = list(map(int, input().split()))

ans = []
for i in range(N):
    f = False
    for j in range(N - i - 1, -1, -1):
        if b[j] == j + 1:
            ans.append(b.pop(j))
            f = True
            break
    if not f:
        print(-1)
        break
else:
    for a in reversed(ans):
        print(a)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n;
int c[600],s[600],f[600];
int t[600];
signed main(){
    cin>>n;
    rep(i,n-1){
        cin>>c[i]>>s[i]>>f[i];
        t[i]=s[i];
    }
    rep(i,n-1){
        rep(j,n-i-1){
            t[i]=max(t[i],s[j+i]);
            if(t[i]%f[j+i])t[i]+=f[j+i]-(t[i]%f[j+i]);
            t[i]+=c[i+j];
        }
    }
    rep(i,n){
        cout<<t[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327
#define NUM 1000000007
#define ss second
#define ff first
using namespace std;
int a, p;
int main(){
	ios::sync_with_stdio(0);
	cin >> a >> p;
	cout << (a * 3 + p )/ 2 <<"\n";
	return 0;
}


Measured memory_bytes: 256