akhauriyash/Code-Regression huggingface dataset:
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut l: Vec<i32> = (0..n * 2).map(|_| read()).collect();

    l.sort();
    let mut ans = 0;
    for i in 0..n * 2 {
        if i % 2 == 0 {
            ans += l[i];
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
/*
反省点
二次元配列は大きくしすぎると実行前にエラーが出てしまう。
maxを変数に使うと、max関数が使えないので注意s

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define big 1000000007
vector<vector<ll> > memo(200000, vector<ll>(3));
vector<vector<ll> > done(200000, vector<ll>(3));
vector<vector<ll> > data1(200000, vector<ll>(3));
ll n;
ll dp(int m, int p)
{ //(基本的にpは0,1,2で前の状態をあら合わす。)
    if (m == n)
    {
        return 0;
    }
    if (p != -1)
    {
        if (done[m][p] == 1)
        {
            //    cout <<"dakfa";
            return memo[m][p];
        }
    }
    ll res = -1;
    /*ll count;
    for (int i = 0; i < 3; i++)
    {
        if (i == p)
        {
            continue;
        }
        count = data[m][i] + dp(m + 1, i, data);
        if (res == -1)
        {
            res = count;
        }
        else
        {
            res = max(res, count); //とりあえず
        }
    }*/
    ll res1 = 0, res2 = 0, res3 = 0;
    if (p != 0)
        res1 = dp(m + 1, 0) + data1[m][0];
    if (p != 1)
        res2 = dp(m + 1, 1) + data1[m][1];
    if (p != 2)
        res3 = dp(m + 1, 2) + data1[m][2];
    res = max({res1, res2, res3});
    if (p != -1)
    {
        memo[m][p] = res;
        done[m][p] = 1;
    }

    return res;
}
int main()
{

    cin >> n;
    data1.resize(n);
    rep(i, data1.size()) data1[i].resize(3, 0);
    memo.resize(n);
    rep(i, n) cin >> data1[i][0] >> data1[i][1] >> data1[i][2];
    memo.resize(n);
    done.resize(n);
	rep(i, memo.size()) memo[i].resize(3, 0);memo.resize(n);
	rep(i, memo.size()) done[i].resize(3, 0);
    cout << dp(0, -1) << endl; //前の状態が指定された時の今後の最大値
                               /* rep(i,n){
  rep(j,3){
  cout <<done[i][j];
  
  }
  }*/
}


Measured memory_bytes: 39296
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] antenna = new int[5];
        boolean can = true;
        for(int i = 0; i < 5; i++){
            antenna[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        for(int i = 0; i < 4; i++){
            for(int j = i+1; j < 5; j++){
                int distance = antenna[j]-antenna[i];
                if(distance > k){
                    can = false;
                    break;
                }
            }
        }
        if(can){
            System.out.println("Yay!");
        } else{
            System.out.println(":(");
        }
    }
}

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

int minimum(int x,int y)
{
    return y^((x^y)&-(x<y));
}

int main()
{
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++)
    {
        int a,b;
        a=dp[i-2]+abs(arr[i]-arr[i-2]);
        b=dp[i-1]+abs(arr[i]-arr[i-1]);
        dp[i]=minimum(a,b);
    }
    cout<<dp[n]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
<?php

class Dice
{
    /**
     * ????????????????§??????????????????£????????¨?????????????????´???????????????
     * direction => [current => after, ...]
     */
    private $directions = [
        'N' => [1 => 5, 2 => 1, 3 => 3, 4 => 4, 5 => 6, 6 => 2],
        'W' => [1 => 4, 2 => 2, 3 => 1, 4 => 6, 5 => 5, 6 => 3],
        'S' => [1 => 2, 2 => 6, 3 => 3, 4 => 4, 5 => 1, 6 => 5],
        'E' => [1 => 3, 2 => 2, 3 => 6, 4 => 1, 5 => 5, 6 => 4],
    ];

    private $positions;

    /**
     * ?????????????????????
     *
     * @param  array $pips
     */
    public function __construct($pips)
    {
        $this->positions = array_combine(range(1, 6), $pips);
    }

    /**
     * ?????????????????????????????????????????¢??????
     *
     * @param  string $direction
     * @return void
     */
    public function roll($direction)
    {
        $positions = $this->positions;
        foreach ($this->directions[$direction] as $current => $after) {
            $this->positions[$after] = $positions[$current];
        }
    }

    /**
     * ?????¨1?????????(?????´)???????????°????????????
     *
     * @param  void
     * @return int
     */
    public function top()
    {
        return $this->positions[1];
    }
}

$dice = new Dice(explode(' ', getStdin()));
$directions = str_split(getStdin());

foreach ($directions as $direction) {
    $dice->roll($direction);
}
echo $dice->top(), PHP_EOL;


function getStdin()
{
    return trim(fgets(STDIN));
}

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

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

const int mod=1e9+7;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,x; cin>>n;
	map<int,int> ct;
	for (int i=0; i<n; i++) {
		cin>>x;
		ct[x]++;
	}

	int ret=1;
	if( (n%2 && ct[0]!=1) || (n%2==0 && ct[0]!=0) ) ret=0;
	for (int i=n-1; i>0; i-=2) {
		if(ct[i]!=2)
			ret=0;
		ret=(ret*2)%mod;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 4096
import java.io.*;
import java.util.*;


class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int count = 0;
	int R = sc.nextInt();
	int[] A = new int[R];
	for(int i = 0;i < R;i++){
	    A[i] = sc.nextInt();
	}
	int N = sc.nextInt();
	int[] B = new int[N];
	for(int j = 0;j < N;j++){
	    B[j] = sc.nextInt();
	}
	for(int j = 0;j < N;j++){
	    if(binarySearch(A,B[j])){
		count++;
	    }
	}
	System.out.println(count);
    }
 //     public static boolean linearSearch(int[] A,int key){
//     	int i = 0;
//     	for(i = 0;i < A.length;i++){
//     	    if(A[i] == key){
//     		return true;
//     	    }
//     	}
//     	return false;
//     }
// }
    public static boolean binarySearch(int[] A,int key){
    	int left = 0;
    	int right = A.length;
    	int mid = 0;
    	while(left < right){
    	    mid = (left + right) / 2;
	 
    	    if(A[mid] == key){
    		return true;
    	    }else if(key < A[mid]){
    		right = mid;
    	    }else{
    		left = mid + 1;
    	    }
    	}
    	return false;
    }
}



Measured memory_bytes: 67320
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s; cin >> s;
  map<char,int> a;
  rep(i,SIZE(s)){
    a[s[i]]++;
  }
  if(SIZE(a)!=2){
    PNO
      return 0;
  }
  for(pair<char,int> i:a){
    if(i.S!=2){
      PNO
        return 0;
    }
  }
  PYES
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    ll n,m,k; cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    ll ans=0;
    ll asatu=0;
    ll bsatu=0;
    ll tmp=0;
    int aindex=0;
    int bindex=0;
    rep(i,n){
        if(tmp+a[i]<=k){
            tmp+=a[i];
            ans++;
            asatu++;
            aindex++;
        }
        else break;
    }
    aindex--;
    while(asatu>=0){
        while(tmp+b[bindex]<=k && bindex<b.size()){
            tmp+=b[bindex];
            bindex++;
            bsatu++;
        }
        ans=max(ans,asatu+bsatu);
        if(aindex>=0) tmp-=a[aindex];
        aindex--;
        asatu--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6424
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

cache = {}
def f(k, n):
    if k == 1:
        return 1
    if k in cache:
        return cache[k]
    result = pow(k, n, MOD)
    for i in range(2, k + 1):
        result -= f(k // i, n)
        result %= MOD
    cache[k] = result
    return result


result = 0
for i in range(1, K + 1):
    result += f(K // i, N) * i
print(result % MOD)


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

int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int x = -2000000000, y = a.at(0);
  for (int i = 1; i < n; i++) {
    x = max(x, a.at(i)-y);
    y = min(y, a.at(i));
  }
  cout << x << endl;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m,q;
    cin>>n>>m>>q;
    int sum[n+1][n+1];
    memset(sum,0,sizeof(sum));
    for(int i=0;i<m;i++){
        int l,r;
        scanf("%d%d",&l,&r);
        sum[l][r]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            sum[i][j]=sum[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
        }
    }
    for(int i=0;i<q;i++){
        int l,r;
        scanf("%d%d",&l,&r);
        cout<<sum[n][r]-sum[l-1][r]<<endl;
    }
}


Measured memory_bytes: 1920
#include<iostream>
#include<queue>
using namespace std;
int M[100][100] = {};
int color[100] = {};
int d[100] = {};
int n;
static const int INTFY = -1;


void bfs(int s) {
	int u;
	queue<int> q;
	color[s] = 1;
	d[s] = 0;
	q.push(s);
	while (!q.empty()) {
		u = q.front();q.pop();
		for (int v = 0;v < n;v++) {
			if (M[u][v] == 1 && color[v] == 0) {
				color[v]++;
				d[v] = d[u] + 1;
				q.push(v);
			}
			color[u]++;
		}
	}
	for (int i = 0;i < n;i++) {
		cout << i + 1 << " " << d[i] << endl;
	}
}
int main() {
	int k, m, j;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> m >> k;
		for (int l = 0;l < k;l++) {
			cin >> j;
			M[m - 1][j - 1] = 1;
		}
	}
	for (int i = 0;i < n;i++) {
		d[i] = INTFY;
	}
	bfs(0);

	


	return 0;
}


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

long long int a(int n,int x){
  if(n==0)return x;
  else return (n*a(n-1,x))%1000000007;
}

int main(){
  long long int n,m,ans;
  cin>>n>>m;
  if(m>n)swap(n,m);			//n>=m
  
  if(n==m)ans=((a(n,a(n,1)))*2)%1000000007;
  else if(n==m+1)ans=a(m,a(n,1));
  else ans=0;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct node{
  int key;
  struct node *p;
  struct node *r;
  struct node *l;
} Tree;
Tree *root = NULL;

void insert(int key){
  Tree *z = (Tree*)malloc(sizeof(Tree));
  z -> key = key;
  z -> l = NULL;
  z -> r = NULL;
  Tree *x, *y;
  x = root;
  y = NULL;
  while(x != NULL){
    y = x;
    if(z -> key < x -> key)
      x = x -> l;
    else
      x = x -> r;
  }
  z -> p = y;
  if(y == NULL)
    root = z;
  else if(z -> key < y -> key) 
    y -> l = z;
  else
    y -> r = z;
}
Tree* find(int key){
  Tree *c = root;
  while(c != NULL){
    if(c -> key == key){
      return c;
    }else if(key < c -> key)
      c = c -> l;
    else
      c = c -> r;
  }
  return NULL;
}
Tree* treeMinimum(Tree *x){
  while(x -> l != NULL)
    x = x -> l;
  return x;
}
Tree* treeSuccessor(Tree *x){
  if(x -> r != NULL)
    return treeMinimum(x -> r);
//  printf("--------------------------------\n");
//Tree *y = x -> p;
//while(y != NULL && x == y -> r){
//  x = y;
//  y = y -> p;
//}
//return y;
}
void delete(Tree *c){
  Tree *x, *y;
  if(c -> l == NULL || c -> r == NULL)
    y = c;
  else
    y = treeSuccessor(c);
  if(y -> l != NULL)
    x = y -> l;
  else
    x = y -> r;

  if(x != NULL)
    x -> p = y -> p;
  
  if(y -> p == NULL)
    root = x;
  else{
    if(y == y -> p -> l)
      y -> p -> l = x;
    else
      y -> p -> r = x;
  }

  if(y != c)
    c -> key = y -> key;
  
  free(y);
}
void printInorder(Tree *u){
  if(u == NULL)
    return;
  printInorder(u -> l);
  printf(" %d", u -> key);
  printInorder(u -> r);
}
void printPreorder(Tree *u){
  if(u == NULL)
    return;
  printf(" %d", u -> key);
  printPreorder(u -> l);
  printPreorder(u -> r);
}

int main(){
  int n, key;
  char line[100];
  char *str_ptr, *key_ptr;

  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &n);
  for(int i = 0; i < n; ++i){
    fgets(line, sizeof(line), stdin);
    if(strcmp(line, "print") == 0 || strcmp(line, "print\n") == 0){
      printInorder(root);
      printf("\n");
      printPreorder(root);
      printf("\n");
    }else{
      str_ptr = strtok(line, " ");
      key_ptr = strtok(NULL, " ");
      sscanf(key_ptr, "%d", &key);
      if(strcmp(str_ptr, "insert") == 0)
        insert(key);
      else if(strcmp(str_ptr, "find") == 0){
        if(find(key) != NULL)
          printf("yes\n");
        else
          printf("no\n");
      }
      else if(strcmp(str_ptr, "delete") == 0){
        Tree *c = find(key);
        delete(c);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 20444
#include<stdio.h>

#define limit 1000000000000000000

int main()
{
    long long int a[100000],i,n,pro;

    scanf("%lld",&n);

    for(i=0,pro=1;i<n;i++)
    {
        scanf("%lld",&a[i]);

        if(a[i]==0)
        {
            printf("0");
            return 0;
        }
    }

    for(i=0;i<n;i++)
    {
        if(pro>limit/a[i])
        {
            printf("-1");
            return 0;
        }

        else
            pro = pro * a[i];

    }


    printf("%lld",pro);
    return 0;
}


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

int main() {
    long long h, w;
    cin >> h >> w;

    if (h==1 || w==1) {
        cout << 1 << endl;
    } else {
        if ((h*w)%2==0) cout << h*w/2 << endl;
        else cout << h*w/2+1 << endl;
    }
}

Measured memory_bytes: 256
import itertools

N, M, X = map(int, input().split())
C = [list(map(int, input().split(' '))) for _ in range(N)]

ans = []
cost = []
for i in range(1, N+1):
    comb_list = itertools.combinations(C, i)
    for comb in comb_list:
        cost_tmp = 0
        ans_tmp = [0] * M
        for c in comb:
            cost_tmp += c[0]
            ans_tmp = [t+c for t, c in zip(ans_tmp, c[1:])]
        cost.append(cost_tmp)
        ans.append(ans_tmp)

ans_result = [all([aa >= X for aa in a]) for a in ans]
try:
    res = min([c for a, c in zip(ans_result, cost) if a])
except:
    print(-1)
    exit()

print(res)


Measured memory_bytes: 11500
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
using Graph = vector<vector<int>>;

signed main(){
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long N;
    cin>>N;
    long long M;
    cin>>M;
    Graph G(N);
    vector<long long> H(N);
    REP(i,N) cin>>H[i];
    for(int i = 0 ; i < M ; i++){
        int a, b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    vector<bool> good(N, true);
    REP(v,N){
        for(int nv: G[v]){
            if(H[nv]>=H[v]) good[v]=false; 
        }
    }
    int ans = 0;
    REP(i,N) if(good[i]) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9860
x=int(input())
a = [1]*1001
ans=1
def prime_factorize(n):
    
    while n % 2 == 0:
        a[2]=a[2]+1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f]=a[f]+1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n]=a[n]+1
    return a

for i in range(1,x+1):
	prime_factorize(i)
for i in range(x+1):
	ans=(ans*a[i])%(10**9+7)
print(ans)

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

int n;
string s;
set<string> words;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        words.insert(s);
    }
    cout << words.size();
}

Measured memory_bytes: 19124
import java.util.Scanner;

//Memory Leak
public class Main{

	final int NULL = -1, NOT = -2;
	
	class R{
		int mem;
		public R(int mem) {
			this.mem = mem;
		}
	}
	
	class Manager{
		boolean error;
		int maxSize, alloc;
		public Manager(int maxSize) {
			this.maxSize = maxSize;
			alloc = 0;
			error = false;
		}
		R malloc(int s){
			if(maxSize<s+alloc)return new R(NULL);
			alloc+=s;
			return new R(s);
		}
		R clone(R r){
			if(r.mem==NOT){
				error = true;
				return new R(NULL);
			}
			if(r.mem==NULL)return new R(NULL);
			if(maxSize<r.mem+alloc)return new R(NULL);
			alloc+=r.mem;
			return new R(r.mem);
		}
		void free(R r){
			if(r.mem==NOT){
				error = true; return;
			}
			if(r.mem==NULL)return;
			alloc-=r.mem;
		}
	}
	
	R[] r;
	Manager manager;
	char[] s;
	int idx;
	char get(){
		return s[idx++];
	}
	
	void line(){
		if(get()=='f'){
			get();
			R e = exp();
			if(0<=e.mem)for(int i=0;i<26;i++)if(r[i]==e)r[i]=new R(NOT);
			manager.free(e);
			get();
		}
		else{
			idx--;
			exp();
		}
	}
	
	R exp(){
		char ch = get();
		if(ch=='('){
			R r = exp();
			get();
			return r;
		}
		if(ch=='m'){
			get();
			int x = 0;
			char c = get();
			do{
				x = x*10 + c-'0';
				c = get();
			}while(Character.isDigit(c));
			return manager.malloc(x);
		}
		if(ch=='c'){
			get();
			R r = manager.clone(exp());
			get();
			return r;
		}
		char nx = get();
		if(nx=='U'){
			get(); get();
			return new R(NULL);
		}
		if(nx=='='){
			R e = exp();
			if(e.mem<0)return r[ch-'A'] = new R(e.mem);
			return r[ch-'A'] = e;
		}
		idx--;
		return r[ch-'A'];
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		r = new R[26];
		for(int i=0;i<26;i++)r[i]=new R(NOT);
		manager = new Manager(sc.nextInt());
		while(sc.hasNext()){
			idx = 0;
			s = (sc.next().replace("malloc", "m").replace("free", "f").replace("clone", "c")+"$").toCharArray();
			line();
		}
		if(manager.error)System.out.println("Error");
		else{
			int u = 0;
			for(int i=0;i<26;i++){
				boolean ok = true;
				for(int j=0;j<i;j++)if(r[i]==r[j])ok = false;
				if(ok&&0<=r[i].mem)u+=r[i].mem;
			}
			System.out.println(manager.alloc-u);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
from collections import defaultdict

MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for ai in a:
    d[ai] += 1
ans = 1
if n % 2:
    for k, v in d.items():
        if k > 0 and v == 2:
            ans *= 2
        elif k == 0 and v == 1:
            ans *= 1
        else:
            ans = 0
            break
        ans = ans % MOD
else:
    for v in d.values():
        if v == 2:
            ans *= 2
        else:
            ans = 0
            break
        ans = ans % MOD
print(ans)


Measured memory_bytes: 14820
#include <stdio.h>
int main(void){
    int a,b,menseki,nagasa;
    scanf("%d %d",&a,&b);
    
    menseki=a*b;
    nagasa=a*2+b*2;
    
    printf("%d %d\n",menseki,nagasa);
    
    return 0;
    
}


Measured memory_bytes: 2604
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




int main() {
    int n;
    bool flag = false;
    cin >> n;
    int x,y,z;
    x = n%10;
    y = (n/10)%10;
    z = (n/100)%10;
    if(x == 7 || y == 7 || z == 7){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }






    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, c-(a-b)) << endl;

	return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    LL ans = 0;
    REP(i, N) {
        if(A[i] <= B[i]) {
            ans += A[i];
            B[i] -= A[i];
            ans += min(B[i], A[i+1]);
            A[i+1] -= min(A[i+1], B[i]);
        } else {
            ans += B[i];
        }
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N+1);
    for(int i = 0 ; i < N+1 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
bool t[15];
bool ok(int n)
{
	while(n>0)
	{
		if(t[n%10])
			return false;
		n/=10;
	}
	return true;
}
int main()
{
	int n,k,a;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>a;
		t[a]=true;
	}
	while(!ok(n))
		n++;
	cout<<n;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[1000000][3];
int vacationdp(vector<vector<int >> arr,int n)
{
dp[0][0]=arr[0][0];
dp[0][1]=arr[0][1];
dp[0][2]=arr[0][2];
for(int i=1; i<n;i++)
{
dp[i][0]=max(arr[i][0]+dp[i-1][1],arr[i][0]+dp[i-1][2]);
dp[i][1]=max(arr[i][1]+dp[i-1][0],arr[i][1]+dp[i-1][2]);
dp[i][2]=max(arr[i][2]+dp[i-1][0],arr[i][2]+dp[i-1][1]);
}
return max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}
int main()
{
int n;
cin>>n;
vector<vector<int >> arr(n,vector<int>(3,-1));
for(int i=0;i<n;i++)
{
for(int j=0;j<3;j++)
{
cin>>arr[i][j];
}
}
cout<<vacationdp(arr,n)<<endl;
return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> ax(n),ay(n),bx(n),by(n);
  for(Int i=0;i<n;i++) cin>>ax[i]>>ay[i]>>bx[i]>>by[i];
  vector<Int> cx,cy;
  copy(ax.begin(),ax.end(),back_inserter(cx));
  copy(bx.begin(),bx.end(),back_inserter(cx));
  sort(cx.begin(),cx.end());
  cx.erase(unique(cx.begin(),cx.end()),cx.end());

  copy(ay.begin(),ay.end(),back_inserter(cy));
  copy(by.begin(),by.end(),back_inserter(cy));
  sort(cy.begin(),cy.end());
  cy.erase(unique(cy.begin(),cy.end()),cy.end());
  
  auto getX=[&](Int x){
    return lower_bound(cx.begin(),cx.end(),x)-cx.begin();
  };
  auto getY=[&](Int y){
    return lower_bound(cy.begin(),cy.end(),y)-cy.begin();
  };

  vector<vector<Int> > dp(cy.size()+1,vector<Int>(cx.size()+1,0));
  for(Int i=0;i<n;i++){
    dp[getY(ay[i])][getX(ax[i])]++;
    dp[getY(ay[i])][getX(bx[i])]--;
    dp[getY(by[i])][getX(ax[i])]--;
    dp[getY(by[i])][getX(bx[i])]++;
  }

  for(Int i=0;i<=(Int)cy.size();i++)
    for(Int j=0;j<(Int)cx.size();j++)
      dp[i][j+1]+=dp[i][j];
  
  for(Int i=0;i<(Int)cy.size();i++)
    for(Int j=0;j<=(Int)cx.size();j++)
      dp[i+1][j]+=dp[i][j];
  
  Int ans=0;
  for(Int i=0;i<(Int)cy.size()-1;i++)
    for(Int j=0;j<(Int)cx.size()-1;j++)
      if(dp[i][j]) ans+=(cy[i+1]-cy[i])*(cx[j+1]-cx[j]);
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 128268
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Mon struct {
	x, h int
}

type Mons []Mon

func (a Mons) Len() int           { return len(a) }
func (a Mons) Less(i, j int) bool { return a[i].x < a[j].x }
func (a Mons) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Node struct {
	x, h int
}

type Queue struct {
	arr []Node
}

func (q *Queue) push(v Node) {
	q.arr = append(q.arr, v)
}

func (q *Queue) first() Node {
	return q.arr[0]
}

func (q *Queue) pop() Node {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *Queue) isEmpty() bool {
	return len(q.arr) == 0
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, D, A := sc.nextInt(), sc.nextInt(), sc.nextInt()
	M := make([]Mon, N)
	for i := 0; i < N; i++ {
		M[i] = Mon{sc.nextInt(), sc.nextInt()}
	}
	sort.Sort(Mons(M))
	var q Queue
	ans := 0
	total := 0
	for i := 0; i < N; i++ {
		m := M[i]
		for !q.isEmpty() && q.first().x < m.x {
			total -= q.pop().h
		}
		if total < m.h {
			m.h -= total
			count := ceil(m.h, A)
			ans += count
			damage := count * A
			q.push(Node{m.x + 2*D, damage})
			total += damage
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

const int MAX_N = 100010;
int parent[MAX_N];

struct XYZ {
    int x, y, z;
};

int find(int n) {
    if (parent[n] == n) {
        return n;
    }
    int p = find(parent[n]);
    parent[n] = p;
    return p;
}
void unite(int a, int b) {
    int pa = find(a);
    int pb = find(b);
    if (pa == pb) {
        return;
    }
    if (pa < pb) {
        parent[pb] = pa;
    } else {
        parent[pa] = pb;
    }
}



int solve(int n, int m, vector<XYZ> xyz) {
    rep(i, MAX_N) {
        parent[i] = i;
    }
    for (auto &v : xyz) {
        unite(v.x, v.y);
    }
    int count[n];
    rep(i, n) {
        count[i] = 0;
    }
    rep(i, n) {
        count[find(i)]++;
    }
    int ans = 0;
    rep(i, n) {
        if (count[i] > 0) {
           ans += 1;
        }
    }
    return ans;
}


int main() {
    int n, m;
    cin >> n >> m;
    vector<XYZ> xyz;
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        xyz.push_back(XYZ{x, y, z});
    }
    int ans = solve(n, m, xyz);
    cout << ans << "\n";
} 

Measured memory_bytes: 3444
import numpy as np
import math
import copy 

N = np.int64(input())

p = []
x  = 2
xen = np.sqrt(N)
while N > 1 : 
    if N%x == 0 :
        p.append(x)
        N = N/x
    else :
        x = x + 1
        if x > xen :
            p.append(int(N))
            break
e = []
while p!=[]:
    i = p[0]
    n = p.count(i)
    p = p[n:]
    e.append(n)
    if p==[]:break

i = 0
m = 0
e = np.array(e)
ans = 0
while True:
    i += 1
    e = e-i
    e = e[e>=0]
    ans = ans + len(e)
    if len(e)==0 : break

print(ans)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    bool dp[k+1];
    memset(dp,false,sizeof dp);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]>=0 && dp[i-a[j]]==0)
                dp[i]=1;
        }
    }
    if(dp[k])   cout<<"First";
    else    cout<<"Second";
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	int a,b,c;
	ll k;
	cin>>a>>b>>c>>k;
	if(k%2==0){
		cout<<a-b<<endl;
	}else{
		cout<<b-a<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n,a[85],m=1000,g=0;cin>>n;
	for(int x=1;x<=n;x++)
	cin>>a[x];
	for(int x=1;x<n;x++)
	{
		if(a[x]<a[x+1])
		{
			g+=(m/a[x]);
			m-=((m/a[x])*a[x]);
		}
		if(a[x]>a[x+1])
		{
			m+=(g*a[x]);
			g=0;
		}
	}
	cout<<m+g*a[n];
	return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#define TRUE 1
#define FALSE 0

int solve(int,int);
int n,*A;

int main(){
  int q;
  int *m;
  int i;
  
  scanf("%d",&n);
   A=(int *)malloc(n*sizeof(int));
   for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
   m=(int *)malloc(q*sizeof(int));
   for(i=0;i<q;i++) scanf("%d",&m[i]);
  
  for(i=0;i<q;i++){
    if(solve(0,m[i])==TRUE) printf("yes\n");
    else printf("no\n");
  }

  free(A);
  free(m);

  return 0;
}

int solve(int i,int m){
  if(m==0) return TRUE;
  if(i>=n) return FALSE;
  int res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define int   long long int  
#define pb push_back
#define BOOST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debugL(i)  cout<<"line no-> "<<i<<" working"<<endl
#define debugVL(i,l)  cout<<"val at line no."<<i<< " ->"<<l<<endl
const int M=1e9 + 7;
using namespace std;
int N=100000+1;
int32_t main() {
    //int q;cin>>q;
    int a;cin>>a;
    string s;cin>>s;
    if((a>=3200))
    {
    	cout<<s<<endl;
	}else{
		cout<<"red"<<endl;
	}
    return 0;
}













Measured memory_bytes: 256
"use strict"

function Main(input) {
  let N = input.split("\n")[0];
  let args = input.split("\n")[1].split(" ").map(e => parseInt(e, 10));

  let Alice = [];
  let Bob = [];

  for (let i = 0; i < N; i++) {
    let max = args.reduce((p, c) => (p > c) ? p : c);
    args.splice(args.indexOf(max), 1);
    if (i % 2 === 0) {
      Alice.push(max);
    } else {
      Bob.push(max);
    }
  }

  console.log(Alice.reduce((p, c) => p + c) - (Bob.reduce((p, c) => p + c)))
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var a, b, c int
	_, _ = fmt.Fscan(reader, &a, &b, &c)
	if (a < c && c < b) || (b < c && c < a) {
		_, _ = fmt.Fprintf(writer, "Yes")
	} else {
		_, _ = fmt.Fprintf(writer, "No")
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
#define mod 1000000007
#define PI acos(-1)
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=4e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline bool read(int &ret){char c=getchar();int sgn;if(c==EOF)return 0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	sgn=((c=='-')?-1:1);ret=((c=='-')?0:(c-'0'));while(c=getchar(),c>='0'&&c<='9')ret=ret*10+(c-'0');ret*=sgn;return 1;}
inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};
int st[4][2]={1,0,0,1,-1,0,0,-1};
int t,cas;
int n,m,k;
struct xxx{int x,w;}a[N];
int main()
{
	ll a,b,c,d;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
	{
		ll sum=b/c-(a-1)/c;
		sum=sum+b/d-(a-1)/d;
		c=d*c/__gcd(d,c);
		sum=sum-b/c+(a-1)/c;
		printf("%lld\n",b-a+1-sum);
	}
}



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

int main(void)
{
    int a, b;
    scanf("%d%d%d%s", &a, &b);
    int c = a+b;
    if (c >= 10)
        printf("error\n");
    else
        printf("%d", c);
    return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

return 0;
}


Measured memory_bytes: 3648
#include <set>
#include <map>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cstring>
#include <algorithm>
#define pc putchar
#define gc() getchar()
typedef long long LL;
//const int N=

inline int read()
{
	int now=0,f=1;register char c=gc();
	for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
	for(;isdigit(c);now=now*10+c-48,c=gc());
	return now*f;
}

int main()
{
	static int dgr[233];
	for(int i=1; i<=6; ++i) ++dgr[read()];
	for(int i=1; i<=4; ++i) if(dgr[i]>2) return !puts("NO");
	puts("YES");

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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 rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100,vector<ll>(3,0));
int main(){
  string s;
  cin >> s;
  rep(i,3){
    if(s[i] == '1'){
      s[i] = '9';
    }else if(s[i] == '9'){
      s[i] = '1';
    }
  }
  cout << s;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	//入力例4:aにk未満しかない→IMPOSSIBLE
	if (k > a.at(n - 1)) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	//aが1つしかない
	if (n == 1) {
		if(a.at(0)==k)cout << "POSSIBLE" << endl;
		else cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	// aの最大公約数を求める
	vector<int> b;
	while (true) {
		b.push_back(a.at(0));
		for (int i = 1; i < a.size(); i++) {
			int mod = a.at(i) % b.at(0);
			if (mod == 0)continue;
			else if (mod == b.at(0))continue;
			else b.push_back(mod);
		}
		sort(b.begin(), b.end());
		a = b;
		b.clear();
		if (a.size() == 1)break;
	}
	int64_t gcd = a.at(0);
	//kがその倍数ならPOSSIBLE,無いならIMPOSSIBLE
	if (k % gcd == 0)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1276
/**
 *    author:  tourist
 *    created: 15.12.2019 12:59:55       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  const int MAX = 86400;
  vector<int> bal(MAX);
  int t = 0;
  int add = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    t = (t + a) % MAX;
    bal[t] += 1;
    int nt = (t + 3 * 3600 + 1) % MAX;
    bal[nt] -= 1;
    if (nt < t) {
      ++add;
    }
    t = (t + b) % MAX;
  }
  int ans = 0;
  int cur = 0;
  for (int i = 0; i < MAX; i++) {
    cur += bal[i];
    ans = max(ans, cur);
  }
  cout << ans + add << '\n';
  return 0;
}


Measured memory_bytes: 640
S = input()

a = S.count('a')
b = S.count('b')
c = S.count('c')
n = len(S)//3
k = len(S)-n*3
if a >= n and b >= n and c >= n:
  if k == 2 and max(a-n,b-n,c-n) == 2:
    print('NO')
  else:
    print('YES')
else:
  print('NO')


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

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

int main() {
    // 入力
    int N; long long W;
    cin >> N >> W;
    vector<long long> weight(N), value(N);
    for (int i = 0; i < N; ++i) cin >> value[i] >> weight[i];

    // DP テーブル定義
    vector<vector<long long> > dp(N+1, vector<long long>(W+1, 0));

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int w = 0; w <= W; ++w) {

            // i 番目の品物を選ぶ場合
            if (w - weight[i] >= 0) {
                chmax(dp[i+1][w], dp[i][w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][w], dp[i][w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 10808
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n;
int A[100001];
pii P[100001];
llong ans[100001];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
        P[i] = min(P[i - 1], pii(-A[i], i));
    }
    priority_queue<pll> pq;
    for (int p = P[n].second, r = n; p > 0; p = P[p - 1].second) {
        while (p <= r) pq.emplace(A[r--], 1);
        int v = -P[p - 1].first;
        llong c = 0;
        while (!pq.empty() && v <= pq.top().first) {
            ans[p] += (pq.top().first - v) * pq.top().second;
            c += pq.top().second;
            pq.pop();
        }
        pq.emplace(v, c);
    }
    for (int i = 1; i <= n; ++i) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 3700
open Scanf
open Printf
open Num

let () =
  let a, b, x = scanf "%s %s %s\n" (fun x y z -> (num_of_string x, num_of_string y, num_of_string z)) in
  printf "%s\n" @@ string_of_num @@ quo_num b x -/ (quo_num a x) +/ (if mod_num a x =/ (num_of_int 0) then (num_of_int 1) else (num_of_int 0))



Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef long long ll;
int n,s,v[10001];
ll dp[10001],ans,dp1[10001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    for(int i=1;i<=n;i++)
    {
        int nr=v[i];
        for(int k=1;k<=s;k++)
        {
            dp1[k]=(dp[k])%mod;
            if(k-nr>=0)
                dp1[k]=(dp[k-nr]+dp1[k])%mod;
            if(k==s)
                ans=(ans+((n-i+1)*dp[k-nr])%mod)%mod;
        }
        for(int j=1;j<=s;j++)
            dp[j]=dp1[j];
        dp[nr]=(dp[nr]+i)%mod;
        if(nr==s)
            ans=(ans+(i*(n-i+1)%mod))%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
X = int(input())
pp = [
    1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169,
    196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576,
    625, 676, 729, 784, 841, 900, 961, 1000
]
pp.append(X)
pp.sort(reverse=True)
for i in range(len(pp) - 1):
    if pp[i] == X:
        print(pp[i + 1])
        break


Measured memory_bytes: 3064
using System;
class AOJ{
public static void Main(){
String[] st=Console.ReadLine().Split(' ');
int W=int.Parse(st[0]);
int H=int.Parse(st[1]);
int x=int.Parse(st[2]);
int y=int.Parse(st[3]);
int r=int.Parse(st[4]);
if(x-r>=0&&y-r>=0&&x+r<=W&&y+r<=H)
Console.WriteLine("Yes");
else
Console.WriteLine("No");



}
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 1) 
        cout << "IMPOSSIBLE" << endl;
    else
        cout << (a + b) / 2 << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	ll n,a,b[200005],sum=0;
	for(int i=0;i<200005;i++)b[i]=0;
	vector<ll>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
		b[a]++;
	}
	for(int i=1;i<=n;i++)sum+=b[i]*(b[i]-1)/2;
	for(int i=0;i<n;i++)
	{
		if(b[v[i]])cout<<sum-(b[v[i]]-1)<<endl;
	}
	return 0;
}

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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

struct UnionFind {
    vector<int> par,rank,large;

    void init(int N){
        rank.assign(N,0);
        large.assign(N,1);
        par.resize(N);
        for(int i= 0; i < N; i++){
            par[i]=i;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(rank[rx]<rank[ry]) {
            par[rx]=ry;
            large[ry]+=large[rx];
            large[rx]=0;
        }
        else {
            par[ry]=rx;
            large[rx]+=large[ry];
            large[ry]=0;
            if(rank[rx]==rank[ry])rank[x]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return large[root(x)];
    }
};

int main() {
  int N,M;
  cin>>N>>M;
  UnionFind tree;
  tree.init(N+M);
  for(int i = 0; i < N; i++){
    int K;
    cin>>K;
    for(int j = 0; j < K; j++){
      int l;
      cin>>l;
      tree.unite(l-1,M+i);
    }
  }
  bool ans = true;
  for(int i = M; i < N+M-1; i++){
    if(!tree.same(i,i+1)) ans=false;
  }
  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 2560
n = int(input())

for i in range(1,n+1):
    x = i
    if (x % 3 == 0):
        print(" "+str(i),end = "")

        continue

    while True :
        if(x % 10 == 3):
            print(" "+str(i),end = "")

            break
        x //= 10
        if(x == 0):

            break


print("")



Measured memory_bytes: 5868
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int main(void) {
  int N; cin >> N;
  REP(i, 0, N) {
    string s; cin >> s;
    stack<int> stk;

    REP(i, 0, s.length()) {

      if(s[i] == '[') {
        stk.push(-1);
      } else if(s[i] == ']') {
        vector<int> v;
        while(1) {
          int d = stk.top();
          stk.pop();
          if(d == -1) break;
          v.push_back(d);
        }
        sort(v.begin(), v.end());
        int d = 0;
        REP(i, 0, (v.size() + 1) / 2) d += v[i];
        stk.push(d);
      } else {
        int d = 0;
        for(; '0' <= s[i] && s[i] <= '9'; i++) d = d * 10 + (s[i] - '0');
        i--;
        stk.push((d + 1) / 2);
      }
    }

    cout << stk.top() << endl;
  }
}

Measured memory_bytes: 3208