akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 114：D - 756


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def ncm(n, m):
    if n<m:
        return 0
    a = 1
    for i in range(m):
        a *= (n-i)
    for i in range(m):
        a /= (m-i)
    return a


def main():
    N = int(raw_input().strip())

    # f = [[], []]
    f = []
    for i in range(2, N+1):
        f.append(factorize(i))
    # print f

    ff = [0]*100
    # print ff
    for fp in f:
        for fpp in fp:
            ff[fpp[0]] += fpp[1]
    # print ff

    '''
      5, 4, 3, 0, 5, 2, 4
    a *  *        *     * >= 4
    b *  *  *     *  *  * >= 2
    '''
    # (4+1) * (4+1) * (2+1) = 75
    # aC2 * (b-2)
    a = 0
    b = 0
    for fn in ff:
        if fn >= 4:
            a += 1
        if fn >= 2:
            b += 1
    n1 = ncm(a, 2) * (b-2)

    # (24+1)*(2+1) = 75
    # a * (b-1)
    a = 0
    b = 0
    for fn in ff:
        if fn >= 24:
            a += 1
        if fn >= 2:
            b += 1
    n2 = a * (b-1)

    # (14+1)*(4+1) = 75
    # a * (b-1)
    a = 0
    b = 0
    for fn in ff:
        if fn >= 14:
            a += 1
        if fn >= 4:
            b += 1
    n3 = a * (b-1)

    # (74+1) = 75
    # a
    a = 0
    for fn in ff:
        if fn >= 74:
            a += 1
    n4 = a

    print n1+n2+n3+n4


if __name__ == '__main__':
    main()


Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

	int n, c;
	cin >> n >> c;
	vector<vector<int>> d(c, vector<int>(c));
	vector<vector<int>> co(n, vector<int>(n));

	rep(i, c) {
		rep(j, c) {
			cin >> d[i][j];
		}
	}
	rep(i, n) {
		rep(j, n) {
			cin >> co[i][j];
		}
	}

	// 必要な色の種類は3種類のみ(1マス以外)
	// どの一色使うか決める
	int ans = inf;

	vector<vector<int>>cNum(3, vector<int>(c, 0));

	rep(i, n) {
		rep(j, n) {
			rep(k, 3) {
				if ((i + j + 2) % 3 == k) {
					cNum[k][co[i][j] - 1]++;
				}
			}
		}
	}

	rep(i, c) {
		rep(j, c) {
			if (j == i) continue;
			rep(k, c) {
				if (k == i || k == j) continue;
				// 0番目にi色を
				// 1番目にj色を
				// 2番目にk色を使う
				int temp = 0;
				rep(l, c) {
					temp += d[l][i] * cNum[0][l];
					temp += d[l][j] * cNum[1][l];
					temp += d[l][k] * cNum[2][l];
				}
				ans = min(ans, temp);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1280
D = int(input())
c = [0] + list(map(int, input().split()))
s = [0] + [[0] + list(map(int, input().split())) for _ in range(D)]
last = [0]*27

for d in range(1, D+1):
    SLvar = [s[d][i] + c[i] * (d - last[i]) for i in range(1, 27)]

    t = SLvar.index(max(SLvar)) + 1
    print(t)
    last[t] = d

Measured memory_bytes: 9400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    long long count = 0;
    for(int i = 1;i <= N;i++)
    {
        if(i % 3 == 0 or i % 5 == 0)
            continue;
        count += i;
    }
    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
#include <list>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef vector<int> vi;

int main(void) {
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	REP(i, n){
		char x, y, z;
		x = a[i], y = b[i], z = c[i];
		if(x == y && y == z) {
		} else if(x == y || y == z || z == x){
			ans += 1;
		} else {
			ans += 2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        long[] a = new long[N];
        long sum = 0;
        for (int i=0; i<N; i++)
            a[i] = Long.parseLong(sc.next());
        Arrays.sort(a);
        for (int i=0; i<N-K; i++)
            sum += a[i];
        out.println(sum);
        
        out.flush();
    }
}

Measured memory_bytes: 50356
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX

ll modex(ll a, ll p, ll m = mod)
{
  if(p==0)
    return 1;
  ll s = 1;
  while(p!=1)
  {
    if(p%2)
      s = (s*a)%m;
    a = (a*a)%m;
    p /= 2;
  }
  return (a*s)%m;
}


 
void solve()
{
    int n,k;
    cin >> n >> k;
    int ans[k+1] = {0};
    int tot1 = 0;
    repd(i,k,1)
    {
        int tot = k/i;
        ans[i] = modex(tot, n);
        int j = i+i;
        while(j<=k)
            ans[i] = (ans[i]-ans[j]+mod)%mod, j+=i;
        tot1 += (i*ans[i])%mod;
        tot1 %= mod;
    }

    cout << tot1 << endl;


}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
int main()
{
	char ch[3];
	cin>>ch;
	if(ch[1]=='B') ch[1]='R';
	else ch[1]='B';
	cout<<ch;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;

int n;
int a[100002];

int main () {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	
	for (int i = n-2; i >= 0; i --) {
		if (a[i] > a[i+1]) {
			a[i] --;
		} 
	}
	
	for (int i = 0; i < n-1; i ++) {
		if (a[i] > a[i+1]) {
			cout << "No";
			return 0;
		}
	}
	
	cout << "Yes";


	return 0;
}

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

#define ll long long
// #define endl '\n'

// void max_self(int &a, int b){a = max(a, b);}
// void min_self(int &a, int b){a = min(a, b);}

void solve(){
	int n, m; cin>>n>>m;
	vector< int > v(m);
	for(int &i : v) cin>>i;
	int ans = 0;
	for(int i : v) ans += i;
	if(ans > n){
		cout<<-1<<endl;
	}else{
		cout<<n - ans<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  cout<<(n+111-1)/111*111<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n;
int main(){
	n=read();
	if(n) printf("0\n");
	else printf("1\n");
	return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n+1,0);
    int input;
    for(int i=1;i<n+1;i++){
        cin >> input;
        a[input]++;
    }
    sort(a.begin(),a.end());
    int hold=0;
    int holdcnt=0;
    for(int i=n;i>=1;i--){
        for(int j=n;j>=1;j--){
            if(a[j]==i){
                hold+=i;
                holdcnt++;
                if(holdcnt==k){
                    cout << n-hold << endl;
                    return 0;
                }
            }else if(a[j]<i)break;
        }
    }
    cout << "0" << endl;
    return 0;
}





Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int i,j;
  int t[n],x[n],y[n];
  for(i=1;i<=n;i++){
    scanf("%d%d%d",&t[i],&x[i],&y[i]);
  }
  t[0]=0;
  x[0]=0;
  y[0]=0;
  for(i=1;i<=n;i++){
    // printf("%d\n",((t[i]-t[i-1])-abs(x[i]-x[i-1])-abs(y[i]-y[i-1]))%2);
    if(t[i]-t[i-1]<abs(x[i]-x[i-1])+abs(y[i]-y[i-1])){
      printf("No\n");
      return 0;
    }
    else if(((t[i]-t[i-1])-abs(x[i]-x[i-1])-abs(y[i]-y[i-1]))%2 == 1){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>

using namespace std;

int main(void){

    long long int n, m;
    cin>>n>>m;

    long long int ans = 1;

    if(m%n==0){
        cout<<m/n<<endl;
        return 0;
    }else{

        for(long long int i =2 ; i<=m; i++){
            if(m%i==0){
                if(m/i > n) ans = i;
            }

            if(m/i < n) break;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define ull unsigned long long int
#define T int test; scanf("%d",&test); while(test--)
#define pb push_back
#define in insert
#define PI acos(-1)
#define sc(n) scanf("%d",&n)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define lsc(n) scanf("%lld",&n)
#define lsc2(a,b) scanf("%lld%lld",&a,&b)
#define rep(i,n) for(i=0;i<n;i++)
#define fr(i,a,b) for(i=a;i<b;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;



int main()
{
	ll n;
	cin >> n;
	ll i,ans=0,j;
	rep(i,n)
	{
		j=i+1;
		if(j%3 && j%5)
		{
			ans+=j;
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
n =  int(input())
a = list(map(int,input().split()))
a_after = [a[i] - i for i in range(n)]
from collections import Counter
cnt = Counter()
for v in a_after:
    cnt[v] += 1
ret = 0  
for i in range(n):
    v = a[i] - i
    cnt[v] -= 1
    ret += cnt[-v-2*i]

print(ret)

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

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

  int f;
  string s;
  cin>>f>>s;

  for (char& c: s) {
    int i = c-'A';
    i += f;
    i %= 26;
    c = (i+'A');
  }

  cout<<s;
  

  return 0;
}


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

using namespace std;
 
#define ll long long
#define endl '\n'
#define mod 1000000007


void solve(){
	int n;
	cin>>n;
	if(n >= 30){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	while(t--)
    	solve();
	return 0;
}


Measured memory_bytes: 3648
S=input()
n=len(S)
t=[]
for i in range(13):
  t.append(0)
t[0]=1
jkmap=[]
for j in range(10):
  jkmap.append([])
  for k in range(13):
    jkmap[j].append((10*k+j)%13)
for i in range(n):
  if S[i]=='?':
    tcopy=[0]*13
    for j in range(10):
      for k in range(13):
        tcopy[jkmap[j][k]]=(tcopy[jkmap[j][k]]+t[k])%(10**9+7)
    for j in range(13):
      t[j]=tcopy[j]
  else:
    j=int(S[i])
    tcopy=[0]*13
    for k in range(13):
      tcopy[jkmap[j][k]]=(tcopy[jkmap[j][k]]+t[k])%(10**9+7)
    for j in range(13):
      t[j]=tcopy[j]
print(t[5])


Measured memory_bytes: 43500
N, Q = [int(x) for x in input().split()]
S = input()
TD = []
for _ in range(Q):
    t, d = input().split()
    TD.append((t, d))


def isDead(targetIdx):
    ti = targetIdx
    for t, d in TD:
        if t == S[ti]:
            if d == 'L':
                ti -= 1
                if ti == -1:
                    return -1
            else:
                ti += 1
                if ti == N:
                    return +1
    return 0


l, r = -1, N

while r - l > 1:
    t = (l + r) // 2
    if isDead(t) == -1:
        l = t
    else:
        r = t

L = r

l, r = -1, N

while r - l > 1:
    t = (l + r) // 2
    if isDead(t) == +1:
        r = t
    else:
        l = t

R = l

print(R - L + 1)

# print((L, R))
# print([isDead(t) for t in range(N)])


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

using namespace std;

constexpr int psize=40;
constexpr long long pnum[psize]={
    2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,
    73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173
};

map<int64_t,int64_t> prime_factor(int64_t n) {
    map<int64_t,int64_t> ret;
    for(int64_t i=2;i*i<=n;i++) {
        while(n%i==0) {
            ret[i]++;
            n/=i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}


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

    long long ans=0;
    long long check=0;
    long long check_cnt=0;
    long long cnt=0;
    for(auto p: prime_factor(n)){
        while(p.second--){
            if(check!=p.first){
                cnt=0;
                int i=1;
                // cout << check_cnt << endl;
                while(check_cnt-i>=0){
                    check_cnt-=i;
                    cnt++;
                    i++;
                }
                ans+=cnt;
                check_cnt=0;
                check=p.first;
            }
            check_cnt++;
            // cout << p.first << " ";
        }
    }
    cnt=0;
    int i=1;
    while(check_cnt-i>=0){
        check_cnt-=i;
        cnt++;
        i++;
    }
    ans+=cnt;

    // cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3632
class BIT:
            
    def __init__(self, L):
        self.N = len(L)
        self.bit = [0]*self.N
        for i,l in enumerate(L):
            self.add(i,l)
        self.N0 = 1
        while self.N0*2 <= self.N:
            self.N0 *= 2

    def add(self, a, w):
        x = a + 1
        for i in range(1000):
            self.bit[x-1] += w
            x += x & -x
            if x > self.N:
                break

    def sum(self, a):
        x = a+1
        ret = 0
        for i in range(1000):
            ret += self.bit[x-1]
            x -= x & -x
            if x <= 0:
                break        
        return ret

    #you can use this function when the BIT has only non-negative values.
    def lower_bound(self, w):
        if w<=0:
            return 0
        x = 0
        k = self.N0
        while k>0:
            if x+k<=self.N:
                if self.bit[x+k-1]<w:
                    w-=self.bit[x+k-1]
                    x+=k
            k//=2
        return x


N,Q = list(map(int,input().split()))
A = list(map(int,input().split()))
bit = BIT(A)

for i in range(Q):
    f,a,b = list(map(int,input().split()))
    if f==0:
        bit.add(a, b)
    else:
        if a==0:
            print(bit.sum(b-1))
        else:
            print(bit.sum(b-1)-bit.sum(a-1))

Measured memory_bytes: 132696
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
using namespace std;
 
signed main(){
  int a,b;cin>>a>>b;
   set<int>c,d,e;
   int f[50][6];
   for(int g=0;g<a;g++){
       for(int h=0;h<6;h++)scanf("%lld",&f[g][h]);
       c.insert(f[g][0]);
       c.insert(f[g][3]);
       d.insert(f[g][1]);
       d.insert(f[g][4]);
       e.insert(f[g][2]);
       e.insert(f[g][5]);
       }
       int taiou[3][100];
       memset(taiou,-1,sizeof(taiou));
       auto r=c.begin();
       for(int l=0;l<c.size();l++,r++){taiou[0][l]=*r;}
       r=d.begin();
       for(int l=0;l<d.size();l++,r++){taiou[1][l]=*r;}
       r=e.begin();
       for(int l=0;l<e.size();l++,r++){taiou[2][l]=*r;}
       int S[99][99][99]{};
       for(int p=0;p<a;p++){
	   for(int x=0;x<99;x++){
	       if(taiou[0][x+1]!=-1&&taiou[0][x]>=f[p][0]&&taiou[0][x+1]<=f[p][3]){
		   for(int y=0;y<99;y++){
		       if(taiou[1][y+1]!=-1&&taiou[1][y]>=f[p][1]&&taiou[1][y+1]<=f[p][4]){
			   for(int z=0;z<99;z++){
			       if(taiou[2][z+1]!=-1&&taiou[2][z]>=f[p][2]&&taiou[2][z+1]<=f[p][5]){
				   S[x][y][z]++;
				   }
			       }
			   }
		       }
		   }
	       }
	   }
	   int ans=0;
	for(int x=0;x<99;x++){
	    for(int y=0;y<99;y++){
		for(int z=0;z<99;z++){
	       if(S[x][y][z]>=b){
		   ans+=(taiou[0][x+1]-taiou[0][x])*(taiou[1][y+1]-taiou[1][y])*(taiou[2][z+1]-taiou[2][z]);
		   }
	           }
		}
	    }
	    cout<<ans<<endl;
    }

Measured memory_bytes: 10740
import numpy as np
h,w,n=map(int, input().split())
c=np.ones(h*w).reshape(w,h)
for i in range(n):
    x,y,a=map(int, input().split())
    if a==1:c[:,:x]=0
    if a==2:c[:,x:]=0
    if a==3:c[:y,:]=0
    if a==4:c[y:,:]=0
print(int(c.sum()))

Measured memory_bytes: 21148
def main():
    N = int(input())
    a,b,c = [0]*N,[0]*N,[0]*N
    for i in range(N):
        a[i],b[i],c[i] = map(int, input().split())

    # dp[i][j] := i日目までの活動履歴のうち、最終日であるi日目には活動j(0:A,1:B,2:C)を選んだ場合の、得られる幸福度の最大値
    dp = [[0]*3 for _ in range(N)]
    dp[0] = (a[0],b[0],c[0])
    for i in range(1,N):
        dp[i][0] = max(dp[i-1][2]+a[i], dp[i-1][1]+a[i])
        dp[i][1] = max(dp[i-1][2]+b[i], dp[i-1][0]+b[i])
        dp[i][2] = max(dp[i-1][1]+c[i], dp[i-1][0]+c[i])
    print(max(dp[-1]))


main()


Measured memory_bytes: 61464
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = 1e9 + 7;

void add(int & a, int b) {
  if ((a += b) >= mod) {
    a -= mod;
  }
}

const int maxn = 1e5 + 100;

int fenw[2][maxn];

void fenwadd(int t, int i, int val) {
  for (; i < maxn; i |= (i + 1)) {
    add(fenw[t][i], val);
  }
}

int get(int t, int i) {
  int res = 0;
  for (; i >= 0; i = ((i & (i + 1)) - 1)) {
    add(res, fenw[t][i]);
  }
  return res;
}

int get(int t, int l, int r) {
  if (l >= r) {
    return 0;
  }
  int res = get(t, r - 1);
  if (l) {
    add(res, mod - get(t, l - 1));
  }
  return res;
}

int n;
ll a[2];
ll s[maxn];

bool read() {
  if (scanf("%d%lld%lld", &n, &a[0], &a[1]) < 3) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", s + i);
  }
  return true;
}

void solve() {
  memset(fenw, 0, sizeof(fenw));
  fenwadd(0, 0, 1);
  fenwadd(1, 0, 1);
  int l[2] = {0, 0};
  for (int i = 1; i < n; i++) {
    for (int it = 0; it < 2; it++) {
      int r = (int) (upper_bound(s, s + i - 1, s[i] - a[!it]) - s) + 1;
      fenwadd(!it, i, get(it, l[it], r));
      if (abs(s[i] - s[i - 1]) < a[it]) {
        l[it] = i;
      }
    }
  }
  int res = get(0, l[0], n);
  add(res, get(1, l[1], n));
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
int main(void)
{
	int a[4],i,b[4],s,k;
	for(i=0;i<4;i++)scanf("%d",&a[i]);
	s=a[2]-a[0];
	k=a[3]-a[1];
	b[0]=a[2]-k;
	b[1]=a[3]+s;
	b[2]=a[0]-k;
	b[3]=a[1]+s;
	printf("%d",b[0]);
	for(i=1;i<4;i++) printf(" %d",b[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u,int k){
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;
  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}


void preorder(Node u){
  if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20488
n = int(input())
a = list(map(int, input().split()))
sum = 1

for i in range(n):
    if a[i] == 0:
        print(0)
        exit(0)

for i in range(n):
    sum *= a[i]
    if(sum > 1000000000000000000):
        print(-1)
        exit(0)

print(sum)


Measured memory_bytes: 21680
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		// テキスト入力
		Scanner sc = new Scanner(System.in);
		StringBuilder all_out = new StringBuilder();
		StringBuilder out = new StringBuilder();
		;

		//
		while (true) {

			int height = sc.nextInt();
			int width = sc.nextInt();

			if (height == 0 && width == 0) {
				break;
			}
			// #を出す処理
			// 行の数
			for (int h = 0; h < height; h++) {

				// 列の数
				for (int w = 0; w < width; w++) {
					out = out.append("#");
				}
				out = out.append("\n");
			}
			all_out = all_out.append(out + "\n");
			out.delete(0, out.length());
		}
		System.out.print(all_out);
	}
}

Measured memory_bytes: 23612
package main

import (
	"fmt"
)

func main() {
	// Code for B - Substring
	var S, T string
	fmt.Scanf("%s", &S)
	fmt.Scanf("%s", &T)

	var count int
	var ans int = len(T)
	for i := 0; i < len(S)-len(T)+1; i++ {
		count = 0
		//fmt.Println(S, T)
		for j := 0; j < len(T); j++ {
			if S[i+j] != T[j] {
				count++
			}
		}
		//fmt.Println(string(S[i]), count)

		if ans > count {
			ans = count
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1848
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int N = int.Parse(input[0]);
		int M = int.Parse(input[1]);
        int X = int.Parse(input[2]);
		int Y = int.Parse(input[3]);

        string[] xs_arr = Console.ReadLine().Split(' ');
        foreach (string xs in xs_arr){
            int x = int.Parse(xs);
            X = Math.Max(X, x);
        }

		string[] ys_arr = Console.ReadLine().Split(' ');
        foreach (string ys in ys_arr){
            int y = int.Parse(ys);
            Y = Math.Min(Y, y);
        }

		//出力
        string res = "No War";
        if (X >= Y){
            res = "War";
        }
		Console.WriteLine(res);
	}
}

Measured memory_bytes: 11092
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
from collections import defaultdict, Counter

t = [ list(map(int, input().split())) for _ in range(N)]
diff = lambda a,b : abs(a[0] - b[0]) + abs(a[1] - b[1])

pos = (0,0)
tim = 0

for i in range(N):
    distance = diff(pos, t[i][1:])
    dis_time = t[i][0] - tim
    if not dis_time % 2 == distance %2 or not dis_time>=distance:
        print("No")
        exit(0)
print("Yes")
exit(0)

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

# print(d)

ans = 0
charlist = list("MARCH")
for i in range(1<<5):
    if not Counter( list ( "{0:05b}".format(i)) )["1"] == 3:
        continue
    
    s = 1
    for e,i in enumerate(list("{0:05b}".format(i))):
        if i == "1":
            s *= d[ charlist[e] ]

    ans += s
print(ans)
    


Measured memory_bytes: 62808
#include<iostream>
#include<cstring>
#include<cstdio>

#define M 1000003
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'B') return 2;
    else if(ch == 'C') return 3;
    else if(ch == 'D') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){
    return key % M;
}

int h2(int key){
    return 1 + (key % (M -1));
}

int find(char str[]){
    long long i, key, h;
    key = getKey(str);
    for(i = 0;;i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0){
            return 1; // found!
        }else if(strlen(H[h]) == 0){
            return 0; // reached empty cell
        }
    }
    return 0; // unreachable
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0;;i++){
        h = (h1(key) + i * h2(key) ) % M;
        if(strcmp(H[h],str) == 0){
            return 1; // already inserted
        }else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0; // insert
        }
    }
    return 0; // unreachable
}

int main(){
    int i,n,h;
    char str[L], com[9];
    for(i = 0; i < M; i++){
        H[i][0] = '\0';
    }

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s" , com, str);

        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 16800
#include<iostream>
#include<vector>
using namespace std;
int n;
int deg[100001];
int root;
vector<int>adj[100001];
bool vis[100001];
int p[200001],q[200001];
int ptr=1;
int dfsc=0;
void dfs(int id,int* a,bool r){
	for(int i=ptr+1; i<=ptr+adj[id].size()-r-1 ;i++) swap(a[i],a[i-1]);
	ptr+=adj[id].size()-r;
	vis[id]=true;
	for(int i=0; i<adj[id].size() ;i++){
		int cur=adj[id][i];
		if(deg[cur]!=1 && !vis[cur]) dfs(cur,a,1);
	}
}
void solve(int id){
	dfsc++;
	int* tmp;
	if(dfsc==1) tmp=p;
	else tmp=q;
	for(int i=1; i<=n ;i++) vis[i]=false,tmp[i]=i;
	ptr=1;
	for(int i=0; i<adj[id].size() ;i++){
		if(deg[adj[id][i]]==1){
			dfs(adj[id][i],tmp,0);
			return;
		}
	}
	dfs(id,tmp,0);
}
void out(int* a){
	for(int i=1; i<=n ;i++) cout << a[i] << ' ';
	cout << endl;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	if(n==2){
		cout << "1 2\n";
		return 0;
	}
	for(int i=2; i<=n ;i++){
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		deg[u]++;deg[v]++;
	}
	for(int i=1; i<=n ;i++){
		int cnt=0;
		if(deg[i]==1) continue;
		for(int j=0; j<adj[i].size() ;j++) cnt+=(deg[adj[i][j]]!=1);
		if(cnt==0){
			cout << 1 << ' ';
			for(int j=3; j<=n-1 ;j++) cout << j << ' ';
			cout << 2;
			if(n!=2) cout << ' ' << n << endl;
			return 0;
		}
		if(cnt==1){
			solve(i);
		}
		if(cnt>=3){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i=1; i<=n ;i++){
		if(p[i]<q[i]) out(p);
		else if(p[i]>q[i]) out(q);
		else continue;
		return 0;
	}
	out(p);
}

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

int main(){
    while(true){
        int x, y;
        cin >> x >> y;

        if(x == 0 && y == 0){
            break;
        }
        else{
            vector<string> v(x);
          for(int i = 0; i < x; i++){
            for(int j = 0; j < y; j++){
                v[i] += "#";
                if(i != 0 && i != x - 1 && j != 0 && j != y - 1){
                    v[i][j] = '.';
                }
            }
            cout << v[i] << endl;
            if(i == x - 1){
                cout << endl;
            }
          } 
        }     
    }
}


Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
using namespace std;
string henkan = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
map< string,char > sym;


void init() {
  sym["101"] = ' ';
  sym["000000"] = '\'';
  sym["000011"] = ',';
  sym["10010001"] = '-';
  sym["010001"] = '.';
  sym["000001"] = '?';
  sym["100101"] = 'A';
  sym["10011010"] = 'B';
  sym["0101"] = 'C';
  sym["0001"] = 'D';
  sym["110"] = 'E';
  sym["01001"] = 'F';
  sym["10011011"] = 'G';
  sym["010000"] = 'H';
  sym["0111"] = 'I';
  sym["10011000"] = 'J';
  sym["0110"] = 'K';
  sym["00100"] = 'L';
  sym["10011001"] = 'M';
  sym["10011110"] = 'N';
  sym["00101"] = 'O';
  sym["111"] = 'P';
  sym["10011111"] = 'Q';
  sym["1000"] = 'R';
  sym["00110"] = 'S';
  sym["00111"] = 'T';
  sym["10011100"] = 'U';
  sym["10011101"] = 'V';
  sym["000010"] = 'W';
  sym["10010010"] = 'X';
  sym["10010011"] = 'Y';
  sym["10010000"] = 'Z';
}
 
string _10to2(int a){
  string s2;
  for(int i = 0 ; i < 5 ; i++ ){
    s2 += (a%2 + '0');
    a /= 2; 
  }
  reverse(s2.begin(),s2.end());
  return s2;
}

int main(){
  init();
  string str;
  while(getline(cin,str)){
    string s = "";
    for(int i = 0 ; i < (int)str.size() ; i++ ){
      s += _10to2(henkan.find(str[i]));
    }
    string a = "";
    string tmp = "";
    for(int i = 0 ; i < (int)s.size() ; i++ ){
      tmp += s[i];
      if(sym.count(tmp)){
	a+=sym[tmp]; 
	tmp = "";
      }
    }
    cout << a << endl; 
  }
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void){
        char mark;
        char mk[4][2]={"S", "H", "C", "D"};
        int n, i, j, num;
        int trump[4][13]={0};
        do{
                scanf("%d", &n);
        }while(n>52);
        for(i=0;i<n*2;i++){
                scanf("%c %d", &mark, &num);
                if(mark=='S')
                        trump[0][num-1]=1;
                if(mark=='H')
                        trump[1][num-1]=1;
                if(mark=='C')
                        trump[2][num-1]=1;
                if(mark=='D')
                        trump[3][num-1]=1;
        }
        for(i=0;i<4;i++){
                for(j=0;j<13;j++){
                        if(trump[i][j]==0)
                                printf("%s %d\n", mk[i], j+1);
                }
        }
        return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll a, b;
    cin >> a >> b;
    if (a > b){
        cout << a - 1;
    } else {
        cout << a;
    }
    return 0;
}

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

int main(void){
  int N,L,i,min,sum;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  L=atoi(p);
  
  for(i=0,min=100000,sum=0;i<N;i++){
    if(abs(min)>abs(L+i)){
      min=L+i;
    }
    sum+=L+i;
  }
  
  printf("%d\n",sum-min);
  
  
  return 0;
}

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

#define mem(arr,x) memset(arr,x,sizeof(arr))
#define pb push_back
#define ll long long
#define mp make_pair
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define all(x)   (x.begin(),x.end())

int max(int a,int b)
{
	if(a>b)
	return a;
	return b;
}
 

int main()
{
	
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string n;
cin>>n;
ll s=0;
for(int i=0;i<(int)n.size();i++)
{
	s+=n[i]-'0';
}
if(s%9==0)
cout<<"Yes";
else
cout<<"No";
	
	
}

Measured memory_bytes: 3768
#include<cstdio>
#include<algorithm>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;i++)
typedef long long int ll;
typedef pair<ll,int> P;

ll a[110][110],r[30][100];
int n,m,c,s,g,x,y,d,id,wf[30][110][110],p[30],q[30][100];

int main(){
  while(scanf("%d%d%d%d%d",&n,&m,&c,&s,&g),n){
    REP(i,n)REP(j,n){
      a[i][j] = 1LL<<50;
      for(int k=0;k<c;k++)wf[k][i][j] = 1<<25;
    }
    
    REP(i,m){
      scanf("%d%d%d%d",&x,&y,&d,&id);
      x--; y--; id--;
      wf[id][x][y] = min(wf[id][x][y],d);
      wf[id][y][x] = min(wf[id][y][x],d);
    }
    
    REP(l,c){
      scanf("%d",&p[l]);
      REP(k,n)REP(i,n)REP(j,n)
	wf[l][i][j] = min(wf[l][i][j],wf[l][i][k] + wf[l][k][j]);
    }

    REP(k,c){
      q[k][0] = 0;
      REP(i,p[k]-1)scanf("%d",&q[k][i+1]);
      q[k][p[k]] = 1<<25;
      REP(i,p[k])scanf("%lld",&r[k][i]);

      REP(i,n)REP(j,n){
	if(wf[k][i][j] < (1<<25)){
	  ll tmp = 0;
	  for(int l=1;l<=p[k];l++){
	    if(wf[k][i][j] <= q[k][l]){
	      tmp += r[k][l-1]*(wf[k][i][j] - q[k][l-1]);
	    break;
	    }else tmp += r[k][l-1]*(q[k][l] - q[k][l-1]);
	  }
	  a[i][j] = min(a[i][j],tmp);
	}
      }
    }
      
    REP(k,n)REP(i,n)REP(j,n)a[i][j] = min(a[i][j],a[i][k] + a[k][j]);

    if(a[s-1][g-1]>=(1LL<<50))printf("-1\n");
    else printf("%lld\n",a[s-1][g-1]);
  }
}

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

struct node{
	int key;
	struct node *prev , *next;
};

typedef struct node * NodePointer;

NodePointer nil;

void init();
void insert( int x );
void deleteNode( NodePointer t );
void deleteFirst();
void deleteLast();
void deleteKey( int x );
void printList();


int main( void ){
	
	int i;
	int n;
	int key;
	int size = 0;
	int np = 0 , nd = 0;
	char com[20];
	
	scanf( "%d" , &n );
	
	init();
	
	for( i = 0; i < n; i++ ){
		
		scanf( "%s%d" , com , &key );
		
		if( com[0] == 'i' ){
			insert( key ); 
			np++; 
			size++;
		}else if( com[0] == 'd' ){
			if( strlen( com ) > 6 ){
				if( com[6] == 'F' ){
					deleteFirst();
				}else if( com[6] == 'L' ){
					deleteLast();
				}
			}else{
				deleteKey(key);
				nd++;
			}
			size--;
		}
	}
	
	printList();
	return 0;
}

NodePointer listSearch( int key ){
	
	NodePointer cur = nil->next;
	
	while( cur != nil && cur->key != key ){
		cur = cur->next;
	}
	
	return cur;
	
}

void init(){
	
	nil = malloc(sizeof(struct node));
	nil->next = nil;
	nil->prev = nil;
	
}

void printList(){
	
	NodePointer cur = nil->next;
	int isf = 1;
	
	while(1){
		
		if ( cur == nil ) {
			break;
		}
		
		if ( isf == 0) {
			printf(" ");
		}
		
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
	
	printf("\n");
}

void deleteNode( NodePointer t ){
	
	if( t == nil ) return;
	
	t->prev->next= t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	
	NodePointer t = nil->next;
	if ( t == nil ) return;
	deleteNode(t);
	
}

void deleteLast(){
	
	deleteNode( nil->prev );
	
}

void deleteKey( int key ){
	
	deleteNode(listSearch(key));
	
}

void insert( int key ){
	
	NodePointer t = malloc(sizeof(struct node));
	
	t->key = key;
	
	t->next = nil->next;
	nil->next->prev = t;
	nil->next = t;
	t->prev = nil;
	
}




Measured memory_bytes: 32928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   string s; 
   cin>>s;
   
   ll ans = 0;
   if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
        ans = 1;
   if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
        ans = 2;
   if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
        ans = 3;
   
   cout<<ans;        
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 3648
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
typedef long long ll;
ll n, m, k, y, x, d, w = -1, num, sum, ans = 0; string s;
vector<vector<pair<int,int>>> Gragh;
int main(void) {
	cin >> n;
	for(int i = 0;i*(i-1)/2 <= n;i++)  {
		if (i * (i - 1) / 2 == n) {
			w = i;
			break;
		}
	}if (w == -1) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		vector<vector<int>> S(w);
		num = 1;
		rep(i, w) {
			for (int j = i + 1; j < w; j++) {
				S[i].push_back(num);
				S[j].push_back(num);
				num++;
			}
		}
		cout << w << endl;
		rep(i, w) {
			cout << S[i].size();
			rep(j, S[i].size()) cout << ' ' << S[i][j];
			cout << endl;
		}
	}
}

Measured memory_bytes: 4308
#include<stdio.h>
#include<string.h>
int MAX(int a,int b){return a<b?b:a;}
//int P[1010],L[1010],R[1010],H[1010],C=1;
int P[3][1010],H[1010],C=1;
//int hyouka(int i,int x){return N[i]<=x?N[i]<x?-1:0:1;}
char N[1010][110];
int hyouka(int i,char *s){return strcmp(s,N[i]);}
int h(int a){return H[P[2][a]]-H[P[1][a]];}
void rot(int a,int t){//L==1,R==2
  int b=P[3-t][a],r=P[0][a];
  P[1][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[2][b])P[0][P[2][b]]=a;
  P[3-t][a]=P[t][b];
  P[t][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[1][b]])+1;
}
void make(int p,int t,char *s){
  P[t][p]=C;
  P[0][C]=p;
  strcpy(N[C],s);
  H[C]=1;
  if(p)H[p]=MAX(2,H[p]);
  C++;
}
int mfind(char *x){
  int i,j,r,n;
  if(C==1){
    make(0,1,x);
    return 1;
  }
  for(i=P[1][0];r=hyouka(i,x);i=n){//printf("%d %s\n",r,x);
    if(r<0){
      if(P[1][i]==0){
	make(i,1,x);
     }
      n=P[1][i];
    }
    else{
      if(P[2][i]==0){
	make(i,2,x);
      }
      n=P[2][i];
    }
  }//printf("%d\n",i);
  //for(j=0;j<C;j++){
  // printf(":%d %d %d %d %s\n",P[0][j],P[1][j],P[2][j],H[j],N[j]);
  //}
  j=P[0][i];
  while(j){
    H[j]=MAX(H[P[1][j]],H[P[2][j]])+1;
    if(h(j)<-1){
      if(h(P[1][j])>0)rot(P[1][j],1);
      rot(j,2);
      break;
    }
    if(h(j)>1){
      if(h(P[2][j])<0)rot(P[2][j],2);
      rot(j,1);
      break;
    }
    if(h(j)==0)break;
    j=P[0][j];
    //if(j==0)break;
  }//printf("%d\n",i);
  return i;
}      
void prim(int n){
  int i;
  if(P[1][n])prim(P[1][n]);
  for(i=0;i<H[n];i++)printf("  ");
  printf("%s\n",N[n]);
  if(P[2][n])prim(P[2][n]);
}
/*int main(){
  int n,i;
  //for(i=0;i<100;i++)H[i]=-1;
  char s[10];
  while(~scanf("%s",s)){
    printf("%d\n",mfind(s));
    for(i=0;i<C;i++){
      printf("%d %d %d %d %s\n",P[0][i],P[1][i],P[2][i],H[i],N[i]);
    }
    prim(P[1][0]);printf("end\n");
  }
  return 0;
}/*/
int main(){
  int i,l,max=0,mj=1,r,a[1010]={};
  char *c,*mi,s[1020];
  fgets(s,1010,stdin);
  mi=strtok(s," \n");
  a[mj=mfind(mi)]++;
  max=strlen(mi);
  // printf("%s\n",mi);
  while(c=strtok(NULL," \n")){
    //printf("%s\n",c);
    a[r=mfind(c)]++;
    //printf("%d\n",r);
    l=strlen(c);//printf("%s %d\n",mi,l);
    if(max<l){
      max=l;
      strcpy(mi,c);
    }//printf("a\n");
    if(a[r]>a[mj])mj=r;//printf("a\n");
  }
  //printf("%s %d\n",mi,mj);
  printf("%s %s\n",N[mj],mi);
  return 0;
  }//*/

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

/* Typedefs */

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

/* Consts */

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

void solve() {
    
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    // ll T; cin >> T;
    // while (T--) solve();
    int R; cin >> R;
    cout << 2 * M_PI * R;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3764
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b,c=mp()
k=int(input())
i=0
while b<=a:
    b*=2
    i+=1
while c<=b:
    c*=2
    i+=1
if i<=k:
    print("Yes")
else:
    print("No")

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

int main(){
    int N;
    cin >> N;
    int a[100000];
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    int maxA = 0;
    for (int i = 0; i < N; i++){
        if(maxA < a[i]) maxA = a[i];
    }
    int list[200000];

    for (int i = 0; i <= maxA + 1; i++){
        list[i] = 0;
    }
    for (int i = 0; i < N; i++){
        if (a[i] != 0){
            list[a[i]]++;
            list[a[i] - 1]++;
            list[a[i] + 1]++;
        }
        else{
            list[a[i]]++;
            list[a[i] + 1]++;
        }
    }
    sort(list, list + maxA + 1, greater<int>());
    cout << list[0] << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{
int n,f=1;
cin>>n;
if(n%4==0||n%7==0)
{
cout<<"Yes";
return 0;	
}

while(n>=0)
{
	n=n-7;
	if(n<0)
	n=n+4;
	if(n>=4&&n%4==0)
	{
		cout<<"Yes";
		return 0;
	}
}
if(f) cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int k;
	cin>>k;
	int ar[n];
	for(int i=0;i<n;i++) {
		cin>>ar[i];
	}
	int dp[n];
	for(int i=0;i<n;i++) {
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for(int i=1;i<n;i++) {
		for(int j=(i-k>=0?i-k:0);j<i;j++) {
			dp[i] = min(dp[i],dp[j] + abs(ar[i]-ar[j]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4320
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

void bfs(Vvec<int>& graph, vector<int>& par, vector<int>& dist, int root)
{
    for(int i=0; i<dist.size(); i++){
        dist[i] = -1;
        par[i] = -1;
    }

    queue<Pii> q;
    q.emplace(root, -1);

    while(!q.empty()){
        int tmp = q.front().first;
        int from = q.front().second;
        q.pop();
        if(dist[tmp] > -1) continue;

        dist[tmp] = (tmp == root) ? 0 : dist[from] + 1;
        par[tmp] = from;
        for(auto& to: graph[tmp]){
            if(to != from) q.emplace(to, tmp);
        }
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    Vvec<int> graph(N), rev(N);
    for(int i=0; i<M; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        rev[v].push_back(u);
    }

    vector<int> par(N), dist(N);
    bool ok = false;
    int mindst = 1e9;
    vector<ll> ans;

    for(int i=0; i<N; i++){
        if(rev[i].empty()) continue;

        bfs(graph, par, dist, i);
        // debug(dist);
        // debug(par);
        for(auto& u: rev[i]){
            if(dist[u] > -1 && dist[u] < mindst){
                ok = true;
                mindst = dist[u];
                ans.clear();
                ans.resize(dist[u]+1);
                // cout << dist[u] + 1 << endl;
                int tmp = u;
                for(int i=0; i<=dist[u]; i++){
                    // cout << tmp + 1 << endl;
                    ans[i] = tmp;
                    tmp = par[tmp];
                }
                break;
            }
        }
    }

    if(!ok) cout << -1 << endl;
    else{
        cout << ans.size() << endl;
        for(auto& x: ans) cout << x+1 << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    int n;
    cin>>n;
    map<int,int> mp;
    for ( int i = 0 ; i < n ; i++ )
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    int found = 0;
    for ( auto it = mp.begin() ; it != mp.end() ; it++ )
    {
        if ( it->second > 1 )
        {
            found = 1;
            break;
        }
    }

    if ( found == 1 )
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
    return 0;
}

Measured memory_bytes: 12800