akhauriyash/Code-Regression huggingface dataset:
A, B = map(int, input().split())

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
      while n % i == 0:   #iで割り切れれば、iはnの素因数
          n /= i
          table.append(i)
      i += 1
  if n > 1:
      table.append(n)
  return table

x = set(prime_decomposition(A))
y = set(prime_decomposition(B))
print(len(x & y) + 1)

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

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, l, r;
	int sum = 0;
	cin >> N;
	rep(i, N) {
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << "\n";
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	var N, W int
	fmt.Scan(&N, &W)
	w := make([]int, N)
	v := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		sc.Scan()
		w[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		v[i], _ = strconv.Atoi(sc.Text())
	}
	col := W + 1
	dp := make([]int64, (N+1)*col)
	for i := 0; i < N; i++ {
		for j := 0; j <= W; j++ {
			if j+w[i] <= W {
				dp[col*(i+1)+j+w[i]] = max(dp[col*(i+1)+j+w[i]], dp[col*i+j]+int64(v[i]))
			}
			dp[col*(i+1)+j] = max(dp[col*(i+1)+j], dp[col*i+j])
		}
	}
	fmt.Println(dp[col*N+W])
}


Measured memory_bytes: 81792
s = int(input())
A = input().split()
for i in range(s):
    v = A[i]
    j = i - 1
    while j >=0 and int(A[j]) > int(v):
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(" ".join(A))

Measured memory_bytes: 7604
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n;
    vector<vector<int>> a(3, vector<int>(3));
    vector<vector<bool>> c(3, vector<bool>(3, false));
    rep(i,3) rep(j,3) cin>>a[i][j];
    cin>>n;
    rep(i,n) {
        int b; cin>>b;
        rep(j,3) rep(k,3) if (a[j][k] == b) c[j][k] = true;
    }

    bool ok = false;
    rep(i,3) {
        bool t = true;
        rep(j,3) {
            if (!c[i][j]) t = false;
        }
        if (t) ok = true;
    }

    rep(j,3) {
        bool t = true;
        rep(i,3) if (!c[i][j]) t = false;
        if (t) ok = true;
    }

    if (c[0][0] && c[1][1] && c[2][2]) ok = true;
    if (c[0][2] && c[1][1] && c[2][0]) ok = true;

    if (ok) cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
    int k;
    cin >> k;
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    s_list = list(map(int, list(S)))[::-1]
    MOD = 2019

    sum_v = 0
    cnt = [0] * MOD
    cnt[0] = 1
    for i, s in enumerate(s_list):
        sum_v += s * pow(10, i, MOD)
        sum_v %= MOD
        cnt[sum_v] += 1
    print(sum([c * (c - 1) // 2 for c in cnt if c > 1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 12240
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-8;
inline void read(ll &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
#define int long long
//==========================head template==========================
const int N=500010;
//int a[N],b[N];
int n;
inline int sgn(ll x) {
	return x<0 ? -1 : x>0;
}
struct P {
	ll a,b;
	inline void in() {
		read(a); read(b);
	}
	inline void print() {
		printf("%lld %lld\n",a,b);
	}
}p[N];
ll ans;
bool cmp(P x,P y) {
	if(sgn(x.a-x.b)!=sgn(y.a-y.b))
		return sgn(x.a-x.b)<sgn(y.a-y.b);
	return x.b>y.b;
}
signed main()
{
	read(n);
	for(int i=1;i<=n;i++) p[i].in();
	sort(p+1,p+n+1,cmp);
	ll sum=0; int pos;
	if(p[1].a==p[1].b) {
		puts("0"); return 0;
	}
	for(int i=1;i<n;i++) ans+=p[i].a;
	printf("%lld\n",ans+p[n].a-p[n].b);
	return 0;
}
/*
5
2 1
1 2
1 2
3 1
1 2

6
1 2
1 2
1 2
2 1
2 1
2 1
*/

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ft first
#define sd second
#define maxn 1000005
#define mod 998244353
#define PI 3.14159265
#define MP make_pair
#define PB push_back
#define heap priority_queue
#define Bjerg ""
using namespace std;
int n ,dem[maxn], m ;
pair < int , int > q[maxn];
int d[maxn];
void update(int x , int val)
{
    for(;x<maxn;x+=(x&-x))
    {
        d[x]=(d[x]+val)%mod;
        if(d[x]<0) d[x]+=mod;
    }
}
void read()
{
    cin >> n >> m ;
    for(int i=1;i<=m;++i) cin >> q[i].ft >> q[i].sd;
    sort(q+1,q+1+m);
    int last = 0 ;
    for(int i=1;i<=m;++i)
    {
        q[i].ft=  max(last+1,q[i].ft);
        if(q[i].ft>q[i].sd) q[i]={0,0};
        last = max(last, q[i].sd);
    }
}
int get(int x)
{
    int res=0;
    for(;x>0;x-=(x&-x)) res=(res+d[x])%mod;
    return res;
}
void solve()
{
    update(1,1);
    update(2,-1);
    for(int i=1;i<n;++i)
    {
        int x = get(i);
        for(int j=1;j<=m;++j)
        {
            if(q[j].ft==0) continue;
            if(i+q[j].ft<=n) update(q[j].ft+i,x);
            if(i+q[j].sd+1<=n) update(q[j].sd+1+i,-x);
        }
    }
    cout << get(n);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Bjerg".inp","r",stdin);
    read();
    solve();
    return 0;
}


Measured memory_bytes: 4440
k, x = map(int, input().split())
rad = k - 1
left = max(-1000000, x - rad)
right = min(1000000, x + rad)
for i in range(left, right+1):
    if i < right:
        print(i, end="")
        print(" ", end = "")
    if i == right:
        print(i)

Measured memory_bytes: 38256
#include <set>
#include <cstdio>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int dp[11][2000];

int main(){
  const int n = getInt();
  const int k = getInt();
  vector<int> t[10];

  REP(i,n){
    const int c = getInt();
    const int g = getInt() - 1;
    t[g].push_back(c);
  }

  REP(i,10){
    sort(t[i].rbegin(), t[i].rend());
    REP(j,t[i].size() - 1)
      t[i][j + 1] = t[i][j + 1] + t[i][j] + 2 * (j + 1);
  }

  REP(i,10) REP(j,k + 1){
    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    for(int s = j + 1; s <= k && s - j - 1 < t[i].size(); s++)
      dp[i + 1][s] = max(dp[i + 1][s], dp[i][j] + t[i][s - j - 1]);
  }

  printf("%d\n", dp[10][k]);

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;


class Task
{
public:
	int A, B;
	Task()
	{
		cin >> A >> B;
	}

	bool operator<(const Task & task)const
	{
		return B < task.B;
	}
};


int main()
{
	int N;
	cin >> N;
	
	vector<Task> task(N);

	sort(task.begin(), task.end());

	int time = 0;
	for (auto t : task)
	{
		time += t.A;
		if (time > t.B)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;

int main(int argc, char const *argv[]) {
  pq_dsc<ll> q;
  int n, m, a;
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    cin >> a;
    q.push(a);
  }

  for (int i = 0; i < m; i++) {
    if (q.top() ==0 ) break;
    a = q.top();
    q.pop();
    q.push(a / 2);
  }

  ll sum = 0;

  while (!q.empty()) {
    if (q.top() ==0 ) break;
    sum += q.top();
    q.pop();
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<int> xs,ys,sums;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		xs.push_back(a); 
	}
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		ys.push_back(a);
	}
	int sum = 0;
	for(int i=0;i<n;i++)
	{
		if(xs[i]-ys[i]>=0)
			sum+=xs[i]-ys[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
n=int(input())
m = int(n ** (0.5)) + 1
ans=[0]*(n+1)
for i in range(1,m):
    a=i**2
    for j in range(1,m):
        b=a
        b+=j**2+i*j
        for k in range(1,m):
            c=b
            c+=k**2+j*k+k*i
            if c<n+1:
                ans[c]+=1
for i in range(1,n+1):
    print(ans[i])

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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 501

using namespace std;

void quick () {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

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



void readFromText(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif // ONLINE_JUDGE
}

int main()
{
    quick();
//    readFromText();
    int a , b ; cin >> a >> b ;
    cout << (a-1)*(b-1);
    return 0;
}


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

int main (int argc, char **argv)
{
  int n = 0;
  int d = 0;
  int ans = 0;

  scanf("%d %d", &n, &d);

  ans = (int)ceil((double)n / (double)((2 * d) + 1));

  printf("%d\n", ans);

  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main(){
  int K, S, i, j, k, cnt=0;
  cin >> K >> S;
  for (i = 0; i <= K; i++){
    for (j = 0; j <= K; j++){
      k = S - i - j;
      if (0 <= k && k <= K){
        cnt ++;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		String s=" "+nextLine();
		int n=s.length()-1;
		for(int i=1;i<=n;i++)
		{
			if(i+1<=n && s.charAt(i)==s.charAt(i+1))
			{
				out.println(i+" "+(i+1));
				return;
			}
			if(i+2<=n && s.charAt(i)==s.charAt(i+2))
			{
				out.println(i+" "+(i+2));
				return;
			}
		}
		out.println(-1+" "+(-1));
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

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

int main(){
  long long n , a = 1;
  cin >> n;
  for (long i = 2 ; i < sqrt(n) + 1 ; i ++) {
    if (n % i == 0) {
      a = i;
    }
  }
  cout  << n / a + a - 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

int h, w;
VI px = {0, 0, 1, -1}, py = {1, -1, 0, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  vector<VB> painted(h, VB(w, false));
  queue<PII> black;
  REP(y, h) REP(x, w)
  {
    char c;
    cin >> c;
    if (c == '#')
    {
      black.push({x, y});
      painted[y][x] = true;
    }
  }
  int ans = 0;
  bool flg = false;
  while(black.size())
  {
    queue<PII> black2;
    while(black.size())
    {
      int by = black.front().second, bx = black.front().first;
      black.pop();
      REP(i, 4)
      {
        int yy = by + py[i], xx = bx + px[i];
        if (0 <= xx && xx < w && 0 <= yy && yy < h && !painted[yy][xx])
        {
          painted[yy][xx] = true;
          flg = true;
          black2.push({xx, yy});
        }
      }
    }
    if (flg) ans++;
    flg = false;
    black = black2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
set<int> si;
int n,k;
int fin = -1;
int s_int(string s){
    return atoi(s.c_str());
}
int check(int n){
    bool ok = 1;
    while(n >= 0){
        if(si.find(n%10) != si.end()){
            return 0;
        }
        n /= 10;
        if(n == 0) break;
    }
    return 1;
}
vector<int> solve(){
    vector<int> ans;
    queue<string> que;
    rep(i,10){
        string s = "";
        s += char('0' + i);
        que.push(s);
    }
    while(1){
        string fa = que.front(); que.pop();
        // cout << fa << endl;
        if(fa.size() > fin) return ans;
        if(!check(s_int(fa))){
            //cout << "out" << endl;
            continue;
        }
        // cout << "push" << endl;
        if(s_int(fa) >=n){
            if(fin == -1) fin = fa.size(); 
            ans.push_back(s_int(fa));
        }
        rep(i,10){
            que.push(string(fa + char('0' + i)));
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    cin >> n >> k;
    rep(i,k){
        int x;
        cin >> x;
        si.insert(x);
    }
    vector<int> ans = solve();
    sort(ans.begin(),ans.end());
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 5184
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    vector<int> a(26,0);
    int i;
    for(i=0;i<s.size();i++) a.at(s.at(i)-'a')++;
    for(i=0;i<26;i++){
        if(a.at(i)==0) break;
    }
    char c = 'a' + i;
    if(i<26) cout << c << endl;
    else cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};


int main(){
    LL n,k;cin >> n >> k;
    vector<LL> v;
    LL now=1;
    while(now<=n){
        LL l=now,r=n+1,t=n/l;
        while(r-l>1){
            LL m=(r+l)/2;
            if(n/m==t){
                l=m;
            }
            else{
                r=m;
            }
        }
        v.pb(r-now);
        now=r;
    }

    vector<vector<LL>> dp(k+1,vector<LL> (v.size()+1,0));
    for (int i = 0; i < v.size(); i++) {
        dp[0][i] = v[i];
    }

    for (int i = 0; i < k-1; i++) {
        vector<LL> S(v.size()+1,0);
        for (int j = 0; j < v.size(); j++) {
            S[j+1] = (dp[i][j] + S[j])%mod;
        }
        for (int j = 0; j < v.size(); j++) {
            dp[i+1][j] = (S[v.size()-j] * v[j])%mod;
        }
    }
    LL ans = 0;
    for (int i = 0; i < v.size(); i++) {
        ans = (ans + dp[k-1][i])%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 51448
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n,k;
  cin>>n>>k;
  int tot = 0;
  for(int i=0;i<n;i++){
  	int w;
  	cin>>w;
  	if(w>=k){
  		tot++;
  	}
  }
  cout<<tot<<endl;
}



Measured memory_bytes: 256
n = int(input())
p = [int(e) for e in input().split()]
result = 0
for i in range(1, n - 1):
  if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
    result += 1
print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    impl(std::forward<Args>(args)...);
}
template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    auto s = read<std::string>();
    int res = 0, ren = 0;
    for (auto c : s) {
        if (c == 'A' || c == 'T' || c == 'G' || c == 'C')
            ++ren;
        else
            ren = 0;
        res = std::max(res, ren);
    }
    out(res);
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


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

using namespace std;

int main(){
   int n;
   cin >> n;
   for (int i = 0; i <= 100; i++){
    for (int j = 0;j <= 100; j++){
        int cur = 4 * i + 7 * j;
        if (cur == n){
            puts("Yes");
            return 0;
        }
    }
   }
   puts("No");
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define p 1000000007

int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll ans[n][k+1];
    for(ll i=0;i<n;i++) ans[i][0]=1;
    for(ll i=0;i<=k;i++)
    {
        if(a[0]>=i) ans[0][i]=1; else ans[0][i]=0;
    }
    ll ps[k+1];
    ps[0]=ans[0][0];
    if(k>0)
    {for(ll i=1;i<=k;i++) ps[i]=ps[i-1]+ans[0][i];}
    if(n>1&&k>0)
    {for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            ans[i][j]=ps[j];
            if(min(a[i],j)!=j) ans[i][j]=ans[i][j]-ps[j-min(a[i],j)-1];
            ans[i][j]=ans[i][j]+p;
            ans[i][j]=ans[i][j]%p;
        }
        ps[0]=ans[i][0];
        for(ll j=1;j<=k;j++)
        {
            ps[j]=ps[j-1]+ans[i][j];
            ps[j]=ps[j]%p;
        }
    }}
    ans[n-1][k]=ans[n-1][k]+p;
    ans[n-1][k]=ans[n-1][k]%p;
    cout<<ans[n-1][k]<<endl;
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int n,W;
   cin >> n >> W;
   int weight[110];
   long long value[110];
   long long dp[110][100010];
   for(int i=0;i<n;i++){
     cin >> weight[i] >> value[i];
   }
   for(int w=0;w<=W;w++){
     dp[0][w];
   }
   for(int i=0;i<n;i++){
     for(int w=0;w<=W;w++){
       if(w>=weight[i]){
         dp[i+1][w] = max(dp[i][w-weight[i]]+value[i],dp[i][w]);
       }
       else{
         dp[i+1][w] = dp[i][w];
       }
     }
   }
   cout << dp[n][W] << endl;
}
  

Measured memory_bytes: 80384
n = gets.chop.to_i
s = gets.chop.split('')

now = s[1..n-1].count("E")
min = s[1..n-1].count("E")

(1..n-1).each do |i|
  now += 1 if s[i-1] == "W"
  now -= 1 if s[i] == "E"
  min = [min, now].min
end

p min


Measured memory_bytes: 30468
#include<stdio.h>
#include<math.h>
int prime(int n)
{
    if (n < 2)
        return 0;
    if (n == 2)
        return 1;
    if (n % 2 == 0)
        return 0;
    int i;
    for (i = 3; i <= (int)sqrt(n); i++)
        if (n%i == 0)
            return 0;
    return 1;
}
int main()
{
    int n;
    scanf("%d", &n);
    unsigned long long int ans = 1;
    int i, k;
    int x;
    for (i = 0; i <= n; i++)
    {
        if (prime(i) == 1)
        {
            k = i;
            x = 0;
            while (n >= k)
            {
                x += n / k;
                k *= i;
            }
            ans *= x + 1;
            ans %= 1000000007;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
n=int(input())
lista=list(map(int,input().split()))
lista.sort(reverse=True)
alice=list()
bob=list()
for i in range(n):
    if i%2==0:
        alice.append(lista[i])
        
    else: 
        bob.append(lista[i])

print(sum(alice)-sum(bob))

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

int main(){
    int N;
    cin >> N;
    int t[110000],x[110000],y[110000];
    t[0] = x[0] = y[0] = 0;
    for(int i =0;i<N;i++){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    bool can = true;
    for(int i=0;i<N;i++){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(dist > dt){
            can = false;
            break;
        }
        if(dist % 2 != dt % 2){
            can = false;
            break;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		while(true){
			int a		= sc.nextInt();
			String op	= sc.next();
			int b		= sc.nextInt();
			
			if ( "?".equals(op) ) {
				break;
			}

			int calcRes = 0;
			if ( "+".equals(op) ) {
				calcRes = a+b;

			} else if ( "-".equals(op) ) {
				calcRes = a-b;

			} else if ( "*".equals(op) ) {
				calcRes = a*b;

			} else if ( "/".equals(op) ) {
				calcRes = a/b;

			}

			System.out.println( calcRes );
		}
		
	}
}

Measured memory_bytes: 18056
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;


inline bool eq(double a, double b) { return fabs(b - a) < EPS;}

struct p_t{
  double x;
  double y;
  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }
};
struct l_t{
	p_t a, b;
};

double cross(p_t p,p_t q);
p_t line(p_t p,p_t q);

bool asc(p_t left,p_t right) {
    return left.x == right.x ? left.y < right.y : left.x < right.x;
}
int Crosspoint(l_t l,l_t m);

int main(){
  int n;
  cin>>n;
  for(int t=0;t<n;t++){
    p_t p,q,r,k,s;
    cin>>p.x>>p.y>>q.x>>q.y>>r.x>>r.y>>k.x>>k.y>>s.x>>s.y;
    l_t pq,qr,rp,ks;
    pq.a=p;
    pq.b=q;
    qr.a=q;
    qr.b=r;
    rp.a=r;
    rp.b=p;
    ks.a=k;
    ks.b=s;
    int ans=0;
    ans+=(Crosspoint(pq,ks)&&Crosspoint(ks,pq));
    ans+=(Crosspoint(qr,ks)&&Crosspoint(ks,qr));
    ans+=(Crosspoint(rp,ks)&&Crosspoint(ks,rp));
    if(ans==1){
      cout<<"OK"<<endl;
    }
    else{
      cout<<"NG"<<endl;
    }
  }
}


p_t line(p_t p,p_t q){
  p_t z;
  z.x=q.x-p.x;
  z.y=q.y-p.y;
  return z;
}


double cross(p_t p,p_t q){
  return p.x*q.y-p.y*q.x;
}

int Crosspoint(l_t l,l_t m){
  p_t aa,bb,cc,dd;
  aa.x=l.b.x-l.a.x;
  aa.y=l.b.y-l.a.y;
  bb.x=m.b.x-m.a.x;
  bb.y=m.b.y-m.a.y;
  cc=aa;
  dd.x=l.b.x-m.a.x;
  dd.y=l.b.y-m.a.y;
	double A = cross(aa,bb);
	double B = cross(cc,dd);
	if (abs(A) < EPS && abs(B) < EPS) return 0;
  if(B/A>0&&B/A<1) return 1;
  return 0;
}



Measured memory_bytes: 3224
N = input()

if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1]  == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9056
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    X, Y = map(int, input().split())

    S = list(map(len, S.split("T")))
    init_x = S[0]
    is_x = 0
    to_x, to_y = [], []
    for i in range(1, len(S)):
        if S[i]:
            to_x.append(S[i]) if is_x else to_y.append(S[i])
        is_x ^= 1

    now_x = {init_x}
    for x in to_x:
        tmp = set()
        for now in now_x:
            tmp.add(now - x)
            tmp.add(now + x)
        now_x = tmp

    now_y = {0}
    for y in to_y:
        tmp = set()
        for now in now_y:
            tmp.add(now - y)
            tmp.add(now + y)
        now_y = tmp

    print("Yes" if X in now_x and Y in now_y else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9720
s = input()
n = len(s)

li = [0] * n
li[0] = int(s[-1])

for i in range(n-1):
    t = int(s[-i-2])
    li[i+1] = (li[i] + t * pow(10, i+1, 2019)) % 2019

dict1 = {}
for i in li:
    if i in dict1:
        dict1[i] += 1
    else:
        dict1[i] = 1

ans = 0

for v in dict1.values():
    ans += v * (v-1) // 2

if 0 in dict1:
    ans += dict1[0]

print(ans)


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		for(int i = 0; i < n; i++) {
			list.add(scan.nextInt());
		}
		
		int min = 0, max = 0;
		long sum = 0;
		for(int i = 0; i < n; i++) {
			if(i == 0) {
				min = list.get(i);
				max = list.get(i);
			}
			
			if(min > list.get(i)) {
				min = list.get(i);
			}
			
			if(max < list.get(i)) {
				max = list.get(i);
			}
			
			sum += list.get(i);
		}
		
		System.out.println(min + " " + max + " " + sum);
		
	}

}



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

int main(){
  int D;
  cin>>D;
  int C[26];
  map<int,int>mp;
  for(int i=0;i<26;i++){
    cin>>C[i];
    if(C[i]>10){
      mp[i]++;
    }   
  }
  int S[365][26];
  for(int i=0;i<365;i++){
    for(int j=0;j<26;j++){
      cin>>S[i][j];
    }
  }
  
  int flag=1;
  int temp=0;
  int now=0;
  int maxans=0;
  while(temp<365){
    maxans=0;
    now=0;
    for(int i=0;i<26;i++){
      if(S[temp][i]>maxans){
        now=i;
        maxans=S[temp][i];
      }
    }
    cout<<now+1<<endl;
    temp++;
  }
  return 0;
}



Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define db double
#define zero(x) (fabs(x)<eps)
const db eps=1e-10;
struct point{
    db x,y;
    point(){}
    point(db x,db y):x(x),y(y){}
    point operator + (point B){ return point(x+B.x,y+B.y); }
    point operator - (point B){ return point(x-B.x,y-B.y); }
    point operator * (db k){ return point(k*x,k*y); }
    db operator * (point B){ return x*B.y-y*B.x; }
    db operator ^ (point B){ return x*B.x+y*B.y; }
    bool operator < (point B){ return (y>0)!=(B.y>0)?y>0:((*this)*B)>0; }
};
db dis2(point A,point B){ return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y); }
struct line{
    point A,B;
    line(){}
    line(point A,point B):A(A),B(B){}
};
point projection(line l,point P){
    point dir=l.B-l.A; P=P-l.A;
    return dir*((P^dir)/dis2(l.A,l.B))+l.A;
}
point reflection(line l,point P){
    return projection(l,P)*2-P;
}
int direction(point P0,point P1,point P2){
    db det=(P2-P0)*(P1-P0); if (!zero(det)) return det<0?1:2;
    db dot=(P2-P0)^(P1-P0); if (dot<0) return 3;
    return dis2(P2,P0)>dis2(P1,P0)?4:5;
}
string s[6]={"666","COUNTER_CLOCKWISE","CLOCKWISE","ONLINE_BACK","ONLINE_FRONT","ON_SEGMENT"};
int main(){
    db x1,y1,x2,y2; scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    point P0(x1,y1),P1(x2,y2);
    int q; scanf("%d",&q);
    while (q--){
        db x,y; scanf("%lf%lf",&x,&y);
        printf("%s\n",s[direction(P0,P1,point(x,y))].c_str());
    }
}



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

namespace ITP1
{
    class ITP1_8_B
    {
        static void Main(string[] args)
        {
            string inputLine;
            int outputLine = 0;

            while (true)
            {
                inputLine = Console.ReadLine();
                if (inputLine == "0")
                {
                    break;
                }

                outputLine = 0;

                foreach (var item in inputLine)
                {
                    outputLine += int.Parse(item.ToString());
                }
                Console.WriteLine(outputLine);
            }
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 17952
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll n;
	instr s;

	ll m = 0;

	REP(i, n)
	{
		set<char> v1, v2, v3;
		REP(j, n)
		{
			v3.insert(s[j]);
			if (j < i)
				v1.insert(s[j]);
			else
				v2.insert(s[j]);
		}
		m = max(m, ll(v1.size() + v2.size() - v3.size()));
	}

	return OUT(m);
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


n = int(input())
f = factorization(n)
#print(f)
ans = 0
for a,b in f:
    if a > 1:
        i = 1
        t = 0
        while True:
            if b - i >= 0:
                t += 1
                b -= i
                i += 1
            else:
                break

        #print(a,t)
        ans += t

print(ans)

Measured memory_bytes: 9492
#include<iostream>
using namespace std;
int main(){
int t1,t2,t3,t4,n1,n2,n3,n4;
cin>>t1>>n1>>t2>>n2>>t3>>n3>>t4>>n4;
if(t1==1){cout<<n1*6000<<endl;}
else if(t1==2){cout<<n1*4000<<endl;}
else if(t1==3){cout<<n1*3000<<endl;}
else if(t1==4){cout<<n1*2000<<endl;}

if(t2==1){cout<<n2*6000<<endl;}
else if(t2==2){cout<<n2*4000<<endl;}
else if(t2==3){cout<<n2*3000<<endl;}
else if(t2==4){cout<<n2*2000<<endl;}

if(t3==1){cout<<n3*6000<<endl;}
else if(t3==2){cout<<n3*4000<<endl;}
else if(t3==3){cout<<n3*3000<<endl;}
else if(t3==4){cout<<n3*2000<<endl;}

if(t4==1){cout<<n4*6000<<endl;}
else if(t4==2){cout<<n4*4000<<endl;}
else if(t4==3){cout<<n4*3000<<endl;}
else if(t4==4){cout<<n4*2000<<endl;}

return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i = 0;i<n;i++){cin >> d[i];}
	
	long long ans;
	
	for(int i=0;i<n-1;i++){
		for(int j = i+1;j<n;j++){
			ans += d[i]*d[j];
		}
	}
	
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a;
    int b;
    int area;
    int length;
    
    cin >> a >> b;
    
    area = a*b;
    length = 2*(a+b);
    
    cout << area << " " << length << endl;
    
    return 0;
}


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

int main() {
	string S;
	int COUNT = 0, ANS[100000] = {};
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'R') {
			COUNT++;
		}
		else {
			ANS[i - 1] += (COUNT + 1) / 2;
			ANS[i] += COUNT / 2;
			COUNT = 0;
		}
	}
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'L') {
			COUNT++;
		}
		else {
			ANS[i + 1] += (COUNT + 1) / 2;
			ANS[i] += COUNT / 2;
			COUNT = 0;
		}
	}
	for (int i = 0; i < S.size(); i++) {
		if (i != 0) cout << " ";
		cout << ANS[i];
	}
	cout << endl;
}

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

int n;
char dire[6];

int main(void)
{
	
	int top, bottom, left, right, front, back;
	int sum, tmp;
	
	while ( 1 ) {
	
		scanf( "%d", &n );
		if ( n == 0 ) break;
		
		top = 1;
		bottom = 6;
		left = 4;
		right = 3;
		front = 2;
		back = 5;
		
		sum = 1;
		
		while ( n-- ) {
			
			scanf( "%s", dire );
			
			if ( strcmp( dire, "North" ) == 0 ) {
				tmp = top;
				top = front;
				front = bottom;
				bottom = back;
				back = tmp;
			}
			else if ( strcmp( dire, "East" ) == 0 ) {
				tmp = top;
				top = left;
				left = bottom;
				bottom = right;
				right = tmp;
			}
			else if ( strcmp( dire, "South" ) == 0 ) {
				tmp = top;
				top = back;
				back = bottom;
				bottom = front;
				front = tmp;
			}
			else if ( strcmp( dire, "West" ) == 0 ) {
				tmp = top;
				top = right;
				right = bottom;
				bottom = left;
				left = tmp;
			}
			else if ( strcmp( dire, "Right" ) == 0 ) {
				tmp = front;
				front = right;
				right = back;
				back = left;
				left = tmp;
			}
			else if ( strcmp( dire, "Left" ) == 0 ) {
				tmp = front;
				front = left;
				left = back;
				back = right;
				right = tmp;
			}
			
			sum += top;
		}
		
		printf( "%d\n", sum );
		
	}
	
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  string S,T;
  int ans=0;
  cin >> S >> T;
  rep(i,3) if(S[i]==T[i]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	string a, b; cin >> a >> b;
	int aa, bb; cin >> aa >> bb;
	string s; cin >> s;
	if (s == a) { cout << aa - 1 << " " << bb << endl; }
	else { cout << aa << " " << bb - 1 << endl; }

	return 0;
}

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

int N, M, Q;
vector<int> a(50), b(50), c(50), d(50);
vector<int> A(10);
int max_score = 0;

int calc_score(vector<int> &A) {
  int score = 0;
  rep(i, Q) {
    if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
      score += d[i];
    }
  }
  return score;
}

void dfs(int i, int N, int M) {
  if (i == N) {
    // rep(l, N) { cout << A[l] << ' '; }
    // cout << calc_score(A) << endl;
    max_score = max(max_score, calc_score(A));
  } else {
    rep(j, M) {
      if (i >= 1 && j < A[i - 1]) continue;
      A[i] = j;
      dfs(i + 1, N, M);
    }
  }
}

int main() {
  cin >> N >> M >> Q;
  rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(0, N, M);
  cout << max_score << endl;
}

Measured memory_bytes: 3400
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

x = int(input())
if (x < 1200):
    print("ABC")
else:
    print("ARC")


Measured memory_bytes: 9040
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
/*int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];*/
using namespace std;
int main() {
	int n;
	int ans = 0;
	cin >> n;
	vector<int>a(n);
	rep0(i, n - 1)cin >> a[i];
	soot(a);
	rep0(i, n - 2) {
		if (a[i] == a[i + 1])
			++ans;
	}
	cout << n - ans << endl;
	return 0;
}

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

signed main(){
  int n, m;
  int votes[1000];
  long voteSum = 0;
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    votes[i] = a;
    voteSum += a;
  }
  int th;
  if((voteSum % (4 * m)) != 0){
    th  = (voteSum / (4 * m)) + 1;
  }else{
    th = voteSum / (4 * m);
  }
  int result = 0;
  for(int i = 0; i < n; i++){
    if(votes[i] >= th)
      result++;
  }
  string resStr = (result >= m) ? "Yes" : "No";
  cout << resStr << endl;
}

Measured memory_bytes: 256
s = gets.chomp.split(" ")
while(s.size > 1)
  i = 0
  while(true)
  if (s[i+2] == "+")
    s[i+2] = s[i].to_i + s[i+1].to_i
    s.delete_at(i)
    s.delete_at(i)
    break
  end
  if (s[i+2] == "*")
    s[i+2] = s[i].to_i * s[i+1].to_i
    s.delete_at(i)
    s.delete_at(i)
    break
  end
  if (s[i+2] == "-")
    s[i+2] = s[i].to_i - s[i+1].to_i
    s.delete_at(i)
    s.delete_at(i)
    break
  end
  i+=1
  end
end
puts s

Measured memory_bytes: 8768
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=200010;

int n,k,b[maxn];

int main(){
    n=read();k=read();
    for(int i=1;i<=n;i++){
    	int x=read();
    	b[x]++;
    }
    sort(b+1,b+n+1);
    int ans=0;
    for(int i=n-k;i>=1;i--)ans+=b[i];
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n,k;
    int ans=0;
    cin >>n>>k;
    int a;
    map<int,int>dis;
    rep(i,n){
        cin>>a;
        dis[a]+=0;
        dis[a]++;
    }
    Vi c;
    repi(itr,dis){
        c.push_back(itr->S);
      //  clog<<(itr->S)<<" ";
    }
    sort(all(c));
    if(c.size()<=k){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<c.size()-k;i++){
        ans+=c[i];
    }
    cout<<ans<<endl;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
    std::string a;
    cin >>a;
    int count = 0;
    for(char b:a){
        if( b == '1'){
            count++;
        }
    }
    cout <<count<<endl;
    return 0;
}


Measured memory_bytes: 256