akhauriyash/Code-Regression huggingface dataset:
#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);
  sort(a.begin(), a.end());
  
  int rec1=0, rec2=0;
  int buf=a.at(0), cnt=0;
  for (int i=0; i<n; i++){
    if (a.at(i) == buf){
      cnt++;
      if (cnt == 2){
        rec1 = rec2; rec2 = a.at(i);
        cnt = 0;
      }
    }else{
      buf = a.at(i);
      cnt = 1;
    }
  }
  cout <<(long)rec1*rec2 <<endl;
}


Measured memory_bytes: 640
// abc125_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (int)(1e9+5)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll mn = INF;
    ll sm = 0;
    int minus = 0;
    REP(i, N) {
        mn = min(mn, abs(A[i]));
        sm += abs(A[i]);
        if (A[i] < 0) minus++;
    }
    if (minus & 1){
        print(sm - 2 * mn);
    } else {
        print(sm);
    }

    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] firstRowInput = br.readLine().split(" ");
            String[] secondRowInput = br.readLine().split(" ");

            int whiteRowCount = Integer.parseInt(firstRowInput[0]);
            int whiteColumnCount = Integer.parseInt(firstRowInput[1]);
            int blackRowCount = Integer.parseInt(secondRowInput[0]);
            int blackColumnCount = Integer.parseInt(secondRowInput[1]);
            int whiteCellsCountIs = (whiteRowCount - blackRowCount) * (whiteColumnCount - blackColumnCount);

            System.out.println(whiteCellsCountIs);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    // 入力
    string S;
    cin >> S;

    int kisu_ok = 0;
    int gusu_ok = 0;
    for (int i = 0; i < S.length(); i++) {
        // cout << S[i] << endl;
        if (i % 2 == 0) {
            //cout << "kisu_enter" << endl;
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
                kisu_ok++;
            }
        }
        else {
            //cout << "gusu_enter" << endl;
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
                gusu_ok++;
            }
        }
    }

    int kisu_ok_max = 0;
    int gusu_ok_max = 0;
    if (S.length() % 2 == 0) {
        kisu_ok_max = S.length() / 2;
        gusu_ok_max = S.length() / 2;
    }
    else {
        kisu_ok_max = S.length() / 2 + 1;
        gusu_ok_max = S.length() / 2;
    }

    string result = "No";
    if (kisu_ok == kisu_ok_max && gusu_ok == gusu_ok_max) {
        result = "Yes";
    }


    //cout << result << " " << kisu_ok << " " << kisu_ok_max << " " << gusu_ok << " " << gusu_ok_max <<  endl;
    cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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 namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  ll ans= LLONG_MAX;
  //cout << ans << endl;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i==0){
      ans=min( ans, n/i + i - 2 );
    }
  }
  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	cin >> n;
	int count = 1;
	while(n--)
	{
		char field[8][8];
		for(int i = 0; i < 8; ++i)
		{
			for(int j = 0; j < 8; ++j)
			{
				cin >> field[i][j];
			}
		}
		int x, y;
		cin >> x >> y;
		field[y - 1][x - 1] = '0';
		queue<P> que;
		que.push(P(x - 1, y - 1));
		while(!que.empty())
		{
			P p = que.front();
			que.pop();
			for(int i = -3; i <= 3; ++i)
			{
				if(p.first + i < 0 || p.first + i >= 8)
				{
					continue;
				}
				if(field[p.second][p.first + i] == '1')
				{
					field[p.second][p.first + i] = '0';
					que.push(P(p.first + i, p.second));
				}
			}
			for(int i = -3; i <= 3; ++i)
			{
				if(p.second + i < 0 || p.second + i >= 8)
				{
					continue;
				}
				if(field[p.second + i][p.first] == '1')
				{
					field[p.second + i][p.first] = '0';
					que.push(P(p.first, p.second + i));
				}
			}
		}
		cout << "Data " << count << ":" << endl;
		for(int i = 0; i < 8; ++i)
		{
			for(int j = 0; j < 8; ++j)
			{
				cout << field[i][j];
			}
			cout << endl;
		}
		++count;
	}
}

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

Measured memory_bytes: 1200
//ΔAGC020A
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if(a%2==b%2)
		cout<<"Alice";
	else
		cout<<"Borys";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int itemCount = inpt[0];
        int len = inpt[1];

        int[] items = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int ans = 0;
        for (int i = 0; i < itemCount; i+=len-1) {
            ans++;
            if(i == itemCount - 1) {
                ans--;
            }
        }

        Console.WriteLine(ans);
    }

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"
 
 
8 3
7 3 1 8 4 6 2 5
 
 
";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define ull unsigned long long
#define ld long double
#define uint unsigned int
struct debug {
~debug() {cerr << "\n";}template<class C> debug& operator<<(C c) {cerr << c;return *this;}
};
#define var(x) " [" << #x << ": " << x << "]"

int n;

void solve() {
    cin >> n;
    for(int i=0; i<n; ++i) {
        cout << "ACL";
    }
    cout << "\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n,x = map(int,input().split())
s = list(map(int,input().split()))
mod = 10**9 + 7
s.sort()
s = s[::-1]
c = max(max(s),x)
dp = [[0]*(c+1) for i in range(n+1)]
dp[0][x] = 1
for i in range(n):
    for j in range(c+1):
        dp[i+1][j%s[i]] += dp[i][j]
        dp[i+1][j%s[i]] %= mod
        dp[i+1][j] += dp[i][j]*(n-i-1)
        dp[i+1][j] %= mod
ans = 0
for i in range(c+1):
        ans += dp[n][i]*i
        ans %= mod
print(ans)

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

int main() {
    int N; cin >> N;
    vector<ll> a(N+1, -1);
    for(int i=1; i<=N; i++){
        cin >> a.at(i);
        if(i==N){
            a.at(0) = a.at(N);
        }
    }

    ll l = 0;
    ll r = a.at(1);
    vector<ll> dp(N+1, -1);

    while(r-l>=0){
        bool flag = false;
        ll tmp_i = 1;
        dp.at(1) = (l+r)/2;

        for(int i=2; i<=N; i++){
            if(a.at(i-1)-dp.at(i-1)<0){
                tmp_i = i;
                flag = true;
                break;
            }
            dp.at(i) = a.at(i-1) - dp.at(i-1);
        }

        //cout << dp.at(1) << " " << dp.at(N) << endl;

        if(flag){
            if(tmp_i%2 == 0) r = dp.at(1)-1;
            else l = dp.at(1)+1;
            continue;
        }

        if(dp.at(1) == a.at(N) - dp.at(N)) break;
        if(dp.at(N) > a.at(N)){
            r = dp.at(1)-1;
        }
        else{
            if(dp.at(1) < a.at(N) - dp.at(N)){
                l = dp.at(1)+1;
            }
            else{
                r = dp.at(1)-1;
            }
        }
    }


    for(int i=1; i<=N; i++){
        cout << 2*dp.at(i);
        if(i!=N) cout << " ";
    }

    cout << endl;

}


Measured memory_bytes: 2944
from collections import deque
from itertools import product


def bfs(x, y):
    dist = [[10 ** 9] * w for _ in range(h)]
    dist[y][x] = 0
    que = deque([(x, y)])

    while len(que) > 0:
        x, y = que.popleft()
        num = product([-2, -1, 0, 1, 2], repeat=2)
        near = [(x + dx, y + dy) for dx, dy in num]
        if (x, y) == (Dw - 1, Dh - 1):
            return dist[y][x]

        for i, j in near:
            cnt = (abs(x - i) + abs(y - j) >= 2)
            if (0 <= i < w and 0 <= j < h and
                    dist[j][i] > dist[y][x] + cnt and s[j][i] == '.'):
                dist[j][i] = dist[y][x] + cnt
                if cnt == 0:
                    que.appendleft((i, j))
                elif cnt == 1:
                    que.append((i, j))
    return -1


h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [input() for _ in range(h)]

print(bfs(Cw - 1, Ch - 1))


Measured memory_bytes: 98356
def main():
    N, Y = map(int, input().split())
    for i in range(N+1):
        for j in range(N-i+1):
            if 10000*i + 5000*j + 1000*(N-i-j) == Y:
                print(i, j, N-i-j)
                return
    print(-1, -1, -1)


if __name__ == "__main__":
    main()


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

int main()
{
    int n, k;
    cin >> n >> k;
    string str;
    cin >> str;

    vector<int> rlen;
    vector<char> state;
    char cur = ' ';
    int idx = -1;
    for(int i = 0; i < n; ++i)
    {
        if(cur != str[i])
        {
            rlen.push_back(0);
            cur = str[i];
            state.push_back(str[i]);
            idx += 1;
        }
        rlen[idx] += 1;
    }

    for(int i = 1; i < (int)rlen.size(); ++i)
    {
        rlen[i] += rlen[i-1];
    }
    vector<int> ans(rlen.size());
    for(int i = 0; i < (int)rlen.size(); ++i)
    {
        int t = 0;
        if(state[i] == '0')
        {
            t = min(idx,i+(2*k-1));
        }
        else
        {
            t = min(idx,i+2*k);
        }
        ans[i] = rlen[t];
        if(i != 0)
        {
            ans[i] -= rlen[i-1];
        }
    }
    cout << *max_element(ans.begin(), ans.end()) << endl;
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fa(x,y) for(auto x:y)
#define endl '\n'
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fr(i,x,n) for(i=x;i>=n;--i)

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

bool valid(int x){
    int tmp=sqrt(x);
    return tmp*tmp==x;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin>>x;
    int ans=1;
    int j;
    f(x+1){
        auto tmp=i;
        fi(j,1,10){
            tmp*=i;
            if(tmp>x) break;
            ans=max(tmp,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n];
	
	for(i=0;i<n;i++){
		cin>>ar[i];
	}

	vector<ll> vc;
	ll gf=1,h=n-1;
	for(j=1;j<=n;j++){
		int f=0;
		for(i=h;i>=0;i--){
			if(ar[i]==(i+1)){
				vc.ps(ar[i]);
				f=1;
				break;
			}
		}
		if(f==0){
			gf=0;
			break;
		}
		for(k=i+1;k<n;k++){
			ar[k-1]=ar[k];
		}
		h--;
	}
	if(gf==0){
		cout<<"-1";
	}
	else {
		reverse(all(vc));
		for(i=0;i<n;i++){
			cout<<vc[i]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  rep(left, n) {
    while (h[left] > 0) {
      int right = left, mini = h[left];
      for (; right < n; right++) {
        if (h[right] == 0) break;
        cmin(mini, h[right]);
      }
      // cout << left << ' ' << right << ' ' << mini << endl;

      for (int i = left; i < right; i++) h[i]--;
      // for (auto a : h) {
      //   cout << a << ' ';
      // }
      // cout << endl;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;

#define pii pair<int,int>
#define pil pair<int,long>
#define pli pair<long,int>
#define pll pair<long,long>

#define vi vector<int>
#define vii vector<pii>
#define vul vector<ull>
#define vs vector<string>
#define vl vector<long>

#define lp(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define loopd(i,a,n) for(i=a;i>n;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define MAX 1000000007
        
vul jump; 
vi arr;
int k,n;

void dp(int i){
  int j;
  ull a;
  if(i>=0){
    jump[i]=MAX;
    loop(j,1,k+1){
      if(i+j>=n){
        break;
      }
      a = jump[i+j] + abs(arr[i+j] - arr[i]);
   	  jump[i] = min(a,jump[i]);
    }
    dp(i-1);
  }
}  

int main(){
  int i;
  cin>>n>>k;
  arr.resize(n);
  jump.resize(n);
  lp(i,n)
    cin>>arr[i];
  jump[n-1]=0;
  if(n>=2)	dp(n-2); 
  cout<<jump[0];
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int poww(int a,int i){
    if(i==0) return 1;
    return a*poww(a,i-1);
}
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int dp[999999];
    dp[0]=0;
    for(int i=0;i<999999;i++){
        dp[i]=i;
    }
    for(int i=0;i<=n;i++){
        for(int j=1;j<=6;j++){
            dp[i+poww(6,j)]=min(dp[i]+1,dp[i+poww(6,j)]);
        }
        for(int j=1;j<=5;j++){
            dp[i+poww(9,j)]=min(dp[i]+1,dp[i+poww(9,j)]);
        }
    }
    cout<<dp[n];
} 


Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>

int main(){
    char s[101], t[101], u[202], v[102];
    long long int tc = 0, uc = 0, vc = 0;
    long long int k;
    long long int ans = 0;
    int len;
    scanf("%s", s);
    scanf("%lld", &k);
    strcpy(t, s);
    for(int i=1; i<strlen(t); i++){
        if(t[i-1] == t[i]){
            t[i] = '&';
            tc++;
        }
    }
    u[0] = t[strlen(t)-1];
    v[0] = t[strlen(t)-1];
    u[1] = '\0';
    v[1] = '\0';
    strcat(u, s);
    strcat(u, s);
    strcat(v, s);
    for(int i=1; i<strlen(u); i++){
        if(u[i-1] == u[i]){
            u[i] = '&';
            uc++;
        }
    }
    for(int i=1; i<strlen(v); i++){
        if(v[i-1] == v[i]){
            v[i] = '&';
            vc++;
        }
    }
    /*printf("s : %s\n", s);
    printf("t : %s\n", t);
    printf("u : %s\n", u);
    printf("v : %s\n", v);*/
    ans += tc;
    k--;
    ans += (k/2) * uc;
    if(k%2){
        ans += vc;
    }
    printf("%lld", ans);

    return 0;
}

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

int main()
{
   int n; cin >> n;
   std::vector<int> v(n);
   for(int i=0; i<n; i++) {
        cin >> v[i];
   }

   sort(v.begin(),v.end());
   ll ans = INT_MAX;
   for(int j = v[0] ; j<= v[n-1]; j++){
        ll max_sum = 0;
        for(int i=0; i<n;i++){
            int tmp = abs(j - v[i]);
            max_sum += tmp*tmp; 
        }
        ans = min(ans,max_sum);
   }

   cout << ans << endl;
   

   return 0;   
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    C = False
    F = False
    for s in S:
        if s=="C":
            C=True
        if s=="F":
            if C:
                F=True

    if C and F:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

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

int main(int argc, char *argv[])
{
  int n, i, j, k;
  int **M;
  int id, op;

  scanf("%d", &n);
  M = (int **)malloc(sizeof(int *) * (n + 1));
  for (i = 1; i <= n; i++) M[i] = (int *)malloc(sizeof(int) * (n + 1));

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      M[i][j] = 0;
    }
  }

  for (i = 1; i <= n; i++) {
    scanf("%d", &id);
    scanf("%d", &k);

    for (j = 0; j < k; j++) {
      scanf("%d", &op);
      M[id][op] = 1;
    }
  }

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (j != n) printf("%d ", M[i][j]);
      else printf("%d\n", M[i][j]);
    }
  }

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

char a[10][10];
bool b[10][10];
int main() {
	ll h,w;
	cin>>h>>w;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>a[i][j];
			if(a[i][j]=='#'){
				b[i][j]=true;
			}
		}
	}
	b[0][0]=false;
	b[h-1][w-1]=false;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			char now=a[i][j];
			if(now=='#'){
				if(a[i+1][j]=='#'&&i+1<h){
					b[i+1][j]=false;
					continue;
				}
				if(a[i][j+1]=='#'&&j+1<w){
					b[i][j+1]=false;
					continue;
				}
			}
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(b[i][j]==true){
				cout << "Impossible";
				return 0;
			}
		}
	}
	cout << "Possible";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000

int main()
{
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<ll, vector<ll>, greater<ll>> r, g;
    rep(i, a) {
        ll l;
        scanf("%lld", &l);
        r.push(l);
    }
    rep(i, b) {
        ll l;
        scanf("%lld", &l);
        g.push(l);
    }
    while (r.size() > x) {
        r.pop();
    }
    while (g.size() > y) {
        g.pop();
    }
    rep(i, c) {
        ll rr = r.top();
        ll gg = g.top();
        ll s;
        scanf("%lld", &s);
        if (s > min(rr, gg)) {
            if (rr < gg) {
                r.pop();
                r.push(s);
            } else {
                g.pop();
                g.push(s);
            }
        }
    }
    ll s = 0;
    while (!r.empty()) {
        s += r.top();
        r.pop();
    }
    while (!g.empty()) {
        s += g.top();
        g.pop();
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 2548
#include <iostream>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a,b) (((a)-(b))>0?((a)-(b)):((b)-(a)))

using namespace std;

int main(){
	int N; cin >> N;
	int A[N];
	bool up;
	cin >> A[0] >> A[1];
	int ii=2;
	// 下落->下落, 上昇->上昇の場合は間を取り除いてよい
	rep(i,2,N){
		bool up = A[ii-1]>A[ii-2];
		cin >> A[ii];
		if( up && A[ii]>A[ii-1] ) A[ii-1]=A[ii];
		else if( !up && A[ii]<A[ii-1] ) A[ii-1]=A[ii];
		else if( A[ii]==A[ii-1] ) continue;
		else ii++;
	}
	N = ii;
	
	llong money = 1000,stock = 0;
	rep(i,0,N-1){
		if( A[i] < A[i+1] ){
	// 次の日の方が高いなら限界まで買う
			stock += money/A[i];
			money %= A[i];
		}else{
	// 次の日の方が安ければすべて売る
			money += stock*A[i];
			stock = 0;
		}
		//cout << money << " " << stock << endl;
	}
	money += stock*A[N-1];
	cout << money << endl;
	
// check
	//rep(i,0,N) cout << A[i] << endl;
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = stdIn.nextInt();
        }
        stdIn.close();
        int[] cnt = new int[N];
        for (int i = 0; i < N; i++) {
            cnt[i] = 0;
            A[i]--;
        }
        for (int i = 0; i < N; i++) {
            cnt[A[i]]++;
        }

        // 消さないとき
        long total = 0;
        for (int i = 0; i < N; i++) {
            total += choose2(cnt[i]);
        }
        // i番目を消したとき
        for (int i = 0; i < N; i++) {
            long ans = total;
            ans -= choose2(cnt[A[i]]);
            ans += choose2(cnt[A[i]] - 1);
            System.out.println(ans);
        }
    }

    // n個の中から2個選ぶ関数
    public static long choose2(long n) {
        return n * (n - 1) / 2;
    }
}

Measured memory_bytes: 89904
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>

main()
{
  int D,N,i,s;
  scanf("%d%d",&D,&N);
  D = pow(100,D);
  for(i=0,s=0; i<N; i++)
    s += D;
  if(N==100)
    s += D;
  printf("%d\n",s);
}


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


void PRINT(char* words,int a,int b){
    for(int i = a-1;i<b;i++){
        printf("%c",words[i]);
    }
    printf("\n");
    return;
}

void REVERSE(char* words,int a,int b){
    char buff[b-a+1];
    for(int i = 0;i<b-a+1;i++){
        buff[i] = words[a+i-1];
    }
    for(int i = 0;i<b-a+1;i++){
        words[b-i-1] = buff[i];
    }
    return;
}

void REPLACE(char* words,int wordsLen,int a,int b,char* c,int cLen){
    char buffB[wordsLen-b];
    for(int i=0;i<wordsLen-b;i++){
        buffB[i] = words[b+i];
    }

    for(int i = 0;i<cLen;i++){
        words[i+a-1] = c[i];
    }
    for(int i = 0;i<wordsLen-b;i++){
        words[i+a+cLen-1] = buffB[i];
    }
    words[wordsLen + cLen - 1] = '\n';
    
    return;
}


int main(){
    
    char STR[1001];
    int OrderNum;

    scanf("%s",STR);
    scanf("%d",&OrderNum);
    //printf("%s",STR);
    //printf("%d",OrderNum);
    for(int i = 0;i < OrderNum;i++){
        char order[10];
        scanf("%s",order);
        //printf("%s",order);
        //printf("%d",strcmp(order,"replace"));

        if(strcmp(order,"print") == 0){
            int a,b;
            scanf("%d%d",&a,&b);
            PRINT(STR,a+1,b+1);
        }else if(strcmp(order,"reverse") == 0){
            int a,b;
            scanf("%d%d",&a,&b);
            REVERSE(STR,a+1,b+1);
        }else if(strcmp(order,"replace") == 0){
            int a,b;
            char c[1001];
            scanf("%d%d%s",&a,&b,c);
            //printf("%d%d%s\n",a,b,c);
            REPLACE(STR,strlen(STR),a+1,b+1,c,strlen(c));
        }
        //printf("%s\n",STR);
    }


    
    


    return 0;
}



Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);

    ll max_a = 0;
    for(ll i=0; i<n; i++){
        cin >> a[i] >> b[i];
        if(a[i] > max_a){
            max_a = a[i];
        }
    }
    priority_queue<ll> thrw;
    for(ll i=0; i<n; i++){
        if(b[i] >= max_a) thrw.push(b[i]);
    }

    ll ttl = 0;
    ll cnt = 0;
    while(ttl < h){
        if(thrw.empty()){
            ttl += max_a;
            cnt++;
        }
        else{
            ttl += thrw.top();
            thrw.pop();
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    ll a; long double b; cin >> a >> b;
    b *= 1000;
    cout << (ll)(a*b/1000) << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
    int paSize = printArray.size();
    for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
    if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int INF = 1e8;
int N;
vec<int> c;
int dp[111111];

int main() {
    cin >> N;
    for (int i = 6; i <= N; i*=6) {
        c.push_back(i);
    }
    for (int i = 9; i <= N; i*=9) {
        c.push_back(i);
    }
    c.push_back(1);

    fill(dp, dp+N+1, INF);
    dp[0] = 0;

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < c.size(); j++) {
            if (i >= c[j]) {
                dp[i] = min(dp[i], dp[i-c[j]]+1);
            }
        }
    }
    cout << dp[N] << endl;

    return 0;
}

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

f=[[0 for i in range(2*n)] for j in range(2*n)]
r=[10000]
b=[]

for k in range(n):
    i,j=map(int,input().split())
    f[i][j]=1
    
for k in range(n):
    i,j=map(int,input().split())
    f[i][j]=2
    
ans=0

for j in f:
    h=0
    for i in j:
        h+=1
        if i==1:
            r.append(h)
            r.sort()
            r.reverse()
        if i==2:
            for k in r:
                if h>=k:
                    ans+=1
                    r.remove(k)
                    break
                
print(ans)
                    

Measured memory_bytes: 3316
import math

daily_coin, bonus_coin, goal = (int(x) for x in input().split())

days = goal // daily_coin
weekly_coin = daily_coin * 7 + bonus_coin

if days < 7:
    print(math.ceil(goal / daily_coin))

elif days == 7:
    if daily_coin * 7 < goal < weekly_coin:
        print(7)
        
else:
    week = goal // weekly_coin
    rest_coin = goal - weekly_coin * week
    if (daily_coin * 7 < rest_coin < weekly_coin) or (daily_coin * 6 < rest_coin < weekly_coin):
        rest_days = 7
        print(week * 7 + rest_days)
    else:
        rest_days = math.ceil(rest_coin / daily_coin)
        print(week * 7 + rest_days)


Measured memory_bytes: 5672
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int[] nums = new int[5];
		int i = 0;
		
		StringTokenizer st = new StringTokenizer(br.readLine()," ");
		
		while(st.hasMoreTokens()) {
			nums[i++] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(nums);
		for (int j = nums.length - 1; j >= 0; j--) {
			System.out.print(nums[j]);
			if(j != 0) System.out.print(" ");
		}
		System.out.println();
		
	}
	
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
     ifstream in("input.txt");
     cin.rdbuf(in.rdbuf());
  //*/
  int N, M, X;
  cin >> N >> M >> X;
  int cost1 = 0, cost2 = 0;
  for(int i = 0; i < M; i++){
    int a;
    cin >> a;
    if(a < X){
      cost1++;
    }else{
      cost2++;
    }
  }
  cout << min(cost1, cost2)<<endl;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, x, y; cin >> n >> x >> y; x--, y--;
    
    vector<int> cnt(n);
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y), g[y].push_back(x);
    for (int i = 0; i < n; i++) {
        vector<int> d(n, inf);
        queue<int> q;
        q.push(i); d[i] = 0;
        while (!q.empty()) {
            int now = q.front(); q.pop();
            for (auto nxt: g[now]) {
                if (d[nxt] < inf) continue;
                d[nxt] = d[now] + 1;
                q.push(nxt);
            }
        }
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            cnt[d[j]]++;
        }
    }
    for (int i = 1; i < n; i++) cout << cnt[i] / 2 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	double a;
	double s = 0;

	while(scanf("%lf", &a) != EOF){
		s = a;
		for(int i=2; i<=10; i++){
			if(i%2 == 0){
				a = a*2;
				s += a;
			}else{
				a = a/3;
				s += a;
			}
		}
		printf("%.8f\n", s);
	}

	return 0;
}

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

int main() {
    int n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2 || p == 5) {
         rep(i, n){
            if ((s[i]-'0') % p == 0) {
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> d(n+1);
    int ten = 1;
    for (int i = n-1; i >= 0; i--) {
        int a = (s[i]-'0') * ten % p;
        d[i] = (d[i+1]+a) % p;
        ten *= 10; ten %= p;
    }
    vector<int> cnt(p, 0);
    for (int i = n; i >= 0; i--) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
}

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

two = 0
four = 0
for i in map(int, input().split()):
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        two += 1

tmp = two * (two > 1)
print('Yes' if (four * 2 + (four == n // 2) + two * (two > 1)) >= n else 'No')


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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N = in.i();
        String[] tmp = in.ss();
        int[] ans = new int[N];
        for(int i = 0; i < N; i++){
          int a = Integer.parseInt(tmp[i]);
          ans[a-1] = i+1;
        }
        for(int i = 0; i < N; i++)
          out.printf("%d ", ans[i]);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 68792
N,T=map(int,input().split())
c=[]
t=[]
for i in range(N):
    ci,ti=map(int,input().split())
    c.append(ci)
    t.append(ti)
min=10**30
for i in range(N):
    if t[i]<=T and min>=c[i]:
        min=c[i]
if min==10**30:
    print("TLE")
else:
    print(min)

Measured memory_bytes: 38256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String w = sc.next();
    String end = "END_OF_TEXT";
    boolean tmp = true;
    int ans = 0;

    while(tmp){
      String t = sc.next();

      if(t.equals(end)){
        tmp = false;
        break;
      }

      if(t.equalsIgnoreCase(w)){
        ans += 1;
      }
    }

    System.out.println(ans);
  }
}



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

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    int at = 0, mini = 0;
    for (char c : S) {
        if (c == '(')
            at++;
        else
            at--;
        mini = min(mini, at);
    }

    string ans;
    for (int i = 0; i < -mini; i++)
        ans += '(';
    ans += S;
    for (int i = 0; i < at - mini; i++)
        ans += ')';

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[501][501],b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l[200001],r[200001],res;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int main() {
    cin>>n>>m>>x;
    rep(i,m){
        cin>>l[i]>>r[i];
        a[l[i]][r[i]]++;
    }
    //rep(i,0,n+1){rep(j,0,n+1){ps(a[i][j]);}p("");}
    rep(i,1,n+1)rep(j,1,n+1)a[i][j]+=a[i][j-1];
    rep(i,1,n+1)rep(j,1,n+1)a[j][i]+=a[j-1][i];
    //rep(i,1,n+1){rep(j,1,n+1){ps(a[i][j]);}p("");}
    rep(i,x){
        cin>>p>>q;
        p(a[q][q]-a[p-1][q]-a[q][p-1]+a[p-1][p-1]);
    }
    return 0;
}


Measured memory_bytes: 6016
n = int(input())
#L, R = list(map(int, input().split()))
#n, x, t = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# n = int(input())
#l = list(map(int, input().split()))
#r = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# data = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
# for i in range(1, int(n**0.5)+1):
count = 0
#_max = 0
for i in range(1, n):
    if a[i-1] > a[i]:
        #_max = a[i]
        count += a[i-1]-a[i]
        a[i] = a[i-1]

print(count)


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

ll gcd(ll a, ll b){
  if(b > a) return gcd(b, a);
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> A(N);
  ll g = 0, ma = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == K) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
    ma = max(ma, A[i]);
    g = gcd(A[i], g);
  }
  
  if(K > ma){
    cout << "IMPOSSIBLE" << endl;
  }else if(K % g == 0){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  } 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using lint = long int;
using llint = long long int;
using namespace std;
double manhattan(const vector<double> &vx, const vector<double> &vy) {
    double dist = 0;
    for (int i = 0; i < vx.size(); i++) {
        dist += abs(vx[i] - vy[i]);
    }
    return dist;
}
double euclide(const vector<double> &vx, const vector<double> &vy) {
    double dist = 0;
    for (int i = 0; i < vx.size(); i++) {
        dist += pow(abs(vx[i] - vy[i]), 2);
    }
    return sqrt(dist);
}
double third(const vector<double> &vx, const vector<double> &vy) {
    double dist = 0;
    for (int i = 0; i < vx.size(); i++) {
        dist += pow(abs(vx[i] - vy[i]), 3);
    }
    return pow(dist, 1.0 / 3.0);
}
double chebyshev(const vector<double> &vx, const vector<double> &vy) {
    double _max = -2001;
    for (int i = 0; i < vx.size(); i++) {
        _max = max(_max, abs(vx[i] - vy[i]));
    }
    return _max;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> vx(n), vy(n);
    rep(i, n) cin >> vx[i];
    rep(i, n) cin >> vy[i];
    cout << fixed;
    cout << setprecision(10) << manhattan(vx, vy) << endl;
    cout << setprecision(10) << euclide(vx, vy) << endl;
    cout << setprecision(10) << third(vx, vy) << endl;
    cout << setprecision(10) << chebyshev(vx, vy) << endl;
    return 0;
}


Measured memory_bytes: 3508
#include<iostream>



using namespace std;
int main()
{   int x=0; int max=0; int z=1; int N; cin>>N; char str[N];
 for(int m=0;m<N;m++)
     { cin>>str[m];
	 }
     for(int i=0;i<N;i++)
{      if(str[i]=='I')
        {       x++;
      if(x>=max)
       {      max=x;}
else {      z=1;} }
      else if(str[i]=='D')
{

      x--;
if(x>=max)
       {      max=x;}
else {      z=1;}
}
      else
continue;
}
cout<<max;
return 0;

              
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    ll n, m, i, j, k, l;
    cin>>n;
    ll res=n/500;
    n%=500;
    ll res1=n/5;
    cout<<(res*1000)+(res1*5)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct BIT{
  ll M=1;
  vector<ll> dat;
  BIT(ll N){
    while(N>M) M*=2;
    dat.resize(M*2-1, 0);
  }
  void update(ll x, ll k){
    for(int i=k+1;i<=M;i+=(i&(-i))){
      dat[i] += x;
    }
  }
  ll sum(ll r){
    ll ret = 0;
    for(int k=r;k>0;k-=(k&(-k))) ret += dat[k];
    return ret;
  }

  ll query(ll l, ll r){
    return sum(r) - sum(l);
  }
};

int main(int argc, char const *argv[]) {
  ll n, q;std::cin >> n >> q;
  vll c(n);
  vvl x = VV(n, 0, 0, ll);
  re(i, n) {
    std::cin >> c[i];
    c[i]--;
    x[c[i]].push_back(i);
  }
  BIT seg(n+1);
  vll ans(q, 0);
  vector<vector<pair<ll, ll>>> d(n);
  for(int i=0;i<q;i++){
    ll l, r;std::cin >> l >> r;
    l--, r--;
    d[r].push_back(pair<ll, ll>(l, i));
  }
  for(int i=0;i<n;i++){
    ll now = c[i];
    auto itr = lower_bound(all(x[now]), i);
    ll pre = 0;
    if(itr!=x[now].begin()){
      itr--;
      pre = (*itr) + 1;
    }
    seg.update(1, i);
    if(pre!=0) seg.update(-1, pre-1);
    for(auto v:d[i]){
      ll l = v.first;
      ll idx = v.second;
      ans[idx] = seg.query(l, i+1);
    }
  }
  re(i, q) std::cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 71932
#!/usr/bin/env python3
def main():
    N = int(input())
    cnt = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include "bits/stdc++.h"
using namespace std;

int N;
double p[3005];
double dp[3005][3005];

// dp[n][h] = prob of obtaining h heads with first n coins;

double rec(int n, int h)
{
    if (dp[n][h] != -1)
        return dp[n][h];

    if (n == 1)
    {
        if (h == 0)
            return dp[n][h] = 1 - p[n];
        else
            return dp[n][h] = p[n];
    }

    if (h == 0)
        return dp[n][h] = rec(n - 1, h) * (1 - p[n]);

    if (h == n)
        return dp[h][n] = rec(n - 1, h - 1) * p[n];

    return dp[n][h] = rec(n - 1, h - 1) * p[n] + rec(n - 1, h) * (1 - p[n]);
}

int main()
{
    cin >> N;
    for (int i = 1; i <= N; i++)
        cin >> p[i];

    for (int i = 1; i <= N; i++)
        for (int j = 0; j <= N; j++)
            dp[i][j] = -1;

    double ans = 0;
    for (int i = N; i >= (N / 2) + 1; i--)
    {
        ans += rec(N, i);
    }
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}

Measured memory_bytes: 70912
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
s1
...
sn
m
t1
...
tm

n m 100
s t 10
 */
int n,m;
map<string,int> mp;

int main(){
  cin>>n;
  REP(i,n){
    char s[11];
    cin>>s;
    mp[s]++;
  }

  cin>>m;
  REP(j,m){
    char t[11];
    cin>>t;
    mp[t]--;
  }

  int ans = 0;
  for(auto i : mp){
    ans=max(ans, i.second);
  }

  cout << max(0,ans) << endl;

  return 0;
}


Measured memory_bytes: 256
(defun evenstrp (k)
  (and (evenp (length k)) (equal (subseq k 0 (/ (length k) 2)) (subseq k (/ (length k) 2)))))
(princ (length (find-if #'evenstrp (mapcon 'list (cdr (reverse (concatenate 'list (read-line))))))))

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

void solve(long long W, long long a, long long b) {

  if (a <= b)
    if (a + W >= b)
      cout << 0 << endl;
    else
      cout << b - (a + W) << endl;

  if (a > b)
    if (b + W >= a)
      cout << 0 << endl;
    else
	cout << a - (b + W) << endl;

}

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

  long long W;
  scanf("%lld", &W);
  long long a;
  scanf("%lld", &a);
  long long b;
  scanf("%lld", &b);
  solve(W, a, b);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a,b,c,d,f,g;
  scanf("%d %d", &a, &b);
  c=a+b;
  d=a-b;
  f=a*b;
  g=c;
  if(g<d){
    g=d;
  }
  if(g<f){
    g=f;
  }
  printf("%d", g);
  return 0;
}

Measured memory_bytes: 128