akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')'<<' ';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define OUTP(x) cout<<'('<<x.first<<','<<x.second<<')'<<endl;
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),ALL(b));}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

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

const ll MOD=1e9+7;
const ll MAX=5e6;

int main() {
  int N;cin>>N;
  vector<ll> AS(N);
  vector<ll> sumAS(N+1,0);
  REP(i,N) cin>>AS[i];
  REP(i,N) sumAS[i+1] = sumAS[i]+AS[i];
  ll ans = 0;
  map<ll,ll> mp;
  REP(i,N+1) {
    ans += mp[sumAS[i]];
    mp[sumAS[i]]++;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <queue>

using namespace std;

struct process
{
	char name[11];
	int time;
};

void simulate(queue<process> processes, int n, int quantum)
{
	int elapsed_time = 0;
	while (!processes.empty())
	{
		process current_process = processes.front(); processes.pop();
		if (current_process.time - quantum <= 0) {
			elapsed_time += current_process.time;
			cout << current_process.name << ' ' << elapsed_time << '\n';
		}
		else {
			current_process.time -= quantum;
			elapsed_time += quantum;
			processes.push(current_process);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);

	int n, quantum;
	queue<process> processes;
	cin >> n >> quantum;
	for (int i = 0; i < n; i++) {
		process input;
		cin >> input.name >> input.time;
		processes.push(input);
	}

	simulate(processes, n, quantum);
	return 0;
}

Measured memory_bytes: 2848
import java.util.*;

public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if ((a*b)%2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
		sc.close();
	}

}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int judge(int num)
{
    for (int i = 2; i * i <= num; i++)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int q;
    cin >> q;
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }
    vector<int> sums(500001, 0);
    vector<int> tt(500001, 0);
    for (int i = 3; i < 500000; i += 2)
    {
        sums[i] = judge(i);
    }
    sums[2] = 1;
    for (int i = 3; i < 500000; i += 2)
    {
        if (sums[i] == 0)
        {
            continue;
        }
        if (sums[(i + 1) / 2] == 1)
        {
            tt[i] = 1;
        }
    }
    for (int i = 0; i < 500000; i++)
    {
        tt[i + 1] += tt[i];
    }
    for (int i = 0; i < q; i++)
    {
        cout << tt[r[i]] - tt[l[i] - 1] << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 7996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  
  cin >> a >> b >> c >> d;
 
  if (a + b > c + d)
  {
    cout << "Left" << endl;
  }
  else if (a + b == c + d)
  {
    cout << "Balanced" << endl;
  }
  else
  {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int a,b;
    cin >> a >> b;
    int n[9];
    if(a>=b) {
        for(int i=0;i<a;++i) {
            n[i]=b;
            cout << n[i];
        }
    }
    else {
        for(int i=0;i<b;++i) {
            n[i]=a;
            cout << n[i];
        }
    }
}



Measured memory_bytes: 256
mod=10**9+7
n=int(input())
alist=list(map(int, input().split()))
suma=sum(alist)%mod
num=0
for i in range(n):
  num+=alist[i]**2
  num=num%mod
ans=(suma**2-num)%mod
if ans%2==0:
  print(ans//2)
else:
  print((ans+mod)//2)

Measured memory_bytes: 31672
function main()
  
  (H,W) = map(x -> parse(Int,x), split(readline()))
  
  S = ["" for i in 1:H, j in 1:W]
  
  for i in 1:H
    S[i,:] = split(chomp(readline())," ")
  end
  
  for i in 1:H, j in 1:W
    
    if S[i,j] == "snuke"
      println('A'+j-1,i)
      break
    end
    
  end
  
end

main()

Measured memory_bytes: 116792
#include<iostream>
#include<iomanip>
#include<queue>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<deque>
#include<algorithm>
#include<algorithm>
#include<stdint.h>
#include<cmath>
#include<set>
#include<stack>
#include<cstdlib>
#include<vector>
#include<cstring>
#include<ctime>
#include<map>
using namespace std;
long long a[100005],d[100005];
int main()
{
	int n,i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%lld",a+i);
	for (i=n;i;i--) d[i]=d[i+1]+abs(a[i]-a[i+1]);
	long long s=0;
	for (i=1;i<=n;i++)
	{
		cout<<s+d[i+1]+abs(a[i-1]-a[i+1])<<endl;
		s+=abs(a[i]-a[i-1]);
	}
	return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {



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

		 //T????????¬??????????????°
		 int T = scan.nextInt();

		//mai????????¬?????????1??????????????????????????°
		 int  mai = 9;

		//1??????????????????????´???§????????????????¢????
		 int hand_no[] = new int[mai];
		 String hand_mark[] = new String[mai];

		 //????????°???????????????
		 int ans = 0;

		 //?????¬??????????????°?????????????????¶?????????
		 for(int end_cnt = 0; end_cnt < T; end_cnt++){

			 //1???????????????????????????????´?
			 for(int  no_mark = 0; no_mark < 2; no_mark++){

				 for(int now1 = 0; now1 < mai; now1++){

					 //1??±?????????????????????2??±?????????????????????????????\??????
					 if(no_mark == 0){
						 hand_no[now1] = scan.nextInt();
					 }else{
						 hand_mark[now1] = scan.next();
					 }

				 }
			 }
			 
			 //???????????´???
			 for(int x = 0; x < mai; x++){
				 
		      for(int y = 0; y < mai - 1; y++){
		        	
		          if(hand_no[y] > hand_no[y + 1]){
		        	  
		            int temp = hand_no[y];
		            hand_no[y] = hand_no[y + 1];
		            hand_no[y + 1] = temp;
		            
		            String temp2 = hand_mark[y];
		            hand_mark[y] = hand_mark[y + 1];
		            hand_mark[y + 1] = temp2;
		            
		          }
		        }
			 }
			 
			 /*
			 for(int i = 0; i < mai ; i++){
				 System.out.print(hand_no[i]);
			 }
			 System.out.println();
			 for(int j = 0; j < mai ; j++){
				 System.out.print(hand_mark[j]);
			 }
			 System.out.println();
			 */
			 
			 for(int i = 0; i < mai - 2; i++){
				 
				 for(int j = i + 1; j < mai - 1; j++){
					 
					 for(int k = j + 1; k < mai; k++){

						 //???????????§?????????
						 if(hand_mark[i].equals(hand_mark[j]) && hand_mark[j].equals(hand_mark[k])){
										 
							 //??????????????£????????????
							 if(hand_no[i] + 1 == hand_no[j]  && hand_no[j] + 1 == hand_no[k]){
								 if(hand_no[i] != 0 ){
									 ans++;
									 hand_no[i] = 0;
									 hand_no[j] = 0;
									 hand_no[k] = 0;
								 }
							 }
							 
							 //??¨?????????????´???§?????????
							 if(hand_no[i] == hand_no[j] && hand_no[j]  == hand_no[k]){
									 if(hand_no[i] != 0 ){
										 ans++;
										 hand_no[i] = 0;
										 hand_no[j] = 0;
										 hand_no[k] = 0;
									 }
								 }
						}
					}
				 }
			 }
			
				 
				 //3?????????????????£???????????°???1??????????????????
				 if(ans == 3){
					 System.out.println("1");
				 }else{
					 System.out.println("0");
				 }
				//????????°???????????????????????????
				 ans = 0;

		 }
		scan.close();

	 }
}

Measured memory_bytes: 29348
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n, k;
llong a[200005];
llong f[200005];

bool check(llong k, llong t) {
    for (int i = 0; i < n; i++) {
        if (a[i] * f[i] > t) {
            k -= (a[i] * f[i] - t + f[i] - 1) / f[i];
        }
    }

    return k >= 0;
}

int main() {

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> f[i];
    }

    sort(a, a + n);
    sort(f, f + n, greater<>());

    llong valid = 1ll << 60ll;
    llong invalid = -1;

    while (valid - invalid > 1) {
        llong mid = (valid + invalid) / 2;

        if (check(k, mid)) {
            valid = mid;
        }
        else {
            invalid = mid;
        }
    }

    cout << valid;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string S;
	cin >> S;
	if (S == "keyence")
	{
		cout << "YES" << endl;
	}
	else
	{
		string temp = "";
		for (int i = 0; i < 7; ++i)
		{
			temp += S[i];
		}
		if (temp == "keyence")
		{
			cout << "YES" << endl;
			return;
		}
		temp.clear();
		for (int i = S.size() - 7; i < S.size(); ++i)
		{
			temp += S[i];
		}
		if (temp == "keyence")
		{
			cout << "YES" << endl;
			return;
		}
		temp.clear();
		string ans = "keyence";
		int pos = 0;
		int cnt = 0;
		while (true)
		{
			if (S[pos] == ans[pos])
			{
				++cnt;
			}
			else
			{
				break;
			}
			++pos;
		}
		pos = S.size() - 1;
		int ansPos = 6;
		while(true)
		{
			if (S[pos] == ans[ansPos])
			{
				++cnt;
				if (cnt == 7)
				{
					cout << "YES" << endl;
					return;
				}
			}
			else
			{
				break;
			}
			--pos;
			--ansPos;
		}
		cout << "NO" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#define _ITERATOR_DEBUG_LEVEL 1


#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 n, i, j, k, x, y, ss;
	cin >> n;
	vector<int> a(n + 2), s(n + 2), ans(n + 1);
	vector<pair<int, int>> aa(n);
	a[0] = 0;
	for (i = 1; i <= n; i++) cin >> a[i];
	a[n + 1] = 0;

	ss = 0;
	for (i = 1; i <= n + 1; i++) {
		s[i] = abs(a[i] - a[i - 1]);
		ss += s[i];
	}

	for (i = 1; i <= n; i++) {
		ans[i] = ss - s[i] - s[i + 1] + abs(a[i + 1] - a[i - 1]);
	}

	for (i = 1; i <= n; i++) cout << ans[i] << "\n";

	return 0;
}


Measured memory_bytes: 3200
N = int(input())
H = list(map(int, input().split()))

s = 'Yes'

H[0] -= 1
for i in range(1, N):
    if H[i] > H[i-1]:
        H[i] -= 1
    
for i in range(1, N):
    if H[i] < H[i-1]:
        s = 'No'
        break

print(s)

Measured memory_bytes: 14396
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int A[3];
	int a[3]={0};
	cin>>A[0]>>A[1]>>A[2];
	a[0]=fabs(A[1]-A[0]);
	a[1]=fabs(A[2]-A[0]);
	a[2]=fabs(A[2]-A[1]);
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<2-i;j++)
		{
			int temp;
			if(a[j]<a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	int sum=0+a[1]+a[2];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  int res = 0;
  while (n--) {
    int h; cin >> h;
    res += h >= k;
  }
  cout << res << '\n';
}

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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int t[] = new int[n + 1];
		int x[] = new int[n + 1];
		int y[] = new int[n + 1];

		t[0] = 0;
		x[0] = 0;
		y[0] = 0;

		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");
			t[i + 1] = Integer.parseInt(str[0]);
			x[i + 1] = Integer.parseInt(str[1]);
			y[i + 1] = Integer.parseInt(str[2]);
		}
		for (int i = 0; i < n; i++) {
			int dt = t[i + 1] - t[i];
			int dist = Math.abs(x[i + 1] - x[i]) + Math.abs(y[i + 1] - y[i]);
			if (dt < dist || dt % 2 != dist % 2) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 43384
#include <atcoder/segtree>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  atcoder::segtree<int, op, e> seg(300001);

  int answer = 0;
  rep(i, N) {
    int A;
    cin >> A;
    int minA = max(0, A - K);
    int maxA = min(300000, A + K);
    int maxLen = seg.prod(minA, maxA + 1) + 1;
    answer = max(answer, maxLen);
    seg.set(A, maxLen);
  }
  cout << answer << endl;
  return 0;
}


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

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rnd(time(0));
#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("avia.in", "r", stdin); freopen("avia.out", "w", stdout);
#define _GLIBCXX_DEBUG
//#define s second
//#define f first
#define pb push_back
#define add insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define res resize
#define NO cout<<"NO"<<'\n'; return;
#define YES cout<<"YES"<<'\n'; return;
#define PI acos(-1)
#define gggg cout << "NO";return;
const ll INF = 1e9;//9223372036854775807L; //LONG_MAX;
constexpr ll mod = 1e9 + 7;


void solve() {
    int a, b, c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<'\n';
    }else{
        cout<<"win"<<'\n';
    }
}

signed main() {
    ioss
    //file
    //id.resize(3e5);
    int t = 1;                                                                                                                                                                        //ll
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  cin >> N;
  //

  long long L[100];
  L[0] = 2;
  L[1] = 1;
  
  rep(i, N-1){
    L[i+2] = L[i+1]+L[i];
  }

  cout << L[N] << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, M, K; cin >> N >> M >> K;
    bool result = false;
    for (int n = 0; n <= N; n++) {
        for (int m = 0; m <= M; m++) {
            if (n * M + m * N - 2 * n * m == K) {
                result = true;
            }
        }
    }
    cout << (result ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H,W;
    while (true){
        cin >> H >> W;
        if (H == 0 && W == 0){
            break;
        }
        for(int j = 0; j < W; j++){
            cout << '#';
        }
        cout << endl;
        for(int i = 1; i < H-1; i++){
            cout << '#';
            for(int j = 1; j < W-1; j++){
            cout << '.';
        }
        cout << '#' << endl;
        }
        for(int j = 0; j < W; j++){
            cout << '#';
        }
        cout << endl << endl;
    }
}



Measured memory_bytes: 3092
s = input()
s_len = len(s)
if s_len == 1:
    print(0)
else:
    dum1 = s[0::2].count("0")
    dum2 = s[1::2].count("1")
    ans1 = s_len-dum1-dum2

    dum3 = s[0::2].count("1")
    dum4 = s[1::2].count("0")
    ans2 = s_len-dum3-dum4
    print(min(ans1,ans2))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 100005;

int N;
int A[SIZE];

int main (){
	
	int odd=0, even=0;
	
	scanf("%d", &N);
	for(int i=0;i<N;i++){
		scanf("%d", &A[i]);
		if(A[i]%2==0) even++;
		else odd++;
	}
	if(odd%2==0){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 640
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }


void main(){
	long n = read.to!long;
	long[] as = readln.split.map!(to!long).array;
	
	long sum = as.reduce!"a + b"();
	
	long ans = long.max;
	long s;
	foreach(i, a; as){
		if(i == as.length - 1) continue;
		s += a;
		long x = abs(s - (sum - s));
		if(x < ans) ans = x;
		}
	
	ans.writeln;
	}

Measured memory_bytes: 11264
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if((n>1&&b>=a)||(n==1&&a==b))
    {
        cout<<(n-2)*(b-a)+1<<endl;
    }    
    else
    {
        cout<<0<<endl; 
    }
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool func(string s) {
  for(int i = 0;i < s.size() / 2;i++) {
    if(s.at(i) != s.at(i + s.size() / 2)) {
      return false;
    }
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  while(true) {
    s.pop_back();
    s.pop_back();
    if(func(s)) {
      cout << s.size() << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<ll> pq;
  for(int i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    pq.push(tmp);
  }
  for(int i = 0; i < m; i++){
    ll tmp = pq.top();
    pq.pop();
    tmp /= 2;
    pq.push(tmp);
  }
  ll sum = 0;
  while(!pq.empty()){
    sum += pq.top();
    pq.pop();
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 200000000
#define MOD 1000000007

using namespace std;

int main()
{
    long long int a, b, x;
    cin >> a >> b >> x;
    if (a > 0 && b > 0)
    {
        cout << ((b / x) + 1) - (((a - 1) / x) + 1) << endl;
    }
    else if (a == 0)
    {
        cout << ((b / x) + 1) << endl;
    }

    return 0;
}


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

int main(){
	int a,b;
	int line =0;
	while(++line){
		cin >> a >> b;
		if(a==0 && b==0) break;
		int count=0;
		if(line > 1) cout << "\n";
		for(int i=a; i <= b; i++){
			if((i % 4==0 && i % 100 !=0) || i % 400 ==0){
				cout << i << "\n";
				count++;
			} 
		}
		if(count ==0) cout << "NA\n";
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
string a="snuke",b="ABCDEFGHIJKLMNOPQRSTUVWXYZ",c;
int n,m;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    for(int j=0;j<m;j++){
        cin>>c;
        if(c==a){cout<<b[j]<<i<<endl;return 0;}
    }
}

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

int main() {
    long long a, b, n;
    scanf("%lld%lld%lld", &a, &b, &n);// don't forget &
    long long ans = 0;
    if (b != 0) {
        long long k = min(n, b - 1);
        ans = a * k / b;
    }
    printf("%lld", ans);
    return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int ans=pinf;
int s=0;

void solve(int s1,int i,vector <int> a,int n)
{
    if(max(s1,s-s1)<ans)
    {
        ans=max(s1,s-s1);
    }
    if(i==n)
        return;
    solve(s1+a[i],i+1,a,n);
    solve(s1,i+1,a,n);
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n;
    cin>>n;

    vector <int> a(n);
    loop(i,0,n)
    {
        cin>>a[i];
    }
    int ans=0;

    bool f=0;
    int p=1;
    loop(i,0,n)
    {
        if(a[i]==p)
        {
            f=1;
            p++;
        }
        else
        {
            ans++;
        }
    }
    if(f==0)
    {
        cout<< "-1";
        return 0;
    }

    cout<<ans;




    return 0;
}


Measured memory_bytes: 4784
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
    for h in range(H):
        for w in range(W):
            if h == 0 or h == H - 1 or w == 0 or w == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 9060
program answer
  implicit none
  integer(8) :: K, i
  character(len=15) :: S
  read(*,*) K
  do i = 1, K
     S(3*i-2:3*i-2)='A'
     S(3*i-1:3*i-1)='C'
     S(3*i:3*i)='L'
  end do
  write(*,*) S(1:3*K)
  stop
 end program answer

Measured memory_bytes: 2796
s = input()
t = input()
n = len(s)
p = [-1] * 26
q = [-1] * 26
b = True
for i in range(n):
    v = ord(s[i]) - ord('a')
    w = ord(t[i]) - ord('a')
    if p[v] != w:
        if p[v] == -1:p[v] = w
        else :b = False
    if q[w] != v:
        if q[w] == -1:q[w] = v
        else :b = False

if b == True:
    print("Yes")
else:
    print("No")

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

namespace myApp
{
    class Program
    {
        // 制約
        const long MAX = 100000;

        // 荷物の重さ
        static long[] baggageWeight = new long[MAX];

        static long baggageCount = 0;
        static long truckCount = 0;

        // 最大積載量Pのk台のトラックで何個の荷物を積めるか
        static long Check(long P) {
            long count = 0;
            for (int i = 0; i < truckCount; i++) {
                long s = 0;
                while (s + baggageWeight[count] <= P) {
                    s += baggageWeight[count];
                    count++;
                    if (count == baggageCount) { return baggageCount; }
                }
            }

            // すべての荷物を積めてない
            return count;
        }

        // 二分探索
        static long Solve() {
            long left = 0;
            // 最大積載量Pの最大値は最大の荷物の個数×1個あたりの最大重量
            long right = 100000 * 10000;

            while (right - left > 1) {
                var mid = (left + right) / 2;
                long v = Check(mid);
                if (v >= baggageCount) {
                    // 荷物を積めることができた最大積載量Pをrightに入れる
                    right = mid;
                } else {
                    // baggageCOunt未満は荷物を積めなかった
                    left = mid;
                }
            }

            return right;
        }

        static void Main(string[] args)
        {
            // 入力
            var line = Console.ReadLine().Split(' ');
            baggageCount = int.Parse(line[0]);
            truckCount = int.Parse(line[1]);
            for (int i = 0; i < baggageCount; i++) {
                baggageWeight[i] = int.Parse(Console.ReadLine());
            }

            // 処理
            long ans = Solve();

            // 出力
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 20852
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int[] W = IntStream.generate(s::nextInt).limit(N).toArray();

			int tmp = 0;
			for (int i = 0; i < N; i++) {
				tmp += W[i];
			}
			final int sum = tmp;

			int si = 0;
			int pre = Integer.MAX_VALUE;
			for (int i = 0; i < N; i++) {
				si += W[i];
				int cur = Math.abs(sum - si * 2);
				if (cur > pre) {
					System.out.println(pre);
					break;
				} else {
					pre = cur;
				}
			}
		}
	}
}


Measured memory_bytes: 27988
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

ll sum1[100010];
ll sum2[100010];

int main(){
  int N; cin >> N;
  priority_queue<ll, vector<ll>, greater<ll>> que1;
  priority_queue<ll> que2;
  rep(i,N){
    int a; cin >> a;
    que1.push(a);
    sum1[0]+=a;
  }
  vector<int> center(N);
  rep(i,N){
    cin >> center[i];
  }
  rep(i,N){
    int a; cin >> a;
    que2.push(a);
    sum2[N]+=a;
  }
  rep(i,N){
    que1.push(center[i]);
    sum1[i+1]=sum1[i]+center[i]-que1.top();
    que1.pop();
  }
  for(int i=N-1;i>=0;i--){
    que2.push(center[i]);
    sum2[i]=sum2[i+1]+center[i]-que2.top();
    que2.pop();
  }
  ll ans=sum1[N]-sum2[N];
  rep(i,N){
    if(sum1[i]-sum2[i]>ans) ans=sum1[i]-sum2[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3956
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll w, h;
    cin >> w >> h;
    vl p(w);
    for (int i = 0; i < w; ++i) {
        cin >> p[i];
    }
    vl q(h);
    for (int i = 0; i < h; ++i) {
        cin >> q[i];
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    ll ret = 0;
    for (int i = 0; i < w; ++i) {
        ret += p[i];
    }
    for (int i = 0; i < h; ++i) {
        ret += q[i];
    }
    for (int i = 0; i < w; ++i) {
        ret += p[i] * ll(q.end() - upper_bound(q.begin(), q.end(), p[i]));
    }
    for (int i = 0; i < h; ++i) {
        ret += q[i] * ll(p.end() - lower_bound(p.begin(), p.end(), q[i]));
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1792
N = gets.chomp.to_i
abc = []
N.times do
  abc << gets.chomp.split(" ").map(&:to_i)
end

dp = { 0 => {}, 1 => {}, 2 => {} }
0.upto(2) {|j| dp[j][-1] = 0 }

0.upto(N-1) do |i|
  dp[0][i] = [dp[1][i-1], dp[2][i-1]].max + abc[i][0]
  dp[1][i] = [dp[0][i-1], dp[2][i-1]].max + abc[i][1]
  dp[2][i] = [dp[0][i-1], dp[1][i-1]].max + abc[i][2]
end

puts [dp[0][N-1], dp[1][N-1], dp[2][N-1]].max


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};


template<typename T>
struct SegmentTree{
  using F = function<T(T, T)>;
  Int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){}
  SegmentTree(F f, T ti):f(f), ti(ti){}

  void init(Int n_){
    n = 1;
    while(n < n_) n<<= 1;
    dat.assign(n<<1, ti);
  }

  void build(const vector<T> &v){
    Int n_ = v.size();
    init(n_);
    for(Int i=0;i<n_;i++) dat[n+i] = v[i];
    for(Int i=n-1;i;i--)
      dat[i] = f(dat[(i<<1)|0], dat[(i<<1)|1]);
  }

  void set_val(Int k, T x){
    dat[k+=n] = x;
    while(k>>=1)
      dat[k] = f(dat[(k<<1) | 0], dat[(k<<1) | 1]);
  }

  T query(Int a,Int b){
    T vl = ti, vr = ti;
    for(Int l=a + n, r = b + n; l<r ; l>>=1, r>>=1){
      if(l&1) vl = f(vl, dat[l++]);
      if(r&1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
    

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


  Int n,k;
  cin>>n>>k;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i],as[i]--;

  Int ans=1;
  for(Int i=0;i<n;i++){
    if(i>as[i]) continue;
    auto f=[](Int a,Int b){return max(a,b);};   
    SegmentTree<Int> seg(f,-n);
    seg.build(vector<Int>(n,-n));
    seg.set_val(as[i],1);
    for(Int j=i+1;j<as[i];j++){
      if(j>as[j]) continue;
      if(as[j]<as[i]) continue;      
      Int res=seg.query(0,as[j]);
      seg.set_val(as[j],res+1);
      //cout<<i<<" "<<j<<":"<<res+1<<endl;
      chmax(ans,res+1);
    }
  }
  
  ans+=k;
  chmin(ans,n/2);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3412
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll a,p;
    std::cin >> a>>p;
    std::cout << (a*3+p)/2 << std::endl;
}


Measured memory_bytes: 256
using namespace std;
#include <iostream>
//#include <algorithm>
//#include <string>
#include <vector>
//#include <deque>

int main()
{
	int n, q;
	cin >> n >> q;
	vector<int> A[1000];  // A[n] とするとエラー

	int a0, a1, a2;

	for (int i = 0; i < q; i++) {
		cin >> a0 >> a1;

		switch (a0) {
		case 0:
			cin >> a2;
			A[a1].push_back(a2);
			break;

		case 1:
			for (int i = 0; i < A[a1].size(); i++) {
				cout << A[a1][i];
				if (i != A[a1].size() - 1) cout << " ";
			}
			cout << endl;
			break;

		case 2:
			A[a1].clear();
			break;
		}
	}
}



Measured memory_bytes: 5920
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1 &&  b == 2)cout << 3 << endl;
	if (a == 1 && b == 3)cout << 2 << endl;
	if (a == 2 && b == 1)cout << 3 << endl;
	if (a == 2 && b == 3)cout << 1 << endl;
	if (a == 3 && b == 1)cout << 2 << endl;
	if (a == 3 && b == 2)cout << 1 << endl;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

vvll memo;
vll a;
vll cans;

ll f(ll l, ll r) {
    if (memo[l][r] != 0) return memo[l][r];
    if (l==r) return 0;
    ll tmp = HIGHINF;
    rep(i, l, r) chmin(tmp, f(l,i)+f(i+1,r));
    return memo[l][r] = tmp + (cans[r+1]-cans[l]);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    a.resize(n); REP(i, n) cin >> a[i];
    cans.resize(n+1, 0);
    REP(i, n) cans[i+1] = cans[i] + a[i];
    memo.resize(n+1, vll(n+1, 0));
    cout << f(0, n-1) << '\n';
    return 0;
}


Measured memory_bytes: 1536
n,*h=map(int,open(0).read().split())
h=list(h)
c=list(map(int,'0'*n))
for i in range(n):
  if i==1:
    c[i]=c[i-1]+abs(h[i]-h[i-1])
  elif i>1:
    k=c[i-1]+abs(h[i]-h[i-1])
    l=c[i-2]+abs(h[i]-h[i-2])
    c[i]=min(k,l)
print(c[-1])

Measured memory_bytes: 13876
#include <stdio.h>

int main()
{
	long long N;
	int X, M;
	scanf("%lld %d %d", &N, &X, &M);
	
	int j, flag[100001] = {};
	long long i, A[100001], sum[100001] = {0, X};
	for (i = 1, A[1] = X, flag[X] = 1; i < N && flag[A[i] * A[i] % M] == 0; i++) {
		A[i+1] = A[i] * A[i] % M;
		flag[A[i+1]] = i + 1;
		sum[i+1] = sum[i] + A[i+1];
	}
	if (i >= N) printf("%lld\n", sum[i]);
	else {
		j = flag[A[i] * A[i] % M];
		printf("%lld\n", (sum[i] - sum[j-1]) * ((N - j + 1) / (i + 1 - j)) + sum[(N-j+1)%(i+1-j)+j-1]);
	}
	fflush(stdout);
	return 0;
}

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

int n;
void solve() {
	cin >> n;
	int a[n][n];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) cin >> a[i][j];
	}
	const int MOD = 1e9 + 7;
	int dp[n][1 << n];
	for (int mask = 0; mask < (1 << n); mask++) 
		dp[0][mask] = 0;
	for (int j = 0; j < n; j++) 
		dp[0][1 << j] = a[0][j];
	for (int i = 1; i < n; i++) {
		for (int mask = 0; mask < (1 << n); mask++) {
			dp[i][mask] = 0;
			if (__builtin_popcount(mask) != i + 1) {
				dp[i][mask] = dp[i - 1][mask];
			}
			else
				for (int k = 0; k < n; k++) if ((mask >> k) & 1) {
					if (a[i][k]) {
//						cerr << "(" << i << "," << mask << ") from (" << i - 1 << "," << (mask ^ (1 << k)) << ")\n"; 
						dp[i][mask] += dp[i - 1][mask ^ (1 << k)],
						dp[i][mask] %= MOD;
					}
				}
//			cout << "dp[" << i << "][" << mask << "] = " << dp[i][mask] << "\n";
		}
	}
	cout << dp[n - 1][(1 << n) - 1];
}

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

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

using namespace std;
using ll = long long;
const int MOD = 1e9+7;

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

int main(){
    int n;
    while (cin >> n) {
        if(n == 0)return 0;
        vector<pair<int,int>> pos;
        pos.push_back({0,0});
        for(int i = 0;i < n-1;i++){
            int b,c;cin >> b >> c;
           // b--;
            pos.push_back({pos.at(b).first + dx[c], pos.at(b).second + dy[c]});
        }
        int xma = -1e9,yma = -1e9;
        int xmi = 1e9, ymi = 1e9;
        for(int i = 0;i < n;i++){
            xma = max(xma, pos.at(i).first);
            xmi = min(xmi, pos.at(i).first);
            yma = max(yma, pos.at(i).second);
            ymi = min(ymi, pos.at(i).second);
        }
        cout<<xma-xmi+1<<" "<<yma-ymi+1<<endl;
    }
}



Measured memory_bytes: 3000
//KnapSack 1

#include<bits/stdc++.h>

#define X real()
#define Y imag()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define FastF freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
#define Fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)
using ll = long long;
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vi::iterator vii;
typedef vector<ll> vl;
typedef vl::iterator vli;
typedef long double C;
typedef complex<C> P;
const int INF = 1e9 + 5;
const ll INFF = 1e18L + 5;
const int M = 1e9 + 7;
const double pi = acos(-1);

int main()
{
	//FastF;
	//Fast;

    int N, W; cin >> N >> W;
    vi weights(N + 1);
    vi profits(N + 1);
    int sum_profit = 0;
    for(int i = 1; i <= N; ++i){
        cin >> weights[i] >> profits[i];
        sum_profit += profits[i];
    }
    vl dp(sum_profit + 1, INFF);
    dp[0] = 0;
    for(int i = 1; i <= N; ++i){
        for(int j = sum_profit; j >= profits[i]; --j)
            dp[j] = min(dp[j], dp[j - profits[i]] + weights[i]);
    }
    int idx = 0;
    for(int i = 1; i <= sum_profit; ++i){
        if(dp[i] <= W) idx = i;
    }
    cout << idx << '\n';
	return 0;
}


Measured memory_bytes: 1024
#ABC176 #F 問題 (Question F) #解説方針 #提出参考
N = int(input())
A = list(map(int, input().split()))

#DP(動的計画法)用配列
ans = [[-N] * (N+1) for _ in range(N+1)]
#初期化 (Initialization)
a0, a1 = A[:2]
ans[a0][a1] = 0
ans[a1][a0] = 0

##最大値の管理
#ans[i] の最大値を集めた配列 (0 <= i <= N)
ma = [-N] * (N+1) 
#ans の初期化に合わせて初期化
ma[a0] = 0
ma[a1] = 0
#ansの全要素の最大値、0で初期化
all_max = 0

#3, 4, 5番目の数が等しいときに加算するための変数
add = 0

#DP部分 多分 O(N ** 2)
for i in range(N - 1): 
    #3, 4, 5番目の数を a, b, c とする
    a, b, c = A[3 * i + 2], A[3 * i + 3], A[3 * i + 4]
    #3つとも等しいとき、最後の三枚を消す
    if a == b == c:
        add += 1
        continue
    Q = []
    for _ in range(3):
        a, b, c = b, c, a
        # a, b, c から残す数を2つ選ぶ
        # ans[c][c] + 1 は [c,c,a,b,c]を想定
        # all_max は DP[i][k][l]の最大値で最大化するときに対応
        Q.append((a, b, max(all_max, ans[c][c] + 1)))
        
        # a, b, c から残す数を1つ選ぶ
        for j in range(1, N + 1):
            #これまでのDP[i][k][l] (k, lのうち片方の変数として見たとき) の最大値
            val = ma[j]
            #2つの数が等しいとき
            if b == c:
                val = max(val, ans[b][j] + 1)
            Q.append((a, j, val))
            
        #配列を使いまわしているので、DP[i + 1][k][l] を DP[i][k][l]で最大化し直す必要なし
        #もしDP[i][k][l]が最大なら、maxを取る過程でこれが残る
    for i, j, val in Q:
        #DP配列の更新
        ans[i][j] = max(ans[i][j], val)
        ans[j][i] = max(ans[j][i], val)
        #最大値の管理
        ma[i] = max(ma[i], val)
        ma[j] = max(ma[j], val)
        all_max = max(all_max, val)
        
#ans の中から最大の値を見つけ出す。O(N ** 2)        
answer = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        #最後に残った3枚が同じならもう1点加算
        if i == j == A[-1]:
            answer = max(answer, ans[i][j] + 1)
        else:
            answer = max(answer, ans[i][j])
            
print(answer + add)



Measured memory_bytes: 189664
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll pow_kai(int a, int n)
{ //aのn乗を計算します。
	ll x = 1;
	while (n > 0)
	{ //全てのbitが捨てられるまで。
		if (n & 1)
		{ //1番右のbitが1のとき。
			x = (x * a) % MOD;
		}
		a = (a * a) % MOD;
		n >>= 1; //bit全体を右に1つシフトして一番右を捨てる。
	}
	return x % MOD;
}

int main()
{
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++){
		for (int k = 0; k <= n; k++){
			int r = n - i - k;
			if(r < 0){
				break;
			}
			if(y == 1000*i + 5000*k + 10000*r){
				cout << r << " " << k << " " << i << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;

const int mod = 1e9 + 7;

int add(int i, int j) {
  if((i += j) >= mod) i -= mod;
  return i;
}

int mult(int i, int j) {
  return (ll) i * j % mod;
}

int n, m;
char A[1001][1001];
int dp[1001][1001];

int main() {
  cin >> n >> m;
  for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= m; ++j)
      cin >> A[i][j];
  dp[0][1] = 1;
  for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= m; ++j)
      if(A[i][j] == '.') dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
  
  cout << dp[n][m];
  
  return 0;
}

Measured memory_bytes: 5248
#include<algorithm>
#include<iostream>
using namespace std;
double concentration(int sugar, int water) {
	double ds = (double)sugar;
	double dw = (double)water;
	return ds / (ds + dw);
}
int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	int max_a = F / 100 * A;
	int max_b = F / 100 * B;
	int max_c = F / C;
	int max_d = F / D;
	double con_e = concentration(E, 100);
	double max_con = -0.5;
	int max_water = 0;
	int max_sugar = 0;
	for (int i = 0;A*i*100 <= F;i++) {
		int weight1 = A*i * 100;
		for (int j = 0; weight1 + B*j * 100 <= F;j++) {
			int weight2 = weight1 + B*j * 100;
			for (int k = 0;weight2+C*k<=F;k++) {
				int weight3 = weight2 + C*k;
				for (int l = 0;weight3+D*l<=F;l++) {
					//i = 0, 1, 2, ..., max_a - 1;
					int water_a = 100 * A*i;
					int water_b = 100 * B*j;
					int sugar_c = C*k;
					int sugar_d = D*l;
					int all_mass = water_a + water_b + sugar_c + sugar_d;
					double all_con = concentration((sugar_c + sugar_d), (water_a + water_b));
					if (all_mass <= F) {
						if (all_con <= con_e) {
							if (all_con > max_con) {
								max_con = all_con;
								max_water = water_a + water_b;
								max_sugar = sugar_c + sugar_d;


							}
						}
					}

				}
			}
		}
	}
	cout << max_water+max_sugar << " " << max_sugar << endl;
}
 

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

char c;

int main () {
  cin >> c;
  if ((c == 'a') || (c == 'i') || (c == 'u') || (c == 'e') || (c == 'o'))
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 256
def f(h, w):
    t = pow(10,9)
    for hi in range(1,h):
        a = hi*w
        b = (h-hi)*(w//2)
        c = (h-hi)*(w-w//2)
        t = min(t, max([a,b,c])-min([a,b,c]))
        b = ((h-hi)//2)*w
        c = ((h-hi)-(h-hi)//2)*w
        t = min(t, max([a,b,c])-min([a,b,c]))
    return t

h, w = map(int, input().split())
print(min(f(h,w), f(w,h)))

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

#define int long long

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

int N, M;
int jisuu[100001] = {};

signed main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        jisuu[a]++;
        jisuu[b]++;
    }
    for (int i = 1; i <= N; i++) {
        if (jisuu[i] % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  if(n>=2*k-1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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


int main()
{
	int n, ans=0;
	cin>>n;
	int d[n];
	for(int i=0;i<n;i++)
		cin>>d[i];
	for(int i=0;i+1<n;i++)
		for(int j=i+1;j<n;j++)
		{
			ans+=d[i]*d[j];
		}
	cout<<ans;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

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

    ll ans = 0;
    NREP() {
        if (i == 0) ans = k;
        else ans *= (k - 1);
    }

    MSG(ans)
}


Measured memory_bytes: 256
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

a,b = map(str,(input().split()))
a = int(a)
b = list(b)
c = []
now = float("inf")
for i in range(len(b)):
    if b[i] == ".":
        now = i
    if i > now:
        c.append(b[i])
b = b[:now]

bnew = int("".join(b))
cnew = int("".join(c))

ans = a*bnew
ans += a*cnew//100
print(ans)

Measured memory_bytes: 86088