akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		double m = sc.nextDouble();
		double[] A = new double[n];
		double sum = 0;
		for(int i = 0; i < n; i++) {
			A[i] = sc.nextDouble();
			sum += A[i];
		}
		double cnt = 0;
		double limit = 1 / (4 * m);
		for(int i = 0; i < n; i++) {
			double num = A[i] / sum;
			if (num >= limit) {
				cnt++;
			}
		}	
		
		if (cnt >= m) out.println("Yes");
		else out.println("No");

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

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

void tree_operation(vector<vector<array<int, 2>>>& tree,vector<int>& ans, int num, int prev){
	if(num!=1 && tree[num].size() == 1){
		return;
	}
	for(int i=0; i<tree[num].size(); i++){
		if(tree[num][i][0] == prev){
			continue;
		}
		if(tree[num][i][1]%2 == 0){
			ans[tree[num][i][0]] = ans[num];
		}else{
			ans[tree[num][i][0]] = (ans[num] + 1)%2;
		}
		tree_operation(tree, ans, tree[num][i][0], num);
	}
	return;
}
int main(){
	int n, u, v, w;
	cin >> n;
	vector<int> ans(n+1);
	vector<vector<array<int, 2>>> tree(n+1);

	for(int i=1; i<n; i++){
		cin >> u >> v >> w;	
		tree[u].push_back({v, w});
		tree[v].push_back({u, w});
	}
	tree_operation(tree, ans, 1, -1);
	for(int i=1; i<n+1; i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 9728
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

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

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);


    int n, k;
    cin >> n >> k;
    vector<bool> v(n, false);
    REP(i, k){
        int b;
        cin >> b;
        REP(j, b){
            int num;
            cin >> num;
            v[num-1] = true;
        }
    }

    int ans = 0;
    REP(i, n){
        if(v[i] == false){
            ans++;
        }
    }

    cout << ans  << "\n"; 


    return 0;



}


Measured memory_bytes: 3652
#include<stdio.h>
 
int main(void){
  struct{
    int boart;
    int flg;
  }bunny[50];
  int m,n,k,i,j,b,r,p,q;
  int sum=0;
  
  for(i=0;i<50;i++) bunny[i].flg=0;
  scanf("%d %d",&n,&k);
  for(i=0;i<k;i++){
    scanf("%d",&m);
    for(j=0;j<m;j++){
      scanf("%d",&b);
      bunny[b-1].boart=i;
    }
  }
  scanf("%d",&r);
  for(i=0;i<r;i++){
    scanf("%d %d",&p,&q);
    if(bunny[p-1].boart==bunny[q-1].boart){
      bunny[p-1].flg=1;
      bunny[q-1].flg=1;
    }
  }
  for(i=0;i<n;i++) sum+=bunny[i].flg;
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX_HEAP_SIZE 2000000
#define COMMAND_LEN 24
#define INF_POS 2000000001
#define INF_NEG -2000000001

int heap[MAX_HEAP_SIZE + 1];

int hsize = 0;

int left(int id);

int right(int id);

int parent(int id);

void maxHeapify(int rootId);
void buildMaxHeap(void);

int heapMaximum();
int heapExtractMax();
void heapIncreaseKey(int id, int key);
void maxHeapInsert(int key);

int main(){
  int n;
  char strBuf[COMMAND_LEN];

  while(1){
    scanf("%s", strBuf);

    if(strcmp("end", strBuf) == 0){
      break;
    }
    else if(strcmp("insert", strBuf) == 0){
      scanf("%d", &n);
      maxHeapInsert(n);
    }
    else if(strcmp("extract", strBuf) == 0){
      printf("%d\n", heapExtractMax());
    }
    else {
      printf("ERROR: INVALID COMMAND\n");
      exit(1);
    }
  }
  
  return 0;
}

int parent(int id){
  return id/2;
}

int left(int id){
  return 2*id;
}

int right(int id){
  return 2*id + 1;
}

void maxHeapify(int rootId){
  int l = left(rootId);
  int r = right(rootId);
  int largest;
  
  //左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= hsize && heap[l] > heap[rootId]){
    largest = l;
  }
  else {
    largest = rootId;
  }

  if(r <= hsize && heap[r] > heap[largest]){
    largest = r;
  }

  int tmp;
  if(largest != rootId){ //rootIdの子の方が値が大きいとき
    tmp = heap[rootId];
    heap[rootId] = heap[largest];
    heap[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  for(int i = hsize/2 ; i >= 1; i--){
    maxHeapify(i);
  }
}
    
int heapMaximum(){
  return heap[1];
}

int heapExtractMax(){
  if(hsize < 1){
    printf("ERROR: HEAP UNDER FLOW\n");
    exit(1);
  }

  int max = heap[1];
  heap[1] = heap[hsize];
  hsize--;
  maxHeapify(1);
  return max;
}
    
void heapIncreaseKey(int id, int key){
  if(key < heap[id]){
    printf("ERROR: KEY VALUE IS SMALLER");
    exit(1);
  }
  heap[id] = key;
  while(id > 1 && heap[parent(id)] < heap[id]){
    int tmp = heap[id];
    heap[id] = heap[parent(id)];
    heap[parent(id)] = tmp;
    id = parent(id);
  }
}

void maxHeapInsert(int key){
  hsize++;
  heap[hsize] = INF_NEG;
  heapIncreaseKey(hsize, key);
}



Measured memory_bytes: 5684
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    if a <= 0 and b >= 0:
        print("Zero")
    elif a > 0:
        print("Positive")
    elif b < 0 and (abs(a - b) + 1) % 2 != 0:
        print("Negative")
    else:
        print("Positive")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println((n % 111 == 0) ? (n / 111) * 111 : (1 + n / 111) * 111);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>

using namespace std;

#define M 405
#define ll long long
#define MOD 1000000007

int n, m, all;
int u[M], v[M], fully[(1<<16)], partly[(1<<16)];
ll ilegal, pw[M], f[3][(1<<16)];

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

int main()
{
	n = read(), m = read(); all = (1 << n);
	for (int i = 1; i <= m; i++)
		u[i] = read(), v[i] = read();

	pw[0] = 1;
	for (int i = 1; i <= m; i++)
		pw[i] = pw[i-1] * 2 % MOD;

	for (int sta = 0; sta < all; sta++)
		for (int j = 1; j <= m; j++)
		{
			if ( ((sta >> (u[j]-1)) & 1) & ((sta >> (v[j]-1)) & 1) ) fully[sta]++;
			if ( ((sta >> (u[j]-1)) & 1) | ((sta >> (v[j]-1)) & 1) ) partly[sta]++;
		}
		
	for (int i = 1; i <= 2; i++)
		for (int sta = 0; sta < all; sta++)
		{
			if ( !((sta >> (i-1)) & 1) ) continue;
			f[i][sta] = pw[fully[sta]];
			for (int sub = sta; sub; sub = (sub-1) & sta)
				f[i][sta] = ((f[i][sta] - f[i][sta-sub] * pw[fully[sub]] % MOD) % MOD + MOD) % MOD;
		}
		
	for (int sub1 = 0; sub1 < all; sub1++)
		for (int sub2 = 0; sub2 < all; sub2++)
			if ( !(sub1 & sub2) && fully[sub1] + fully[sub2] == fully[sub1|sub2])
				ilegal = (ilegal + f[1][sub1] * f[2][sub2] % MOD * pw[m - partly[sub1|sub2]] % MOD) % MOD; 
 
	cout << ((pw[m] - ilegal) % MOD + MOD) % MOD;

	return 0;
}

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

using namespace std;

const int MOD = 1000000007;

int main()
{
	string S;
	cin >> S;
	
	int n = S.size();
	
	// 動的計画法
	vector<vector<long>> dp(n + 1, vector<long>(13, 0));
	
	// dpの初期化
	dp[0][0] = 1;
	
	for (int i = 0; i < n; i++)
	{
		int c = 0;
		if (S[i] == '?')
		{
			c = -1;
		}
		else {
			c = S[i] - '0';
		}
		
		for (int j = 0; j < 10; j++)
		{
			if (c != -1 && c != j)
			{
				continue;
			}
			
			for (int k = 0; k < 13; k++)
			{
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}
		
		for (int j = 0; j < 13; j++)
		{
			dp[i + 1][j] %= MOD;
		}
	}
	
	
	// 答えの5あまる数を出力する
	long answer = dp[n][5];
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 13696
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n, k;
    while (cin >> n >> k)
    {
        ll* p = new ll[n + 5];
        for (int i = 0; i <= n + 3; i++)p[i] = 0;
        for (int i = 0; i < k; i++)
        {
            ll x;
            cin >> x;
            for (int j = 1; j <= x; j++)
            {
                ll b;
                cin >> b;
                p[b] += x;
            }
        }
        ll ans = 0;
        for (int i = 1; i <= n; i++)
            if (p[i] == 0)ans++;
        cout << ans << '\n';
    }
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define ll long long
#define rint register int
#define gc() getchar()
inline ll read(ll ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
ll N; int a[20], L;
int DP(int L, int limit){if(!L) return 0; if(!limit) return 9*L; return max(DP(L-1,1)+a[L],a[L]>0?DP(L-1,0)+a[L]-1:0);}
int Calc(ll N){for(; N; a[++L] = N%10, N /= 10); return DP(L,1);}
int main(){N = read(), printf("%d\n",Calc(N)); return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct _node {
  struct _node *left, *right;
  int key;
} node;

node *root = NULL;

int find(int key) {
  node *x;
  x = root;

  while(x != NULL && x->key != key) {
    if(key < x->key)
      x = x->left;
    else if(key > x->key)
      x = x->right;
  }

  return x == NULL ? 0 : 1;
}

void insert(int key) {
  node *new, **x;

  x = &root;
  while(*x != NULL) {
    if(key < (*x)->key)
      x = &(*x)->left;
    else if(key > (*x)->key)
      x = &(*x)->right;
  }

  new = (node *)malloc(sizeof(node));
  new->left = NULL;
  new->right = NULL;
  new->key = key;
  *x = new;

  return;
}

void inorder(node *current) {
  if(current == NULL)
    return;

  inorder(current->left);
  printf(" %d", current->key);
  inorder(current->right);
}

void preorder(node *current) {
  if(current == NULL)
    return;

  printf(" %d", current->key);
  preorder(current->left);
  preorder(current->right);
}

void print() {
  inorder(root);
  printf("\n");

  preorder(root);
  printf("\n");
}

int main() {
  int i, n, key;
  char command[20];

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%s", command);
    switch(command[0]) {
      case 'i':
        scanf("%d", &key);
        insert(key);
        break;
      case 'p':
        print();
        break;
      case 'f':
        scanf("%d", &key);
        find(key) ? printf("yes\n") : printf("no\n");
        break;
    }
  }

  return 0;
}



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

int main() {
  int n,m;
  
  cin >> n >> m;

  int a,b;
  int sum = 0;

  vector<long long> h(n);
  vector<int> flag(100000,1);


  rep(i,n){
    cin >> h.at(i);
  }

  //vector<pair<int,int>> road(m);

  rep(i,m){
    cin >> a >> b;
    //flag.at(a-1) = 0;
    //flag.at(b-1) = 0;
    if(h.at(a-1)>=h.at(b-1)){
      flag.at(b-1) = 0;
      //h.at(b-1) = 0;
    }
    
    if(h.at(a-1)<=h.at(b-1)){
      flag.at(a-1) = 0;
      //h.at(a-1) = 0;

    }
  }

  rep(i,n){
    if(flag.at(i)==1)
    sum+=1;
  }

  // rep(i,n){
  //   cout << flag.at(i);
  // }

  cout << sum;




}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long ;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int N, vector<int> const &t, vector<int> const &x, vector<int> const &y, bool &flg){

    int t_dif{}, x_dif{}, y_dif{}, thr{};
    for(int i = 0; i != N; ++i){
        t_dif = t.at(i+1) - t.at(i);
        x_dif = abs(x.at(i+1) - x.at(i));
        y_dif = abs(y.at(i+1) - y.at(i));
        thr = t_dif - (x_dif + y_dif);

        if(thr < 0){
            flg = false;
            break;
        }
        else if(thr%2 != 0){
            flg = false;
            break;
        }
    }

    return;
}

int main(){

    int N;
    cin >> N;
    vector<int> t(N+1);
    vector<int> x(N+1);
    vector<int> y(N+1);
    for(int i = 1; i != N+1; ++i) cin >> t.at(i) >> x.at(i) >> y.at(i);

    bool flg = true;
    solver(N, t, x, y, flg);

    if(flg) cout << "Yes"s << endl;
    else cout << "No"s << endl;

    return 0;
}

Measured memory_bytes: 4060
package main

import (
	"fmt"
	"strings"
)

func main() {
	N := 0
	S := ""
	fmt.Scan(&N, &S)
	ans := S
	remaining := 0
	for i := 0; i < N; i++ {
		if S[i] == '(' {
			remaining++
		} else {
			if remaining > 0 {
				remaining--
			} else {
				ans = "(" + ans
			}
		}
	}
	ans += strings.Repeat(")", remaining)
	fmt.Println(ans)
}


Measured memory_bytes: 1844
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			int t = cin.nextInt();
			if(t==0)break;
			int n = cin.nextInt();
			int sum=0;
			for(int i = 0;i<n;i++){
				int s=cin.nextInt();
				int f=cin.nextInt();
				sum+=f-s;
			}
			if(sum>=t){
				System.out.println("OK");
			}
			else{
				System.out.println(t-sum);
			}
			
		}
		

	}

}

Measured memory_bytes: 13000
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N, K = LI()

if N == K:
    print(0)
elif N > K:
    a1 = N % K
    print(min(a1, abs(K-a1)))
else:
    print(min(N, abs(K-N)))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
string s;
map<string,string>mp;
int main()
{
	mp["Sunny"]="Cloudy";
	mp["Cloudy"]="Rainy";
	mp["Rainy"]="Sunny";
	cin>>s;
	cout<<mp[s]<<"\n";
	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);
  string s; cin >> s;
  int x = stoi(s.substr(0, 2));
  bool b = 1 <= x and x <= 12;
  x = stoi(s.substr(2, 2));
  bool c = 1 <= x and x <= 12;
  if (b and c) cout << "AMBIGUOUS" << '\n';
  else if (b) cout << "MMYY" << '\n';
  else if (c) cout << "YYMM" << '\n';
  else cout << "NA" << '\n';
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string N;
	cin>>N;
    string ans = "No";
    rep(i,N.size()){
        if(N[i]=='7'){
            ans = "Yes";
        }
    }
    cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var s = sc.intarr;
        int a = s[0];
        int b = s[1];
        int c = s[2];
        int x = s[3];
        int y = s[4];

        int ans1 = a * x + b * y;
        int ans2 = 2 * c * Math.Min(x, y);
        int ans3;
        if (x < y)
        {
            ans3 = (y - x) * Math.Min(2 * c, b);
        }
        else
        {
            ans3 = (x - y) * Math.Min(2 * c, a);
        }
        ans3 += ans2;
        wr.wri(Math.Min(ans1, ans3));
    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

class Main {
  public static void main(String[] args){ 
  Scanner scan = new Scanner(System.in);
  String[] input = scan.nextLine().split(" ");
  int a = Integer.parseInt(input[0]);
  int b = Integer.parseInt(input[1]);
  int c = Integer.parseInt(input[2]);
  int k = Integer.parseInt(input[3]);
   int out = 0;
   if((k>=a)){
   for(int i = a; i > 0; i--){
   out+=1;
   
   }
   
   for(int i = k-a-b; i > 0; i--){
   out+=-1;
   
   }
   } else {
   out = 1*k;
   }
   System.out.println(out);
  }


}

Measured memory_bytes: 27008
#include<iostream>
#include<algorithm>

using namespace std;

void display(int array[], int N);
int selectionSort(int array[],int N);

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int n  = selectionSort(A,N);
  display(A,N);
  cout << n << endl;
  return 0;
}

int selectionSort(int array[],int N){
  int n = 0;
  for(int i=0;i<N;i++){
    int min = 100;
    int index = i;
    for(int j=i;j<N;j++){
      if(array[j]<array[index]) index = j;
    }
    if(i != index){
      swap(array[i],array[index]);
      //display(array,N);
      n++;
    }
  }
return n;
}


void display(int array[], int N){
  for(int i=0;i<N;i++){
    if(i>0) cout << " ";
    cout << array[i];
  }
  cout << endl;
}

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

int prime(int n){
  long long cnt=0;
  bool f[n+1];
  for(int i=0;i<=n;i++){
    f[i]=true;
  }
  f[0]=f[1]=false;
  for(int i=2;i<=n;i++){
    if(f[i]){
      cnt++;
      for(int j=2*i;j<=n;j+=i){
        f[j]=false;
      }
    }
  }
  return cnt;
}

int main(){
  long long n;
  while(cin >> n){
    cout << prime(n) << endl;
  }
  return 0;
}



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

int bubbleSort(int *array, int N) {
    int sortCount=0;
    bool flag = 1;
    while (flag) {
        flag = 0;
        for (int i=N-1; i>0; i--) {
            if (array[i] < array[i-1]) {
                int tmp = array[i];
                array[i] = array[i-1];
                array[i-1] = tmp;
                flag = 1;
                sortCount++;
            }
        }
    }
    
    /*
    for (int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
            if (array[i] > array[j]) {
                int tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
                sortCount++;
            }
        }
    }
     */
    return sortCount;
}

int main(int argc, const char * argv[]) {
    int N, array[100], sortCount=0;
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> array[i];
    }
    sortCount = bubbleSort(array, N);
    for (int i=0; i<N; i++) {
        cout << array[i];
        if (i == N-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    cout << sortCount << endl;
    
    return 0;
}


Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll a;  ld b;
	cin >> a >> b;
	ll x = b * 100 + eps;
	cout << a * x / 100 << '\n';
}

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

ll cost[(2 << 12) + 1 ];
ll dp[(2 << 12) + 1 ];

int main() {
  int N,M;
  cin >> N >> M;
  REP(i, 2<<(N-1)) dp[i] = 10000000000;
  REP(i, 2<<(N-1)) cost[i] = 10000000000;
  REP(i,M) {
    ll a,b;
    cin >> a >> b;
    int cmask = 0;
    REP(j,b) {
      int c;
      cin >> c;
      cmask |= (1 << (c-1));
    }
    cost[cmask] = min( cost[cmask], a );
  }
//  REP(i, 2<<(N-1)) cout << i << " : cost " << cost[i] << endl;
  dp[0] = 0;
  REP(i, 2<<(N-1)) REP(j, 2<<(N-1)) {
    dp[i|j] = min( dp[i|j], dp[i] + cost[j]);
//    cout << i << " " << j << " : " << dp[i|j] << endl;
  }

  ll ans = (dp[(2<<(N-1))-1] == 10000000000) ? -1 : dp[(2<<(N-1))-1];
  cout << ans << endl;
}


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

#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long int

int main()
{
    ios::sync_with_stdio(0);// Input and output clearance
    cin.tie(0);
    ll n;
    cin>>n;
    int tem=0,cnt=0;
    f(i,1,n)
    {
        if(n%i==0)
        {
            tem--;
        }
        tem+=n/i;
    }
    cout<<tem;
}

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


int main(){
  	int N;
  cin >> N;
  int p[N];
  int up[N];
  for (int i=0;i<N;i++){
    	cin >> p[i];
    	up[i]=i+1;
  }
  int f=0;
  for (int i=0;i<N;i++){
  	if (up[i]!=p[i]) f++;
  }
  if (f==0 || f==2)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;
}

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

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int j =0;
    rreps(i,  min(a,b)){
        if(a % i == 0 && b % i == 0){
            j++;
        }
        if(k == j){
            cout << i << endl;
            return 0;
        }
    }
}



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

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

for i in range(n-1):
  for j in range(i, n):
    k = j + (j - i)
    if k >= n:
      break
    else:
      if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
        ans -= 1
print(ans)



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

int main(){
	int n, x, i, j, k, s;
	
	while(1){
		cin >> n >> x;
		
		if(n == 0 && x == 0){
			break;
		}
		
		s = 0;
		for(i = 1; i <= n - 2; i++){
			for(j = i + 1; j <= n - 1; j++){
				for(k = j + 1; k <= n; k++){
					if(i + j + k == x){
					s++;
					}
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
import sys

input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

B = sorted(A, reverse=True)
max = B[0]
next_max = B[1]

for i in range(N):
    if A[i] == max:
        print(next_max)
    else:
        print(max)

Measured memory_bytes: 59344
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;

const ll INF = 1e15;
struct edge { int from, to, cost; };
int V, E;
ll d[1000];
edge es[2000];

ll shortest_path() {
    for (int i = 0; i < V; i++) {
        for (int k = 0; k < E; k++) {
            edge& e = es[k];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    return -d[V-1];
}

int main() {
    scanf("%d %d", &V, &E);
    for (int i = 0; i < E; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        es[i] = {a-1, b-1, -c};
    }
    fill(d, d+1000, INF);
    d[0] = 0;
    ll ans1 = shortest_path();
    ll ans2 = shortest_path();

    if (ans1 == ans2)
        printf("%lld\n", ans1);
    else
        printf("inf\n");
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
bool will_be_in(int i, int n, int q, string &s, vector<char> &t, vector<char> &d) {

    REP(i, q) {
        if (s[i] == t[i]) {
            if (d[i] == 'L') i--; else i++;
            if (i < 0 || n <= i) return false;
        }
    }

    return true;

}

int find_one(int i, int n, int q, string &s, vector<char> &t, vector<char> &d) {

    

}

// 処理内容
int main() {
    
    ll n, q;
    string s;
    cin >> n >> q >> s;

    vector<char> t(q), d(q);
    REP(i, q) {
        cin >> t[i] >> d[i];
    }

    int lend = -1;
    int rend = n;

    for (int i = q; i--; ) {
        if (d[i] == 'L') {
            if (t[i] == s[lend+1]) {
                lend++;
            }
            if (rend < n) if (t[i] == s[rend]) {
                rend++;
            }
        } else {
            if (t[i] == s[rend-1]) {
                rend--;
            }
            if (lend >= 0) if (t[i] == s[lend]) {
                lend--;
            }
        }
    }

    cout << max(0, rend - lend - 1) << endl;
    
}


Measured memory_bytes: 900
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
 
struct Node{
  Node *right;
  Node *left;
  Node *parent;
  int key;
};
 
Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
 
  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y==NIL) root = z;
  else{
      if(z->key < y->key) y->left = z;
      else y->right = z;
  }
}
 
void inorder(Node *u){
  if(u !=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
 
void preorder(Node *u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
 
Node * treeMinimum(Node *x) {
    while( x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k) {
    while( u != NIL && k != u->key ) {
        if(k< u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x) {
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y  = x->parent;
    while(y!=NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *u) {
    Node *y;
    Node *x;

    if(u->left == NIL || u->right == NIL) y = u;
    else y = treeSuccessor(u);
    // y??????x????±???????
    if (y->left != NIL) {
        x = y->left;
    }else {
        x = y->right;
    }

    if(x != NIL) {
        x->parent = y->parent;
    }

    if(y->parent == NIL) {
        root = x;
    } else {
        if( y == y->parent->left ) {
            y->parent->left = x;
        }else {
            y->parent->right = x;
        }
    }

    if(y != u) {
        u->key = y->key;
    }

    free(y);
}
 
 
int main(){
  int n, i, x;
  Node *res;
  char com[20];
 
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0] == 'f') {
      scanf("%d", &x);
      res =find(root, x);
      if(res != NIL){
          printf("yes\n");
      }else {
          printf("no\n");
      }
    }else if(com[0] == 'd') {
        scanf("%d", &x);
        treeDelete(find(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 21960
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        
        	String W = sc.next();
        	W = W.toLowerCase();
            String T;
        	int count = 0;
        
        while(true){
            
            T = sc.next();
            
            if(T.equals("END_OF_TEXT")) break;
            
            T = T.toLowerCase();
            
            if (T.equals(W)) {
                        count++;
                }
        }
                        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 26044
n = int(input())
w = list(map(int, input().split()))
ans = 1000000
for i in range(n - 1):
    s1 = 0
    for j in range(i + 1):
        s1 += w[j]
    s2 = sum(w) - s1
    ans = min(ans, abs(s1 - s2))
print(ans)


Measured memory_bytes: 2940
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	ary := make([]int, n)
	for i := 0; i < n; i++ {
		ary[i] = nextInt(sc)
	}
	trace(ary, n)
	insertionSort(ary, n)
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

func trace(ary []int, n int) {
	s := strconv.Itoa(ary[0])
	for i := 1; i < n; i++ {
		s += " " + strconv.Itoa(ary[i])
	}
	fmt.Println(s)
}

func insertionSort(ary []int, n int) {
	for i := 1; i < n; i++ {
		v := ary[i]
		j := i - 1
		for 0 <= j && v < ary[j] {
			ary[j+1] = ary[j]
			j--
		}
		ary[j+1] = v
		trace(ary, n)
	}
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define REP(i, n, s) for (LL i = (s); i < (n); i++)
#define MOD 1000000007
using namespace std;
typedef long long int LL;
typedef long double LD;

LL _pow(LL a, LL k) {
	LL res = 1;
	while (k) {
		if (k&1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		k >>= 1;
	}
	return res;
}

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

	LL N, K;
	cin >> N >> K;

	map<int, LL> num;
	REP(i, sqrt(N)+1, 1) {
		if (N%i == 0) {
			num[i] = _pow(K, (i+1)/2);
			int j = N / i;
			num[j] = _pow(K, (j+1)/2);
		}
	}
	for (auto p1 : num) {
		for (auto p2 : num) {
			if (p2.first != p1.first && p2.first % p1.first == 0) {
				num[p2.first] -= num[p1.first];
				num[p2.first] = (num[p2.first] + MOD) % MOD;
			}
		}
	}
	LL res = 0;
	for (auto p : num) {
		res = (res + p.second * p.first / (1 + !(p.first&1))) % MOD;
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

string s;
int _, t;
int f;
char c;
stack<tuple<int, bool, char> > q;
int inv = 0;

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

	cin >> s;
	cin >> _;

	for (int i = 0; i < _; i++)
    {
        cin >> t;
        if (t == 1)
        {
            inv++;
        }
        else
        {
            cin >> f >> c;
            q.push(make_tuple(inv, (f == 1), c));
        }
    }

    if (inv % 2 == 1)
        reverse(s.begin(), s.end());

    string left = "";
    string right = "";
    while (!q.empty())
    {
        auto x = q.top();
        q.pop();

        if ((inv - get<0>(x)) % 2 == 1)
            get<1>(x) = !get<1>(x);

        if (get<1>(x) == 1)
            left += get<2>(x);
        else
            right += get<2>(x);
    }

    s = left + s;
    reverse(right.begin(), right.end());
    s += right;

    cout << s;

	return 0;
}


Measured memory_bytes: 2000
N=int(input())
T=[int(i) for i in input().split()]
M=int(input())
k=[]
for i in range(M):
 PX=[int(j) for j in input().split()]
 k.append(sum(T)-T[PX[0]-1]+PX[1])
for i in k:
 print(i)

Measured memory_bytes: 3188
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m, x = na()
ca = [na() for i in range(n)]
ans = 10 ** 10
for i in range(2 ** n):
    a = [0] * m
    ct = 0
    for j in range(n):
        if (i >> j) & 1:
            tmp = ca[j]
            ct += tmp[0]
            for k in range(m):
                a[k] += tmp[k+1]
    if x <= min(a):
        ans = min(ans, ct)
if ans == 10 ** 10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9236
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static bool Solve(int a, int b, int c)
        {
            long n = c - a - b;
            return n >= 0 && Math.BigMul(a, b) * 4 < n * n;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], V[2]) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 5;

LL A[MAXN + 5];

LL N, K;

LL gcd(LL x, LL y)
{
	if(y == 0) return x;
	return gcd(y, x % y);
}

int main()
{
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
	scanf("%lld %lld", &N, &K);
	for(int i = 1; i <= N; i++) scanf("%lld", &A[i]);
	LL ans = A[1];
	for(int i = 1; i <= N; i++) ans = gcd(ans, A[i]);
	bool check = false;
	for(int i = 1; i <= N; i++){
		LL x = A[i];
		if(x >= K && (x - K) % ans == 0) check = true;
	}
	if(check) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,k;cin>>n>>k;k=2*k+1;
  cout<<(n/k)+(n%k?1:0)<<endl;
  //caricurate
  //output
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
inline bool check_min(ll a,ll &b){return a<b?b=a,1:0;}
inline bool check_max(ll a,ll &b){return a>b?b=a,1:0;}
const int N=2010;
ll s[N];
ll x,ans;
int ind[N];
int n,m;
ll calc()
{
	ll ret=m*x;
	for(int i=1;i<=n;i++)
		ret+=s[i];
	return ret;
}
void rot()
{
	for(int i=n;i;i--)
	{
		int p=ind[i],q=ind[i]+1;
		if(q>n)q-=n;
		check_min(s[p],s[q]);
		ind[i]=q;
	}
}
int main()
{
	scanf("%d%lld",&n,&x);
	m=0;
	for(int i=1;i<=n;i++)
		scanf("%lld",s+i),ind[i]=i;
	ans=calc();
	for(;m<=n;m++,rot())
		check_min(calc(),ans);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
while True:
	numlist = list(int(i) for i in input().split())
	mid = numlist[0]
	final = numlist[1]
	retest = numlist[2]

	sum = mid + final

	if mid == -1 and final == -1 and retest == -1:
		break

	if mid == -1 or final == -1:
		print("F")	
	elif sum >= 80:
		print("A")
	elif 80 > sum >= 65:
		print("B")
	elif 65 > sum >= 50:
		print("C")
	elif 50 > sum >= 30 and retest < 50:
		print("D")
	elif 50 > sum >= 30 and retest >= 50:
		print("C")
	elif sum < 30:
		print("F")

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;
LL INF=1e9;

LL dp[105][100005];
int n,w;


LL weights[100], values[100];

LL func(int i, int x)
{
    if(i==n)
        return 0;
    LL & r=dp[i][x];
    if(r!=-1)
        return r;
    LL ans=func(i+1,x);
    if(weights[i]<=x)
        ans=max(ans,values[i]+func(i+1,x-weights[i]));
    return r=ans;
}
void solve()
{
    setneg(dp);
    cin>>n>>w;
    REP(i,0,n-1)
        cin>>weights[i]>>values[i];
    cout<<func(0,w)<<nl;
}
int main()
{
    fast;
        solve();
}


Measured memory_bytes: 82304