akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

#define max(a,b) ((a)>(b))?(a):(b);
#define min(a,b) ((a)>(b))?(b):(a);

int main(void)
{
	int cnt=0, nc=0, n;
	scanf("%d\n", &n);
	char s[51];
	char* sp = s;
	scanf("%s", sp);

	while (*sp)
	{
		if (nc + 'A' != *sp)
		{
			nc = 0;
		}
		if (nc+'A'==*sp)
		{
			nc++;
			if (nc + 'A' == 'C' + 1)
			{
				nc = 0;
				cnt++;
			}
		}
		sp++;
	}

	printf("%d", cnt);
}


Measured memory_bytes: 128
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, fl = 0;
    cin >> n;
    
    vector<int> v(n);
    for (auto &x : v) cin >> x, fl |= x == 0;
    
    if (fl) return cout << 0 << "\n", 0;
    
    double tmp = 0.0;
    for (auto x : v) tmp += log10(x);
    if (tmp > 18.5) return cout << -1 << "\n", 0;
    
    int mult = 1;
    for (auto x : v) mult *= x;
    cout << (mult > INF ? -1 : mult) << "\n";
    
    return 0;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int mul = 1;
    long long int a[100010];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(a[i] == 0){
            return cout << 0 , 0;
        }
    }
    for(int i = 1; i <= n; i++){
       if(a[i] > powl(10, 18) / mul) return cout <<-1, 0; 
        else mul *= a[i];
    }
    return cout << mul , 0;
}

Measured memory_bytes: 4356
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
	int d=0, t=0,s=0;
	double sum=0;
	cin>>d>>t>>s;
	sum=(double)d/t;
	if(sum>s)
	 cout<<"No"<<endl;
	else
	 cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3612
import heapq

n, m = map(int, input().split())
a = list(map(lambda x : -int(x), input().split()))

heapq.heapify(a)

for _ in range(m) :
    max = heapq.heappop(a)
    heapq.heappush(a, -(-max // 2))

print(-sum(a))


Measured memory_bytes: 14252
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }


//エラトステネスの篩
vector<char> eratos(int n) {
	vector<char> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i * i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j += i;
			}
		}
	return is_prime;
}
//戻り値: n以下の素数
vector<int> get_primes(int n) {
	vector<char> is_prime = eratos(n);
	vector<int> primes;
	for (int i = 0; i < n + 1; i++)
		if (is_prime[i])
			primes.emplace_back(i);
	return primes;
}
vector<int> divisor(int x) {
	vector<int> ret;
	int i;
	for (i = 1; i * i < x; i++) {
		if (x % i)
			continue;
		ret.emplace_back(i);
		ret.emplace_back(x / i);
	}
	if (i * i == x)
		ret.emplace_back(i);
	return ret;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);


	int N, K; cin >> N >> K;
	vector<int>a(N); rep(i, 0, N) { cin >> a[i]; }
	sort(all(a));
	int ss = accumulate(all(a), 0ll);
	auto d = divisor(ss);
	auto f = [&](int m) {
		vector<int>b = a;
		int sum = 0;
		rep(i, 0, N) {
			b[i] %= m;
			sum += b[i];
		}
		if (sum%m != 0)return false;

		int x = sum / m;
		sort(all(b));
		int k = 0;
		rep(i, N - x, N) {
			k += m - b[i];
		}
		return k <= K;
	};
	int ans = 0;
	for (auto dd : d) {
		if (f(dd)) {
			chmax(ans,dd);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
guidebook = []
for i in range(N):
  S, P = input().split()
  guidebook.append([i + 1, S, int(P)])
sort_guidebook = sorted(guidebook, key=lambda x:(x[1],-x[2]))
for i in range(N):
  print(sort_guidebook[i][0])

Measured memory_bytes: 3060
from math import ceil

n,k, *aa = map(int, open(0).read().split())

left = 0
right = max(aa)

while right - left > 1:
    mid = (left + right) // 2
    summ = sum(0--a//mid-1 for a in aa)
    if summ <= k:
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 108924
// ARC109
// C - Skip

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;

int N, X;
int x[MAX_N];

int gcd(int a, int b) {
    while (b > 0) {
        swap(b, a %= b);
    }
    return a;
}

int solve() {
    int ans = abs(x[0] - X);
    for (int i = 1; i < N; i++) {
        ans = gcd(ans, abs(x[i] - X));
    }
    return ans;
}

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,n;cin>>N;
  FOR(n,1,N+1){
    ll ans=0;
    for(ll i=1;i*i<=2*n;i++){
      for(ll j=1;j*j<=2*n-i*i;j++){
        ll a=sqrt(2*n-i*i-j*j);
        if(a*a==2*n-i*i-j*j&&(a+i+j)%2==0&&i+j>a&&j+a>i&&a+i>j){
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

ll tot = 0;

struct dsu{
  int n;
  vector<int> parent, size;
  dsu(int x) : n(x) {
    parent.resize(n);
    size.resize(n);
    this->init();
		tot = n;
		tot *= (n-1);
		tot /= 2;
  };

  void init(){
    for(int i=0; i<n; ++i){
      parent[i] = i;
      size[i] = 1;
    }
  }

  int get_set(int x){
    if( parent[x] == x ){
      return x;
    }
    return parent[x] = get_set(parent[x]);
  }

  void unite(int a, int b){
    int aa = get_set(a);
    int bb = get_set(b);
    if( aa == bb ){ return ;}

    if( size[bb] > size[aa] ){
      swap(aa,bb);
    }
		ll temp = size[aa];
		temp *= (size[aa]-1);
		temp /= 2;
		tot += temp;
		temp = size[bb];
		temp *= (size[bb]-1);
		temp /= 2;
		tot += temp;
    size[aa] += size[bb];
		temp = size[aa];
		temp *= (size[aa]-1);
		temp /= 2;
		tot -= temp;
    parent[bb] = aa;
  }
};
typedef struct dsu ds;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	ds a(n);
	vector<pair<int,int>> edges;
	for(int i=0; i<m; ++i){
		int x,y; cin>>x>>y ; x--; y--;
		edges.push_back({x,y});
	}
	reverse(edges.begin(),edges.end());
	vector<ll> ans;
	for(auto i : edges){
		ans.push_back(tot);
		a.unite(i.first,i.second);
	}
	reverse(ans.begin(),ans.end());
	for(auto i : ans ){
		cout<<i<<endl;
	}

	return 0;
}


Measured memory_bytes: 3828
using System;

namespace Product_Max
{
    class Program
    {
        static void Main(string[] args)
        {
            long a, b, c, d;
           

            string inD0 = Console.ReadLine();
            string[] cngD0 = inD0.Split(' ');

           a= long.Parse(cngD0[0]);
           b= long.Parse(cngD0[1]);
           c= long.Parse(cngD0[2]);
           d= long.Parse(cngD0[3]);

           long a1 = a * c;
           long a2 = a * d;
           long a3 = b * c;
           long a4 = b * d;

            Console.WriteLine("{0}", Math.Max(a1, Math.Max(a2, Math.Max(a3, a4))));
        }
    }
}


Measured memory_bytes: 27460
#include <bits/stdc++.h>
using namespace std;
struct node{
	int ff,num;
}v[200005];

int main(){
	int n,q;
	cin >> n >> q;
	for(int i = 1;i <= n;i++){
		v[i].ff = 0;
		v[i].num = 0;
	}
	for(int i = 1;i <= n - 1;i++){
		int x,y;
		cin >> x >> y;
		v[y].ff = x;
	}
	for(int i = 1;i <= q;i++){
		int x,y;
		cin >> x;
		cin >> y;
		v[x].num += y;
	}
	cout << v[1].num;
	for(int i = 2;i <= n;i++){
		v[i].num += v[v[i].ff].num;
		cout << " " << v[i].num;
	}
	cout << endl;
	return 0;
}

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

ans = 0

def judge(s):
    for i in range(len(s) // 2):
        if s[i] != s[len(s) - i - 1]:
            return 0
    return 1

for i in range(a, b + 1):
    ans += judge(str(i))

print(ans)

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0

for i in range(n-2):
    for y in range(i+1,n-1):
        if a[y]==a[i]:
            continue
        for j in range(y+1,n):
            if a[j]==a[y]:
                continue
            if a[i]+a[y]>a[j]:
                ans+=1
            else:
                break

print(ans)

Measured memory_bytes: 9196
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;
const LL mod = 1e9 + 7;

int N;
char s[5010];
int x;
LL dp[5001][5002];

int main(){
	scanf("%d" , &N);
	scanf("%*c%s" , s);
	for(x = 0 ; s[x] != 0 ; ++x);
	dp[0][x] = 1;
	for(int i = 1 ; i <= N ; ++i){
		dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
		dp[i][0] %= mod;
		for(int j = 1 ; j < 5001 ; ++j){
			dp[i][j] = dp[i - 1][j + 1] + 2 * dp[i - 1][j - 1];
			dp[i][j] %= mod;
		}
	}
	printf("%lld\n" , dp[N][0]);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  for (int i = 1; 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
from collections import defaultdict
from itertools import combinations

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s[0]] += 1

con = []
for c in ('M', 'A', 'R', 'C', 'H'):
    k = d[c]
    if k:
        con.append(k)

ans = 0
for a, b, c in combinations(con, 3):
    ans += a * b * c

print(ans)


Measured memory_bytes: 3564
#include <bits/stdc++.h>
 
using namespace std;
  int S, W;
 
void pre(){
  if (W >= S) {
    cout << "unsafe" << "\n";
  } else {
    cout << "safe" << "\n";
  } 
}
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
 
  cin >> S >> W;
pre();
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

typedef long long ll;

int appS[26];
int appT[26];
int main() {
  string s,t; cin >> s >> t;
  for ( int i = 0; i < s.length(); i++ ) {
    appS[s[i]-'a']++;
    appT[t[i]-'a']++;
  }

  sort(appS,appS+26);
  sort(appT,appT+26);
  bool f = true;
  for ( int i = 0; i < 26; i++ ) {
    if ( appS[i] != appT[i] ) f = false;
  }

  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] dice1 = Console.ReadLine().Split(' ');
            string[] dice2 = Console.ReadLine().Split(' ');

            if((dice1[0]==dice2[2]&&dice1[5]==dice2[3])||(dice1[0]==dice2[3]&&dice1[5]==dice2[2]))
            {
                string tmp = dice2[1];
                dice2[1] = dice2[2];
                dice2[2] = dice2[4];
                dice2[4] = dice2[3];
                dice2[3] = tmp;
            }
            
            for(int i=0;i<3;i++)
            {
                if (dice1[0] == dice2[0] && dice1[5] == dice2[5])
                    break;
                string tmp = dice2[0];
                dice2[0] = dice2[1];
                dice2[1] = dice2[5];
                dice2[5] = dice2[4];
                dice2[4] = tmp;
            }

            for (int i = 0; i < 3; i++)
            {
                if (dice1[1] == dice2[1] && dice1[4] == dice2[4])
                    break;
                string tmp = dice2[1];
                dice2[1] = dice2[2];
                dice2[2] = dice2[4];
                dice2[4] = dice2[3];
                dice2[3] = tmp;
            }

            if (dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] && dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5])
                Console.WriteLine("Yes");
            else Console.WriteLine("No");

        }
    }
}

Measured memory_bytes: 8876
//2019.7.22 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 1e18+1e9
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=150+10;
namespace MAIN{
    int n,k,kcz;
    int dp[N][N][N];
    int f[N][N];
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1;
    }
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:x+y;
    }
    inline int mul(const res &x,const res &y){
        return int(1LL*x*y%kcz);
    }
    inline int solve(const res &n,const res &k){
        for(res i=0;i<=n;i++)
            for(res j=0;j<=k;j++)
                f[i][j]=0;
        f[0][0]=1;
        for(res i=0;i<n;i++)
            for(res j=0;j<=k;j++)
                if(f[i][j])add(f[i+1][0],f[i][j]),add(f[i+1][j+1],f[i][j]);
        res ret=0;
        for(res i=0;i<=k;i++)add(ret,f[n][i]);
        return ret;
    }
    inline void MAIN(){
        n=read(),k=read(),kcz=read();
        if(k%2==0){printf("%d\n",mul(solve(n>>1,k>>1),solve(n-(n>>1),k>>1)));return;}
        dp[0][0][0]=1;
        for(res i=0;i<=n;i++){
            res r=i<<1,l=r-k;
            for(res j=0;j<=n;j++)
                for(res p=0;p<=k;p++)
                    if(dp[i][j][p]){
                        add(dp[i+1][0][0],dp[i][j][p]);
                        if((1<=r&&r<=n)&&(1<=l&&l<=n))add(dp[i+1][j+1][max(p+1,j+1)],dp[i][j][p]);
                        if((1<=r&&r<=n))add(dp[i+1][j+1][0],dp[i][j][p]);
                        if((1<=l&&l<=n))add(dp[i+1][0][p?p+1:p],dp[i][j][p]);
                    }
        }
        printf("%d\n",dp[n+1][0][0]);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


void solve() {
    ll h, w; cin >> h >> w;
    ll n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    Vl b(n); b = a;
    int k = 0;
    vector<vector<ll>> ans(h, vector<ll>(w, 0));
    rep(i, 0, h){
        if(i%2 == 0){
            rep(j, 0, w){
                if(a[k] == 0) k++;
                ans[i][j] = k+1;
                a[k]--;
            }
        }else{
            for(int j = w-1; j >= 0; j--){
                if(a[k] == 0) k++;
                ans[i][j] = k+1;
                a[k]--;
            }
        }
    }

    rep(i, 0, h) {
        rep(j, 0, w){
            if(j) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }
    return;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#define mod 1000000007
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define srep(i,s,t) for (ll i = s; i < t; i++)
#define drep(i,n) for(ll i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef vector<vector<char>> field_t;
typedef unsigned long long ull;
typedef pair<ll, ll> point_t;
using Graph = vector<vector<ll>>; // グラフ型 // グラフ


int main()
{
    ll k;
    cin >> k;
    string s;
    char c;
    ll r=0;
    ll r1=0;
    rep(i,k){
        cin>>c;
        s+=c;
        if(c=='R')r++;
    }
    rep(i,r){
        if(s[i]=='R')r1++;
    }
    cout<<r-r1<<endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(ll i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

ll countfactors(ll n)
{
	if(n==1)return 1;

	ll c=1;
	forA(i,2,sqrt(n)+1,1)
	{
		if(n%i==0)
		{
			ll temp=0;
			while(n%i==0)
			{
				temp++, n/=i;
			}
			c*=(temp+1);
		}
	}
	if(n>1)c*=2;
	return c;
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n; cin>>n; ll ans=0;
	
	forA(i,1,n,1)
	{
		ll temp = countfactors(n-i); //cout<<i<<" "<<temp<<"\n";
		ans+=temp;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>

using namespace std;

int main() {

	int a, b, sum;
	cin >> a >> b;
	sum = 0;
	for (int i = 0; i < 2;i++) {

		if (a > b) {
			sum += a;
			a = a - 1;
		}
		else {
			sum += b;
			b = b - 1;
		}
	}
	cout << sum << endl;

	//cin >> /*変数他*/;
	//cout << /*文字列*/ << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n,k;
    int r,s,p;
    cin >> n >> k;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    map <int,char> table; 
    int score = 0;

    for(int i=1; i<=n; i++){
        int amari = i % k;
        if(table.count(amari)){//k回まえが存在
            if(table.at(amari) == t[i-1]){
                table.erase(amari);
            }
            else{
                if(t[i-1] == 'r'){
                    score += p;
                    table.erase(amari);
                    table[amari] = 'r';
                }
                if(t[i-1] == 's'){
                    score += r;
                    table.erase(amari);
                    table[amari] = 's';
                }
                if(t[i-1] == 'p'){
                    score += s;
                    table.erase(amari);                    
                    table[amari] = 'p';
                }
            }

        }
        else{//kで割ったあまりが初めて
            table[amari] = t[i-1];
            if(t[i-1] == 'r'){
                score += p;
            }
            if(t[i-1] == 's'){
                score += r;
            }
            if(t[i-1] == 'p'){
                score += s;
            }
        }
    }

    cout << score << endl;
}


Measured memory_bytes: 7780
#include <iostream>

using namespace std;

int main(void) {

    int a, b, c, temp;
    cin >> a >> b >> c;
    
    if (a > b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    if (b > c)
    {
        temp = b;
        b = c;
        c = temp;
    }
    if (a > b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    
    cout << a << " " << b << " " << c << endl;

    return 0;
}



Measured memory_bytes: 3104
// Last Change: 04/20/2019 21:03:23.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A < C and C < B) {
    cout << "Yes" << endl;
  } else if (B < C and C < A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,n2,a[101][101],i,j,x,y;

  for(i=1; i<101; i++)
    for(j=1; j<101; j++)
      a[i][j]=0;

  scanf("%d",&n);

  for(i=1; i<n+1; i++){
    scanf("%d%d",&x,&n2);
    for(j=0; j<n2; j++){
      scanf("%d",&y);
      a[x][y]=1;
    }
  }

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

  return 0;
}
	   

    



Measured memory_bytes: 2112
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int n = sc.nextInt();
 
    int ang = 0;
    for(int i = 0; i < 1000000; i++){
      ang += n;
      if(ang % 360 == 0){
        System.out.println(i+1);
        break;
      }
    }
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 25264
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,num[30],cnt,js;
char s[2000];
int main()
{
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
	  scanf("%s",s);
	  for (j=0;j<m;j++)
	    num[s[j]-'a']++;
	}
	if (n%2==0&&m%2==0)
	{
		for (i=0;i<=26;i++)
		  if (num[i]%4!=0) {printf("No");return 0;}
		printf("Yes");
	}
	else
	if ((n%2!=0&&m%2==0)||(n%2==0&&m%2!=0))
	{
		if (n%2!=0)  swap(n,m);
		for (i=0;i<=26;i++)
		  if (num[i]%4!=0)
		  {
            if (num[i]%2!=0)  {printf("No");return 0;}
            else  js++;
          }
        if (js>n/2)  printf("No");
        else  printf("Yes");
	}
	else
	{
		cnt=0;
		for (i=0;i<=26;i++)
		  if (num[i]%4!=0)
		  {
		  	if (num[i]%2!=0)  cnt++;
		  	else  js++;
		  	if (num[i]%4==3)  js++;
		  	if (cnt>1) {printf("No");return 0;}
		  }
		if (cnt==1&&js<=(n-1+m-1)/2)  printf("Yes");
		else  printf("No");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    int count = 1;

    for (int i = 0; i < N; i++) {
        if (i != N-1){
            if (A.at(i) < A.at(i+1)){
                for (int j = 1; j < N-i-1; j++) {
                    if (A.at(i+j) > A.at(i+j+1)){
                        count++;
                        i += j;
                        break;
                    }
                    else if (j == N-i-2){
                        i += j;
                    }
                }
            }
            else if (A.at(i) > A.at(i+1)){
                for (int j = 1; j < N-i-1; j++) {
                    if (A.at(i+j) < A.at(i+j+1)){
                        count++;
                        i += j;
                        break;
                    }
                    else if (j == N-i-2){
                        i += j;
                    }
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3700
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<cstring>
#include<tuple>
#include<queue>
#include<map>
#define INF 0x7fffffff
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main()
{
    int n,i,j,temp;
    int count=0;
    cin >> n;
    int array[n];
    for (i=0;i<n;i++){
        cin>>array[i];
    }
    for (i=0;i<n;i++){
        for (j=n-1;j>i;j--){
            if(array[j]<array[j-1]) {
                temp=array[j];
                array[j]=array[j-1];
                array[j-1]=temp;
                count++;
            }

        }
    }
    for (i=0;i<n;i++){
        cout<<array[i]<<((i==n-1)?"\n":" ");
    }
    cout<<count<<endl;

}



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

const int maxn = 15;
char s[maxn];

int main() {

    scanf("%s", s);
    if(!strcmp(s, "Sunny")) printf("Cloudy");
    else if(!strcmp(s, "Cloudy")) printf("Rainy");
    else printf("Sunny");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(void){
    int n; cin>>n;
    vector <int> a(n);
    vector <int> d(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    d[n-1]=0; int x = 1;
    for(int i=n-1;i>=0;i--){
        if(x) d[n-1]+=a[i];
        else d[n-1]-=a[i];
        x = 1-x;
    }
    //cout<<d[n-1]<<endl;
    for(int i=n-2;i>=0;i--){
        d[i] = 2*a[i+1]-d[i+1];
    }
    //なんかずれたw
    cout<<d[n-1]<<' ';
    for(int i=0;i<n-1;i++){
        cout<<d[i]<<' ';
    }
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll dp[1000010];
ll dp_odd[1000010];


int main(void){
    for(ll i=0;i<1000010;i++){
        dp[i]=(ll)INF;
        dp_odd[i]=(ll)INF;
    }
    vector<ll>a,b,c;
    for(ll i=1;;i++){
        ll tmp = i*(i+1)/2;
        if(i>1000000)break;
        a.push_back(tmp);
    }
    ll sum = 0;
    for(ll i=0;;i++){
        sum+=a[i];
        if(sum>1000000)break;
        b.push_back(sum);
        if(sum%2==1)c.push_back(sum);
    }
    ll asize = a.size();
    ll bsize = b.size();
    ll csize = c.size();
    dp[0]=0;
    dp_odd[0]=0;
    for(ll i=1;i<1000000;i++){
        for(ll j=0;j<bsize;j++){
            if(i>=b[j])dp[i]=min(dp[i],dp[i-b[j]]+1);
            else break;
        }
    }
    for(ll i=1;i<1000000;i++){
        for(ll j=0;j<csize;j++){
            if(i>=c[j])dp_odd[i]=min(dp_odd[i],dp_odd[i-c[j]]+1);
            else break;
        }
    }
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        cout<<dp[n]<<" "<<dp_odd[n]<<endl;
    }
    return 0;
}




Measured memory_bytes: 26664
s = input()
t = input()

for i in range(len(s)-len(t),-1,-1):
    tmp = s[i:i+len(t)]
    ans = ''
    for j in range(len(t)):
        if tmp[j] != t[j] and tmp[j] != '?':
            break
        ans += t[j]
        if j == len(t)-1:
            ans = s[:i]+ans+s[len(t)+i:]
            print(ans.replace('?','a'))
            exit()
print('UNRESTORABLE')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  int h, w;
  cin >> h >> w;
  char c[h][w];
  REP(i, h) {
    REP(j, w) { cin >> c[i][j]; }
  }
  REP(i, h) {
    REP(j, w) { cout << c[i][j]; }
    cout << endl;
    REP(j, w) { cout << c[i][j]; }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

const int N = 2002;
int dp[N][N];
int sm[N][N];

const int MOD = 998244353;

int C[N+1][N+1];

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    for (int n=0; n<=N; ++n) {
        C[n][0] = C[n][n] = 1;
            for (int k=1; k<n; ++k)
                C[n][k] = (C[n-1][k-1] + C[n-1][k]) % MOD;
    }

    memset(dp, 0, sizeof(dp));
    memset(sm, 0, sizeof(sm));
    for (int i = 0; i < N; i++) {
        dp[0][i] = 1;
        sm[0][i] = 1;
    }

    for (int cubes = 1; cubes < N; cubes++) {
        sm[cubes][0] = sm[cubes-1][0] + dp[cubes][0];
        sm[cubes][0] %= MOD;
        for (int mx = 1; mx < N; mx++) {
            //for (int cnt = 0; cnt <= cubes; cnt++) {
            //    dp[cubes][mx] += dp[cubes - cnt][mx-1];
            //    dp[cubes][mx] %= MOD;
            //}
            dp[cubes][mx] += sm[cubes][mx-1];
            dp[cubes][mx] %= MOD;
            sm[cubes][mx] = sm[cubes-1][mx] + dp[cubes][mx];
            sm[cubes][mx] %= MOD;
        }
    }

    int k, n;
    cin >> k >> n;

    for (int i = 2; i <= 2 * k; i++) {
        int q = 0;
        for (int j = 1; 2*j <= i; j++) {
            int j2 = i - j;
            if (j <= k && j2 <= k) {
                q++;
            }
        }
        // cout << "Q " << q << endl;
        long long ans = dp[n][k];
        int f = 1;
        for (int a = 1; a <= q; a++) {
            if (n < 2*a) {
                break;
            }
            f *= -1;
            ans += 1LL * f * C[q][a] * dp[n-2*a][k];
            ans += 1LL * MOD * MOD;
            ans %= MOD;
            // cout << "ANS " << ans << endl;
        }
        cout << ans << endl;
    }

    return 0;
}


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

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int cnt = 0;
        for(int j = 1; j <= i; j++){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>

#define rep(i,n) for(int i=0; i<n;i++)
typedef long long ll;

using namespace std;
const int V = 100005;


int a[100005];
int x,y;
int n;


int main(){
  cin >> x >> y;
  int big = max(x,y);
  int small = min(x,y);
  int amari = big % small;
  while(amari != 0){
    small = amari;
    amari = big % small;
    big = small;
  }
  cout << small << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define int long long
using namespace std;
static const int inf =1ll<<60ll;

int N,M;
int d[1005];
int c[1005];
int mem[1005][1005];

int cal(int n,int m){
    int res=inf;
    if(mem[n][m]!=-1)return mem[n][m];
    if(n==N+1) return 0;
    if(m>M)return inf;
    res=min(cal(n+1,m+1)+(d[n]*c[m]),min(cal(n,m+1),res));
    return mem[n][m]=res;
}

signed main(){
    memset(mem,-1,sizeof(mem));
    cin>>N>>M;
    for(int i=1;i<=N;++i)cin>>d[i];
    for(int i=1;i<=M;++i)cin>>c[i];
    cout<<cal(1,1)<<endl;
}

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
long long a[87],n;
void work()
{
	cin>>n;
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=n;i++)
    {
        a[i]=a[i-1]+a[i-2];
	}
    cout<<a[n]<<endl;
}
int main()
{
	work();
	return 0;
}

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

class Solution {
  struct Exam {
    int a, b;
  };
  vector<Exam> A;
  int n;
public:
  void run(istream &in, ostream &out) {
    in >> n;
    A.resize(n);
    long long suv = 0, need = 0;
    for (int i = 0; i < n; ++i) in >> A[i].a, suv += A[i].a;
    for (int i = 0; i < n; ++i) in >> A[i].b, need += A[i].b;
    if (suv < need) {
      out << -1 << '\n';
      return;
    }
    need = 0;
    vector<int> left;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (A[i].a < A[i].b) need += A[i].b - A[i].a, ++ans;
      else left.push_back(A[i].a - A[i].b);
    }
    sort(left.begin(), left.end(), greater<int>());
    int i = 0;
    while (need > 0) {
      need -= left[i++];
    }
    out << ans + i << '\n';
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Solution().run(cin, cout);
  return 0;
}



Measured memory_bytes: 1660
fun main(args: Array<String>) {
    val coin500 = readLine()?.toInt() ?: return
    val coin100 = readLine()?.toInt() ?: return
    val coin50 = readLine()?.toInt() ?: return
    val result = readLine()?.toInt() ?: return

    var count = 0

    for (i500 in 0 .. coin500) {
        for (i100 in 0 .. coin100) {
            for (i50 in 0 .. coin50) {

                if ((i500 * 500 + i100 * 100 + i50 * 50) == result) {
                    count++
                }
            }
        }
    }

    println(count)
}

Measured memory_bytes: 31924
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))

Lsum = sum(L)
Lmax = max(L)

ans = "No"
if Lmax < (Lsum-Lmax):
    ans = "Yes"
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

void BJ(int a,int b,int c){
  int sum=a+b+c;
  if(sum>21)printf("bust");
  else printf("win");
}

int main(){
  int x,y,z;
  scanf("%d %d %d",&x,&y,&z);
  BJ(x,y,z);
  return 0;
}

Measured memory_bytes: 128
n, t = gets.chomp.split.map(&:to_i)
queue = Array.new(n){[]}
t.times{
    query = gets.chomp.split.map(&:to_i)
    case query[0]
    when 0
        i, x = query[1..2]
        queue[i].push x
    when 1
        i = query[1]
        puts queue[i].first unless queue[i].empty?
    when 2
        i = query[1]
        queue[i].shift
    end
}


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


int main(){
  int m,f,r;
  scanf("%d%d%d",&m,&f,&r);
  while(!(m==-1) || !(f==-1) ||!(r==-1)){
    if(m==-1 || f==-1){
      printf("F\n");}
    else{
      if(m+f>=80) printf("A\n");
      else if(m+f>=65) printf("B\n");
      else if(m+f>=50) printf("C\n");
      else if(m+f>=30){
        if(r>=50) printf("C\n");
        else printf("D\n");}
      else printf("F\n");}
    scanf("%d%d%d",&m,&f,&r);}
  return 0;}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int cnt = 0;
    for (int i = 0; i < h;i++){
        string a;
        cin >> a;
        for (int j = 0; j < w;j++){
            if(a[j]=='#')
                cnt++;
        }
    }
    if(cnt==h+w-1)
        cout << "Possible" << endl;
        else
            cout << "Impossible" << endl;
        return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

c = [[0] * (2 ** 10) for i in range(N)]
for i in range(N):
    for j in range(2 ** 10):
        for k in range(10):
            if j >> k & 1 == 1 and F[i][k] == 1:
                c[i][j] += 1

s = [0] * (2 ** 10)
for i in range(N):
    for j in range(2 ** 10):
        s[j] += P[i][c[i][j]]

print(max(s[1:]))


Measured memory_bytes: 3956
import sys
sys.setrecursionlimit(100000)
N, *A = map(int, open(0).read().split())
memo = [[-1]*N for i in range(N)]
for i in range(N):
    memo[i][i] = A[i] if N % 2 else 0
def dfs(p, q, t):
    if memo[p][q] != -1:
        return memo[p][q]
    if t:
        memo[p][q] = r = max(A[p] + dfs((p+1)%N, q, 0), A[q] + dfs(p, (q-1)%N, 0))
    else:
        if A[p] < A[q]:
            memo[p][q] = r = dfs(p, (q-1)%N, 1)
        else:
            memo[p][q] = r = dfs((p+1)%N, q, 1)
    return r
ans = 0
for i in range(N):
    ans = max(ans, A[i] + dfs((i+1)%N, (i-1)%N, 0))
print(ans)



Measured memory_bytes: 97868
# coding: utf-8
n = int(input())
data = list(map(int,input().split()))

ans = 0
for i in range(n - 2):
    lst = [data[i], data[i + 1], data[i + 2]]
    if max(lst) != data[i + 1] and min(lst) != data[i + 1]:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int itemNum, popItemNum, totalVotes = 0;
    double quaterVotes = 0;
    
    scanf("%d %d", &itemNum, &popItemNum);
    int votesArray[itemNum];
    
    for(int i = 0; i < itemNum; i++)
    {
        int partVotes;
        scanf("%d", &partVotes);
        totalVotes += partVotes;
        votesArray[i] = partVotes;
    }
    
    quaterVotes = totalVotes * (1.0 / (4 * popItemNum));
    
    /* Using popItemNum(M) as counter to judge if the requirement of task is fulfilled.
     If goes beyond 0, then it means M popular items can be selected. */
    
    for(int i = 0; i < itemNum; i++)
    {
        if(votesArray[i] >= quaterVotes)
        {
           popItemNum--;
        }
    }
    
    if(popItemNum <= 0)
    {
        printf("Yes \n");
    }
    else
    {
        printf("No \n");
    }
    
    return 0;
}


Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
signed main(){ 
  int n=1,m;
  char s[1000];
  char c;
  cin>>s;
  m=strlen(s);
  sort(s,s+m);
  c=s[0];
  for(int i=1;i<=m;i++){
    if(c==s[i])
      n++;
    else{
      c=s[i];
      if(n%2==1){
	cout<<"No"<<endl;
	return(0);
      }
      n=1;
    }
  }
  cout<<"Yes"<<endl;
  return(0);
}


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;
  int n,m,q;
  vector<vector<int>> v(55,vector<int> (4));
  vector<int> path;
  ll ans=0LL;
  void check(){
    ll val=0;
      for(int i=0;i<q;i++){
         if((path[v[i][1]]-path[v[i][0]])==v[i][2]){
           val+=v[i][3];
         }
      }
      ans = max(ans,val);
  }
  void dfs(int i,int cur){
     if(i>=n){
        check();
        return;
     }
       for(int j=cur;j<=m;j++){
          path.push_back(j);
          dfs(i+1,j);
          path.pop_back();
       }
  }

  void solve(){
     cin >> n >> m >> q;
     for(int i=0;i<q;i++){
        cin >> v[i][0] >> v[i][1]>> v[i][2]>> v[i][3];
        v[i][0]--,v[i][1]--;
     }
     
     dfs(0,1);
     cout << ans;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3812
def main(input_list):
    count = 0
    for i_1, _ in enumerate(input_list):
        watch_sea = True
        for i_2 in range(i_1):
            if input_list[i_1] < input_list[i_2]:
                watch_sea = False
        if watch_sea:
            count += 1

    return count


if __name__ == "__main__":
    input()
    input_list = list(map(int, input().split()))
    print(main(input_list))


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

int mod = 1e9 + 7;

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    return modpow(x, y / 2) * modpow(x, y / 2) % mod;
}

int main(){
    vector<long long> fac(1'000'001, 1);
    for (int i = 1; i <= 1'000'000; i++) fac[i] = fac[i - 1] * i % mod;
    int x, y;
    cin >> x >> y;
    long long ans = 0;
    for (int i = 0; i <= max(x, y); i++){
        if (x - i < 0 || y - i * 2 < 0) continue;
        if ((x - i) % 2) continue;
        int p = (x - i) / 2;
        if (p != (y - i * 2)) continue;
        ans += fac[i + p] * modpow((fac[i] * fac[p] % mod), mod - 2) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
lr = [list(map(int, readline().split())) for _ in range(m)]

left = 0
right = n
for i in range(m):
    left = max(left, lr[i][0])
    right = min(right,lr[i][1])
print(max(0,right-left+1))

Measured memory_bytes: 27380
#include<iostream>
#include<math.h>
using namespace std;
#define size 100010
long long x[size];
int n,k;
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n>>k)
    {
        for(int i=0;i<n;i++)
        {
            cin>>x[i];
        }
        long long ans=0x3f3f3f3f;
        int left,right;
        int temp1,temp2;
        for(int i=0;i<(n-k+1);i++)
        {
            left=i;
            right=i+k-1;
            temp1=abs(x[left])+abs(x[right]-x[left]);
            temp2=abs(x[right])+abs(x[right]-x[left]);
            if(ans>temp1) ans=temp1;
            if(ans>temp2) ans=temp2;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(n, m, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

signed main() {
    string s;
    cin >> s;
    rep(s.size(), i) {
        if (s[i] == '1') cout << 9;
        else cout << 1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i] and L[i]+L[j]+L[k] > 2*max(L[i],L[j],L[k])):
        ans+=1
print(ans)

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

const int MAX=300000;
bool num[MAX];

void sieve()
{
  int j;
  for(int i=0;i<MAX;i++)
    num[i]=false;
  for(int i=6;i<MAX;i++)
    if(i%7==1||i%7==6) num[i]=true;
  for(int i=6;i<MAX;i++){
    if(num[i])
      for(j=2;j*j<=i;j++)
	if(num[j]&&!(i%j)){
	  num[i]=false; break;
	}
  }
}

int main()
{
  sieve();
  int n;
  for(;;){
    cin>>n;
    if(n==1) break;
    cout<<n<<":";
    for(int i=6;i<=n/6;i++)
      if(num[i]&&!(n%i)) cout<<" "<<i;
    if(num[n]) cout<<" "<<n;
    cout<<endl;
  }
}


Measured memory_bytes: 1452
S = input()
ans = [0 for _ in range(len(S))]
cnt = 0
for i, s in enumerate(S):
    if s == "R":
        cnt += 1
    else:
        x = cnt // 2
        ans[i] += x
        ans[i - 1] += x + cnt % 2
        cnt = 0
cnt = 0
for i, s in enumerate(S[::-1]):
    if s == "L":
        cnt += 1
    else:
        i += 1
        x = cnt // 2
        ans[-i] += x
        ans[-i + 1] += x + cnt % 2
        cnt = 0
print(*ans)


Measured memory_bytes: 10676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char S;
  cin >> S;

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

Measured memory_bytes: 256