akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> v(n, vector<int>(m));
	rep(i, n)
	{
		cin >> c[i];
		rep(j, m)
		{
			cin >> v[i][j];
		}
	}
	int ans = INT_MAX;
	int all = 1 << n;
	for (int bit = 0; bit < all; bit++)
	{
		int tmp_ans = 0;
		vector<int> sum(m, 0);
		for (int i = 0; i < n; i++)
			if (1 << i & bit)
			{
				tmp_ans += c[i];
				rep(j, m)
					sum[j] += v[i][j];
			}
		bool is_ok = true;
		rep(i, m)
		{
			if (sum[i] < x)
				is_ok = false;
		}
		if (is_ok)
			ans = min(ans, tmp_ans);
	}
	if (ans == INT_MAX)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void){
	long long a[6];
	long long i,ans;
	for(i=0;i<6;i++){
		scanf("%lld",&a[i]);
	}
	long long min = a[1];
	for(i=1;i<6;i++){
		if(min > a[i]){
			min = a[i];
		}
	}
	//移動手段の中で一番人数が少ないやつと同じ数だけ毎分運ぶ
	//最後の1人が1から2まで行くのに(N+min-1)/min 分
	//あとは最後の1人は1分ごとに次の国に行くので+4で目的地に到達する
	ans = 0;
	ans = (a[0]+min-1)/min + 4;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
from itertools import permutations
input = sys.stdin.readline

def dist(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

N = int(input())
c = 1
for n in range(1, N + 1):
    c *= n
ans = [0] * c
xy = [0] * N
for n in range(N):
    xy[n] = tuple([int(x) for x in input().strip().split()])

i = 0
for xy_ in permutations(xy, N):
    pos = -1
    pre = 0
    ans_ = 0
    for n in range(N):
        if pos == -1:
            pre = xy_[n]
        pos = xy_[n]
        ans_ += dist(pre[0], pre[1], pos[0], pos[1])
        pre = pos
    ans[i] += ans_
    i += 1

print(sum(ans) / c)

Measured memory_bytes: 4340
a, b, c, d, e, f = map(int, input().split())
max_a = f // (100*a)
max_b = f // (100*b)
max_c = f // c
max_d = f // d
wat = []
sug = []
for i in range(max_a + 1):
    for j in range(max_b + 1):
        w = 100 * a * i + 100 * b * j
        if w <= f and w > 0:
            wat.append(w)
for i in range(max_c + 1):
    for j in range(max_d + 1):
        s = c*i + d*j
        if s < f:
            sug.append(s)
ans = 0
for x in wat:
    for y in sug:
        if x + y <= f and y <= e * x / 100:
            if ans <= 100 * y / (x + y):
                ans =  100 * y / (x + y)
                out = [x+y, y]
print(*out)

Measured memory_bytes: 12440
import java.util.*;

public class Main {
	static final int r = 1000000000 + 7;
	public static long pow(int a, int b) {
		long ans = 1;
		for(int i = 0; i < b; ++i){
			ans *= (long)a;
			ans %= (long)r;
		}
		return ans;
	}
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int ans = 0;
		if(n > 1){
			long tmp = pow(10, n) - pow(9, n) - pow(9, n) + pow(8, n);
			tmp %= r;
			ans = (int)((tmp + (long)r) % r);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35748
S = gets.chomp
T = gets.chomp

T.size

# charsの1回転
rotated = S
can_rotate = false
T.size.times do |t|
  first = rotated[0]
  rotated = rotated[1..-1]
  rotated += first
  if rotated == T
    can_rotate = true
    break
  end
end

status = can_rotate == true ? 'Yes' : 'No'
puts status

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return(1);
    ll sol=power(a,b/2,m);
    sol=(sol*sol)%m;
    if(b%2==1)
        sol=(sol*a)%m;
    return(sol);
}
ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
int a[105];
void solve()
{
    int n,m,x,sol1=0,sol2=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        if(a[i]<x)
            sol1++;
        else
            sol2++;
    }
    cout<<min(sol1,sol2);

}
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
	return 0;
}



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

int main() {
	int N,K;
	cin>>N>>K;
  	int sum=0;
	for(int i=0;i<N;i++){
		int x;
		cin>>x;
		if(x>=abs(K-x)){
			sum+=2*abs(K-x);
		}
		else{
			sum+=2*x;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define mod 1000000007
    #define f first
    #define s second
     
    using namespace std;
     
    /*int gcd(int a,int b){
    	if(b == 0)
    		return a;
    	return gcd(b,a%b);
    }*/
     
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
     
    int main(){
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
      
      	string s;
      	cin>>s;
      
      	int win  =0;
      	for(int i =0;i<s.size();i++)
          if(s[i] == 'o')
            win++;
      
        if(15 - s.size() + win >= 8)
          cout<<"YES";
      	else
          cout<<"NO";
     
      	
      
     
     
     
    	return 0;
    }

Measured memory_bytes: 256
/*
14:03 - 14:24 
14:24 - 14:46 debug
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<set>
#include<deque>
#include<cassert>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 500

using namespace std;

struct Data{
  int x,y,cost;
  Data(int x=IINF,int y=IINF,int cost=IINF):x(x),y(y),cost(cost){}
};

int H,W,N,ix,iy,ox,oy;
int dx[] = {0,2,0,-2};
int dy[] = {2,0,-2,0};
bool G[MAX][MAX];
bool used[MAX][MAX];

void print(){
  rep(i,2*H+1){
    rep(j,2*W+1){
      cout << G[i][j];
    }
    cout << endl;
  }
  cout << endl;
}

inline bool isValid(int nx,int ny){ return ( 0 <= nx && nx <= 2*W && 0 <= ny && ny <= 2*H ); }

int getValue(){
  if( ix == ox && iy == oy )return 0;
  rep(i,2*H+1)rep(j,2*W+1)used[i][j] = false;
  deque<Data> deq;
  deq.push_back(Data(ix,iy,0));
  used[iy][ix] = true;
  while(!deq.empty()){
    Data data = deq.front(); deq.pop_front();
    int x = data.x, y = data.y;
    rep(i,4){
      int nx = x + dx[i],ny = y + dy[i];
      int mx = (x+nx) / 2, my = (y+ny) / 2;
      if(!isValid(nx,ny))continue;
      if( G[my][mx] )continue;
      if(used[ny][nx])continue;
      used[ny][nx] = true;
      if( nx == ox && ny == oy )return data.cost + 1;
      deq.push_back(Data(nx,ny,data.cost+1));
    }
  }
  return IINF;
}

int main(){

  cin >> W >> H >> N;
  rep(i,2*H+1)G[i][0] = G[i][2*W] = true;
  rep(i,2*W+1)G[0][i] = G[2*H][i] = true;
  rep(i,N){
    int sx,sy,dx,dy;
    cin >> sx >> sy >> dx >> dy;
    sx <<= 1, sy <<= 1, dx <<= 1, dy <<= 1;
    REP(y,min(sy,dy),max(sy,dy)+1)REP(x,min(sx,dx),max(sx,dx)+1) G[y][x] = true;
  }

  cin >> ix >> iy >> ox >> oy;
  ix <<= 1, iy <<= 1,ox <<= 1, oy <<= 1;
  ix++,iy++,ox++,oy++;

  int tmp = getValue();
  int ans = 0;
  rep(y,2*H+1)rep(x,2*W+1){
    if( y == 0 || x == 0 || y == 2*H || x == 2*W )continue;
    if( !(y&1) && !(x&1) )continue;
    if(  (y&1) &&  (x&1) )continue;
    if( G[y][x] )continue;
    G[y][x] = true;
    int cost = getValue();
    if(cost != IINF)ans = max(ans,cost-tmp);
    G[y][x] = false;
  }

  cout << ans << endl;

  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int x = in.nextInt(), a = in.nextInt(), b = in.nextInt();

			if (0 <= b && b <= a) {
				out.println("delicious");
			} else if (a < b && b <= a+x) {
				out.println("safe");
			} else {
				out.println("dangerous");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
    int n, m, ans = 0;
    cin >> n;
    vector<string> s(n);
    string t;
    map<string, int> mp, mpt;
    for(int i = 0; i < n; ++i) cin >> s[i], mp[s[i]]++;
    cin >> m;
    for(int i = 0; i < m; ++i) cin >> t, mpt[t]++;
    for(int i = 0; i < n; ++i) {
        ans = max(ans, mp[s[i]] - mpt[s[i]]);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
W, a, b = map(int, input().split())

tmp = a+W - b

A = set(range(a,a+W))
B = set(range(b,b+W))

if len(A&B):
    print(0)

else:
    if a<b:
        print(abs(a+W - b))
    else:
        print(abs(b+W - a))


Measured memory_bytes: 24296
X, Y = map(int, input().split())
a = (4*X-Y)//2
b = X-a

# print(a, b, X, Y, a+b, 2*a+4*b)

if a+b == X and 2*a+4*b == Y and a >= 0 and b >= 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61708
def main():
    n,m = map(int,input().split())
    li = [-1 for i in range(n)]
    for i in range(m):
        s,c = map(int,input().split())
        if li[s-1] == -1: 
            li[s-1] = c
        elif li[s-1] == c:
            continue
        else:
            print(-1)
            exit()
    if li[0] == 0 and n != 1:
        print(-1)
        exit()
    else:
        for i in range(n):
            if li[i] == -1:
                li[i] = 0
    if li[0] == 0 and n != 1:
        li[0] = 1
    ans = 0
    for i in range(n):
        ans += li[i] * 10 ** (n-i-1)
    print(ans)
      

if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int i, j, k, s[1000000], t[1000000], n, l1, l2, count = 0, left, right, mid;
  char buf[2];
  scanf("%d", &l1);
  for (n = 0; n < l1 && (j = scanf("%d%1[\n]", s+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;
  scanf("%d", &l2);
  for (n = 0; n < l2 && (j = scanf("%d%1[\n]", t+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;

  for (i = 0; i < l2; i++) {
    left = 0;
    right = l1;
    while (left < right) {
      mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        count++;
        break;
      } else if (t[i] < s[mid] ) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }

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



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

int n, mn, x[200005], y;
string s;
int main() {
	int i;
	cin >> n >> s;
	s = "-" + s;
	for(i=1; i<=n; i++) x[i] = x[i-1] + (s[i]=='#');
	mn = x[n];
	for(i=n; i; i--) {
		y += s[i]=='.';
		mn = min(mn, y + x[i-1]);
	}
	cout << mn;
	return 0;
}

Measured memory_bytes: 1344
import heapq

*T, K = [int(i) for i in input().split()]
A, B, C = [sorted([int(i) for i in input().split()], reverse=True)
           for _ in range(3)]

def get_next(t):
    x, y, z = t
    return [(x + 1, y, z), (x, y + 1, z), (x, y, z + 1)]

def evaluate(t):
    x, y, z = t
    return (-(A[x] + B[y] + C[z]), t)


q = []
heapq.heappush(q, evaluate((0, 0, 0)))
result = []
memo = set()

for _ in range(K):
    v, t = heapq.heappop(q)
    result.append(-v)

    for i, nt in enumerate(get_next(t)):
        if nt[i] < T[i] and nt not in memo:
            heapq.heappush(q, evaluate(nt))
            memo.add(nt)

for r in result:
    print(r)


Measured memory_bytes: 4972
K=int(input())
A=list(map(int,input().split()))
l,h=2,2
for a in A[::-1]:
    l=-(-l//a)*a
    h=(h//a+1)*a-1
    if l>h:
        l=h=-1
        break
if l==h==-1:
    print(-1)
else:
    print(l,h)

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

int a[12][12];
const int INF = 1001001001;

int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
    }

    int ans = INF;
    //全ビット探索
    for (int s = 0; s < 1<<n; s++) {
        //cost 今までの本の総額
        //d 理解度
        int cost = 0;
        vector<int> d(m);

        for (int i = 0; i < n; i++) {
            //i番目の本を購入する場合
            if (s>>i&1) {
                cost += c[i];
                for (int j = 0; j < m; j++)
                    d[j] += a[i][j];
            }
        }
        bool ok = true;
        //アルゴリズムj番目の理解度がx未満なら判定を
        //falseにする
        for (int j = 0; j < m; j++) 
            if (d[j] < x)
                ok = false;
        if (ok)
            ans = min(ans, cost);
    }

    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3584
from collections import deque

K = int(input())

deq = deque([(1, 1)])
history = set()

while True:
	to = deq.popleft()
	if to[0] == 0:
		print(to[1])
		break
	elif to[0] not in history:
		history.add(to[0])
		deq.appendleft((to[0] * 10 % K, to[1]))
		deq.append((to[0] + 1, to[1] + 1))

Measured memory_bytes: 21228
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;

ll hako[200000];
int main()
{
  int n,t,tmp=1001,count=0;
  int i=0;
  in n>>t;
  int c[n];
  int hoge[n];
  for(;i<n;i++){
    in c[i];
    in hoge[i];
    if(t>=hoge[i]){
      if(tmp>c[i])tmp=c[i];
    }
    else count++;
  }
  if(count==i)cout<<"TLE"<<endl;
  else cout<<tmp<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	static int N;
	static long ans;
	static int[] S;
	static long[] memo;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
			 N = sc.nextInt();
			 S = new int[N];

			 for(int i = 0 ; i < N ; i++){
				 S[i] = sc.nextInt();
			 }
		sc.close();

		memo = new long[N];

		memo[0] = 0;
		memo[1] = Math.abs(S[1] - S[0]);

		System.out.println(dp(S,memo,N));


	}

	static long dp(int[] S,long[] memo,int n){
		if(n==1){
			return 0;
		}

		else if(n==2){
			return Math.abs(S[1] - S[0]);
		}


		else{
		for(n = 3; n <= N; n++){
				ans = Math.min(Math.abs(S[n-1]-S[n-2]) +memo[n-2],Math.abs(S[n-1]-S[n-3]) + memo[n-3]);
				memo[n-1] = ans;
		}
		/*
		else if(n <= N){
			if(memo[N-1] != 0){
				ans = Math.min(Math.abs(S[N-1]-S[N-2]) +memo[N-1],Math.abs(S[N-1]-S[N-3]) + memo[N-2]);
			}
			else{
				memo[N-1] = dp(S,memo,N-1);
				memo[N-2] = dp(S,memo,N-2);
				ans = Math.min(Math.abs(S[N-1]-S[N-2]) +dp(S,memo,N-1),Math.abs(S[N-1]-S[N-3])+dp(S,memo,N-2));
			}
		}*/
		}

		return ans;
	}
}

Measured memory_bytes: 60428
n = gets

SUIT = ['S', 'H', 'C', 'D']
hash = {}

SUIT.each do |s|
  hash[s] = [*1..13]
end

while line = gets
  suit, num = line.split
  num = num.to_i

  hash[suit].delete(num)
end

SUIT.each do |s|
  unless hash[s].empty?
    hash[s].each do |num|
      puts "#{s} #{num}"
    end
  end
end

Measured memory_bytes: 8648
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: String};
    let n: String = n;
    let mut sum = 0;

    for i in n.chars() {
        sum += i as i32 - 48;
    }

    println!("{}", if sum % 9 == 0 { "Yes" } else { "No" })
}


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

int main(){
  int a,b;
  cin >> a >> b;

  int N;
  cin >> N;

  int s,f;
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> s >> f;
    if(s<=a && a<f){
      ans++;
    }else if(s<b && b<=f){
      ans++;
    }else if(a<=s && f<=b){
      ans++;
    }
  }

  if(ans>0){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }

  return 0;
}



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

char H[NUM][L];

//文字から数字に変換
int getChar(char ch) {
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

ll getKey(char str[]) {
  ll sum = 00, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}
int h1(int key) {
  return key % NUM;
}

int h2(int key) {
  return 1 + (key % (NUM - 1));
}

int find(char str[]){
  ll key, i, h;
  key = getKey(str);
  for (i = 0;;i++){
    h = (h1(key) + i * h2(key)) % NUM;
    if( strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]) {
  ll key, i, h;
  key = getKey(str); //文字列を数字に変換
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % NUM;
    if( strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < NUM; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%s %s", com, str);
    if(com[0] == 'i'){
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}




Measured memory_bytes: 20056
n,m=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]
inf=10**10
dist=[[inf for _ in [0]*n] for _ in [0]*n]
for i in range(n):dist[i][i]=0
for a,b,c in abc:
    dist[a-1][b-1]=c
    dist[b-1][a-1]=c
for k in range(n):
    for i in range(n):
        for j in range(n):dist[i][j]=min(dist[i][j],(dist[i][k]+dist[k][j]))

cnt=0
for a,b,c in abc:
    if dist[a-1][b-1]!=c:
        cnt+=1
        
print(cnt)

Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main()
{
    int n, x;
    cin >> n;
    int min = 1000000001;
    int max = -1;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        if (x < min)
            min = x;
        if (x > max)
            max = x;
    }
    cout << max - min;

    return 0;
}


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

const int mod = 998244353;
const double pi = acos(-1.0);
const double eps = 1e-6;

LL dp[3001][3001];

int main()
{
    int n, s, a;
    cin >> n >> s;
    dp[0][0] = 1;
    Rep(i, n) {
        cin >> a;
        for(int j = s; j >= a; --j) {
            dp[i][j] += dp[i-1][j-a];
        }
        rep(j, s+1) dp[i][j] = (dp[i][j] + dp[i-1][j] * 2) % mod;
    }
    LL ans = 0, base = 1;
    rep(i, n) {
        ans = (ans + base * dp[n-i][s]) % mod;
        base = base * 2 % mod;
    }
    cout << dp[n][s] << endl;
    return 0;
}


Measured memory_bytes: 73900
<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = 0;
for($i = $a; $i <= $b; $i++){
    if(substr($i, 0 ,1) == substr($i, 4 ,1) && substr($i, 1 ,1) == substr($i, 3 ,1)){
        $c++;
    }
}
echo $c;

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

using namespace std;

typedef const int ct;

ct N = 1e2 + 20;

int q, n, m, dp[N][N], x, y;

char arr_v[N][N];

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			cin >> arr_v[i][j];
	}
	if (arr_v[1][1] == '#')
		dp[1][1] = 1;
	for (int j = 2; j <= m; j++) {
		dp[1][j] = dp[1][j - 1];
		if (arr_v[1][j] == '#' && arr_v[1][j - 1] == '.')
			dp[1][j]++;
		//cout << 1 << "  " << j << "   " << dp[1][j] << endl;
	}
	for (int i = 2; i <= n; i++) {
		dp[i][1] = dp[i - 1][1];
		if (arr_v[i][1] == '#' && arr_v[i - 1][1] == '.')
			dp[i][1]++;
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 2; j <= m; j++) {
			x = dp[i][j - 1];
			if (arr_v[i][j] == '#' && arr_v[i][j - 1] == '.')
				x++;
			y = dp[i - 1][j];
			if (arr_v[i][j] == '#' && arr_v[i - 1][j] == '.')
			y++;
			dp[i][j] = min (x, y);
		}
	}
//	cout << endl << endl << endl;
/*	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			cout << dp[i][j] << " ";
		cout << endl;
	}
	*/
	cout << dp[n][m];
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  ll l = S.size();

  ll result = 0;
  if (l==2) result = S[0]==S[1] ? 1 : 2;
  if (l==3) {
    if (S[0]==S[1]&&S[1]==S[2]) result = 1;
    else if (S[0]!=S[1]&&S[1]!=S[2]&&S[2]!=S[0]) result = 3;
    else result = S[0]==S[1]||S[1]==S[2] ? 6 : 7;
  }
  else {
    bool diff = true, adj = false;
    rep(i,l) { diff &= (S[i]==S[0]); if (i) adj |= (S[i-1]==S[i]); }
    ll dp[l][3][3] = {}; rep(i,3) dp[0][i][i] = 1;
    rep(i,l-1) rep(j,3) rep(k,3) rep(l,3) if (k!=l) dp[i+1][(j+l)%3][l] = (dp[i+1][(j+l)%3][l]+dp[i][j][k]) % MOD;
    ll count[3] = {}; rep(i,3) rep(j,3) count[i] = (count[i]+dp[l-1][i][j]) % MOD;
    // debug(count, count+3);
    ll p3 = 1; rep(i,l-1) p3=p3*3%MOD;
    ll cp3 = 0; rep(i,l) cp3 = (cp3+(S[i]-'a')) % 3;
    if (diff) result = 1;
    else result = adj ? (p3-count[cp3]+MOD) % MOD : (p3-count[cp3]+1+MOD) % MOD;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 17808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
ll dp[401][401];
ll sum(int i, int j, vector<ll> &v){
    ll val = 0;
    for(int k=i;k<=j;k++){
        val+=v[k];
    }
    return val;
}
ll solve(vector<ll> &v, ll i, ll j){
    if(i>=j)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=1e18L+5;
    for(int k=i;k<=j;k++){
        dp[i][j]=min(dp[i][j],solve(v,i,k)+solve(v,k+1,j)+sum(i,k,v)+sum(k+1,j,v));
    }
    return dp[i][j];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> v;
    ll tmp;
    for(int i=0;i<n;i++){
        cin>>tmp;
        v.pb(tmp);
    }
    for(int i=0;i<401;i++){
        for(int j=0;j<401;j++)
            dp[i][j]=-1;
    }
    cout<<solve(v,0,n-1)<<endl;
    return 0;
}


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

int a[105];

int main() {
    int n, m, sum = 0;
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
        cin >> a[i], sum += a[i];
    sort(a, a+n);
    for(int i = n-1; i >= n-m; --i)
        if(a[i]*4*m<sum) return cout << "No", 0;
    cout << "Yes";
    return 0;
}

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

int main(){
    long long w,n,ans = 0;
    cin>>n>>w;
    vector<long long> weight(w+1),dp(w+1);
    for(int item = 0;item<n;item++){
        int v,wi;
        cin>>wi>>v;
        for(int i = 0;i+wi<=w;i++){
            weight[i+wi] = max(dp[i]+v,dp[i+wi]);
            //cout<<weight[i+wi]<<"  ";
        }
        dp = weight ;
    }
    for(int x = 0;x<=w;x++){
        ans = max(ans,dp[x]);
        //cout<<weight[x]<<endl;
    }
    cout<<ans<<endl;

}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
#define INF lli(1e19)

#define forz(i, n) for (lli i = 0; i < n; i++)
#define fore(i, m, n) for (lli i = m; i < n; i++)
#define rforz(i, n) for (lli i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (lli i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define newline cout<<endl;
//#define endl "\n"



inline lli power(lli x, lli y, lli p = mod)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

inline lli modadd(lli a, lli b, lli m = mod)
{
    a += b;
    if (a >= m)
        a -= m;
    return a;
}

inline lli modmul(lli a, lli b, lli m = mod)
{
    return ((a % m) * (b % m)) % m;
}

inline lli modi(lli a, lli m = mod) { return power(a, m - 2, m); }
inline lli md(lli x) {if(x>=0)return x; return -x;}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
lli n,m,k;
const lli mxN = 2e5;
bool vis[mxN];
vector<lli> adj[mxN];
//void init()
//{
//    forz(i,n) vis[i]=0, adj[i].clear();
//}

lli dfs(lli x)
{
    if(vis[x]) return 0;
    vis[x]=1;
    lli z = 1;
    for(auto y: adj[x])
        z+=dfs(y);
    return z;
}
int32_t main()
{
    kira;

    lli T=1;
//    cin>>T;

    while(T--)
    {
        cin>>n>>m;
        lli u, v;
        forz(i,m)
        {
            cin>>u>>v, u--, v--;
            adj[u].pb(v);
            adj[v].pb(u);
        }
        lli r = 0;
        forz(i,n)
        {
            if(!vis[i]) r = max(r,dfs(i));
        }

        cout<<r<<endl;
    }

    return 0;

}


Measured memory_bytes: 20976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[20], n;
int main()
{
     cin >> n;
     dp[4] = dp[7] = 1;
     for(ll i = 8; i < 20; i++)
     {
         dp[i] = (dp[i-4] or dp[i-7]);
     }
     if(n>19)cout << "Yes";
     else
     {
         if(dp[n]) cout << "Yes";
         else cout << "No";
     }
}


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

int main() {
    int t;
    ll a = 0, b = 0;

    cin >> t;

    cin >> a >> b;
    t--;
    
    while (t--) {
        ll x, y;
        cin >> x >> y;
        ll m = (a + x - 1) / x;
        ll n = (b + y - 1) / y;
        a = x * max(m, n);
        b = y * max(n, m);
    }
    cout << a + b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
    int n, i, j, k;
    long long ans = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            int t = __gcd(i, j);
            for (k = 1; k <= n; k++) {
                ans += __gcd(t, k);
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1700
#include <iostream>
#include <utility>
#include <vector>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

using P=pair<ll, ll>;
vector<P> prime_factorize(ll N) {
    vector<P> res;
    for (ll a = 2; a*a <= N; a++) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ex++;
            N /= a;
        }

        // その結果を push
        res.push_back(P(a, ex));
    }

    // 最後に残った数について
    if (N != 1) res.push_back(P(N, 1));
    return res;
}

const int MAX = 1e6;

ll N, ans;
vector<ll> pCount(MAX);
int main() {
	cin >> N;

	// 素因分解
	const auto &res = prime_factorize(N);
    rep(i, 0, res.size()) {
		int a = res[i].second;

		int b = 1;
		while(1){
			a -= b;
			if(a < 0) break;
			ans++;
			b++;
		}
    }
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10696
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int64_t i = 0; i < (n); i++)
using namespace std;

const int64_t maxN = 5 * 1e5 + 1;
const int64_t mod = 1e9 + 7;
int64_t fac[maxN], finv[maxN], inv[maxN];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < maxN; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

int64_t COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int64_t PRM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[n - k] % mod;
}

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, M;
  cin >> N >> M;
  COMinit();

  int64_t answer = 0;
  rep(k, N + 1) {
    int64_t add = PRM(M - k, N - k);
    add = (add * add) % mod;
    add = (add * PRM(M, k)) % mod;
    add = (add * COM(N, k)) % mod;
    if (k % 2 == 0) {
      answer = (answer + add) % mod;
    } else {
      answer = (answer - add + mod) % mod;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 15328
#include <stdio.h>

#define MAX_SIZE (51000)

int prime[MAX_SIZE + 1];

int main(void)
{
	int n, i, j;
	
	for (i = 0; i < MAX_SIZE; i++){
		prime[i] = 1;
	}
	
	prime[0] = prime[1] = 0;
	
	for (i = 2; i * i <= MAX_SIZE; i++){
		if (prime[i] == 1){
			for (j = i * i; j <= MAX_SIZE; j += i){
				prime[j] = 0;
			}
		}
	}
	
	while (scanf("%d", &n) != EOF){
		i = n - 1;
		while (prime[i] != 1){
			i--;
		}
		printf("%d ", i);
		
		i = n + 1;
		while (prime[i] != 1){
			i++;
		}
		printf("%d\n", i);

	}
	
	return (0);
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int a,b;
  cin>>a>>b;
  int max=-INF;
  max=a+b;
  if(max<=a*b){
    max=a*b;
  }
  if(max<=a-b){
    max=a-b;
  }
  cout<<max<<endl;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> L(N);

  for(int i = 0; i < N; i++){
    cin >> L[i];
  }

  sort(L.begin(), L.end());

  int cnt = 0;

  for(int i = 0; i < L.size(); i++){
    for(int j = i + 1; j < L.size(); j++){
      if(L[i] == L[j]){
        continue;
      }
      for(int k = j + 1; k < L.size(); k++){
        if(L[k] >= L[i] + L[j]){
          break;
        }else if(L[j] != L[k]){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3636
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int a[1005][1005];
vll adjlist[1005*1005];
int ind[1005*1005];
int dp[1005*1005];
void solve(){  
	int n;
	cin>>n;
	rep(i,1,n+1){
		rep(j,1,n){
			cin>>a[i][j];
			int x=i;
			int y=a[i][j];
			if(x>y) swap(x,y);
			a[i][j]=x*n+y;
			if(j>1){
				adjlist[a[i][j-1]].pb(a[i][j]);
				ind[a[i][j]]++;
			}
		}
	}
	queue<int> q;
	rep(i,1,n*n+1){
		if(ind[i]==0) q.push(i);
	}
	int vis=0;
	int ans=0;
	while(!q.empty()){
		int k=q.front();
		q.pop();
		++vis;
		ans=max(ans,dp[k]+1);
		for(int i:adjlist[k]){
			ind[i]--;
			dp[i]=max(dp[i],dp[k]+1);
			if(ind[i]==0) q.push(i);
		}
	}
	if(vis!=n*n) cout<<-1<<endl;
	else
	cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 66304
#include<iostream>

using namespace std;


int main()
{
	int N;
	int *a;
	int ans = 0;
	int mode = 0;

	cin >> N;
	a = new int[N];

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

	int prev = a[0];

	for(int i=1;i<N;i++)
	{
		if(mode == 0)
		{
			if(a[i-1]<a[i])mode = 1;
			else if(a[i-1]>a[i])mode = -1;

			if(mode != 0)ans++;
		}
		else if(mode==1 && a[i-1]>a[i])mode = 0;
		else if(mode==-1 && a[i-1]<a[i])mode = 0;
	}

	if(mode == 0)ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
a = list(input())
flag = True

a = a[:-1]
while(flag):
    flag = False
    if len(a)%2!=0:
        a = a[:-1]
        flag = True
        continue
    if a[0:len(a)//2]!=a[len(a)//2:]:
            a = a[:-1]
            flag = True



print(len(a))

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<pii> v(N+M);
  rep(i,N){
    int a;
    cin >> a;
    v[i]=pii(a,1);
  }
  rep(i,M){
    int b,c;
    cin >> b >> c;
    v[i+N]=pii(c,b);
  }
  sort(v.begin(),v.end(),greater<pii>());
  ll ans=0;
  int s=0;
  rep(i,M+N){
    s+=v[i].second;
    if(s<N) ans+=(ll)v[i].first*v[i].second;
    else{
      ans+=(ll)v[i].first*(v[i].second-(s-N));
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int num[5];
    rep(i,5){
        cin >> num[i];
    }
    rep(i,5){
        if(num[i] != i+1){
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3596
n = int(input())
ss = input()

max_cnt = 0
for i in range(1, n):
    cnt = 0
    for j in range(n - i):
        if ss[j] == ss[j + i]:
            cnt += 1
            max_cnt = max(cnt, max_cnt)
            if cnt == i:
                break
        else:
            cnt = 0

print(max_cnt)

Measured memory_bytes: 42524
# -*- coding: utf-8 -*-
x = int(input())


def five(n):
    ans = 1
    for i in range(5):
        ans *= n

    return ans


break_flag = False
for i in range(100000000):
    b_five = five(i)
    x_plus_b = x + b_five
    x_minus_b = x - b_five
    for k in range(100000000):
        a_five = five(k)
        a_five_minus = -1 * a_five
        if a_five == x_plus_b:
            a = k
            b = i
            break_flag = True
            break
        elif a_five == x_minus_b:
            a = k
            b = -i
            break_flag = True
            break
        elif a_five_minus == x_plus_b:
            a = -k
            b = i
            break_flag = True
            break
        elif a_five_minus == x_minus_b:
            a = -k
            b = -i
            break_flag = True
            break
        elif a_five > x_plus_b and a_five_minus < x_minus_b:
            break
    if break_flag:
        break

print("{} {}".format(a, b))



Measured memory_bytes: 9228
import heapq

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

a = [-1*i for i in a]

heapq.heapify(a)

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

print(-1 * sum(a))


Measured memory_bytes: 14180
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    int x;
    cin >> x;

    vector<int> primes;
    primes.push_back(2);

    for (int i = 3; i < x;)
    {
        bool isprime = true;
        for (auto &&p : primes)
        {
            isprime &= i % p != 0;
        }
        if (isprime)
            primes.push_back(i);
        i++;
        i++;
    }

    int n;
    for (n = x;; n++)
    {
        bool isprime = true;
        for (auto &&p : primes)
        {
            isprime &= n % p != 0;
        }
        if (isprime)
            break;
    }
    if (x == 2)
        n = 2;

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 384
module A = Array
module C = Char
module I = Int64
module L = List
module Q = Queue

let pf = Printf.printf
let sf = Scanf.scanf
let ssf = Scanf.sscanf

let read_int () = sf "%d " (fun x -> x)
let read_float () = sf "%f " (fun x -> x)
let read_str () = sf "%s " (fun x -> x)
let read_array n read () = A.init n (fun _ -> read ())
let err s = raise (Failure s)

let range s t = A.init (t - s) @@ (+) s
let foreach fold_f init s t map_f =
  range s t |> A.map map_f |> A.fold_left fold_f init

let inf = int_of_float 1e18
let eps = 1e-11

module S = struct
  include String
  let of_array a = String.init (A.length a) (A.get a)
  let to_array s = A.init (String.length s) (String.get s)
end;;

let () =
  let h = read_int () in
  let w = read_int () in
  let c = read_array 10 (read_array 10 read_int) () in
  let a = read_array (h * w) read_int () in
  for k = 0 to 9 do
    for i = 0 to 9 do
      for j = 0 to 9 do
        c.(i).(j) <- min c.(i).(j) (c.(i).(k) + c.(k).(j))
      done
    done
  done;
  let f x = if x = -1 then 0 else c.(x).(1) in
  let res = A.map f a |> A.fold_left (+) 0 in
  pf "%d\n" res


Measured memory_bytes: 5120
N, M = map(int, input().split())
lights = []
for _ in range(M):
    lights.append([int(i) for i in input().split()])
p = [int(i) for i in input().split()]

ans = 0
for switch in range(0, 2**N):
    flag = True
    for i in range(M):
        s = 0
        for j in range(lights[i][0]):
            s += (switch >> (lights[i][j + 1] - 1)) & 0b1
        if s % 2 != p[i]:
            flag = False
    if flag:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <string,string> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

int tx[4],ty[4];

bool used[1<<16];

int dfs(int stage,int c){	
	if(c==8) return 1;	

	int res = 0;
	int sx = -1;
	int sy = -1;
	for(int y=0;y<4;y++){
		for(int x=0;x<4;x++){
			if(~stage & (1<<(y*4+x))){	
				sx = x;
				sy = y;
				goto found;
			}
		}
	}
found:;


	if(sx == -1) return 0;

	for(int i=0;i<4;i++){
		int dx = sx + tx[i];
		int dy = sy + ty[i];
		if(dx < 0 || dx >= 4 || dy < 0 || dy >= 4) continue;
		if(stage & (1<<(dy*4+dx))) continue;

		//bitset<16> next = stage;
		stage |= (1<<(dy*4+dx));
		stage |= (1<<(sy*4+sx));
		res += dfs(stage,c+1);
		stage &= ~(1<<(dy*4+dx));
		stage &= ~(1<<(sy*4+sx));
	}

	return res;
}

int main(){

	while(~scanf("%d",tx+0)){
		if(tx[0] >= 5) break; 
		scanf("%d %d %d %d %d %d %d",ty+0,tx+1,ty+1,tx+2,ty+2,tx+3,ty+3);

		memset(used,0,sizeof(used));
		printf("%d\n",dfs(0,0));
	}
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int,input().split()))

count = 0

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            count += 1
if count == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
/*
    It is the level of one's commitment that determines the success, far more than the knowledge one possess.
    
    I never lose, I either win or I learn.
                - Competitive Programming

*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        int n = Integer.parseInt(br.readLine());
        int[] a = new int[n+1];
        st = new StringTokenizer(br.readLine());
        for(int i=1 ; i<=n ; i++) {
            a[i] = Integer.parseInt(st.nextToken());
        }

        int[] dp = new int[n+2];
        dp[2] = dp[1] + Math.abs(a[2]-a[1]);
        for(int i=3 ; i<=n ; i++) {
            dp[i] = Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
        }

        pw.println(dp[n]);

        
        
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 31768
#include<stdio.h>
int main(){
  int x;

  scanf("%d",&x);

  switch(x%7){
  case 0:
    printf("thu\n");
  break;
  
 case 1:
   printf("fri\n");
   break;
   
 case 2:
    printf("sat\n");
    break;

 case 3:
   printf("sun\n");
   break;

 case 4:
   printf("mon\n");
   break;

 case 5:
   printf("tue\n");
   break;

 case 6:
   printf("wed\n");
   break;
  }
  
   return 0;
}

Measured memory_bytes: 1812
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{ 
  ld w,h,x,y; cin>>w>>h>>x>>y;
  ld ans = w*h;
  ans/=2.0;
  cout<<fixed<<setprecision(9)<<ans<<" ";
  if(2*x==w and 2*y==h) cout<<1;
  else cout<<0;  
} 
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

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

int main() {
int A; int B;
  cin>>A>>B;
  if(A==1){
    if(B==2)
      cout<<3<<endl;
    else cout<<2<<endl;
  }
  else if(A==2){
    if(B==1)
      cout<<3<<endl;
    else cout<<1<<endl;
  }
  else{
    if(B==1)
      cout<<2<<endl;
    else cout<<1<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e10;
using Graph = vector<vector<int>>;

signed main()
{
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> B(M);
  vector<pair<int, int>> key(M);
  for( int i = 0; i < M; i++ ){
    cin >> A[i] >> B[i];
    int S = 0;
    for( int j = 0; j < B[i]; j++ ){
      int C;
      cin >> C;
      C--;
      //Sと1をC個左シフトした数字でorをとる（＝C番目のbitを立たせる）
      S |= 1<<C;
    }
    key.at(i) = {S, A[i]}; //集合Sに含まれる宝箱をA[i]円で開けられる
  }

  //N桁の二進数であらわす
  vector<int> dp(1<<N, INF);
  dp[0] = 0;
  for( int s = 0; s < 1<<N; s++ ){
    for( int i = 0; i < M; i++ ){
      //sとi番目の鍵で開けられる宝箱の和集合
      int T = s | key[i].first;
      dp[T] = min(dp[T], dp[s]+key[i].second);
    }
  }
  if( dp.back() == INF ) cout << -1 << endl;
  else cout << dp.back() << endl;

}


Measured memory_bytes: 3672