akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int main()
{
	int n, k = 0;
	ll m = 1;
	cin >> n;
	while(m < n) m *= 3, k++;
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 0
n = int(input())
s = [2,3,4,5,6,7,8,9]
flag = True
 
if 1<= n <=9:
    print("Yes")
    flag = False
else:
    for i in s:
        if n % i == 0 and n/i <= 9:
            flag = False
            print("Yes")
            break
if flag:
    print("No")

Measured memory_bytes: 3060
n = int(input())
s = input()
dp=[0]*(n)
dp[0] = s[1:].count("E")
for i in range(1,n):
  temp=dp[i-1]
  if s[i-1] == "W":
    temp+=1
  if s[i] == "E":
    temp-=1
  
  dp[i]=temp

print(min(dp))

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

int main(){
	int N;
	cin >> N;
	int p[N+1];
	rep(i,N) cin >> p[i+1];
	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (p[i] == i) {
			swap(p[i], p[i+1]);
			ans++;
		}
	}
	if (p[N] == N) ans++;
	cout << ans << endl;

	return 0;
}


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

int main()

{
	
	int s;
	cin >> s;
	if(s%10==((s%100)/10) or ((s%100)/10)==(s%1000/100) or s%10000/1000==(s%1000/100))
	cout<< "Bad";
	else 
	cout<<"Good";
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAXN 100005

int main ()
{
	int n;
	while(scanf("%d", &n) != EOF)
	{
		int n1 = 0, n2 = 0, n3 = 0;
		int a;
		while(n--)
		{
			scanf("%d", &a);
			if(a%4 == 0)n1++;
			else if(a%2 == 0)n2++;
			else n3++;
		}
		if((n3 - 1 > n1) || n3 - 1 == n1 && n2)
		printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"YES"<<"\n"
#define         no             cout<<"NO"<<"\n"
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         ss             second
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){Faysal

    ll ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>n>>r;
    if(n>=10) cout<<r<<endl;
    else cout<<r+(100*(10-n))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,M,L;
  cin >> N >> M >> L;

  const int INF=1000000010;
  
  vector<vector<int> > c(N,vector<int>(N,INF));

  int A,B,C;
  for(int i=0;i<M;i++){
    cin >> A >> B >> C;
    c[A-1][B-1]=C;
    c[B-1][A-1]=C;
  }
  for(int i=0;i<N;i++) c[i][i]=0;
  
  int r;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
	r=c[k][i]+c[i][j];
	if(r<c[k][j]){
	  c[k][j]=r; c[j][k]=r;
	}
      }
    }
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(c[i][j]<=L) c[i][j]=1;
      else c[i][j]=INF;
    }
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
	r=c[k][i]+c[i][j];
	if(r<c[k][j]){
	  c[k][j]=r; c[j][k]=r;
	}
      }
    }
  }



  int Q;
  cin >> Q;
  int s,t;
  for(int i=0;i<Q;i++){
    cin >> s >> t;
    --s;--t;
    if(c[s][t]==INF) cout << -1 << endl;
    else cout << c[s][t]-1 << endl;
  }  
  
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int n;
vector<int> g;

int dfs(const vector<int> &v)
{
    int d = 0;
    while(d<n && v[d]==g[d]) ++d;

    if(d==n) return 0;

    int ret = n;
    vector<int> t(v);
    int z = g[d]-v[d];

    for(int i=d; i<n; ++i)
    {
        t[i] = (t[i]+z+10)%10;
        ret = min(ret,dfs(t)+(z!=0));
    }

    return ret;
}

int main()
{
    while(cin >>n,n)
    {
        string a,b;
        cin >>a >>b;

        vector<int> s(n);
        g.resize(n);

        rep(i,n)
        {
            s[i] = a[i]-'0';
            g[i] = b[i]-'0';
        }

        cout << dfs(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
a=int(input())
n=list(map(int,input().split()))
m=list(map(int,input().split()))
o=list(map(int,input().split()))
result1=0

for i in range(0,a-1):
    if n[i]+1==n[i+1]:
        result1+=o[n[i]-1]

for i in range(a):
    result1+=m[n[i]-1]
print(result1)

Measured memory_bytes: 61368
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		int x = Integer.parseInt(s);
		int sec = x % 60;
		x /= 60;
		int min = x % 60;
		x /= 60;
		int hour = x;
		
		
		System.out.println(hour+":"+min+":"+sec);
	}

}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

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

    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i, n) {
        rep(j, n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(all(a[i]));
    }
    vector<P> q;
    auto check = [&](int i) {
        if (a[i].size() == 0) return;
        int j = a[i].back();
        if (a[j].size() == 0) return;
        if (a[j].back() == i) {
            P p(i, j);
            if (p.second < p.first) swap(p.first, p.second);
            q.pb(p);
        }
    };
    rep(i, n) {
        check(i);
    }
    int day = 0;
    while (q.size() > 0) {
        day++;
        sort(all(q));
        q.erase(unique(all(q)), q.end());
        vector<P> prevQ;
        swap(prevQ, q);
        for (P p : prevQ) {
            int i = p.first, j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for (P p : prevQ) {
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }
    rep(i, n) {
        if (a[i].size() != 0) {
            puts("-1");
            return 0;
        }
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], a = tmp[1], b = tmp[2];
        WriteLine(Math.Min(n*a, b));
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N],l[N],r[N];

int gcd(int a,int b) { return b==0 ? a : gcd(b,a%b); }

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	l[1]=a[1]; for (int i=2;i<=n;i++) l[i]=gcd(l[i-1],a[i]);
	r[n]=a[n]; for (int i=n-1;i;i--) r[i]=gcd(r[i+1],a[i]);
	
	int ans=l[n];
	ans=max(ans,max(r[2],l[n-1]));
	for (int i=2;i<=n-1;i++)
		ans=max(ans,gcd(l[i-1],r[i+1]));
	printf("%d\n",ans);	  
	return 0;
}

Measured memory_bytes: 1408
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S=gets.chomp
days={}
days["SUN"]=7
days["MON"]=6
days["TUE"]=5
days["WED"]=4
days["THU"]=3
days["FRI"]=2
days["SAT"]=1
puts days[S]

Measured memory_bytes: 1788
import java.util.Scanner;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int K = stdIn.nextInt();

        if(K%2 == 0){
            System.out.println(-1);
            return;
        }

        int offset = 0;
        int rest = 7;
        while(rest < K){
            rest *= 10;
            rest += 7;
            offset++;
        }

        for(int i=0; i<K; i++){
            while(rest >= K){
                rest -= K;
            }

            if(rest == 0){
                System.out.println(i + offset + 1);
                return;
            }

            rest *= 10;
            rest += 7;
        }

        System.out.println(-1);
    }
}

Measured memory_bytes: 35588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
	int mat, gre, geo, dp, gra, oth;
	while(cin >> mat >> gre >> geo >> dp >> gra >> oth, mat||gre||geo||dp||gra||oth) {
		int a = mat + dp;
		int b = gre + gra;
		int c = geo + oth;
		int res = 0;
		res += a/3;
		a %= 3;
		res += b/3;
		b %= 3;
		res += c/3;
		c %= 3;
		res += min(a, min(b, c));

		int res2 = 0;
		a = mat + dp;
		b = gre + gra;
		c = geo + oth;
		res2 += max(0, min(a, min(b, c))-1);
		a -= res2;
		b -= res2;
		c -= res2;
		res2 += a/3;
		res2 += b/3;
		res2 += c/3;

		int res3 = 0;
		a = mat + dp;
		b = gre + gra;
		c = geo + oth;
		res3 += min(a, min(b, c));
		a -= res3;
		b -= res3;
		c -= res3;
		res3 += a/3;
		res3 += b/3;
		res3 += c/3;

		cout << max(res3, max(res, res2)) << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int ans=0;
        string s,t;
        cin>>s>>t;
        for (int i = 0; i < 3; i++)
        {
            /* code */
            if (s[i]==t[i])
            {
                /* code */
                ans++;
            }
            
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;


int main(){
  int n,k;
  cin >> n >> k;
  if((n+1)/2>=k){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>
#include <complex>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

using F = tuple<int64, int64>;  // (分子, 分母)

constexpr int64 MOD = 1e9 + 7;

int64 GCD(int64 a, int64 b) {
    if (b == 0) return a;
    return GCD(b, a % b);
}

F reduce(F f) {
    int64 bunbo, bunshi;
    tie(bunshi, bunbo) = f;

    if (bunshi == 0) {
        return F(0, 1);
    }
    int64 g = GCD(abs(bunshi), abs(bunbo));
    bunshi /= g;
    bunbo /= g;
    if (bunbo < 0) {
        bunshi *= -1;
        bunbo *= -1;
    }
    return F(bunshi, bunbo);
}

int64 powMod(int64 a, int64 n) {
    if (n == 0) return 1;
    if (n % 2 == 1) {
        return (a * powMod(a, n - 1)) % MOD;
    }
    int64 b = powMod(a, n / 2);
    return (b * b) % MOD;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    int64 num_a_is_zero = 0,
          num_b_is_zero = 0,
          num_both_zero = 0;
    map<F, int64> counter;
    for (int i = 0; i < n; i++) {
        int64 a, b;
        cin >> a >> b;

        if (a == 0 && b == 0) {
            num_both_zero++;
            continue;
        }
        if (a == 0) num_a_is_zero++;
        if (b == 0) num_b_is_zero++;
        if (a != 0 && b != 0) {
            counter[reduce(F(a, b))]++;
        }
    }
    int64 ans = (powMod(2, num_a_is_zero) +
                 powMod(2, num_b_is_zero) + MOD - 1) % MOD;

    set<F> S;
    for (auto& mp : counter) {
        auto f = mp.first;
        auto f2 = reduce(F(-get<1>(f), get<0>(f)));
        if (S.count(f) || S.count(f2)) continue;

        int64 cnt1 = counter.count(f) ? counter[f] : 0,
              cnt2 = counter.count(f2) ? counter[f2] : 0;
        ans *= (powMod(2LL, cnt1) +
                powMod(2LL, cnt2) + MOD - 1);
        ans %= MOD;
        S.insert(f);
        S.insert(f2);
    }
    ans += num_both_zero - 1 + MOD;
    ans %= MOD;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 40608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//ABC130
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int X,Y,x,y; cin>>X>>Y>>x>>y;
    cout<<setprecision(30)<<X*Y/2.0<<' ';
    if(x*2==X and y*2==Y)cout<<1<<endl;
    else cout<<0<<endl;

}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(long long i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define adp(a) for(auto ii:a) cout << ii.F << " " << ii.S << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll MAXN = 100007;
const ll p = 1000000007;
#define N 200003
#define INF INTMAX_MAX

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};

// ll dx[] = {1, -1, 0, 0};
// ll dy[] = {0, 0, 1, -1};
ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }

bool cmp(const pll &a, const pll &b)
{
    if (a.F != b.F) {
        return a.F > b.F;
    }
    else
        return a.S < b.S;
}

// bool check(ll i, ll j)
// {
//     if (i >= 0 && i < n && j >= 0 && j < m && a[i][j] != '#')
//         return true;
//     return false;
// }

int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        ll n, x, t;
        cin >> n >> x >> t;
        ll y = (n - 1) / x + 1;
        cout << y*t << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

typedef __int128 ll;

#define pb push_back
#define mp make_pair
#define x first
#define y second

const int inf=2147483647;

ll read()
{
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}

void print(ll x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}

map<ll,int>M[111];
const int mod=998244353;
int dfs(int n,ll S){
	if(!n)return 1;
	if(M[n].count(S))return M[n][S];
	int sum=dfs(n-1,S>>1)*(S&1?2:1)%mod;
	ll st=0;
	for(int k=1;k<=n;k++){
		st=st<<1|1;
		ll T=S&st;
		for(int w=k;w<=n;w+=k){
			if(w>k)sum=(sum+1ll*dfs(k,T)*dfs(n-w,S>>w))%mod;
			T&=S>>w;
		}
	}
	return M[n][S]=sum;
}
char str[110];
int main(){
	scanf("%s",str);
	int n=0;while(str[n])n++;
	ll S=0;
	for(int i=n;i--;)S=S<<1|(str[i]=='1');
	
	printf("%d\n",dfs(n,S));
}


Measured memory_bytes: 3840
#最大公約数、最小公倍数、階乗
import fractions
n = int(input())
a = list(map(int, input().split()))

def calcGCDr():
    R = [0 for i in range(n+1)]
    R[n] = 0
    for i in range(1,n+1):
        R[n-i] = fractions.gcd(R[n-i+1],a[n-i])
    return R

def calcGCDl():
    L = [0 for i in range(n+1)]
    L[0] = 0
    for i in range(n):
        L[i+1] = fractions.gcd(L[i],a[i])
    return L

R = calcGCDr()
L = calcGCDl()
max_ans = 1
for i in range(n):
    pre_ans = fractions.gcd(L[i], R[i+1])
    max_ans = max(pre_ans, max_ans)

print(max_ans)

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

int main() {
  char c;
  cin >> c;

  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


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

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

  for (int i = 1; i < 4; i++) {
    if (S.at(i - 1) == S.at(i)) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

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

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

    ll count_4 = 0, count_2 = 0;
    rep(i, n){
        ll tmp;
        cin >> tmp;
        if(tmp % 4 == 0){
            count_4++;
        }else if(tmp % 2 == 0){
            count_2++;
        }
    }

    count_4 += count_2 / 2;

    if(count_4 >= n / 2){
        puts("Yes\n");
    }else{
        puts("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
result = ["mada"]*n
wac = [0]*n
AC = 0
WA = 0
p = []
s = []
for i in range(m):
    pi,si = map(str,input().split())
    p.append(int(pi))
    s.append(si)

for i in range(m):
    pp = p[i]
    ss = s[i]
    if ss == "WA":
        if result[pp-1] == "mada":
            wac[pp-1] += 1
        elif result[pp-1] == "AC":
            continue
    elif ss == "AC":
        if result[pp-1] == "mada":
            result[pp-1] = "AC"
        elif result[pp-1] == "AC":
            continue

for i in range(n):
    if result[i] == "AC":
        AC += 1
        WA += wac[i]

print(AC,WA)


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

int main(){
    int n;
    cin >> n;
    int count=0;
    for(int i=0;i<n;i++){
        int candidate;
        cin >> candidate;
        double limit = sqrt(candidate);
        bool notDevided = true;
        for(int j=2;j<=(int)limit;j++){
           if(candidate%j==0){
               notDevided = false;
               break;
           } 
        }
        if(notDevided)count++;
        
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
using namespace std;
 
int main() {
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i<MAX; i++) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }
    
    // 2017likeかどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; i++) {
        if (i%2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }
    
    // 累積和
    vector<int> s(MAX, 0);
    for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];
    
    int Q;
    cin >> Q;
    for (int i = 0; i<Q; i++) {
        int l, r;
        cin >> l >> r;
        r++;
        
        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
        tmp=max(tmp,a[i]);
    }
    rep(i,n){
        if(tmp==a[i])cnt++;
    }
    if(cnt>=2){
        rep(i,n)Cout(tmp);
    }
    else{
        sort(b,b+n);
        reverse(b,b+n);
        rep(i,n){
            if(tmp==a[i]){
                Cout(b[1]);
            }
            else Cout(tmp);
        }
    }
    return 0;
}


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


auto solve(long long N, std::vector<long long> a){
    auto r = minmax_element(begin(a), end(a));
    return *r.second - *r.first;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    auto result = solve(N, std::move(a));
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int h,w,n,i,a;
	char z[100][101];
	while(scanf("%d%d",&h,&w)!=EOF)
	{
		for(i=0;i<h;i++)
		{
			scanf("%s",&z[i]);
		}
		a=w+2;
		for(i=0;i<a;i++)
			printf("#");
		printf("\n");
		for(i=0;i<h;i++)
		{
			printf("#%s#\n",z[i]);
		}
		while(a--)
		printf("#");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
class BGoldenCoins {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int X = 0;
	    in >> X;

	    const int gohyaku = X / 500;
	    const int go = (X - 500 * gohyaku) / 5;

	    out << gohyaku * 1000 + go * 5 << endl;
	}
};


int main() {
	BGoldenCoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;

fn main() {
    input! {
        (n, m, k):(usize, usize, usize),
        a: [usize; n],
        b: [usize; m],
    }
    let mut la = vec![0; n + 1];
    let mut lb = vec![0; m + 1];
    for i in 0..n {
        la[i + 1] += la[i] + a[i];
    }
    for i in 0..m {
        lb[i + 1] += lb[i] + b[i];
    }
    let mut ans = 0;
    let mut t = m;
    for i in 0..=n {
        if k < la[i] {
            break;
        }
        while k - la[i] < lb[t] {
            t -= 1;
        }
        ans = std::cmp::max(ans, i + t);
    }
    println!("{}", ans);
}

// 10 50 1  1  1
// 20 20 20 20 20
//
// k = 70
// 0 10 60 61 62 63
// 0 20 40 60 80 100


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

int main() {
  int N;
  cin >> N;
  bool C= false;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      C = true;
    }
  }
  if (C) {
  cout << "Four" << endl;
  }
  else {
  cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

void func(){
    int n=in();
    ll ans=0;
    vector<vector<pii>> que(2);
    rep(i,n){
        int k=in(),l=in(),r=in();
        if(l > r){
            ans += r;
            l -= r;
            que[0].pb(mp(-k,l));
        }else{
            ans += l;
            r -= l;
            que[1].pb(mp(-(n-k),r));
        }
    }
    rep(x,2){
        sort(ALL(que[x]));
        pq p;
        int tmp=n;
        int id=0;
        while(tmp>=1){
            while(id < que[x].size()){
                if(-que[x][id].first == tmp){
                    p.push(que[x][id].second);
                    id++;
                }else{
                    break;
                }
            }
            if(!p.empty()){
                ans += p.top();
                p.pop();
            }
            tmp--;
        }
    }
    cout<<ans<<endl;
}

int main(){
    int t=in();
    rep(i,t)func();
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    Int n;
    cin >> n;
    auto v = IntsIn(n);
    sort(ALL(v), greater<Int>());
    if (n % 2 == 0) {
        auto m = n / 2;
        Int s = 0;
        rep(i, m) {
            if (i < m - 1) {
                s += 2 * v[i];
            } else {
                s += v[i];
            }
        }
        Int t = 0;
        for (int i = m; i < n; i++) {
            if (i == m) {
                t += v[i];
            } else {
                t += 2 * v[i];
            }
        }
        PUTS(s - t);
    } else {
        auto m = n / 2;
        Int s = 0;
        rep(i, m + 1) {
            if (i < m - 1) {
                s += 2 * v[i];
            } else {
                s += v[i];
            }
        }
        Int t = 0;
        for (int i = m + 1; i < n; i++) {
            t += 2 * v[i];
        }

        Int u = 0;
        rep(i, m) {
            u += 2 * v[i];
        }
        Int w = 0;
        for (int i = m; i < n; i++) {
            if (i > m + 1) {
                w += 2 * v[i];
            } else {
                w += v[i];
            }
        }

        PUTS(max(s - t, u - w));
    }
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const double PI = 3.1415926535897932;
const int i_INF = 2147483647;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
	int n;
	cin >> n;
	vector<char> a(n);
	vector<char> b(n);
	vector<char> c(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n)cin >> b[i];
	rep(i, 0, n)cin >> c[i];
	int ans = 0;
	rep(i, 0, n) {
		int h = 0;
		if (a[i] == b[i])h++;
		if (a[i] == c[i])h++;
		if (c[i] == b[i])h++;
		if (h == 0)ans += 2;
		else if (h == 1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<pair<double,double>>pts(100);
double distance(double x, double y,int n){
    double ans = 0;
    for(int i=0; i<n; i++){
        double d=sqrt((pts[i].first-x)*(pts[i].first-x) + (pts[i].second-y)*(pts[i].second-y));
        ans=max(ans, d);
    }
 return ans;
}

double search(double x,int n){
    double l=0,r=1000;
    int t=100;
     while(t--){
        double mid1=(2*l+r)/3.0;
        double mid2=(l+2*r)/3.0;

        if(distance(x,mid1,n)>distance(x,mid2,n)) l=mid1;
        else r=mid2;
    }
    return distance(x,l,n);
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        pts[i].first=x;
        pts[i].second=y;
    }

    double l=0,r=1000;
    for(int i=0;i<100;i++){
        double mid1=(2*l+r)/3.0;
        double mid2=(l+2*r)/3.0;

        if(search(mid1,n)>search(mid2,n)) l=mid1;
        else r=mid2;
    }
    
    cout<<fixed<<setprecision(20)<<search(l,n)<<endl;
    return 0;
}


Measured memory_bytes: 3816
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
	int n,m;
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2;
}

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

int main()
{
  int N;
  cin >> N;
  long long int ans = 1;
  for(int i=1; i<=N; ++i) {
    ans = ans*i;
    ans = ans%1000000007;
  }
  cout << ans << endl;
  return 0;
}


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

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

Measured memory_bytes: 19220
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n = int(input())
s,t = input().split()

for c in zip(s,t):
    print("{}{}".format(*c), end="")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = 998244353;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll h, w, n, sr, sc, l, r, u, d;
    string s, t;
    cin >> h >> w >> n >> sr >> sc >> s >> t;
    sr--;
    sc--;
    reverse(ALL(s));
    reverse(ALL(t));
    l = 0;
    r = w-1;
    u = 0;
    d = h-1;
    REP(i,n){
        if(t[i]=='L') r = min(r+1, w-1);
        if(t[i]=='R') l = max(l-1, 0LL);
        if(t[i]=='U') d = min(d+1, h-1);
        if(t[i]=='D') u = max(u-1, 0LL);

        if(s[i]=='L') l++;
        if(s[i]=='R') r--;
        if(s[i]=='U') u++;
        if(s[i]=='D') d--;

        if(l>r || u>d) break;
    }
    if(sc >= l && sc <= r && sr >= u && sr <= d){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    int k=0;
    while(1){
        cin>>H>>W;
        if(k>0)cout<<endl;
        if(H==0&&W==0)break;
        
        k++;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<"#";
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;

int main(){
  ios_base::sync_with_stdio(false); 
  cin >> N;
  int m = 0;
  long long res = 0;
  int mn = INT_MAX;
  for(int i=0; i<N; ++i){
    int x; cin >> x; 
    if(x < 0) ++m;
    res += abs(x);
    mn = min(mn, abs(x));
  }
  if(m&1)
    res -= 2*mn;
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int N;

long double x[10], y[10];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> y[i];
	}

	long double ave = 0.0;

	int cnt = 0;

	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			ave += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
				cnt++;
		}
	}

	ave /= double(cnt);

	cout << setprecision(12)<<fixed<<ave*(1.0*N - 1.0) << endl;

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const N = input[0];

  var S1 = 0;
  var S2 = 0;
  
  // parseInt and get sum.
  const W = input[1].split(" ").map(v => {
    var tmp = parseInt(v);
    S2 += tmp;
    return tmp;
  });
  	
  var min = 100;
  for(var t = 0; t < N ; t++){
    S1 += W[t];
    S2 -= W[t];
    var abs = Math.abs(S1-S2) 
    min = min > abs ? abs : min; 
  }
  
  //出力
  console.log(min);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		int sum = C;
		for (int j = 0; j < M; j++) {
			int A;
			cin >> A;
			sum += A * B[j];
		}
		res += sum > 0;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;
const int inf = 1<<30;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i, a) {
    x *= n-i;
    y *= i+1;
  }
  return x/y;
}

int main() {
  int n, a, b; cin >> n >> a >> b;
  mint ans = mint(2).pow(n);
  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);
  cout << ans.x << endl;

  return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

const ll MAX_N = 200000;
ll mat[26][MAX_N];

// 最大公約数（ユークリッドの互除法による）
ll get_gcd(ll n, ll m){
	if (n > m){
		ll l = n;
		n = m;
		m = l;
	}
	while (1){
		ll l = n;
		n = m%n;
		m = l;
		if (n == 0){
			break;
		}
	}
	return m;
}

int main(){
	ll N, K;
	cin >> N >> K;
	ll i, j;
	vll A;
	ll max_A = 0;
	for (i = 0; i < N; i++){
		ll a;
		cin >> a;
		max_A = max(max_A, a);
		A.push_back(a);
	}
	if (K > max_A){
		cout << "IMPOSSIBLE" << endl;
	}
	else{
		ll gcd = A[0];
		for (i = 1; i < N; i++){
			gcd = get_gcd(gcd, A[i]);
		}
		if (K%gcd == 0){
			cout << "POSSIBLE" << endl;
		}
		else{
			cout << "IMPOSSIBLE" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
int valores[10] = {0,2,5,5,4,5,6,3,7,6};
int dp[maxn];
vector<int> A;
int f(int k){
	if(k < 0) return INT_MIN;
	if(k == 0) return 0;
	if(dp[k] != -1) return dp[k];
	int best = INT_MIN;
	for(int num: A){
		int now = f(k - valores[num]);
		if(now != INT_MIN) now++;
		best = max(now, best);
	}
	return dp[k] = best;
}
void rec(int k){
	if(k <= 0) return;
	int ans = f(k), digit = 0;
	for(int num : A){
		if(f(k - valores[num]) + 1 == ans){
			digit = max(num, digit);
		}
	}
	cout << digit;
	rec(k - valores[digit]);
}
int main() {
	int n, k, num;
	cin >> k >> n;
	memset(dp,-1,sizeof(dp));
	for(int i = 0; i < n; ++i){ 
		cin >> num;
		A.push_back(num);
	}
	rec(k);
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf 1e18
#define endl "\n"

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main()
{
    fastio
    ll test=1,n,i,k,tl,xtra,qty,mx,spent;

    // cin >> test;

    while(test--)
    {
        cin >> n ;

        ll ar[n+1];
        tl=1000;
        for(i=0; i<n; i++) cin >> ar[i];

        ar[n]=-1;
        qty = tl/ar[0];
        xtra = tl%ar[0] ;
        spent = tl - xtra;
        mx = ar[0];

        for(i=1; i<=n; i++)
        {
            // cout << "tl - " << tl << " qty - " << qty << " xtra - " << xtra << " spent - " << spent << " mx - " << mx << endl;
            mx = max(mx,ar[i]);
            if(ar[i] < mx)
            {
                tl = mx*qty + xtra;
                qty = tl/ar[i];
                xtra = tl%ar[i];
                spent = tl-xtra;
                mx = ar[i];
            }
        }

        cout << tl << endl;
    }


    return 0;
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    a, b, c = MI()
    print(c, a, b, sep=" ")


main()


Measured memory_bytes: 64524
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int maxn = 0, n;
struct MyStruct
{
	int mat[2][100];
}st;

int func(int x, int y, MyStruct sst, int sum) {


	sum += sst.mat[x][y];

	if (y >= n) return 0;

	if (x == 1 && y == n - 1) {
		maxn = max(maxn, sum);
		return 0;
	}

	if (x == 1) {
		func(x, y + 1, sst, sum);
	}
	else if (x == 0 && y < n ) {
		func(x, y + 1, sst, sum);
		func(x + 1, y, sst, sum);
	}

	return 0;
}

int main() {
	int i, j, k;
	MyStruct sst;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> sst.mat[0][i];
	}
	for (i = 0; i < n; i++) {
		cin >> sst.mat[1][i];
	}

	func(0, 0, sst, 0);



	cout << maxn << endl;






	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 384
import math

K = int(input())
sum = 0
tmp = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        tmp = math.gcd(a, b)
        for c in range(1, K + 1):
            sum += math.gcd(tmp, c)
print(sum)

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

using namespace std;

void print_vec2(vector<string>& vec){
  std::cout << vec.size() << '\n';
  std::cout << vec[0].size() << '\n';
  for(int i=0; i<vec.size(); i++){
    for(int j=0; j<vec[0].size(); j++){
      std::cout << vec[i][j];
    }
    std::cout << '\n';
  }
}

int main(){
  int h, w;
  std::cin >> h >> w;
  vector<string> a;
  for(int i=0; i<h; i++){
    string col_elm;
    std::cin >> col_elm;
    a.push_back(col_elm);
  }

  vector<string> middle_ans;
  for(int i=0; i<h; i++){
    bool addflag = false;
    for(int j=0; j<w; j++){
      if( a[i][j] == '#' ) addflag = true;
    }
    if( addflag ) middle_ans.push_back(a[i]);
  }

  vector<bool> show_flags(middle_ans[0].size(), false);
  for(int i=0; i<middle_ans[0].size(); i++){
    for (int j=0; j<middle_ans.size(); j++) {
      if( middle_ans[j][i] == '#' ){
        show_flags[i] = true;
        break;
      }
    }
  }

  for(int i=0; i<middle_ans.size(); i++){
    for (int j=0; j<middle_ans[0].size(); j++) {
      if(show_flags[j]) std::cout << middle_ans[i][j];
    }
    std::cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
#b.sort()
c.sort()
ans = 0
for i in range(n):
    low = bisect.bisect_left(a,b[i])
    upp = bisect.bisect_right(c,b[i])
    ans += low*(n-upp)
print(ans)

Measured memory_bytes: 23232
from collections import Counter as C
n = int(input())
V = list(input().split())

V1 = C(V[::2]).most_common()
V2 = C(V[1::2]).most_common()

if V1[0][0] != V2[0][0]:
  ans = n - (V1[0][1] + V2[0][1])
else:
  l = V1[0][1] + V2[1][1] if len(V2) > 1 else V1[0][1]
  r = V1[1][1] + V2[0][1] if len(V1) > 1 else V2[0][1] 
  if l >= r:
    ans = n - l
  else:
    ans = n - r
print(ans)

Measured memory_bytes: 23004
a, b = map(int, input().split())

def gcd(x,y):
    if y==0: return x
    return gcd(y, x%y)

def factorize(n):
    arr = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp%i == 0:
            cnt = 0
            while tmp%i == 0:
                cnt += 1
                tmp /= i
            arr.append([i,cnt])
    if tmp != 1:
        arr.append([tmp,1])
    return arr

print(len(factorize(gcd(a,b)))+1)


"""        
cf = []
for i in range(2,min(a,b)+1):
    if a % i == 0 and b % i == 0:
        cf.append(i)

print(cf)


dest = int(math.sqrt(cf))
cf_list = list(range(2, cf+1))
prime_list = []

for i in range(len(cf)):
    num_min = min(cf_list[i])
    if num_min >= dest:
        prime_list.extend(cf_list[i])
        break
    prime_list.append(num_min)

    j = 0

    while True:
        if i>= len(cf_list):
            break
        elif cf_list[i] % num_min == 0:
            cf_list.pop(i)
        j += 1

print(prime_list)
"""


Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int64_t H, W;

  cin >> H >> W;

  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }

  int64_t ans = (H / 2) * W;
  if (H % 2 == 1) {
    ans += (W + 1) / 2;
  }

  cout << fixed << ans << endl;

  return 0;
}


Measured memory_bytes: 256