akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vi> g(n);
  REP(i, n) {
    int u, k;
    cin >> u >> k;
    u--;
    REP(i, k) {
      int v;
      cin >> v;
      v--;
      g[u].push_back(v);
    }
  }

  queue<pair<int, int>> q;
  vi ans(n, -1);
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    if (ans[p.first] != -1)
      continue;
    ans[p.first] = p.second;
    for (auto v : g[p.first]) {
      q.push(make_pair(v, ans[p.first] + 1));
    }
  }

  REP(i, n) { cout << i + 1 << " " << ans[i] << endl; }

  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	int n=s.size();
	int sum=0;
	for(int i=0;i<n;i++){
	    if(s[i]=='0'){
	        sum++;
	    }
	}
	cout<<2*min(sum,n-sum)<<endl;
}

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

using namespace std;

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

int main(){
    string s;
    cin >> s;
    int num[100005]={0};
    int Rf, Lf;
    int i;
    for(i = 0; i < s.size()-1; i++){
        if(s[i]=='R' && s[i+1]=='L'){
            Lf = i+1;
        }
        if(i == s.size()-2)i++;
        if((s[i]=='L' && s[i+1]=='R') || i == s.size()-1){
            num[Lf-1] = (Lf-Rf+1)/2+(i-Lf+1)/2;
            num[Lf] = (i-Rf+1)-num[Lf-1];
            Rf = i+1;
        }
    }

    for(int i = 0; i < s.size(); i++){
        cout << num[i] << ' ';
    }
    cout << endl;
    return 0;
}

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

int main() {
	int N; cin >> N;
	vector<int> A(N);
	ll S=0;
	REP (i,N){
		cin >> A.at(i);
		S+=A.at(i);
	}

	REP (i,N-1) {
		if (A.at(i+1)<A.at(i)) A.at(i+1)=A.at(i);
	}
	ll _S=0;
	REP(i,N){
		_S+=A.at(i);
	}
	cout << (_S-S) << endl;
	return 0;
}


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

int main()
{
  int N;cin>>N;
  set<string> st;
  for (int i=0;i<N;i++)
  {
    string s;cin>>s;
    st.insert(s);
  }
  
  cout<<st.size()<<endl;
}

Measured memory_bytes: 19180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    double ans = 0;
    int n;
    cin >> n;
    pair<int, int> p[8];
    for (int i = 0; i < n;i++){
        cin >> p[i].first >> p[i].second;
    }
    vector<int> nums(n);
    int c = 0;
    iota(nums.begin(), nums.end(), 0);
    do{
        for (int value : nums)
        {
            //cout << value << " ";
        }
        c++;
        //cout << endl;
        for (int i = 0; i < n - 1;i++){
            
            ans += sqrt(pow(abs(p[nums[i]].first - p[nums[i + 1]].first),2) + pow(abs(p[nums[i]].second - p[nums[i + 1]].second),2));
            //cout << ans << endl;
        }
    } while (next_permutation(nums.begin(), nums.end()));
    cout << fixed << setprecision(15) << ans / c;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
P=list(map(int,input().split()))
sums=[sum(j for j in range(i+1)) for i in range(1001)]
ans=0

for i in range(K):
    ans+=sums[P[i]]/P[i]
tmp=ans

for i in range(K,N):
    l=sums[P[i-K]]/P[i-K]
    r=sums[P[i]]/P[i]
    tmp=tmp-l+r
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 25604
#include<iostream> 
#include<vector> 
#include<string> 
#include<algorithm> 
using namespace std; 
int main()
{
	int n; 
	cin >> n;
	int ans = 0;
	int a = 0;
	int q = -1;
	for (int i = 1; i <=n; i++)
	{ 
		a = i;
		int p = 0;
		for(;;)
		{
			if (a % 2 == 0)
			{
				p++; 
				a = a / 2;
			}
			else
			{
				break;
			}
		}
		if (q<p)
		{
			q = p; 
			ans = i;
		}
	} 
	cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.chomp
a = s[0, 2].to_i
b = s[2, 2].to_i
mmyy = 1 <= a && a <= 12
yymm = 1 <= b && b <= 12

if mmyy && yymm
  puts 'AMBIGUOUS'
elsif mmyy
  puts 'MMYY'
elsif yymm
  puts 'YYMM'
else
  puts 'NA'
end

Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>


int descending_compare(const void *a, const void *b) {
	if (*(int*)a > *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

int ascending_compare(const void *a, const void *b) {
	if (*(int*)a < *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y) {
	if (y == 0) {
		return x;
	}
	else if (x > y) {
		return gcd(y, x % y);
	}
	else {
		return gcd(x, y % x);
	}
}



long long factorial(int x) {
	long long rtn = 1;
	int i;
	for (i = x; i > 1; i--) {
		rtn = (rtn*i);
	}
	return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

int main(void) {
	int n;
	char s[105];
	char t[105];
	scanf("%d", &n);
	scanf("%s", s);
	scanf("%s", t);
	int len = strlen(s);
	int match = len;
	for (int i = 0; i < len; i++)
	{
		int flag = 1;
		for (int j = 0; j < len - i; j++)
		{
			if (s[i + j] != t[j]) {
				flag = 0;
			}
		}
		if (flag == 1)
		{
			match = i;
            break;
		}
	}
	int tlen = strlen(t);
	printf("%d\n", match + tlen);
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
from collections import Counter
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    c=Counter(a)
    ans=n
    cnt_two=0
    for key in c.keys():
        if c[key]>=3:
            if c[key]%2==1:
                ans-=c[key]-1
                c[key]=1
            else:
                ans-=c[key]-2
                c[key]=2
                cnt_two+=1
        elif c[key]==2:
            cnt_two+=1

    if cnt_two%2==0:
        ans-=cnt_two
    else:
        ans-=cnt_two-1
        ans-=2

    print(ans)

if __name__=="__main__":
    main()

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

using namespace std;

int main()
{
    while (true) {
        int n, k, s;
        cin >> n >> k >> s;
        if (n == 0 && k == 0 && s == 0) {
            break;
        }

        // n 個から k 個選ぶためのビットマスク
        vector<bool> bitMask(n);
        for (int i = 0; i < k; ++i) {
            bitMask[i] = true;
        }
        sort(begin(bitMask), end(bitMask));
        int count = 0;
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                // 組み合わせに選ばれた値
                if (bitMask[i]) {
                    // 0からなので1ずらす
                    sum += i + 1;
                }
            }
            if (sum == s) {
                count += 1;
            }
        // 次のマスクを求める
        } while (next_permutation(begin(bitMask), end(bitMask)));
        cout << count << endl;
    }
}


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

int main() {
    ll n;
    cin >> n;
    int d = 0;
    ll last_sum = 0;
    for (int i = 1; i <= 11; i++) {
        last_sum += pow(26, i);
        if (last_sum + 1 <= n) {
            d = i;
        } else {
            last_sum -= pow(26, i);
            break;
        }
    }
    ll k = n - last_sum;

    string name = "";
    ll index_sub = k - 1;
    for (int i = 0; i < d + 1; i++) {
        ll q = index_sub / 26;
        ll r = index_sub % 26;
        index_sub = q;
        name += r + 'a';
    }

    reverse(name.begin(), name.end());
    cout << name;
    return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k, x, min, max;
    cin >> k >> x;
    
    min = x - (k - 1);
    max = x + (k - 1);
    
    for (int i = min; i <= max; i++ ) {
        cout << i << " ";
    }
    
}


Measured memory_bytes: 256
import itertools as it
a = int(input())
l = tuple(list(map(int,input().split())))
L = tuple(list(map(int,input().split())))
# print(l)
t = range(1,a+1)
T = list(it.permutations(t))
# print(T)
ans = abs (T.index(l)-T.index(L) )
print(ans)

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

class humberger {
  public: 
  vector<long long int> size;
  vector<long long int> pattySize;
  void init() {
    size.resize(51);
    pattySize.resize(51);
    size[0] = 1;
    pattySize[0] = 1;
    for(int i=1;i<51;i++) {
      size[i] = size[i-1] * 2 + 3;
      pattySize[i] = pattySize[i-1] * 2 + 1;
    }
  }
  long long int patty (int level, long long int x) {
    if(level == 0) return (x == 0 ? 0LL : 1LL);
    else {
      if(x == 0 || x == 1) return 0;
      else if(x <= size[level-1] + 1) return patty(level-1, x-1);
      else if(x == size[level-1] + 2) return pattySize[level-1] + 1;
      else if(x <= 2 * size[level-1] + 2) return pattySize[level-1] + 1 + patty(level-1, x - size[level-1] - 2);
      else return 2 * pattySize[level-1] + 1;
    }
  }
};

int main() {
  int N;
  long long int X;
  cin >> N >> X;

  humberger a;
  a.init();

  cout << a.patty(N, X) << endl;
}

Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve(t, R, S, P):
    n = len(t)
    m = [[0] * 3 for i in range(n)]
    m[0][0] = R if t[0] == 's' else 0
    m[0][1] = S if t[0] == 'p' else 0
    m[0][2] = P if t[0] == 'r' else 0

    for i in range(1, n):
      m[i][0] = max(m[i-1][1], m[i-1][2])
      m[i][0] += R if t[i] == 's' else 0
      m[i][1] = max(m[i-1][0], m[i-1][2])
      m[i][1] += S if t[i] == 'p' else 0
      m[i][2] = max(m[i-1][0], m[i-1][1])
      m[i][2] += P if t[i] == 'r' else 0

    return max([m[n-1][0], m[n-1][1], m[n-1][2]])


def main():
    N, K = read_int_list()
    R, S, P = read_int_list()
    T = read_str()

    res = 0
    for i in range(K):
      res += solve(T[i::K], R, S, P)
    
    print(res)


main()


Measured memory_bytes: 23252
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int num = 1;
        while (true)
        {
            if(num * num > N)
            {
                Console.WriteLine((num - 1) * (num - 1));
                break;
            }
            num++;
        }
    }
}


Measured memory_bytes: 11220
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    for i in range(2, int(sqrt(num))+1):
        while num % i == 0:
            num //= i
            d[i] += 1
        if num == 1:
            break
    if num != 1:
        d[num] += 1
    return d

def extgcd(a, b, x, y):
    """ 拡張ユークリッドの互除法(ax+by=gcd(a, b)の解を求める) """

    if b == 0:
        x = 1
        y = 0
        return (y, x)
    else:
        x, y = extgcd(b, a%b, y, x)
        y -= a // b * x
        return (y, x)

N = INT()

fact = list(factorize(N*2).items())
M = len(fact)

ans = N
for bit in range(1<<M):
    a = b = 1
    for i in range(M):
        if (bit>>i) & 1:
            a *= fact[i][0] ** fact[i][1]
        else:
            b *= fact[i][0] ** fact[i][1]
    y, x = extgcd(a, b, 0, 0)
    if x == 0 or y == 0:
        continue
    res = min(a*abs(x), b*abs(y))
    ans = min(ans, res)
print(ans)


Measured memory_bytes: 71696
#include<stdio.h>
#include<string.h>
int main(void){
   int A,B,C,a;
   scanf("%d %d %d",&A,&B,&C);
   a=A-B;
   if(a>=C){
      printf("0");
   }else{
      printf("%d",C-a);
   }
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int > P(M+5), Y(M+5);
  std::vector<int > year[100005];
  for (int i=0; i<M; i++){
    scanf("%d", &P[i]);
    scanf("%d", &Y[i]);
    year[P[i]].push_back(Y[i]);
  }
  for (int i=0; i<N+5; i++){
    std::sort(year[i].begin(), year[i].end());
  }
  /*  for (int i=0; i<year[1].size(); i++){
    printf("%d = %d\n",i,year[1][i]);
    }*/
  for (int i=0; i<M; i++){
    //std::cout << std::lower_bound(year[P[i]].begin(), year[P[i]].end(), Y[i]) - year[P[i]].begin() << std::endl;
    int order = int(std::lower_bound(year[P[i]].begin(), year[P[i]].end(), Y[i]) - year[P[i]].begin());
    printf("%06d%06d\n",P[i], order+1);
  }
  return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string b;
  cin >> b;
  
  if(b=="A"){
    cout << "T" << endl;
  }else if(b=="T"){
    cout << "A" << endl;
  }else if(b=="C"){
    cout << "G" << endl;
  }else{
    cout << "C" << endl;
  }
}

Measured memory_bytes: 256
S = input().strip()
K = int(input().strip())

# 全部同じ文字
before = S[0]
check = False
for s in S:
    if s != before:
        check = True

if not(check):
    x = len(S)*K
    print(x//2)

elif S[0] == S[len(S)-1]:
    before = ""
    cnt = 0
    x = 0
    head_size = 0
    tail_size = 0
    head = S[0]
    for s in S:
        if head == s:
            head_size += 1
        else:
            break

    for s in S[head_size:]:
        if before == s:
            cnt+=1
        else:
            x += (cnt//2)
            cnt = 1
            before = s
    tail_size = cnt
    x += ((head_size + tail_size)//2)
    ans = K * x

    # 先頭数えてない分
    ans += (head_size//2)

    # 最後数えすぎ分を減らす
    ans -= ((head_size + tail_size)//2)
    ans += (tail_size//2)

    print(ans)

else:
    before = ""
    cnt = 0
    x = 0
    for s in S:
        if before == s:
            cnt+=1
        else:
            x += (cnt//2)
            cnt = 1
            before = s
    x += (cnt//2)

    print((K*x))

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(void)
{

	double cnt;
	int N;
	cin >> N;
	
	if(N%2==0)
	{

		cnt=(N/2.0)/N;

	}

	else
	{

		cnt=(((N-1)/2.0)+1)/N;
	}

	printf("%10f\n",cnt); 
	return 0;



}


Measured memory_bytes: 256
lis =[]
for _ in range(3):
  a, b = map(int, input().split())
  lis.append(a)
  lis.append(b)
boo = False
for i in range(1, 5):
  if lis.count(i) >= 3:
    boo = True
if boo:
  print("NO")
else:
  print("YES")

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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;
	int index = 0;

	void run() {
		int N = sc.nextInt();
		while (N-- > 0) {
			index = 0;
			String input = sc.next();
			System.out.println(expression(input.substring(0,
					input.length() - 1)));
		}
	}

	int expression(String sb) {
		int res = term(sb);
		for (; index < sb.length();) {
			if (sb.charAt(index) == '+') {
				index++;
				res += term(sb);
			} else if (sb.charAt(index) == '-') {
				index++;
				res -= term(sb);
			} else {
				break;
			}
		}
		return res;
	}

	int term(String sb) {
		int res = factor(sb);
		for (; index < sb.length();) {
			if (sb.charAt(index) == '*') {
				index++;
				res *= factor(sb);
			} else if (sb.charAt(index) == '/') {
				index++;
				res /= factor(sb);
			} else {
				break;
			}
		}
		return res;
	}

	int factor(String sb) {
		int res = 0;
		if (index < sb.length() && sb.charAt(index) == '(') {
			index++;
			res = expression(sb);
			index++;
		} else {
			res = number(sb);
		}
		return res;
	}

	int number(String sb) {
		int res = 0;
		while (index < sb.length() && Character.isDigit(sb.charAt(index))) {
			res *= 10;
			res += sb.charAt(index) - '0';
			index++;
		}
		return res;
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 17304
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;


int main() {
  long n, m;
  scanf("%ld %ld", &n, &m);

  long ans;
  if(n==1 && m==1) ans = 1;
  else if(n==1) ans = m-2;
  else if(m==1) ans = n-2;
  else ans = (m-2)*(n-2);

  printf("%ld\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct Item {
	int w;
	int s;
	int v;
	bool operator<(const Item &right) const {
		//return w + s < right.w + right.s;
		return w + s < right.w + right.s;
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<Item> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i].w >> A[i].s >> A[i].v;
	}
	sort(A.begin(), A.end());
	int INF = (int)1 << 60;
	vector<vector<int> > dp(N + 1, vector<int>(10001, -INF));
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		dp[i + 1] = dp[i];
		for (int j = 0; j <= A[i].s; j++) {
			if (j + A[i].w <= 10000) {
				dp[i + 1][j + A[i].w] = max(dp[i + 1][j + A[i].w], dp[i][j] + A[i].v);
			}
			res = max(res, dp[i][j] + A[i].v);
		}
		
	}

	cout << res << endl;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 AB,BC,CA;
    cin >> AB >> BC >> CA;
    cout << AB*BC/2 << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import copy
from collections import deque
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for k in range(K+1): #0-K
  for left in range(N+1): #0-N
    for right in range(N-left+1):
      push = k - (left + right)
      if push < 0 or push > left+right:
        continue
      Acopy = copy.copy(A)
      Acopy = deque(Acopy)
      B = []
      for t in range(left):
        temp = Acopy.popleft()
        B.append(temp)
      for t in range(right):
        #print(left,right)
        temp = Acopy.pop()
        B.append(temp)
      B.sort()
      wa = sum(B)-sum(B[:push])
      ans = max(ans,wa)
print(ans)


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

using namespace std;

int main()
{
  long long n, k;
  cin >> n >> k;
  map<int, long long> m;
  for (int i = 0; i < n; i++)
  {
    int a, b;
    cin >> a >> b;
    m[a] += b;
  }
  for (pair<int, long long> t : m)
  {
    cerr << t.first << " " << t.second << endl;
    if (k <= t.second)
    {
      cout << t.first << endl;
      return 0;
    }
    k -= t.second;
  }

  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

string s;

int main(){

    cin >> s;

    for(int i = 0; i < s.length(); i++){
        cout << 'x';
    }










}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 256
// Problem : C - Traveling Salesman around Lake
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	int a[N];
	void main()
	{
		int k=qread(),n=qread(),ans=INF;fo(i,0,n-1) a[i]=qread();
		fo(i,0,n-2) chmin(ans, k-(a[(i+1)]-a[i]) );chmin(ans,a[n-1]-a[0]);write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	// freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	//debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

constexpr ll MOD = 1e9 + 7;

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    auto sieve = [](ll n) -> vll {
        str flg = str(n + 1, '1');
        for (ll i = 2; i * i <= n; i++) if (flg[i] ^ '0')
            for (ll j = i * i; j <= n; j += i)
                flg[j] = '0';

        vll res;
        for (ll i = 2; i <= n; i++)
            if (flg[i] ^ '0') res.push_back(i);

        return res;
    };

    auto legendre = [&](ll n, ll p) -> ll {
        ll res = 0;
        for (ll i = p; i <= n; i *= p)
            res += n / i;

        return res;
    };

    ll ans = 1;
    for (ll p : sieve(n))
        (ans *= legendre(n, p) + 1) %= MOD;

    std::cout << ans << '\n';
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000005;
char s[maxn];
int sum=0;
struct bigint{
	int a[maxn],n;
	inline void input(){
		scanf("%s",s);
		n=strlen(s);
		reverse(s,s+n);--n;
		rep(i,0,n)a[i]=s[i]-'0';
	}
	inline void digit_sum(){
		sum=0;
		rep(i,0,n)sum+=a[i];
	}
	inline void operator *=(int d){
		int c=0;
		for(int i=0;i<=n||c;++i){
			c=(a[i]=a[i]*d+c)/10;
			a[i]%=10;
			n=max(n,i);
		}
	}
	inline void operator +=(int c){
		for(int i=0;c;++i){
			sum-=a[i];
			c=(a[i]+=c)/10;
			a[i]%=10;
			sum+=a[i];
			n=max(n,i);
		}
	}
}myt;
int main(){
	myt.input();
	myt*=9;
	myt.digit_sum();
	rep(k,1,1000000){
		myt+=9;
		if(9*k>=sum){
			cout<<k<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int n;
	cin >> n;
	pair<int, int> red[n], blue[n];
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		red[i] = make_pair(b, a);
	}

	rep(i, 0, n) {
		int c, d;
		cin >> c >> d;
		blue[i] = make_pair(c, d);
	}

	sort(red, red + n);
	reverse(red, red + n);
	sort(blue, blue + n);

	int cnt = 0;
	bool used_red[n], used_blue[n];
	memset(used_red, false, sizeof(used_red));
	memset(used_blue, false, sizeof(used_blue));
	rep(i, 0, n) rep(j, 0, n) {
		if(red[i].first < blue[j].second and red[i].second < blue[j].first and used_blue[j] == false and used_red[i] == false) {
			cnt++;
			used_red[i] = true;
			used_blue[j] = true;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, m;
vector<int> g[1010], gr[1010];
bool used[1010];
int cmp[1010];
vector<int> vs;
void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
	vs.push_back(x);
}
void rdfs(int v, int k){
	used[v]=1;
	cmp[v]=k;
	for(auto y:gr[v]){
		if(!used[y]) rdfs(y, k);
	}
}
int scc(){
	fill(used, used+n, 0);
	vs.clear();
	for(int i=0; i<n; i++){
		if(!used[i]) dfs(i);
	}
	fill(used, used+n, 0);
	int k=0;
	for(int i=vs.size()-1; i>=0; i--){
		if(!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
int main()
{
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int a, b; cin>>a>>b; a--; b--;
		g[a].push_back(b);
		gr[b].push_back(a);
	}
	int k=scc();
	if(k==n) cout<<-1<<endl;
	else cout<<0<<endl;
	return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

int w, h, x, y;

void hawawa()
{
	cin >> w >> h >> x >> y;
	if (x == 0) x = w;
	if (y == 0) y = h;
	double size = (double)w * h;
	double ans = 0, sm = 0, big = w;
	int check = (x * 2 == w && y * 2 == h);
	cout << fixed << setprecision(10) << size / 2 << " " << check << "\n";
}


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


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int counter = 0;
  int res = 0;

  for (int i = 0; i < n; i++)
  {
    if(s[i] == 'I') counter++;
    else counter--;
    res = max(res, counter);
  }
  cout << res << endl;

}


Measured memory_bytes: 256
function Main(input) {
	var a = parseInt(input.split(" ")[0], 10);
	var b = parseInt(input.split(" ")[1], 10);
	var c = parseInt(input.split(" ")[2], 10);

	console.log((a === b && b === c) ? 'Yes' : 'No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n;
    cin >> n;
    vector<int> r(n);
    for(auto& i : r) cin >> i;
    int maxv = -INT_MAX;
    int minv = r.at(0);
    for(int i = 1; i < n; i++){
        maxv = max(maxv, r.at(i)-minv);
        minv = min(minv, r.at(i));
    }
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int w, n, b, c, p;
	int a[31];

	cin >> w >> n;

	for (int i = 1; i <= w; i++){
		a[i] = i + 1;
	}
	
	for (int i = 1; i <= n; i++){
		scanf("%d,%d", &b, &c);
		p = a[b];
		a[b] = a[c];
		a[c] = p;
	}

	for (int i = 1; i <= w; i++){
		printf("%d\n", a[i] - 1);
	}
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define DAU  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
set<int> poz[30];
int n, op, x, y, res;
char ch;
string s;
int main() {
    DAU
    cin >> n >> s;
    for (int i = 0; i < n; ++i)
        poz[s[i] - 'a'].emplace(i);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> op >> x;
        --x;
        if (op == 1) {
            cin >> ch;
            poz[s[x]-'a'].erase(x);
            poz[ch-'a'].emplace(x);
            s[x] = ch;
        }
        else {
            cin >> y;
            res = 0;
            for (int i = 0; i < 26; ++i)
                res += (poz[i].lower_bound(x) != poz[i].lower_bound(y) && !poz[i].empty());
            cout << res << '\n';
        }
    }
    PLEC
}

Measured memory_bytes: 24220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h=0,w=0;
        while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0)
        {
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 65904
#include <bits/stdc++.h>
#define ll int
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define inf 1000000007
#define fi first
#define se second
using namespace std;
 
const ll n6=1e6+10;
const ll n5=1e5+10;

ll a[200010];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll i,j,k,t,x,y,n,p,q,m,f,tt,l,r;
	string s,ls,rs;
	cin>>n;
	FOR(i,1,n) cin>>a[i];
	if(n&1){
		m=n;
		cout<<a[m];
		m-=2;
		while(m>0){
			cout<<" "<<a[m];
			m-=2;
		}
		m=2;
		while(m<=n){
			cout<<" "<<a[m];
			m+=2;
		}
		cout<<endl;
	}
	else{
		m=n;
		cout<<a[m];
		m-=2;
		while(m>0){
			cout<<" "<<a[m];
			m-=2;
		}
		m=1;
		while(m<n){
			cout<<" "<<a[m];
			m+=2;
		}
		cout<<endl;
	}
 	return 0;
}  

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x = 1;
		for(int i = 1;i <= N; i++){
			x = (int)(x*i%(Math.pow(10,9)+7));
			if(x==0){
				System.out.println(i);
				break;
			}
		}
		System.out.print(x);
	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<ll> x,y;
    vector<ll> x1in(n),y1in(n),x2in(n),y2in(n);
    rep(i,n){
        cin >> x1in[i] >> y1in[i] >> x2in[i] >> y2in[i];
        x.pb(x1in[i]); x.pb(x2in[i]);
        y.pb(y1in[i]); y.pb(y2in[i]);
    }
    sort(ALL(x)); sort(ALL(y));
    x.erase(unique(ALL(x)),x.end());
    y.erase(unique(ALL(y)),y.end());
    vector<ll> low[4040],high[4040];
    rep(i,n){
        x1in[i]=(int)(lower_bound(ALL(x),x1in[i])-x.begin());
        x2in[i]=(int)(lower_bound(ALL(x),x2in[i])-x.begin());
        y1in[i]=(int)(lower_bound(ALL(y),y1in[i])-y.begin());
        y2in[i]=(int)(lower_bound(ALL(y),y2in[i])-y.begin());
        low[y1in[i]].pb(x1in[i]);
        low[y1in[i]].pb(x2in[i]);
        high[y2in[i]].pb(x1in[i]);
        high[y2in[i]].pb(x2in[i]);
    }
    ll ans=0;
    vector<ll> imos(4040,0);
    rep(i,y.size()-1){
        for(int j=0;j<low[i].size();j+=2){
            for(int k=low[i][j];k<low[i][j+1];k++){
                imos[k]--;
            }
        }
        for(int j=0;j<high[i].size();j+=2){
            for(int k=high[i][j];k<high[i][j+1];k++){
                imos[k]++;
            }
        }
        rep(j,x.size()-1){
            if(imos[j]!=0){
                ans+=(y[i+1]-y[i])*(x[j+1]-x[j]);
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3500
exist :: Int -> Bool
exist n
 | n < 4  = False 
 | n `mod` 4 == 0 || n `mod` 7 == 0  = True
 | otherwise  = exist (n-4) || exist (n-7)

main = putStrLn =<< (\b -> if b then "Yes" else "No").exist.read <$> getLine

Measured memory_bytes: 508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, k;
int A[100010];

int gc(int x, int y){return y?gc(y,x%y):x;}

void solve(){
	scanf("%d%d", &n, &k);
	for(int i=1;i<=n;i++) scanf("%d", A+i);
	int g = 0;
	for(int i=1;i<=n;i++) g = gc(g, A[i]);
	if(k % g != 0) puts("IMPOSSIBLE");
	else if(k > *max_element(A+1, A+n)) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
}

int main(){
	int T = 1; // scanf("%d", &T);
	while(T--) {
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 764
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int N,K;
        int[] rousoku;
        N = int.Parse(words[0]);
        K = int.Parse(words[1]);

        rousoku = new int[N];
        line = Console.ReadLine();
        words = line.Split(' ');
        for (int i = 0; i < N; i++)
        {
            rousoku[i] = int.Parse(words[i]);
        }
        int min = 2000000000;
        int kouho = 0;
        int x1, x2;
        if (K == 1)
        {
            for (int i = 0; i < N; i++)
            {
                kouho = Math.Abs(rousoku[i]);
                if (min > kouho)
                {
                    min = kouho;
                }
            }
        }
        else
        {
            for(int i = 0; i < N-K+1; i++)
            {
                x1 = Math.Abs(rousoku[i]);
                x2 = Math.Abs(rousoku[i + K - 1]);
                if (rousoku[i] < 0 && rousoku[i + K - 1] < 0)
                {
                    kouho = x1;
                }
                else if (rousoku[i] >= 0 && rousoku[i + K - 1] >= 0)
                {
                    kouho = x2;
                }
                else
                {
                    if (x1 > x2)
                    {
                        kouho = x1 + x2 * 2;
                    }
                    else
                    {
                        kouho = x1 * 2 + x2;
                    }
                }

                if (min > kouho)
                {
                    min = kouho;
                }
            }
        }
        Console.WriteLine(min);

    }
}

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

using namespace std;

#define int long long

int divisor(int n){
	int cnt = 1;
	int ok = false;
	while(n%2 == 0){
		if(!ok){
			ok = true;
			cnt++;
		}
		n/=2;
	}
	
	for(int i = 3; i*i <= n; i+=2){
		ok = false;
		while(n%i == 0){
			if(!ok){
				ok = true;
				cnt++;
			}
			n/=i;
		}
	}
	
	if(n > 2) cnt++;
	
	return cnt;
}

signed main(){
    int a,b; cin>>a>>b;
    int n = __gcd(a, b);
    cout<<divisor(n)<<"\n";
	return 0;
}

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

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

    vector<int> a(q+1);
    for(int i=1; i<=q; i++){
        cin >> a[i];
    }

    vector<int> times(n+1,0);
    for(int i=1; i<=q; i++){
        times[a[i]] += 1;
    }

    for(int i=1; i<=n; i++){
        if(k - (q - times[i]) > 0) cout << "Yes" << endl;
        if(k - (q - times[i]) <= 0) cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

int n, k, s;

int solve(int n, int k, int s)
{
	if (s < 0) return 0;
	if (n < 0) return 0;
	if (k == 0)
	{
		if (s == 0) return 1;
		else return 0;
	}
	return solve(n - 1, k - 1, s - n) + solve(n - 1, k, s);

}

int main()
{
	while (cin >> n >> k >> s, n)
	{
		cout << solve(n, k, s) << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w; cin >> h >> w;
	int n; cin >> n;
	
	VE a(n);
	rep(i, n) {
		cin >> a[i];
	}
	vector<int>ans;
	rep(i, n) {
		rep(j, a[i]) {
			ans.push_back(i + 1);
		}
	}
	int now = 0;
	vector<vector<int>>field(h, vector<int>(w));
	rep(i, h) {
		if (i % 2 == 0) {
			rep(j, w) {
				field[i][j] = ans[now];
				now++;
			}
		}
		else {
			rep(j, w) {
				field[i][w-j-1] = ans[now];
				now++;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << field[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
	
	vector<int> num(5, 0);
	for (int i = 0; i < 3; i++) {
		int a, b; cin >> a >> b;
		num[a]++;
		num[b]++;
	}
	string ans = "YES";
	for (int i = 1; i <= 4; i++) {
		if (num[i] == 0) ans = "NO";
		if (num[i] == 3) ans = "NO";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		int n = in.nextInt();
		
		int res = 0;
		for (int i=1; i<=n; i++)
			res += i;
		
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
        System.out.println(a * b > c * d ? a * b : c * d);
    }
}

Measured memory_bytes: 23252