akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}
int c['z'+1];

void solve(void){
    int n;
    cin >> n;
    if(n == 1 || n == 2 || n == 3)  cout <<  1 << endl;
    rrep(i,n,4){
        rep(j,2,sqrt(i)+2){
            bool flag; 
            int tmp = i;
            while(true){
                if(tmp == 1) break; 

                if(tmp % j == 0) {
                    flag = true;
                    tmp /= j;           
                }else{
                    flag = false;
                    break;
                }
            }

            if(flag){cout << i <<endl;return;}
        }  
    }
}

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

Measured memory_bytes: 256
"""
B- Shift Boy
"""

#出力すべき回数の定義
i = 0

#入力される整数の個数
a = int(input())

b = list(map(int, input().split()))

#数値を半分にする関数
def half(n):
    return n/2

#数値の余りを調べる関数
def mod(n):
    return n%2


#上記関数が動かせるかの確認
#c = list(map(half, b))
d = list(map(mod, b))

while d.count(1)<1:
    b = list(map(half, b))
    d = list(map(mod, b))
    i += 1

print(i)

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<pii> vec;
  reps(i, 1, n) {
    int tmp = __builtin_ctz(i);
    vec.push_back(pii(tmp, i));
  }

  sort(all(vec), greater<>());

  cout << vec[0].second << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> list(n);
  int total=0;
  for(int i=0; i<n; i++) {
    cin >> list.at(i);
    total += list.at(i);
  }
  int x=0,y=0,ans=100000000;
  for(int i=0; i<n-1; i++) {
    x += list.at(i);
    y = abs((total-x)-x);
    ans = min(ans,y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3540
from statistics import mean
_ = input()
A = [int(i) for i in input().split()]
m = mean(A)

min_d = 100
index = 0
for i in range(len(A)):
  if abs(A[i] - m) < min_d:
    min_d = abs(A[i] - m)
    index = i
print(index)

Measured memory_bytes: 10896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        
        int array[] = new int[N];
        int gap = 0;
        
        for(int i=0;i<N;i++){
            array[i] = sc.nextInt();
        }
        
        int tmp;
        
        for(int i=0;i<N-1;i++){
            tmp = array[i+1] - array[i];
            gap = Math.max(gap, tmp);
        }
        
        tmp = (array[0] + K) - array[N-1];
        gap = Math.max(gap, tmp);
        
        System.out.println(K-gap);
    }
}


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

int N, M, X;

struct ptype {
	int c;
	int cost;
};


int main(){
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<int> A[N];
	
	
	for ( int i = 0; i < N; i++ ){
		cin >> C[i];
		A[i].resize(M);
		for ( int j = 0; j < M; j++ ){
			cin >> A[i][j];
		}
	}
	
	// c,cost
	vector<ptype> c_cost(1<<N);
	for ( int c = 0; c < (1<<N); c++ ){
		int cost = 0;
		for ( int i = 0; i < N; i++ ){
			if ( c&(1<<i) )
				cost += C[i];
		}
		c_cost[c] = {c,cost};
	}
	
	auto f = [](ptype &l, ptype &r){ return l.cost < r.cost;};
	sort(c_cost.begin(),c_cost.end(),f);
	
//	for ( auto p : c_cost )
//		cout << p.c << " " << p.cost << endl;
	
	int m[12];
	int min_cost = -1;
	for ( auto p : c_cost ){
		for ( int j = 0; j < M; j++ )
			m[j] = 0;
		
		for ( int i = 0; i < N; i++ ){
			if ( (1<<i) & p.c ){
				for ( int j = 0; j < M; j++ ){
					m[j] += A[i][j];
				}
			}
		}
		
		bool success = true;
		for ( int j = 0; j < M; j++ ){
			if ( m[j] < X )
				success = false;
		}
		if ( success ) {
			min_cost = p.cost;
			break;
		}
	}
	
	cout << min_cost << endl;
	
	return 0;
}



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

int check(int64_t &x){
  int k=0;
  while(true){
    
    if(x%2==1){
      return k;
    }
    else x/=2;
    k++;
  }
}
int main(){
  int N; cin >> N;
  vector<int64_t> MY(N);
  for (int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int count=0;
  for (int i=0;i<N;i++){
    count+=check(MY.at(i));
  }
  cout << count << endl;
}
  

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <utility>



void fastio(){std::ios_base::sync_with_stdio(false);std::cin.tie(0);}

using std::string;using std::cin;using std::cout;using std::vector;using std::map;using std::set;using std::pair;using std::max;using std::min;

template<class T> int sz(T x){return (int)x.size();};

using ll=long long;

#define f first
#define s second

int main(){
    ll n;
    cin >> n;
    vector<std::array<ll, 3> > dp(n, {(ll)1e18, (ll)1e18, (ll)1e18});
    vector<std::array<ll, 3> > a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    for(int i = 0; i < 3; i++) {
        dp[0][i] = a[0][i];
    }
    for(int i = 1; i < n; i++) {
        dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][1], dp[i-1][0]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";
    return 0;
}



Measured memory_bytes: 8020
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  char C;
  std::cin >> C;
  const std::string a_to_z = "abcdefghijklmnopqrstuvwxyz";
  std::cout << *(std::find(a_to_z.begin(), a_to_z.end(), C) + 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import math

n = int(input())
arr = [0] * n

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= n:
                arr[ans - 1] += 1

for i in range(n):
    print(arr[i])

Measured memory_bytes: 9336
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

struct Node {
  int id;
  int parent;
  int depth;
  vector<int> child;
  
  Node() : id(), parent(-1), depth(0), child(0, 0) {}
};

static vector<Node> TREE(100000);

static void inputNode(Node& node, int id, int k) {
  node.id = id;

  int c;
  for (int i = 0; i < k; i++) {
    cin >> c;
    node.child.push_back(c);
  }
}

static const string ROOT = "root";
static const string INTERNAL_Node = "internal node";
static const string LEAF = "leaf";

static const string& getNodeType(const Node& node) {
  if (node.parent == -1) {
    return ROOT;
  } else if (node.child.size() != 0) {
    return INTERNAL_Node;
  } else {
    return LEAF;
  }
}

static void setDepth(vector<Node>& tree, Node& node) {
  for (int i : node.child) {
    tree[i].depth = node.depth + 1;
    setDepth(tree, tree[i]);
  }
}

static void setupTree(vector<Node>& tree, int num) {
  for (int i = 0; i < num; i++) {
    const Node& node = tree[i];
    for (int j : node.child) {
      tree[j].parent = node.id;
      tree[j].depth = node.depth + 1;
      setDepth(tree, tree[j]);
    }
  }
}

static void printTree(const vector<Node>& tree, int num) {
  int node, parent = -1, depth = 0;

  for (int i = 0; i < num; i++) {
    const string type = getNodeType(tree[i]);
    printf("node %d: parent = %d, depth = %d, %s, [", i, tree[i].parent, tree[i].depth, type.c_str());
    for (int j  = 0; j < tree[i].child.size(); j++) {
      if (j != 0) {
        printf(", "); 
      }
      printf("%d", tree[i].child[j]);
    }
    printf("]\n");
  }
}

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

  int id, k;
  for (int i = 0; i < n; i++) {
    cin >> id >> k;
    inputNode(TREE[id], id, k);
  }
  
  setupTree(TREE, n);
  printTree(TREE, n);

  return 0;
}



Measured memory_bytes: 7668
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    int n;
    string s[100];
    cin >> n;
    for(int i = 0; i < n; i++){
    cin >> s[i];
    if(i == 0) continue;
    else{
        for(int j=0;j<i;j++){
            if(s[i] == s[j]) cout << "No" << endl,exit(0);
        }
    }
    if(s[i-1][s[i - 1].size() - 1] != s[i][0]) cout << "No" << endl,exit(0);
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    ll in, cnt = 0;
    rep(i, n){
        cin >> in;
        if((i+1)%2!=0){
            if(in%2!=0){
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>


int main()
{
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	char s[6][7];
	for (int i = 0; i < h; ++i)
	{
		scanf("%s", s[i]);
	}

	int ans = 0;
	for (int i = 0; i < (1 << h); ++i)
	{
		for (int j = 0; j < (1 << w); ++j)
		{
			int cnt = 0;
			for (int y = 0; y < h; ++y)
			{
				for (int x = 0; x < w; ++x)
				{
					if (s[y][x] == '#' && (i & (1 << y)) == 0 && (j & (1 << x)) == 0) {
						++cnt;
					}
				}
			}
			if (cnt == k)
			{
				ans++;
			}
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <math.h>

using namespace std;

//void B_159()
int main()
{
  string S;
  cin >> S;

  int len = (int)S.size();
  string str1 = S.substr(0, (len - 1) / 2);
  string str2 = S.substr((len + 3)/2 - 1, (len - 1) / 2);
  
  bool b = true;
  string str1_r = str1;
  string str2_r = str2;
  string S_r = S;
  reverse(str1_r.begin(), str1_r.end());
  reverse(str2_r.begin(), str2_r.end());
  reverse(S_r.begin(), S_r.end());

  if (str1 != str1_r) b = false;
  if (str2 != str2_r) b = false;
  if (S != S_r)       b = false;

  if (b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define lnode node*2,start,mid
#define rnode node*2+1,mid+1,end
#define rep(i,a,b) for(ll i=a;i<=(b);i+=1)
#define input freopen("in32.txt", "r", stdin)
#define out freopen("out32.txt", "w", stdout)
#define To_string(num,str) {stringstream ss;ss<<num;ss>>str;}
#define To_num(str,num) {stringstream ss;ss<<str;ss>>num;}
const double pi=acos(-1.0);
const int maxn=(1000+10);
const int inf=0x3f3f3f3f;
const ll mod=10000003;
using namespace std;
ll in()
{  ll x=0,f=0;char ch=getchar();
   while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
   while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
   return f? -x:x;
}
int sum[300001];
int main()
{   ios::sync_with_stdio(false);
    int n,k,q;
    //input;
	//out; 
    cin>>n>>k>>q; 
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=q;i++)
    {  int x;
       cin>>x;
       sum[x]+=1;
	}
	for(int i=1;i<=n;i++)
	  if(k-q+sum[i]>0)
        cout<<"Yes"<<endl;
	  else 
	    cout<<"No"<<endl; 
	return 0;
}


Measured memory_bytes: 1792
package main

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

func isLoadable(numTrucks int, sizeTrucks int, elems []int) bool {
	ti := 0
	sum := 0
	for i := 0; i < len(elems); i++ {
		if sum+elems[i] > sizeTrucks {
			ti++
			if ti >= numTrucks {
				return false
			}
			sum = 0
		}
		sum += elems[i]
	}
	return true
}

func calcMinTruckSize(numTrucks int, elems []int) int {
	lo, hi := 0, 0
	for i := 0; i < len(elems); i++ {
		if lo < elems[i] {
			lo = elems[i]
		}
		hi += elems[i]
	}
	for lo+1 <= hi {
		mid := (lo + hi) / 2
		if isLoadable(numTrucks, mid, elems) {
			hi = mid
		} else {
			lo = mid + 1
		}
	}
	return hi
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, _ := nextInt(sc)
	k, _ := nextInt(sc)

	elems := make([]int, n)
	for i := 0; i < n; i++ {
		x, _ := nextInt(sc)
		elems[i] = x
	}
	fmt.Println(calcMinTruckSize(k, elems))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}


Measured memory_bytes: 2332
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    int F[N][15];
    int P[N][15];
    for (int i = 0; i < N; i++){
        for (int k = 0; k < 10; k++){
            cin >> F[i][k];
        }
    }

    for (int i = 0; i < N; i++){
        for (int k = 0; k < 11; k++){
            cin >> P[i][k];
        }
    }
    int res = -(1<<30);
    for (int i = 1; i < (1<<10); i++){
        int cc = 0;
        for (int k = 0; k < N; k++){
            int c = 0;
            for (int p = 0; p < 10; p++){
                //開店数をカウント
                //if ((i & (1<<p))&& F[k][p]) c++;
                if ((i>>p&1)&& F[k][p]) c++;
            }
            cc += P[k][c];
        }
        res = max(res,cc);
    }
    cout << res << endl;
            


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    double n,m,d; cin>>n>>m>>d;
    double ans=2*(n-d)*(m-1)/(n*n);
    if(d==0) ans/=2;
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
if N % 2 == 1:
    print(0)
elif N == 0:
    print(0)
else:
    le=len(str(N))
    count=0
    for i in range(1, le*2):
        count+=(N//2)//5**i
        if (N//2)//5**i==0:
            break
    print(count)


Measured memory_bytes: 38384
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	map<int, int> s1, s2;
	for (int i = 1; i <= n;++i)
	{
		int x;
		cin >> x;
		s1[i - x]++;
		s2[i + x]++;
	}
	ll ans = 0;
	auto it1 = s1.begin(), it2 = s2.begin();
	while(it1!=s1.end() && it2!=s2.end())
	{
		if(it1->first==it2->first)
		{
			ans += (ll)(it1->second) * (it2->second);
			it1++;
			it2++;
		}
		else if(it1->first>it2->first)
			it2++;
		else
			it1++;
	}
	cout << ans;

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


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

#define ll long long int
ll mod=1e9+7;

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        cin >> n;
        // ll arr[n];

        // for(i=0;i<n;i++)
        // {
        //     cin >> arr[i];
        // }

        if(n >= 30)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
        
    }
    
    return 0;
}

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

cnt = 0
anagrams = {}
for _ in range(n):
    s = input()
    sorted_s = ''.join(sorted(s))
    if sorted_s in anagrams:
        anagrams[sorted_s] += 1
        cnt += anagrams[sorted_s]
    else:
        anagrams[sorted_s] = 0

print(cnt)


Measured memory_bytes: 17892
import numpy as np

N,D = list(map(int, input().split()))
points = []
for i in range(N):
  points.append(np.array(list(map(int, input().split()))))
points = np.array(points)
# print(points)

res = 0
for i in range(N):
  for j in range(i+1,N):
    dist = np.sqrt(sum((points[i] - points[j])**2))
    if dist - int(dist) == 0:
        res += 1
print(res)


Measured memory_bytes: 12452
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val input = sc.nextInt()

    val result =
      if (input == 2) {
        // dirty...
        2
      } else {
        nextPrime(input)
      }

    println(result.toString)
  }

  @scala.annotation.tailrec
  def nextPrime(num: Int): Int = {
    val isPrime =
      (2.to(math.ceil(math.sqrt(num)).toInt))
        .forall(value => num % value != 0)
    if (isPrime) {
      num
    } else {
      nextPrime(num + 1)
    }
  }
}


Measured memory_bytes: 27196
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String S = sc.next();
	String T = sc.next();
	char[] s = new char[N];
	char[] t = new char[N];
	for(int i=0;i<N;i++){
	    s[i] = S.charAt(i);
	    t[i] = T.charAt(i);
	}
	for(int i=0;i<N;i++){
	    System.out.print(s[i]);
	    System.out.print(t[i]);
	}
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int main ()
{
	int b,count=0,n;
	char str[100];
	scanf ("%s",str);
	b=strlen(str);
	for (n=0;n<b;n++)
	{
		if(str[n]==str[n+1])
			count++;
	}
	if (count==0)
		printf ("Good\n");
	else 
		printf ("Bad\n");
	return 0;
}




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

int main(){
    std::vector<string> d(3);
    for(ll i=0;i<3;++i){
        cin>>d[i];
    }
    ll a=0,b=0,c=0;
    char now='a';
    while(1){
        switch(now){
            case 'a':
                if(a>=d[0].length()){
                    cout<<char(now+'A'-'a');
                    return 0;
                }
                now=d[0][a];
                a++;
            break;
            case 'b':
                if(b>=d[1].length()){
                    cout<<char(now+'A'-'a');
                    return 0;
                }
                now=d[1][b];
                b++;
            break;
            case 'c':
                if(c>=d[2].length()){
                    cout<<char(now+'A'-'a');
                    return 0;
                }
                now=d[2][c];
                c++;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#define min(a,b) ((a<b)?a:b)
#define max(a,b) ((a>b)?a:b)
#define ll long long int
#define BIG 1e9
using namespace std;

int main() {
	ll dp[101][100001]={},v[200],w[200],W,N,ans;
	cin>>N>>W;
	for(int i=0; i<N; i++){
		cin>>w[i]>>v[i];
	}
	for(int i=0; i<N; i++){
		for(int j=1; j<=W; j++){
			if(w[i]<=j){
				dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j]);
			}else{
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	ans = dp[N][W];
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, ll> mp;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (mp.count(a[i])) mp[a[i]]++;
		else mp[a[i]] = 1;
	}

	ll sum = 0;
	for (auto item : mp) {
		sum += item.second * (item.second - 1) / 2;
	}

	for (int i = 0; i < n; i++) {
		ll ans = sum;
		ans -= mp[a[i]] * (mp[a[i]] - 1) / 2;
		ans += (mp[a[i]] - 1) * (mp[a[i]] - 2) / 2;
		cout << ans << endl;
	}
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N;
  vector<string>red(N);
  for(int i=0;i<N;i++){
    cin>>red.at(i);
  }
  cin>>M;
  vector<string>blue(M);
  for(int i=0;i<M;i++){
    cin>>blue.at(i);
  }
  int sum;
  for(int i=0;i<N;i++){
    string mark=red.at(i);
    int countp=0;
    int countm=0;
    for(int j=0;j<N;j++){
      if(red.at(j)==mark){
        countp++;
      }
      else{
      }
    }
    for(int j=0;j<M;j++){
      if(blue.at(j)==mark){
        countm++;
      }
      else{
      }
    }
    if(i==0){
      sum=countp-countm;
    }
    else if(sum<countp-countm){
      sum=countp-countm;
    }
    else{
    }
  }
  for(int i=0;i<M;i++){
    string mark=blue.at(i);
    int countp=0;
    int countm=0;
    for(int j=0;j<N;j++){
      if(red.at(j)==mark){
        countp++;
      }
      else{
      }
    }
    for(int j=0;j<M;j++){
      if(blue.at(j)==mark){
        countm++;
      }
      else{
      }
    }
    if(sum<countp-countm){
      sum=countp-countm;
    }
    else{
    }
  }
  if(sum<0){
    sum=0;
  }
  else{
  }
  cout<<sum<<endl;
}
        

  
      
  
  
  
    

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    println(problem076c(s, t))
}

fun problem076c(s: String, t: String): String {
    val s = s.toCharArray()
    val t = t.toCharArray()
    var count = 0
    val tStartList = mutableListOf<Int>()
    while (true) {
        val size = tStartList.size
        for (i in 0 until s.size) {
            if (!tStartList.contains(i - count) && (s[i] == t[count] || s[i] == '?')) {
                count++
            } else {
                count = 0
            }
            if (count == t.size) {
                if (!tStartList.contains(i - count + 1)) {
                    tStartList.add(i - count + 1)
                    count = 0
                }
            }
        }
        if (size == tStartList.size) break
    }
    if (tStartList.isEmpty()) {
        return "UNRESTORABLE"
    }
    val resList = mutableListOf<String>()
    for (j in 0 until tStartList.size) {
        val tStart = tStartList[j]
        resList.add("")
        for (i in 0 until s.size) {
            val si = s[i]
            if (i >= tStart && i < tStart + t.size && si == '?') {
                resList[j] = resList[j] + t[i - tStart]
            } else if (si == '?') {
                resList[j] = resList[j] +  'a'
            } else {
                resList[j] = resList[j] +  si
            }
        }
    }
    return resList.sorted().first()
}

Measured memory_bytes: 33976
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main (int argc, char const* argv[]){
  string str;
  int i;
  
  
  getline(cin,str);
  transform(str.begin(), str.end(), str.begin(), ::toupper);
  cout << str << endl;
  
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int A, B;
int N;
void input(){
    int a, b;
    cin>>a>>b>>N;
    A = max(a ,b);
    B = min(a, b);
    int ans = 0;
    if(N%A == 0) ans = N/A;
    else ans = N/A +1;
    cout<<ans<<endl;
}

void solve(){

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC124C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long N = input[0].Length;
            string str = input[0];
            long cnt = 0;
            List<Char> strOutput = new List<Char>();
            strOutput.Add(str[0]);

            for(int i = 1; i < N; i++)
            {
                if (str[i] == strOutput[i - 1])
                {
                    cnt++;
                    if (str[i] == '0')
                    {
                        strOutput.Add('1');
                        
                    }
                    else
                    {
                        strOutput.Add('0');
                    }
                }
                else
                    strOutput.Add(str[i]); 
            }
            Console.WriteLine(cnt);
            //Console.WriteLine(strOutput);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cassert>
#include <functional>
#include <set>
#include <cmath>

using namespace std;
#define get(x) if (DEBUG) cout << #x << " : " << x << endl;
#define print(x) if (DEBUG) cout << x << endl;
#define int long long
#define double long double

void fast() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int MAX = (int)1e6;
const long long INF = 1e18;

signed main() {
    fast();
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    double ps[n + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> ps[i];
    }
    ps[0] = 0;
    double p[n + 1][n + 1];
    fill(p[0], p[0] + n + 1, 0);
    p[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        p[i][0] = p[i - 1][0] * (1 - ps[i]);
        for (int j = 1; j <= n; ++j) {
            p[i][j] = p[i - 1][j] * (1 - ps[i]) + p[i - 1][j - 1] * ps[i];
        }
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i) ans += p[n][i];
    cout.precision(30);
    cout << ans;

    return 0;
}

Measured memory_bytes: 140928
#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <string>

using namespace std;

int DigitSum(int n) {
	int dsum = 0;
	while (n > 0) {
		dsum += n % 10;
		n /= 10;
	}
	return dsum;
}

template<typename T>
bool IsInRangeInclusive(T v, T min, T max) {
	return min <= v && v <= max;
}

int main() {
	int n, a, b, c;
	cin >> n >> a >> b;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (IsInRangeInclusive(DigitSum(i), a, b))
		{
			sum += i;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    rrep(n, N, 1)
    {
        int cnt = 0;
        int m = n;
        while (m % 2 == 0)
        {
            m /= 2;
            ++cnt;
        }
        if (m == 1)
        {
            cout << n << endl;
            return;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  
  int a,b,c; cin>>a>>b>>c;
  string ans="NO";
  for(int i=0;i<150;i++){
    if(a*i%b==c) ans="YES";
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int a, b;
  cin >> a >> b;

  if(a + b >= 10) cout << "error";
  else cout << a + b;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,cnt=0;
cin>>A>>B;
for(int i=A;i<=B;i++){
    int a=i/10000,b=i%10,c=(i/1000)%10,d=(i/10)%10;
    if(a==b&&c==d)cnt++;
}
cout<<cnt;
return 0;
}


Measured memory_bytes: 256
program colorful_hats_2
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, a(100000) = 0, i, c(3) = 0, j
  integer(8) :: ans = 1_8, m
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    m = 0_8
    do j = 1, 3
      if (a(i) == c(j)) m = m+1_8
    end do
    ans = mod(ans*m,md)
    do j = 1, 3
      if (a(i) == c(j)) then
        c(j) = c(j)+1
        exit
      end if
    end do
  end do
  write(*,'(i0)') ans
end program colorful_hats_2

Measured memory_bytes: 1152
fn solve() {
    let n = read();
    let mut a: Vec<usize> = vec![];
    for _ in 0..n {
        a.push(read());
    }
    let mut cur = a[0];
    let mut res = 0;
    for i in 0..n {
        if cur > a[i] {
            res += cur - a[i];
        } else {
            cur = a[i];
        }
    }
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2712
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n, a, b; cin >> n >> a >> b;
  lint ans = 0;
  ans += (n / (a + b)) * a;
  n %= (a + b);
  ans += min(a, n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(0);cin.tie(0)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define slld(t) scanf("%lld",&t)
#define plld(t) printf("%lld\n",t)
#define sc(t) scanf("%c",&t)
#define pb(x) push_back(x)
#define ii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<ii >
#define vvii vector<vii >
#define clr(x) memset(x,0,sizeof(x))
#define rep(i,begin,end) for(__typeof(end) i=begin-(begin>end);i!=end-(begin>end);i+=1-2*(begin>end))
#define MOD 1000000007
#define MAX 100005
#define EPS 1e-9
using namespace std;

int main()
{
	ll A[3];
	slld(A[0]);
	slld(A[1]);
	slld(A[2]);
	sort(A,A+3);
	if(A[2]%2) plld(A[0]*A[1]);
	else plld(0LL);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N, K;
  cin >> N >> K;
  int h[N];
  for(int i=0; i<N; i++) cin >> h[i];
  int dp[N];
  const int INF = 1e9;
  for(int i=0; i<N; i++) dp[i] = INF;
  dp[0] = 0;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<min(N, K+1); j++){
      if(i+j < N)
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdint>
#include <vector>
#include <utility>
#include <queue>

const uint32_t MAX_N = 707;

bool edge[MAX_N][MAX_N];
uint32_t vis[MAX_N];
uint32_t n;

std::vector<std::pair<uint32_t, uint32_t>> comps;

void input() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	uint32_t eCnt;
	std::cin >> n >> eCnt;
	for (uint32_t i = 0;i < eCnt;i++) {
		uint32_t a, b;
		std::cin >> a >> b;
		edge[a - 1][b - 1] = edge[b - 1][a - 1] = true;
	}
	for (uint32_t i = 0;i < n;i++) {
		edge[i][i] = true;
	}
}

bool calc_comps() {
	for (uint32_t i = 0;i < n;i++) {
		if (vis[i]) {
			continue;
		}
		vis[i] = 1;
		std::queue<uint32_t> next;
		next.push(i);
		//std::cerr << "Start comp " << i << ": " << 1 << "\n";
		while (!next.empty()) {
			uint32_t cur = next.front();
			next.pop();
			for (uint32_t j = 0;j < n;j++) {
				if (!edge[cur][j]) {
					if (vis[j]) {
						if (vis[j] == vis[cur]) {
							return false;
						}
					} else {
						vis[j] = vis[cur] == 1 ? 2 : 1;
						//std::cerr << "Assign " << j << ": " << vis[j] << "\n";
						next.push(j);
					}
				}
			}
		}

		uint32_t curCnt[] = {0, 0};
		for (uint32_t j = 0;j < n;j++) {
			if ((vis[j] >= 1) && (vis[j] <= 2))  {
				curCnt[vis[j] - 1]++;
				vis[j] = 3;
			} 
		}
		if (curCnt[0] > curCnt[1]) {
			std::swap(curCnt[0], curCnt[1]);
		}
		comps.push_back({curCnt[0], curCnt[1]});
	}
	return true;
}

bool possib[MAX_N + 1];

uint32_t calc_ans() {
	for (uint32_t i = 0;i <= n;i++) {
		possib[i] = false;
	}
	possib[0] = true;
	uint32_t baseSum = 0;
	for (auto c : comps) {
		baseSum += c.first;
		uint32_t delta = c.second - c.first;
		for (uint32_t j = n - delta;j <= n;j--) {
			if (possib[j]) {
				possib[j + delta] = true;
			}
		}
	}
	uint64_t best = n * n;
	for (uint32_t j = 0;j <= n;j++) {
		if (!possib[j]) {
			continue;
		}
		uint64_t a = baseSum + j;
		uint64_t b = n - a;
		//std::cerr << a << " " << b << "\n";
		uint64_t cur = a * (a - 1) / 2 + b * (b - 1) /2;
		best = std::min(cur, best);
	}
	return best;
}

int main() {
	input();
	if (!calc_comps()) {
		std::cout << "-1\n";
	} else {
		std::cout << calc_ans() << "\n";
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t M, K;
    cin >> M >> K;
    int64_t H = 1 << M;
    // M = 1 の場合だけは排他的論理総和が1となるので例外。
    if (M == 1) {
        if(K == 0) {
            cout << "0 0 1 1" << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    if(K >= H) {
        cout << -1 << endl;
        return 0;
    }
    // 排他的総和が0になることを活かす
    for(int64_t i = 0; i < H; i++) {
        if(i != K) cout << i << " ";
    }
    cout << K << " ";
    for(int64_t i = H - 1; i >= 0; i--) {
        if(i != K) cout << i << " ";
    }
    cout << K << endl;
    return 0;
}

Measured memory_bytes: 1792
<?php
list($n, $k) = ints();
$a = ints();
if ($k % gcdAll($a) === 0 && $k <= max($a)) echo 'POSSIBLE';
else echo 'IMPOSSIBLE';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 最大公約数（2つ）
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最大公約数（3つ以上）
function gcdAll($arr)
{
    $gcd = array_pop($arr);
    foreach ($arr as $a) {
        $gcd = gcd($gcd, $a);
    }
    return $gcd;
}

// 最小公倍数（2つ）
function lcm($m, $n)
{
    return (int) ($m / gcd($m, $n) * $n); // オーバーフローしないように先に割り算
}

// 最小公倍数（3つ以上）
function lcmAll($arr)
{
    $lcm = array_pop($arr);
    foreach ($arr as $a) {
        $lcm = lcm($lcm, $a);
    }
    return $lcm;
}


Measured memory_bytes: 27104
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  cout << vec[N-1]-vec[0]<<endl;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

int main() {
    string s;
    cin >> s;
    int ans = 1;
    rep(i, s.length()/2) {
        if ( s[i] != s[s.length()-i-1] ) {
            ans = 0;
        }
    }
    rep(i, s.length()/4) {
        if ( s[i] != s[ ((s.length()-1)/2)-i-1] ) {
            ans = 0;
            // cout << "a" << endl;
        }
        if ( s[((s.length()+3)/2)+i-1] != s[s.length()-i-1]) {
            ans = 0;
            // cout << "b" << endl;
        }
    }

    cout << (ans ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

ST = S + T
ST_set= set(ST)

list = []
for i in ST_set:
    list.append(S.count(i) - T.count(i))

if max(list) > 0:
    print(max(list))
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int a[100000];
    for(int i=0; i<M; i++){
        cin >> a[i];
    }
    
    int cnt=0;
    
    ll dp[100001];
    dp[0]=1;
    if(a[0]==1){
        dp[1]=0;
        cnt++;
    }else{
        dp[1]=1;
    }
    
    for(int i=2; i<=N; i++){
        if(cnt<M && a[cnt]==i){
            dp[i]=0;
            cnt++;
        }else{
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=MOD;
        }
    }
    
    cout<<dp[N]<<endl;
    return 0;
}






Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  long n,k,q;
  cin >> n >> k >> q;
  vector<long> a(n+1,0);

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

  for (int i=1; i<=n; i++) {
    bool ans = (q-a[i] < k);
    cout << (ans? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 1408
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if s1 <= 12 and s2 <= 12 and s1 >= 1 and s2 >= 1:
    print('AMBIGUOUS')
elif s1 <= 12 and s1 >= 1:
    print('MMYY')
elif s2 <= 12 and s2 >= 1:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
n,w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[10**11] * (n * (10**3) + 1) for _ in range(n+1)]

for i in range(1,n+1):
    dp[i-1][0] = 0
    w_temp, v_temp = wv[i-1]
    for j in range(1, (n*10**3)+1):
        if(j >= v_temp):
            dp[i][j] = min(dp[i-1][j],
                            dp[i-1][j-v_temp] + w_temp)
        else:
            dp[i][j] = dp[i-1][j]

last = dp[-1]
ans = 0
for j in range((n*10**3)+1):
    if(last[j] <= w):
        ans = j

print(ans)


Measured memory_bytes: 119148
#include <bits/stdc++.h>
using namespace std;
#define int long long

constexpr char BLACK = 'B';

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

    string s;
    cin >> s;

    const int n = s.size();

    int count = 0;
    int black_end = n - 1;

    for (int i = n - 1; i >= 0; i--)
    {
        const int t = s[i];

        if (t == BLACK)
        {
            count += black_end - i;
            black_end--;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 720
from fractions import gcd

X = int(input())

line = input()
numbers = [int(n) for n in line.split()]

left_list = [0]*(X+1)
right_list = [0]*(X+1)
for i in range(X):
    left_list[i+1] = gcd(left_list[i], numbers[i])
    right_list[X-1-i] = gcd(right_list[X-i], numbers[X-1-i])
predicted_value = max([gcd(left_list[i], right_list[i+1]) for i in range(X)])

print(predicted_value)

Measured memory_bytes: 17144
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef pair<string, int> P;
void solve()
{
	int n;
	bool flag = false;
	while(cin >> n, n)
	{
		if(flag)
		{
			cout << endl;
		}
		flag = true;
		vector<P> data(n);
		int temp[3];
		for(int i = 0; i < n; ++i)
		{
			cin >> data[i].first >> temp[0] >> temp[1] >> temp[2];
			data[i].second = temp[0] * 3 + temp[2];
		}
		
		for(int i = 0; i < n; ++i)
		{
			for(int j = n - 1; j > i; --j)
			{
				if(data[j].second > data[j - 1].second)
				{
					P a = data[j];
					data[j] = data[j - 1];
					data[j - 1] = a;
				}
			}
		}
		for(int i = 0; i < n; ++i)
		{
			cout << data[i].first << "," << data[i].second << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    int maxx = (max)({a, b, c});
    cout<<a+b+c-maxx<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int parent(int );
int left(int );
int right(int );
void maxHeapInsert(int );
int heapIncreaseKey(int ,int ); 
int heapExtractMax(void);
void maxHeapify(int );
int heap_size=0;
int A[2000000];
int main() {
	char string[10];
	int key;
	while(1) {
		scanf("%s",string);
		if(strcmp(string,"end") == 0) break;
		if(strcmp(string, "insert") == 0)  {
			scanf("%d",&key);
			maxHeapInsert(key);
		}
		if(strcmp(string,"extract") == 0) printf("%d\n",heapExtractMax());
	}
	return 0;
}

int parent(int i) { return i/2; }
int left(int i) { return 2*i; }
int right(int i) { return 2*i+1; }

void maxHeapInsert(int key) {
	heap_size++;
	A[heap_size] = -1;
	heapIncreaseKey(heap_size,key);
}

int heapIncreaseKey(int i,int key) {
	int temp;
	if(key < A[i]) return 0; //新しいキーは、現在のキーより小さい
	A[i] = key;
	while ( i >1&& A[parent(i)] < A[i]) {
		temp = A[i];
		A[i] = A[parent(i)];
		A[parent(i)] = temp;
		i = parent(i);
	}
}

int heapExtractMax(void) {
	int max;
	if( heap_size < 1) return 0; //ヒープアンダーフロー
	max = A[1];
	A[1] = A[heap_size];
	heap_size--;
	maxHeapify(1);
	return max;
}

void maxHeapify(int i) {
    int l,r,temp,largest=0;
    l = left(i);
    r = right(i);
    if( l <= heap_size && A[l] > A[i] ) largest = l;
    else largest = i;
    if( r <= heap_size && A[r] > A[largest] ) largest = r;
    if(largest != i) {
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeapify(largest);
    }
}

Measured memory_bytes: 4696