akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = inp()
a = inpl()
cntsum = list(itertools.accumulate(a))
cntcol = Counter(cntsum)
res = 0
for key in cntcol.keys():
    if key == 0:
        res += cntcol[key]
    if cntcol[key] >= 2:
        res += conb(cntcol[key],2)
print(res)

Measured memory_bytes: 42172
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, A, B, C;
    cin >> n >> A >> B >> C;
    vector<int> len(n);
    for (int i = 0; i < n; i++)
    {
        cin >> len[i];
    }
    vector<int> bit(3); // 3種類bitを用意する
    int ans = INF;

    // 4bit全探索
    for (bit[0] = 1; bit[0] < (1 << n); bit[0]++)
    {
        for (bit[1] = 1; bit[1] < (1 << n); bit[1]++)
        {
            if (bit[0] & bit[1])
            {
                continue;
            }
            for (bit[2] = 1; bit[2] < (1 << n); bit[2]++)
            {
                if (bit[0] & bit[2])
                {
                    continue;
                }
                if (bit[1] & bit[2])
                {
                    continue;
                }
                vector<int> sum(3, 0), cnt(3, 0);
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (bit[j] & (1 << i))
                        {
                            sum[j] += len[i];
                            cnt[j]++;
                        }
                    }
                }

                int tmp = 0;
                tmp += abs(sum[0] - A);
                tmp += abs(sum[1] - B);
                tmp += abs(sum[2] - C);
                for (int i = 0; i < 3; i++)
                {
                    tmp += (cnt[i] - 1) * 10;
                }
                chmin(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;

	vector<vector<int> > ten(20, vector<int>(20, 0));
	ll cnt = 0;
	REP(i, n) {
		double x; cin >> x;
		ll tmp = x * 1e9 + 0.1;
		int two = 0;
		int five = 0;
		while (!(tmp % 2)) {
			tmp /= 2;
			two++;
		}
		while (!(tmp % 5)) {
			tmp /= 5;
			five++;
		}
		if (two > 18) two = 18;
		if (five > 18) five = 18;
		for (int j = 18 - two; j <= 18; j++)
			for (int k = 18 - five; k <= 18; k++)
				cnt += ten[j][k];
		ten[two][five]++;
	}

	cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3700
K, X = map(int, input().split())
min_num = X - K + 1
max_num = X + K - 1

if min_num < -1000000:
    min_num = -1000000
if 1000000 < max_num:
    max_num = 1000000

num_list = list(range(min_num, max_num + 1))
num_list = [str(x) for x in num_list]
print(" ".join(num_list))


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;
    int n = s.length();

    if (n == 1) {
        cout << s << endl;
    } else {
        bool q = true;
        for (int i = 1; i < n; ++i) {
            if (s[i] != '9') {
                q = false;
            }
        }

        if (q) {
            cout << s[0] - '0' + 9 * (n - 1) << endl;
            return 0;
        }

        if (s[0] == '1') {
            cout << 9 * (n - 1) << endl;
        } else {
            cout << s[0] - '0' - 1 + 9 * (n - 1) << endl;
        }
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

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

    int ans=0;
    if (n == 2) {
        if (a[0] == a[1]) {
            ans++;
        }
    }else{  // case n>3
        for (int i = 0; i < n-1; i++) {
            if (a[i] == a[i+1]) {
                a[i+1] = -1;
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


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

ll a[102];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=INF;
	for(int i=-100;i<=100;i++){
		ll sum=0;
		for(int j=0;j<n;j++){
			ll now=a[j];
			sum+=(now-i)*(now-i);
		}
		ans=min(ans,sum);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

char a[ 4 ][ 4 ] ;

int main() {
   string ans = "" ;
   forn( int , i , 0 , 3 ){
     forn( int , j , 0 , 3 ){
        cin >> a[ i ][ j ] ;
        if( i == j ) ans += a[ i ][ j ] ;
     }
   }
   cout << ans ;
   return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];

void solve()
{
	int n = 5;
	for(int i = 1; i <= n; i++)
	{
		int data;
		cin >> data;
		if(data == 0)
		{
			cout << i << endl;
			return;
		}
	}
}
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

int main() {
  int k, n;
  cin >> k >> n;
  vector <int> a(n);
  for (int i = 0; i < n; i++) scanf("%i", &a[i]);
  a.push_back(a[0]+k);
  int len = 0;
  for (int i = 0;i < n; i++) {
    len = max(len, a[i + 1] - a[i]);
  }
  cout << k - len << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5;
const ll mod=1e9+7;
ll a[maxn+5],num[maxn+5],cnt[maxn+5],S,D[maxn+5];
int pre[maxn+5],suf[maxn+5];
int n;
ll c[2][maxn+5];
ll ans=0;
ll Pow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return Pow(a,mod-2,mod);
}
int lowbit(int x)
{
    return x&(-x);
}
ll add(ll *c,int k,ll data)
{
    for(;k<=n+1;k+=lowbit(k)) c[k]=(c[k]+data)%mod;
}
ll query(ll *c,int k)
{
    ll ans=0;
    for(;k;k-=lowbit(k)) ans=(ans+c[k])%mod;
    return ans;
}
int main()
{

    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&a[i]),++num[a[i]];
    for(int i=n-1;i>=1;--i) num[i]+=num[i+1];
    S=1;
    D[0]=1;
    for(int i=1;i<=n;++i)
    {
        cnt[i]=num[i]-(n-i),S=S*cnt[i]%mod;
        if(cnt[i]<=0) return 0*printf("0\n");
        D[i]=D[i-1];
        if(cnt[i]>1) D[i]=D[i]*(cnt[i]-1)%mod*inv(cnt[i])%mod,pre[i]=pre[i-1];else pre[i]=i;
    }
    suf[n]=n;
    for(int i=n-1;i>=1;--i)
        if(cnt[i]>1)
        {
            if(cnt[i+1]>1) suf[i]=suf[i+1];else suf[i]=i;
        }
        else suf[i]=i;
   // for(int i=1;i<=n;++i) printf("pre : %d suf : %d\n",pre[i],suf[i]);
   // for(int i=1;i<=n;++i) printf("%lld ",cnt[i]);printf("\n");
   // printf("%lld\n",S);
   // for(int i=1;i<=n;++i) printf("%lld ",D[i]);printf("\n");
    for(int i=1;i<=n;++i)
    {
        ans=(ans+(query(c[0],a[i])-query(c[0],pre[a[i]]-1))%mod*S%mod*D[a[i]]%mod*inv(2LL)%mod)%mod;
        if(ans<0) ans+=mod;
        add(c[0],a[i],inv(D[a[i]]));
    }
    for(int i=1;i<=n;++i) c[0][i]=0;
    for(int i=1;i<=n;++i)
    {
       // if(D[a[i]]==0) continue;
        ans=(ans+S*(query(c[1],n)-query(c[1],a[i]))%mod-inv(2LL)*S%mod*inv(D[a[i]])%mod*(query(c[0],suf[a[i]])-query(c[0],a[i]))%mod)%mod;
        if(ans<0) ans+=mod;
        add(c[0],a[i],D[a[i]]);
        add(c[1],a[i],1LL);
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long ans = 0;
	rep(i, n) {
		ans += distance(a.begin(), lower_bound(a.begin(), a.end(), b[i])) * distance(upper_bound(c.begin(), c.end(), b[i]), c.end());

	}

	cout << ans << endl;
	return 0;
}


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

int main(){
	int n;
	string s,t;
	cin >>n;
	cin >> s >> t;

	string ans=s+t;
	for(int i=0; i<n; i++){
		ans[2*i] = s[i];
		ans[2*i+1] = t[i];
	}
	cout << ans << endl;
	
	return 0;

}




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

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

  queue<long long> que;
  for (long long i = 1; i <= 9; i++) que.push(i);

  int count = 0;
  long long ans;
  while(count!=k){
    long long now = que.front();
    que.pop();
    int d = now%10;
    if(d!=0) que.push(now*10+d-1);
    que.push(now*10+d);
    if(d!=9) que.push(now*10+d+1);

    ans = now;
    count++;
  }
  cout << ans << endl;
  
}

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

int main()
{
  string s;
  cin >> s;
  int w;
  cin >> w;
  for (int i = 0; i < s.size(); i += w)
  {
    cout << s[i];
  }
  cout << endl;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    if(n==k)
       cout<<0<<endl;
    else
    {
        if(k==1)
          cout<<0<<endl;
        else
           cout<<n-k<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i, n;
	char t[4];
	int c[4];
	for (i=0; i<4; ++i) c[i]=0;
	while (scanf("%d,%s", &n, t) != EOF) {
		switch (t[0]) {
			case 'A': if (t[1]=='B') c[2]++; else c[0]++; break;
			case 'B': c[1]++; break;
			case 'O': c[3]++; break;
		}
	}
	if (c[1] > 10) return 1;
	for (i=0; i<4; ++i) printf("%d\n", c[i]);
	return 0;
}

Measured memory_bytes: 0
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 3e5 + 10;
int a[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= 3 * n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + 3 * n + 1);
    ll ans = 0;
    for (int i = 3 * n - 1; i > (n - 1); i -= 2) ans += a[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略
 
int main(){
  ll x;
  cin >> x;
  ll sum = 100;
  ll ans = 0;
  while(true){
    if(sum >= x){
      break;
    }
    ans++;
    sum = sum + (sum/100);
    
  }
  cout << ans;
}

Measured memory_bytes: 3636
// 4_abc127_d
#include <algorithm>
#include <bitset>
#include <complex>
#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>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#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>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    if(a < 6) cout << 0;
    else if(a < 13) cout << b / 2;
    else cout << b;
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

signed main()
{

 	FLASH

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

 	bool ok = (a <= 8 and b <= 8);
 	if(ok) cout<<"Yay!";
 	else cout<<":(";
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

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

int main() {
    ll i, j, k;
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    for(i = L; i < R + 1; i++) {
        if(i % d == 0)
            ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int calc_f(int a, int b) {
  int64_t a2 = a * a;
  int64_t b2 = b * b;
  int64_t a5 = a2 * a2 * a;
  int64_t b5 = b2 * b2 * b;
  return a5 - b5;
}

void find_ans(int& a, int& b, int x) {
  for (a = -119; a <= 119; ++a) {
    for (b = -119; b <= 119; ++b) {
      if (calc_f(a, b) == x) {
        return;
      }
    }
  }
}

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

  int a, b;
  find_ans(a, b, x);

  cout << a << " " << b << endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;
import java.util.InputMismatchException;


class Main{
public static void main(String[] args){
Scanner scan =new Scanner(System.in);
try{
double r=scan.nextDouble();
double a=r*r*3.141592653589;
double b=r*2.00000000*3.141592653589;
System.out.printf("%f %f\n",a,b);
}catch (InputMismatchException e){
      System.out.println("?????????????????????" + e);
    }

}
}

Measured memory_bytes: 28164
#include <cassert>
#include <cstring>
#include <iostream>
using namespace std;

long long solve2(int n, int E, int T, int *x) {
    long long dp[n];
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < n; i++) dp[i] = max(T, 2 * (x[i] - x[0]));
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) {
            dp[i] = min(dp[i], dp[j] + max(T, 2 * (x[i] - x[j+1])));
        }
    }
    return E + dp[n-1];
}

long long solve(int n, int E, int T, int *x) {
    long long dp[n], b[n+1];
    fill(dp, dp+n, 1LL<<60);
    fill(b, b+n+1, 1LL<<60);
    for (int i = 0, j = 0; i < n; i++) {
        while (2 * (x[i] - x[j]) > T) j++;
        // cerr << i << " " << j << endl;
        dp[i] = min(dp[i], (j > 0 ? dp[j-1] : 0) + T);
        dp[i] = min(dp[i], max(2LL * (x[i] - x[0]), (long long)T));
        for (int k = j-1; k > 0; k -= k&-k)
            dp[i] = min(dp[i], b[k] + 2 * x[i]);
        for (int k = i+1; k <= n; k += k&-k)
            b[k] = min(b[k], dp[i] - 2 * (i < n-1 ? x[i+1] : 0));
    }
    // for (int i = 0; i < n; i++) cerr << i << ' ' << dp[i] << endl;
    return E + dp[n-1];
}

int main() {
    int N, E, T; cin >> N >> E >> T;
    int x[N]; for (int i = 0; i < N; i++) cin >> x[i];
    long long ans = solve(N, E, T, x);
    cout << ans << endl;

    // long long expect = solve2(N, E, T, x);
    // if (ans != expect) {
    //     cerr << "expect: " << expect << ", got " << ans << endl;
    //     exit(1);
    // }
}


Measured memory_bytes: 5100
#include <iostream>
#include<string>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <numeric>
#include<queue>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
int func(int n){
  int res=1;
  for(int i=2;i*i<=n;++i){
    if(n%i)continue;
    int ex=0;
    while(n%i==0){
      ++ex;
      n/=i;
    }
    res*=ex+1;
  }
  if(n!=1)res*=2;
  return res;
}
int main(){
  int n;cin>>n;
  int ans=0;
  for(int i=3;i<=n;i+=2){
    if(func(i)==8)ans++;
  }
  cout<<ans<<endl;
}

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

int main(){
    int n, q, ans = 0;
	cin >> n;
	vector<int> s(n);
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	cin >> q;
	vector<int> t(q);
	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	for(int i = 0; i < q; i++){
		for(int j = 0; j < n; j++){
			if(t[i] == s[j]){
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3272
#include<stdio.h>
#define ll long long int
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    ll a,sum=0;
    for (ll i=0;i<m;i++){
        scanf("%lld",&a);
        sum+=a;
    }
    sum=n-sum;
    if (sum<0){
        printf("-1\n");
    }
    else
        printf("%lld",sum);

    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;

int b_search(ll *s, int len, ll key) {
  int start = 0;
  int end = len - 1;

  while (start <= end) {
    int mid = (start + end) / 2;
    if (s[mid] == key) {
      return 1;
    }

    if (s[mid] < key) {
      start = mid + 1;
    } else if (s[mid] > key) {
      end = mid - 1;
    }
  }
  return 0;
}

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

  ll S[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }

  int q;
  cin >> q;

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


  int count = 0;
  for (int i = 0; i < q; i++) {
    count += b_search(S, n, T[i]);
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 4200
#include<iostream>
using namespace std;
int s[366][26];
int main() {

	int d;
	cin >> d;
	int c[26];
	int i, j, j2;
	for (i = 0; i < 26; i++) {
		cin >> c[i];
	}

	for (i = 0; i < d; i++) {
		for (j = 0; j < 26; j++) {
			cin >> s[i][j];
		}
	}
	int last[26];
	for (i = 0; i < 26; i++) {
		last[i] = 0;
	}
	int jmax, jindex, jindex2;
	for (i = 1; i <= d; i++) {

		jmax = 0;
		jindex = -1;
		jindex2 = -1;
		/*for (j = 0; j < 26; j++) {
			if (c[j] *(i - last[j]) > jmax) {
				jmax = c[j] *(i - last[j]);
				jindex = j;
			}
			else if (c[j] *(i - last[j]) == jmax) {
				if (s[i - 1][j] > s[i - 1][jindex]) {
					jindex = j;
				}
			}
		}*/
		for (j = 0; j < 26; j++) {
			for (j2 = 0; j2 < 26; j2++) {
				if (j != j2) {
					if (s[i - 1][j] + 6 * c[j] * (i - last[j]) + s[i][j2] + 6 * c[j2] * (i + 1 - last[j2]) > jmax) {
						jmax = s[i - 1][j] + 6 * c[j] * (i - last[j]) + s[i][j2] + 6 * c[j2] * (i + 1 - last[j2]);
						jindex = j;
						jindex2 = j2;
					}
				}
				else {
					if (s[i - 1][j] + 6 * c[j] * (i - last[j]) + s[i][j2] + 6 * c[j2] > jmax) {
						jmax = s[i - 1][j] + 6 * c[j] * (i - last[j]) + s[i][j2] + 6 * c[j2];
						jindex = j;
						jindex2 = j2;
					}
				}
			}
		}
		/*for (j = 0; j < 26; j++) {
			if (s[i - 1][j] + 15 * c[j] * (i - last[j]) >= jmax) {
				jmax = s[i - 1][j] + 15 * c[j] * (i - last[j]);
				jindex = j;
			}
		}*/
		last[jindex] = i;
		cout << jindex + 1 << endl;
		


	}
	return 0;


}

Measured memory_bytes: 3652
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int x,y,z;
    cin>>x>>y>>z;
    
    x-=z;
    cout<<x/(y+z)<<endl;
    
    return 0;
}








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


int main() {
string s;
cin >> s;
int ssize = s.size();
int ans = 0;
  int count = 0;
for(int i = 0;i < ssize;i++){
  if(s[i] == 'A'||s[i] == 'T'||s[i] == 'C'||s[i] == 'G'){
        count++;
        ans = max(count,ans);
    }
    else{
      count = 0;
    }
}


cout << ans <<endl;

  }



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

int main() {
	int n;

	cin >> n;

	for (int i = 3; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
			continue;
		}

		while (x) {
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}
			x /= 10;
		}
		
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 3092
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

res=1
for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
        res=i

print(res+(n//res)-2)

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

const int MOD=1000000007;

ll gcd(ll x, ll y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}

ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

// void solve(long long N, std::vector<long long> v){
//     double avg=v[0], x,y;
//     for (int i = 0; i < N-1; i++) {
//         auto itr_x = min_element(v.begin(), v.end());
//         x = *itr_x;
//         v.erase(itr_x);
//         auto itr_y = min_element(v.begin(), v.end());
//         y = *itr_y;
//         v.erase(itr_y);
//         avg = (x+y)/2.0;
//         v.push_back(avg);
//     }
//     cout << setprecision(16) << fixed << avg << endl;
// }

void solve(long long N, std::vector<double> v){
    double avg=v[0], x,y;
    if (N==2) {
        cout << (v[0]+v[1])/2.0 << endl;
        return;
    }
    for (int i = 0; i < N-1; i++) {
        sort(v.begin(), v.end());
        x = v[0];
        y = v[1];
        v.erase(v.begin());
        v.erase(v.begin());
        v.push_back((x+y)/2.0);
        // v.insert(v.begin(), (x+y)/2.0);
    }
    cout << setprecision(16) << fixed << v[0] << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

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


		while(true) {	//0が入力されたら終了

			//入力と同時に文字列を配列arrayに初期化
			String str = scanner.nextLine();

			if(str.equals("0")) {
				break;
			}

			int sum = 0;

			for(char a : str.toCharArray()) {


				sum += Integer.parseInt(String.valueOf(a));

			}

			System.out.println(sum);

		}
	}
}


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

set<int> used;
int main() {
    lli n,k;
    cin >> n >> k;
    vector<pair<lli,lli>>t(n);
    rep(i,n)
    cin >> t[i].second >> t[i].first;
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    lli cur = 0,ans = 0;
    priority_queue<pair<lli,lli>, vector<pair<lli,lli>>, greater<pair<lli,lli>>> que;
    rep(i,k){
        cur += t[i].first;

        //cout << t[i].first << "  " << t[i].second << endl;;
        if(used.find(t[i].second) != used.end()){
            que.push(t[i]);
        }
        used.insert(t[i].second);
    }
    cur = cur + (lli)used.size() * (lli)used.size();
    ans = cur;
    for(int i = k;i<n;i++){
        //cout << t[i].first << " " << t[i].second << endl;
        if(used.find(t[i].second) != used.end()){
            continue;
        }
        if(que.size()==0){
            continue;
        }
        auto q = que.top();
        que.pop();
        cur = cur - q.first + t[i].first + 2 * (lli)used.size() + 1;

        //cout << "#" << q.first << " " << q.second << " " << cur << " " << t[i].first << endl;
        ans = max(cur,ans);
        used.insert(t[i].second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5752
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<18, mod = 1e9 + 7;
int n, a[maxn], b[maxn];
int k;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	int iter = 0;
	while(k--) {
		iter++;
		memset(b, 0, sizeof b);
		for(int i = 0; i < n; i++) {
			b[max(0, i-a[i])]++;
			b[min(n+1, i+a[i]+1)]--;
		}
		for(int i = 0; i < n; i++) a[i] = (b[i] += (i?b[i-1]:0));
		int ok = 0;
		for(int i = 0; i < n; i++) ok |= a[i] < n;
		if(!ok) break;
	}
	for(int i = 0; i < n; i++) cout << a[i] << " ";
	return 0;
}


Measured memory_bytes: 5464
import java.util.*;
class Main{
  private static Scanner sc = new Scanner(System.in);
  private static int[] clear = {5, 7, 5, 7, 7};

  public static void main(String[] args){
    while(resolve());
  }

  public static boolean resolve(){
    int n = sc.nextInt();
    if(n == 0) return false;
    int[] to_nums = new int[n];
    for(int i = 0; i < n; i++) to_nums[i] = sc.next().length();

    for(int i = 0; i < to_nums.length; i++){
      int cnt = 0, j = 0;
      for(int k = i; k < to_nums.length; k++){
        int x = to_nums[k];

        cnt += x;
        if(cnt == clear[j]){
          j += 1;
          cnt = 0;
          if(j >= clear.length){
            System.out.println(i + 1);
            return true;
          }
        }else if(cnt > clear[j]) break;
      }
    }

    return true;
  }
}

Measured memory_bytes: 30640
#include <bits/stdc++.h>
#define int long long
int dp[105][9];
using namespace std;

signed main(){
  int H,W,K;
  cin>>H>>W>>K;
  const int INF=1e9+7;
  int fi[9]={0,1,1,2,3,5,8,13,21};
  dp[0][1]=1;
  for(int i=W+1;i<9;i++)fi[i]=0;
  for(int j=2;j<=8;j++)dp[0][j]=0;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      dp[i][j]=dp[i-1][j-1]*fi[j-1]*fi[W-j+1]+dp[i-1][j+1]*fi[j]*fi[W-j]+dp[i-1][j]*fi[j]*fi[W-j+1];
      dp[i][j]%=INF;
    }
  }
  cout<<dp[H][K]<<endl;
}


Measured memory_bytes: 256
# @uthor : Kaleab Asfaw
import sys

input = sys.stdin.readline

def main(n, k, lst):
    for i in range(n-k):
        if lst[i+k] > lst[i]:print("Yes")
        else: print("No")
        
    
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
main(n, k, lst)




Measured memory_bytes: 31124
N = int(input())
B = list(map(int,input().split()))
D = [0] * N

for i in range(N-1):
	if B[i] - B[i+1] > 0:
		D[i+1] += B[i] - B[i+1]
		B[i+1] += D[i+1]

print(sum(D))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  vector<int> h(N);
  REP(i, N) cin >> h[i];
  h.push_back(0);
  // int mx = *max_element(h.begin(), h.end());
  // cout << mx << endl;
  int flag = 1;
  while(flag) {
    flag = 0;
    for(int i = 0; i < N; i++) {
      if(h[i] != 0 && h[i + 1] == 0) {
        h[i]--;
        ans++;
        flag = 1;
      } else if(h[i] != 0) {
        h[i]--;
        flag = 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
W=[]
for i in range(N):
    Wi=input()
    W.append(Wi)
ans="Yes"
for i in range(N-1):
    if W[i][-1]!=W[i+1][0] or W.count(W[i])!=1:
        ans="No"
        break
print(ans)

Measured memory_bytes: 3060
n  = int(input())
ls = list(map(int, input().split()))
ls_plus1  = list(map(lambda x: x + 1, ls))
ls_minus1 = list(map(lambda x: x - 1, ls))
dic = {}
for a in ls_minus1 + ls + ls_plus1:
    dic[a] = dic.get(a, 0) + 1
print(sorted(dic.values())[-1])
    

Measured memory_bytes: 26588
#include<iostream>
#include<string>

using namespace std;

int main(){
  string s;
  std::cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    if(s[i] == '?')s[i] = 'D';
  }
  std::cout << s << std::endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  vector<ll> csum;
  partial_sum(va.begin(), va.end(), back_inserter(csum));

  ll diff = 0, cnts = 0;
  for (int i = 0; i < n; ++i) {
    ll a = csum[i] + diff;
    if (i % 2 == 0 && a >= 0) {
      diff -= a + 1;
      cnts += a + 1;
    } else if (i % 2 == 1 && a <= 0) {
      diff += -a + 1;
      cnts += -a + 1;
    }
  }

  diff = 0;
  ll cnts2 = 0;
  for (int i = 0; i < n; ++i) {
    ll a = csum[i] + diff;
    if (i % 2 == 1 && a >= 0) {
      diff -= a + 1;
      cnts2 += a + 1;
    } else if (i % 2 == 0 && a <= 0) {
      diff += -a + 1;
      cnts2 += -a + 1;
    }
  }

  cout << min(cnts, cnts2) << '\n';

  return 0;
}

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

class Main{	
	
	static void run(){
Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int mountain[] = new int[10];
			
			for(int i=0;i<10;i++){
				mountain[i] = sc.nextInt();
			}
			Arrays.sort(mountain);
			
			System.out.println(mountain[9]+"\n"+mountain[8]+"\n"+mountain[7]);
		}
		
	
	}
	
	public static void main (String[] args){
		run();
	}
}

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

const int N_ALL_CARDS = 52;
const int N_SUITS     = 4;
const int N_NUMBERS   = 13;

int suit_to_idx(int suits[], char suit) {
    for (int i = 0; i < N_SUITS; i++)
        if (suits[i] == suit) return i;
}

int main() {
    int n_cards;
    std::cin >> n_cards;
    if (n_cards == N_ALL_CARDS)
        return 0;

    int suits[N_SUITS] = { 'S', 'H', 'C', 'D' };
    int cards[N_SUITS][N_NUMBERS] = {};
    char suit;
    int number;

    for (int i = 0; i < n_cards; i++) {
        std::cin >> suit >> number;
        int suit_idx = suit_to_idx(suits, suit);
        cards[suit_idx][number - 1] = 1;
    }

    for (int i_s = 0; i_s < N_SUITS; i_s++) {
        for (int i_n = 0; i_n < N_NUMBERS; i_n++) {
            if ( cards[i_s][i_n] == 0 ) {
                printf("%c %d\n", suits[i_s], i_n + 1);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n, r;
  cin >> n >> r;
  if(n >= 10){
    cout << r << "\n";
    return 0;
  }
  cout << r + 100 * (10 - n) << "\n";
}
  
  
  
  
  
  
  
  

Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a, b, c, k;

int main(){
	cin >> a >> b >> c >> k;
	ll ans = (k%2)? b-a : a-b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;


class Rectangle{
		static void Main(){
		string str = Console.ReadLine();

		string[] spStr = str.Split (' ');


		int a = int.Parse(spStr[0]);
		int b = int.Parse(spStr[1]);


		Console.WriteLine(a * b + " " + 2 *(a + b));

		}

	}

Measured memory_bytes: 9172
#include <iostream>

using namespace std;

int main(void)
{
    int red, green, blue;
    int mul_times;

    cin >> red >> green >> blue;
    cin >> mul_times;

    int mul_cnt = 0;
    while(red >= green){
        green *= 2;
        mul_cnt += 1;
    }

    while(green >= blue){
        blue *= 2;
        mul_cnt += 1;
    }

    if(mul_cnt <= mul_times){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int x; cin >> x;
    prt(360 / gcd(x, 360));

    return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
long long n,a[100002],b[100002],ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i],&b[i]);
	long long t;
	for(long long i=n;i>=1;i--)
	{
		a[i]+=ans;
		long long j;
		for(j=a[i]/b[i];;j++)
			if(j*b[i]>=a[i])
				break;
		t=j*b[i]-a[i];
		ans+=t;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
int main(){
    int n;
    bool res=false;
    scanf("%d", &n);

    int x[20], y[20];

    for (int i = 1; i <10 ; ++i) {
        for (int j = 1; j <10 ; ++j) {
            x[i]=i;
            y[j]=j;
            if(x[i]*y[j]==n) res=true;
        }

    }
    while(res){
        printf("Yes");
        return 0;
    }
    printf("No");
}

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

int main() {
  double N;
  int K;
  cin >> N >> K;
  int n=N;
  vector<double> P(N,1/N);
  while (K>1){
    for (int i=0;i<min(n,K-1);i++){
      P[i]/=2.0;
    }
    K=(K+1)/2;
  }
  double ans=0;
  for (int i=0;i<n;i++){
    ans+=P[i];
  }
  cout << fixed << setprecision(9);
  cout << ans << endl;
}

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

int a[88];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    long m = 1000, k = 0;
    for(int i = 0; i < n; i++)
        if(a[i] < a[i + 1])
            k += m / a[i], m %= a[i];
        else
            m += k * a[i], k = 0;
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var H, W int
	fmt.Scan(&H, &W)

	C := make([]string, H)
	for i := range C {
		fmt.Scan(&C[i])
	}

	for i := 0; i < H*2; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%c", C[i/2][j])
		}
		fmt.Printf("\n")
	}
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
  val list = listOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
  val K = readInt()
  println(list[K - 1])
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map(Integer::parseInt)
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 31944
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
	int N;
	scanf("%d", &N);
	ll ruiseki[N];
	scanf("%lld", ruiseki);
	for (int i = 1; i < N; ++i){
		ll tmp;
		scanf("%lld", &tmp);
		ruiseki[i] = ruiseki[i - 1] + tmp;
	}
	ll answer = ruiseki[N - 1], candidate;
	int l = 0, r = 2;
	for (int m = 1; m < N - 2; ++m){
		while(l < m - 1 && abs(ruiseki[m] - (ruiseki[l]<<1)) > abs(ruiseki[m] - (ruiseki[l+1]<<1))) l++;
		if(r == m) r++;
		while(r < N - 2 && abs(ruiseki[N-1] + ruiseki[m] - (ruiseki[r]<<1)) > abs(ruiseki[N-1] + ruiseki[m] - (ruiseki[r+1]<<1))) r++;
		if(candidate = max({ruiseki[l], ruiseki[m] - ruiseki[l], ruiseki[r] - ruiseki[m], ruiseki[N - 1] - ruiseki[r]}) - min({ruiseki[l], ruiseki[m] - ruiseki[l], ruiseki[r] - ruiseki[m], ruiseki[N - 1] - ruiseki[r]}); candidate < answer) answer = candidate;
	}
	printf("%lld\n", answer);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, arr[MAXN+10][3], dp[MAXN+10][3];

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++) scanf("%d%d%d", &arr[i][0], &arr[i][1], &arr[i][2]);

    for(i=1; i<=N; i++)
    {
        dp[i][0]=max(dp[i-1][1], dp[i-1][2])+arr[i][0];
        dp[i][1]=max(dp[i-1][0], dp[i-1][2])+arr[i][1];
        dp[i][2]=max(dp[i-1][0], dp[i-1][1])+arr[i][2];
    }
    printf("%d", max({dp[N][0], dp[N][1], dp[N][2]}));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a==c)cout<<1<<endl;
    else if(a==b||b==c||c==a)cout<<2<<endl;
    else cout<<3<<endl;

    return 0;
}



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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;
typedef long long int ll;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a > 100000) {
            ans++;
            continue;
        }
        mp[a]++;
    }
    const int MAX = 100010;
    for (int i = 1; i < MAX; ++i) {
        if (mp[i] == 0) continue;
        cerr << mp[i] - i << endl;
        if (mp[i] - i < 0) {
            ans += mp[i];
            continue;
        }
        ans += mp[i]- i;
    }
    printf("%lld", ans);
    return 0;
}



Measured memory_bytes: 4992
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, N: int, a: "List[int]"):
    S = []
    for i, n in enumerate(a):
        j = i + 1
        S.extend([j] *  n)
    
    for h in range(H):
        row = S[h*W:h*W+W]
        if h % 2 == 0:
            print(' '.join(map(str, row)))
        else:
            print(' '.join(map(str, row[::-1])))

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(H, W, N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40048
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<typename A, size_t N, typename T>void Fill(A (&a)[N], const T &v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const int N=2e5;
int n;
string s;
ll ans;
void f(ll a, ll b){
  if(a>b) swap(a, b);
  ans += a*(a-1) + b*(b+1);
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  n = sz(s);
  bool p=true;
  int u = 0, d = 0;
  FOR(i, 0, n){
    if(s[i]=='<'){
      if(p){
        u++;
      }else{
        f(u, d);
        u = 1;
        d = 0;
        p = true;
      }
    }else{
      p = false;
      d++;
    }
  }
  f(u, d);
  cout << ans/2 << endl;
}

Measured memory_bytes: 1172