akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, X, T; cin >> N >> X >> T;
  ll result = (N+X-1) / X * T;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3608
N = int(input())
s  = input().strip()

cnt = 0
for key in range(1000):
    key = '{:0>3}'.format(str(key))    #; print(key)
    i0 = s.find(key[0])
    if 0 <= i0 < N-2:
        i1 = s.find(key[1], i0+1)
        if 0 < i1 < N-1:
            i2 = s.find(key[2], i1+1)
            if i2 != -1:
                cnt += 1
            else:
                continue
        else:
            continue        
    else:
        continue
                                   
print(cnt)         

Measured memory_bytes: 9276
#include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 300500

int main(){
	int table[NUM],limit,pre_div,tmp;

	for(int i=0; i < NUM;i++)table[i] = 1;

	limit = sqrt(NUM);

	pre_div = -1;

	for(int i=1;7*i+pre_div<=limit;){
		if(table[(tmp=7*i+pre_div)] == 1){
			for(int k=2*tmp;k < NUM; k += tmp){
				table[k] = 0;
			}
		}
		if(pre_div == -1){
			i++;
			pre_div = -6;
		}else{
			pre_div = -1;
		}
	}

	int n;

	while(true){
		scanf("%d",&n);
		if(n == 1)break;

		pre_div = -1;
		printf("%d:",n);
		for(int i=1;7*i+pre_div<=n;){
			if(table[7*i+pre_div] == 1 && n%(7*i+pre_div) == 0){
				printf(" %d",7*i+pre_div);
			}

			if(pre_div == -1){
				i++;
				pre_div = -6;
			}else{
				pre_div = -1;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int r=sc.nextInt();
        int c=sc.nextInt();
        int[][] rc=new int[r+1][c+1];     
        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                rc[i][j]=sc.nextInt();
            }
        }
        int sum;
        for(int k=0;k<r;k++){
            sum=0;
            for(int l=0;l<c;l++){
                sum=sum+rc[k][l];
                if(l==c-1){
                    rc[k][c]=sum;
                }
            }
        }for(int a=0;a<=c;a++){
            sum=0;
            for(int b=0;b<r;b++){
                sum=sum+rc[b][a];
                if(b==r-1){
                    rc[r][a]=sum;
                }
            }
        }
        for(int d=0;d<=r;d++){
            for(int e=0;e<=c;e++){
                System.out.print(rc[d][e]);
                if(e!=c){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}


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


int main(){
    int right[7][7];//[top][front]
    fill(right[0],right[7],0);
    right[1][2]=3; right[1][3]=5; right[1][5]=4; right[1][4]=2;
    right[2][1]=4; right[2][4]=6; right[2][6]=3; right[2][3]=1;
    right[3][1]=2; right[3][2]=6; right[3][6]=5; right[3][5]=1;
    right[4][1]=5; right[4][5]=6; right[4][6]=2; right[4][2]=1;
    right[5][1]=3; right[5][3]=6; right[5][6]=4; right[5][4]=1;
    right[6][2]=4; right[6][4]=5; right[6][5]=3; right[6][3]=2;

    int h[200][200];//(100,100)???????????¨??????
    int top[200][200];
    int n;
    while(cin>>n,n){
        fill(h[0],h[200],0);
        fill(top[0],top[200],0);
        for(int i=0;i<n;i++){
            int t,f,r;
            cin>>t>>f;
            r=right[t][f];
            int x=100, y=100;
            while(true){
                int b=7-f; int l=7-r;//b:back, l:left
                int nx=x, ny=y;
                for(int d=6;d>3;d--){
                    if(f==d&&h[x][y]>h[x][y-1]){//????????¢??????
                        ny=y-1; f=t; t=b;
                        break;
                    }
                    if(r==d&&h[x][y]>h[x+1][y]){//????????¢??????
                        nx=x+1; r=t; t=l;
                        break;
                    }
                    if(b==d&&h[x][y]>h[x][y+1]){//???????????¢??????
                        ny=y+1; f=7-t; t=7-b;
                        break;
                    }
                    if(l==d&&h[x][y]>h[x-1][y]){//????????¢??????
                        nx=x-1; r=7-t; t=7-l;
                        break;
                    }
                }
                if(nx==x&&ny==y){
                    h[x][y]++;
                    top[x][y]=t;
                    break;
                }else{
                    x=nx,y=ny;
                    continue;
                }
            }
        }
        int c[7]={};
        for(int i=0;i<200;i++){
            for(int j=0;j<200;j++){
                c[top[i][j]]++;
            }
        }
        for(int i=1;i<7;i++){
            if(i-1) cout<<" ";
            cout<<c[i];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3388
K,N=input().split()
K=int(K)
N=int(N)
A=list(map(int,input().split()))
i=0
C=[]
for i in range(N-1):
    if (2<=K<=10**6)and(2<=N<=2*10**5)and(0<=A[i]<A[i+1]<K)and(i<N-1):
        B=A[i+1]-A[i]
        C.append(B)
        i+=1
    if (i==N-1)and(A[N-1]<K):
        B=K-A[N-1]+A[0]
        C.append(B)
d=max(C)
e=K-d
print(e)

Measured memory_bytes: 26444
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef float Item;
static Item *s;
static int N;
void STACKinit(int);
int STACKempty(void);
void STACKpush(Item);
Item STACKpop(void);
int main(void){
  char a[400];
  int i=0;
  scanf("%[^\n]",a);
  int n=strlen(a);
  int stackin=0;
  STACKinit(214748364);
  for(i=0;i<n;i++){
    if(a[i]=='+'){
      STACKpush(STACKpop()+STACKpop());
      stackin--;
    }
    if(a[i]=='-'){
      int l=STACKpop();
      STACKpush(STACKpop()-l);
    }
    if(a[i]=='*'){
      STACKpush(STACKpop()*STACKpop());
    }
    if((a[i]>='0')&&(a[i]<='9')){
      STACKpush(0);
    }
    while((a[i]>='0')&&(a[i]<='9')){
      STACKpush(10*STACKpop()+(a[i++]-'0'));
      stackin++;
    }
  }
  printf("%d\n",(int)STACKpop());
  return 0;
}
void STACKinit(int maxN){
  s=malloc(maxN*sizeof(Item));
  N=0;
}
int STACKempty(void){
  return N==0;
}
void STACKpush(Item item){
  s[N++]=item;
}
Item STACKpop(void){
  return s[--N];
}

Measured memory_bytes: 1764
/* ex4_2
	kanon */

#include <stdio.h>
#include <math.h>

int main(void)
{

    //与えられる値を入れる数を宣言
    double length_a,length_b,hour,minute;

    //変数に値を入力する
    scanf("%lf %lf %lf %lf",&length_a,&length_b,&hour,&minute);
  
    //radianの計算
    double radian=(hour+minute/60)*(360/12)-minute*(360/60);
    radian/=180;
    radian*=M_PI;
    
    //余弦定理を行う
    double ans=pow(length_a,2)+pow(length_b,2)-2*length_a*length_b*cos(radian);
    ans=sqrt(ans);

    printf("%.10lf",ans);

    return 0;
}

Measured memory_bytes: 2600
import sys
input=sys.stdin.readline
from bisect import bisect_right, bisect_left
n=int(input())
a = [list(map(int, input().split())) for _ in range(3)]
a[0].sort()
a[2].sort()



cnt=0
for i in range(n):
    index_1 = bisect_left(a[0],a[1][i])
    index_2 = n-bisect_right(a[2],a[1][i])
    cnt+=index_1*index_2
print(cnt)


Measured memory_bytes: 92644
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n, k;
vector<int> adj[MAXN];
int dep[MAXN];

void read()
{
	cin >> n >> k;
	for(int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

void dfs_visit(int u, int pr = -1, int d = 0)
{
	chkmin(dep[u], d);
	for(int v: adj[u])
		if(v != pr)
			dfs_visit(v, u, d + 1);
}

int solve_vertex(int u)
{
	for(int i = 1; i <= n; i++) dep[i] = n + 1;
	dfs_visit(u);

	int cnt = 0;
	for(int i = 1; i <= n; i++)
		if(dep[i] <= k / 2) 
			cnt++;

	return n - cnt;
}

int solve_edge(int u, int v)
{
	for(int i = 1; i <= n; i++) dep[i] = n + 1;
	dfs_visit(u);
	dfs_visit(v);

	int cnt = 0;
	for(int i = 1; i <= n; i++)
		if(dep[i] <= k / 2) 
			cnt++;

	return n - cnt;
}


void solve()
{
	int answer = n;
	if(k % 2 == 1)
		for(int i = 1; i <= n; i++)
			for(int j: adj[i])
				chkmin(answer, solve_edge(i, j));
	else
		for(int i = 1; i <= n; i++)
			chkmin(answer, solve_vertex(i));
	
	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 24960
n,pa,pb,pc,pd,ta,tb,tc,td=map(int,open(0).read().split())
r=range(n+1)
m=1e9
for i in r:
    for j in r:
        for k in r:
            l=0--(n-ta*i-tb*j-tc*k)//td
            m=min(m,pa*i+pb*j+pc*k+pd*l*(l>=0))
print(m)


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

// Macros
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
#define ALL(container)   container.begin(),container.end()
#define RALL(container)  container.rbegin(),container.rend()
#define MAKE_UNIQUE(vec) vec.erase(unique(ALL(vec)),vec.end())

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Random
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/* [a,b] */ template<class T> T rnd_IntType(T a, T b){ return uniform_int_distribution<T>(a, b)(rng); }
/* [a,b) */ template<class T> T rnd_RealType(T a, T b){ return uniform_real_distribution<T>(a,b)(rng); }

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const deque<T> &v)  { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef LOCAL
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(__attribute__((unused)) istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


void solve(){
	int n;
	cin >> n;

	vector<pii> arr(n);
	for(auto &i: arr) cin >> i.F >> i.S;
	sort(ALL(arr));

	if(n % 2){
		int start = arr[n/2].F;

		for(auto &i: arr) swap(i.F, i.S);
		sort(ALL(arr));

		int end = arr[n/2].F;

		cout << end - start + 1 << "\n";
	}
	else{
		int s1 = arr[(n-1)/2].F, s2 = arr[n/2].F;

		for(auto &i: arr) swap(i.F, i.S);
		sort(ALL(arr));

		int e1 = arr[(n-1)/2].F, e2 = arr[n/2].F;

		int start = s1 + s2, end = e1 + e2;

		trace(s1,s2,e1,e2,start,end);

		cout << end - start + 1 << "\n";
	}
}

signed main (void){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}

Measured memory_bytes: 4784
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl P(N, 0);
  REP(i, N) {
    ll p;
    cin >> p;
    P[p - 1] = i + 1;
  }

  REP(i, N) { cout << 30000 * (i + 1) << " "; }
  cout << endl;
  REP(i, N) { cout << 30000 * (N - (i + 1)) + P[i] << " "; }

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using namespace __gnu_pbds;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

string s;

ll x, y;

const ll HOR = 1;
const ll VER = 0;

vector<ll> m[2];

bool solve(ll val, vector<ll> v) {
  set<ll> possible = {0};
  for (ll x: v) {
    set<ll> nxt;
    for (ll p: possible) {
      nxt.insert(p+x);
      nxt.insert(p-x);
    }
    possible = nxt;
  }
  return possible.find(val) != possible.end();
}

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);
  cin >> s;
  cin >> x >> y;
  int pos = 0;
  while(pos < s.size() && s[pos] == 'F') {
    pos++;
  }
  x -= pos;
  ll dir = HOR;
  
  ll cur = 0;
  while(pos < s.size()) {
    if (s[pos] == 'T') {
      if (cur > 0) {
        m[dir].push_back(cur);
      }
      dir = !dir;
      cur = 0;
    } else {
      cur++;
    }
    pos++;
  }

  if (cur > 0) {
    m[dir].push_back(cur);
  }

  /*cerr << "NEW x, y: " << x << ", " << y << endl;
  cerr << "HOR: " << endl;
  for (auto x: m[HOR])
    cerr << x << ' '; cerr << endl;
  cerr << "VERT: " << endl;
  for (auto x: m[VER])
    cerr << x << ' '; cerr << endl;
    */
  
  if (solve(x, m[HOR]) && solve(y, m[VER])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    #include<string.h>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main(){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==b)cout<<c<<endl;
        if(a==c)cout<<b<<endl;
        if(b==c)cout<<a<<endl;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
ll f(ll a,ll b){
	if(b==0)return 1;
	if(b%2==0){
		ll t=f(a,b/2);
		return t*t;
	}
	return a*f(a,b-1);
}

signed main(){
	int n; cin>>n;
	map<ll,ll> mp;
	ll b=0;
	rep(i,0,n){
		ll a; cin>>a;
		b+=a;
		mp[b]++;
	}
	ll ans=0;
	ans+=(mp[0]);
	for(auto c:mp){
		ll j=c.second;
		ans+=(j*(j-1)/2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15972
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int dx[4] = {0,-1,0,1};
int dy[4] = {-1,0,1,0};


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}


int main(){
   int d,t,s;
   cin >> d >> t >> s;
   int a = t*s;
   if(a >= d){
       cout << "Yes" <<endl;
   }
   else {
       cout << "No" <<endl;
   }

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
bool f(vec& a,int x){
    ll n=a.size();
    vector<vector<bool>> dp(n,vector<bool>(16500));
    dp[0][a[0]+8000]=true;
    rep2(i,1,n-1)rep2(j,0,16499){
      bool p=false,q=false;
      if(j>=a[i])p=dp[i-1][j-a[i]];
      if(j+a[i]<16500)q=dp[i-1][j+a[i]];
      dp[i][j]=p||q;
    }
    return dp[n-1][x+8000];
}
int main(){
    string s=stin();
    int ain=0,bin=0;
    vec a(s.length()),b(s.length());
    bool bl=true;
    rep(i,s.length()){
        if(s.at(i)=='T'){
            if(bl){
                bin++;
                bl=false;
            }else{
                ain++;
                bl=true;
            }
        }else{
            if(bl)a[ain]++;
            else b[bin]++;
        }
    }
    if(f(a,in())&f(b,in()))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 18944
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a,b;
	string s;
	cin >> b;
	cin >> s;
	a = s.length();
	if (a <= b)cout << s;
	else {
		for (int i = 0; i < b; i++) {
			cout << s[i];
		}cout << "...";
	}
	
	return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

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

		while(sc.hasNext()){
			int[] data = new int[5];
			for (int i = 0; i < data.length; i++){
				data[i] = sc.nextInt();
			}
			
			for (int i = 0; i < data.length; i++){
				if (i>0){
					System.out.print(" ");
				}
				int buff = data[i];
				int buffnum = i;
				for (int j = i; j < data.length; j++){
					if (data[j] > buff){
						buff = data[j];
						buffnum = j;
					}
				}
				data[buffnum] = data[i];
				data[i] = buff;
				System.out.print(data[i]);
			}
			System.out.println();
		}
		sc.close();
	}
}

Measured memory_bytes: 17328
import java.util.*;
import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public void run() {
		int q=sc.nextInt();
		while(q--!=0){
			String n=sc.next();

			int t=0;
			while(n.length()>1){
				int max=0;
				for(int i=1;i<n.length();i++){
					String a=n.substring(0,i);
					String b=n.substring(i);
					max=Math.max(Integer.parseInt(a)*Integer.parseInt(b),max);
				}
				n=max+"";
				t++;
			}
			ln(t);
		}

	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 23112
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int n,i,x,y;
	cin>>n;
	int a;
	int* b;
	
	b=(int *)malloc(sizeof(int)*n);

	x=n/2;
	if(n%2==0)
	{
		y=1;
	}
	else
	{
		y=-1;
	}

	for(i=0; i<n; i++)
	{
		cin>>a;
		b[x+i*y]=a;
		x+=i*y;
		y*=-1;
	}

	for(i=0;i<n;i++)
	{
		cout<<b[i];
		if(i==n-1)
		{
			cout<<"\n";
		}
		else
		{
			cout<<" ";
		}
	}

	free(b);

	return 0;
}

Measured memory_bytes: 2944
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, d, sum, Q;
LL ans;
LL no;
bool b, bb[100001];
string s, t;
int main() {
	int A, B;
	cin >> A>>B;
	for (int i = 0; i < 1010; i++) {
		if (A == int(i*0.08)&&B == int(i*0.1)) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
alphabet = [chr(i) for i in range(97, 97+26)]
ans = ""
i = 0
# 次26**iを引いたらマイナスになるよ、というところで抜ける
while n - 26**i >= 0:
    n -= 26**i
    i += 1
# ここを抜けた時,iは桁数、nは「i桁の中でn番目」を表す

# したからk番目は、26**kで割った余り（に対応するアルファベット）
# 「上の桁で表現しきれなかった数」＝「その桁での表現」
#　これ、10進法をn進法に変換するアルゴリズムの正当性の説明を適用するとしっかりわかるわ！
for _ in range(i):
    q,r = divmod(n,26)
    n = q
    ans += alphabet[r]
print(ans[::-1])

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
  for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = s.size();

    vector<int> mods(2020, 0);
    int nowmod = 0, now = 1;
    int ans = 0;
    for(int i = n - 1; i >= 0; i--) {
        mods[nowmod]++;
        nowmod += (s[i] - '0') * now, nowmod %= 2019;
        ans += mods[nowmod];
        now *= 10, now %= 2019;
    }
    cout << ans << endl;
  for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int N=200009;

int n,a,b;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

inline bool chkmax(int &a,int b){if(a<b){a=b;return 1;}return 0;}
inline bool chkmin(int &a,int b){if(a>b){a=b;return 1;}return 0;}

struct tree
{
	int to[N<<1],nxt[N<<1],beg[N],tot;
	int dep[N],fa[N];
	bool vis[N];
	tree()
	{
		memset(to,0,sizeof(to));
		memset(nxt,0,sizeof(nxt));
		memset(beg,0,sizeof(beg));
		memset(dep,0,sizeof(dep));
		memset(vis,0,sizeof(vis));
		tot=0;
	}
	inline void add(int u,int v)
	{
		to[++tot]=v;
		nxt[tot]=beg[u];
		beg[u]=tot;
	}
	inline void dfs(int u)
	{
		vis[u]=1;
		for(int i=beg[u],v;i;i=nxt[i])
			if(!vis[(v=to[i])])
			{
				fa[v]=u;
				dep[v]=dep[u]+1;
				dfs(v);
			}
	}
	inline void init(int st)
	{
		dep[st]=0;
		dfs(st);
	}
}sp,sn;

const int Inf=1e9;

int f[N];

inline bool check(int u,int v)
{
	int d=0;
	while(++d<=2 && u!=v)
		if(sp.dep[u]<sp.dep[v])
			v=sp.fa[v];
		else
			u=sp.fa[u];
	return u!=v;
}

inline int dfs(int u)
{
	if(!f[u])return 0;

	f[u]=sp.dep[u];
	for(int i=sn.beg[u],v;i;i=sn.nxt[i])
		if(sn.dep[u]<sn.dep[v=sn.to[i]])
		{
			if(check(u,v)){puts("-1");exit(0);}
			chkmax(f[u],dfs(v));
		}
	return f[u];
}

int main()
{
	n=read();
	a=read();
	b=read();
	if(a==b)
	{
		puts("0");
		return 0;
	}
	
	for(int i=1,u,v;i<n;i++)
	{
		u=read();
		v=read();
		sn.add(u,v);
		sn.add(v,u);
	}
	for(int i=1,u,v;i<n;i++)
	{
		u=read();
		v=read();
		sp.add(u,v);
		sp.add(v,u);
	}
	sn.init(a);
	sp.init(b);

	for(int i=1;i<=n;i++)
		if(sp.dep[i]>sn.dep[i])
			f[i]=1;
	printf("%d\n",dfs(a)<<1);

	return 0;
}


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

int main(){
    long long N,A,B;
    cin>>N>>A>>B;
    long long ans;
    if(B<A) ans=0;
    else if(N==1 && B>A) ans=0;
    else if(N==1 && B==A) ans=1;
    else ans=1+(N-2)*(B-A);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int main()
{
	ll n,k,ans=0;
	cin>>n>>k;
	//ll sum=(1+n)*n/2;
	for(ll i=k;i<=n;i++)
	{
		ll t1=(i-1)*i/2;
		ll t2=(n+n-i+1)*i/2;
		ans+=(t2-t1+1)%mod;
	}
	cout<<(ans+1)%mod;
	return 0; 
} 

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

int main () {

    int N, K;
    string S;
    cin >> N >> S >> K;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != S[K-1]) {
            S[i] = '*';
        }
    }
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int x,y;cin>>x>>y;
  x--;y--;
  int root[12];
  rep(i,12){
    if(i==3||i==5||i==8||i==10){
      root[i]=3;
    }
    else if(i==1){
      root[i]=1;
    }
    else root[i]=0;
  }
  if(root[x]==root[y]) prin("Yes");
  else prin("No");

  
  

  return 0;
}


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

int digit_sum(int n) {
    if (n == 0) return 0;
    return n % 10 + digit_sum(n / 10);
}

int main() {
    int n;
    cin >> n;
    int mini = 100;
    for (int i = 1; i <= n / 2; i++) {
        mini = min(mini, digit_sum(i) + digit_sum(n - i));
    }
    cout << mini << endl;
}

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


int main(){
    int N;
    cin >> N;
    vector<ll> a(3*N, 0);
    for (int i = 0; i < 3*N; i++) scanf("%lld", &a[i]);

    vector<ll> lsum(3*N, 0);
    priority_queue<ll, vector<ll>, greater<ll> > q;
    for (int i = 0; i < N; i++) {
        lsum[N-1] += a[i];
        q.push(a[i]);
    }
    for (int i = N; i < 2*N; i++) {
        lsum[i] = lsum[i-1] + a[i];
        q.push(a[i]);
        lsum[i] -= q.top();
        q.pop();
    }

    vector<ll> rsum(3*N, 0);
    priority_queue<ll> r;
    for (int i = 3*N-1; i >= 2*N; i--) {
        rsum[2*N] += a[i];
        r.push(a[i]);
    }
    for (int i = 2*N-1; i >= N; i--) {
        rsum[i] = rsum[i+1] + a[i];
        r.push(a[i]);
        rsum[i] -= r.top();
        r.pop();
    }
    ll ans = lsum[N-1]-rsum[N];
    for (int i = N; i < 2*N; i++) {
        if (lsum[i] - rsum[i+1] > ans) ans = lsum[i] - rsum[i+1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9588
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
	"math"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc057b(N int, M int){
	human_list := [][]int{}
	var a int
	var b int
	for i := 0; i < N; i++{
		fmt.Scan(&a)
		fmt.Scan(&b)
		ap := []int{a,b}
		human_list = append(human_list,ap)
	}
	point_list := [][]int{}
	for i := 0; i < M; i++{
		fmt.Scan(&a)
		fmt.Scan(&b)
		ap := []int{a,b}
		point_list = append(point_list,ap)
	}
	for j := 1; j <= N; j++{
		min := 1000000000.0
		ans := 1000000000.0
		for i := 1; i <= M; i++{
			x := math.Abs(float64(human_list[j-1][0]-point_list[i-1][0]))
			y := math.Abs(float64(human_list[j-1][1]-point_list[i-1][1]))
			current := x + y
			if current < min{
				ans = float64(i)
				min = current
			}
		}
		fmt.Println(ans)
	}
}
func main(){
	n,m := 0,0
	fmt.Scan(&n)
	fmt.Scan(&m)
	abc057b(n,m)
}

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

int d,score,i,j,k,pscore,cscore,id;
int c[26],s[365][26],last[26],t[365];
int day1,day2,v1,v2,csize,f,check[4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> d;
  for(i=0;i<26;i++) {
    cin >> c[i];
  }
  for(i=0;i<d;i++) {
    for(j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }
  for(i=0;i<d;i++) {
    for(j=0;j<26;j++) {
      int tscore=s[i][j];
      for(int k=0;k<26;k++) {
        if(k==j) continue;
        tscore-=c[k]*(i+1-last[k]);
      }
      if(j==0) score=tscore;
      else if(tscore>score) {
        score=tscore;
        t[i]=j;
      }
    }
    last[t[i]]=i+1;
  }
  int cnt=600000;
  while(cnt--) {
    day1=rand()%d;
    v1=rand()%26;
    while(t[day1]==v1) {
      v1=rand()%26;
    }
    check[0]=t[day1];
    check[1]=v1;
    csize=2;
    if(cnt<150000) {
      day2=rand()%d;
      while(day2==day1) {
        day2=rand()%d;
      }
      v2=rand()%26;
      while(v2==t[day2]) {
        v2=rand()%26;
      }
      if(t[day1]!=t[day2]&&v1!=t[day2]) {
        check[csize++]=t[day2];
      }
      if(t[day1]!=v2&&v1!=v2) {
        check[csize++]=v2;
      }
    }
    pscore=0;
    cscore=0;
    for(i=0;i<csize;i++) last[check[i]]=0;
    for(i=0;i<d;i++) {
      pscore+=s[i][t[i]];
      last[t[i]]=i+1;
      for(j=0;j<csize;j++) {
        int id=check[j];
        pscore-=c[id]*(i+1-last[id]);
      }
    }
    for(i=0;i<csize;i++) last[check[i]]=0;
    for(i=0;i<d;i++) {
      if(day1==i) {
        cscore+=s[i][v1];
        last[v1]=i+1;
      }
      else if(cnt<150000&&day2==i) {
        cscore+=s[i][v2];
        last[v2]=i+1;
      }
      else {
        cscore+=s[i][t[i]];
        last[t[i]]=i+1;
      }
      for(j=0;j<csize;j++) {
        id=check[j];
        cscore-=c[id]*(i+1-last[id]);
      }
    }
    if(pscore<cscore) {
      t[day1]=v1;
      if(cnt<150000) t[day2]=v2;
    }
  }
  for(i=0;i<d;i++) {
    printf("%d\n",t[i]+1);
  }
}

Measured memory_bytes: 3840
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	string n;
	cin >> n;
	if (n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int index = -1;
    REP(i, n-1){
        if(a[i] + a[i+1] >= l){
            index = i+1;
            break;
        }
    }

    if(index == -1){
        cout << "Impossible" << endl;
    }else{
        stack<int> st;
        for(int i = index; i >= 1; i--){
            st.push(i);
        }
        for(int i = index+1; i < n; i++){
            st.push(i);
        }
        cout << "Possible" << endl;
        while(!st.empty()){
            cout << st.top() << endl;
            st.pop();
        }
    }
}

Measured memory_bytes: 1624
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const lli mod = 1e9 + 7;
lli mypow(lli a, lli b)
{
	a %= mod;
	lli res = 1, tmp = a;
	while(b)
	{
		if(b % 2) res = (res * tmp) % mod;
		tmp = (tmp * tmp) % mod;
		b /= 2;
	}
	return res;
}
bool cmp(lli a, lli b)
{
	return a > b; 
}
lli func[200050];
lli C(lli a, lli b)
{
	if(b == 0 || b == a) return 1;
	lli one = func[a], two = func[a - b], three = func[b];
	lli t1 = mypow(two, mod - 2), t2 = mypow(three, mod - 2);
	lli res = (one * t1) % mod;
	res = (res * t2) % mod;
	return res;
}
int main()
{
	lli a, b; cin >> a >> b;
	lli arr[a + 50], ans = 0;
	for(int i=0; i<a; i++)
		cin >> arr[i];
	func[0] = 1;
	for(lli i=1; i <= a; i ++)
		func[i] = (func[i - 1] * i) % mod;
	sort(arr, arr + a, cmp);
	for(int i=0; i <= a - b; i++)
	{
		lli res = C(a - i - 1, b - 1);
		lli tmp = (arr[i] * res) % mod;
		ans = (ans + tmp) % mod;
	}
	sort(arr, arr + a);
	for(int i=0; i <= a - b; i++)
	{
		lli res = C(a - i - 1, b - 1);
		lli tmp = (arr[i] * res) % mod;
		ans = (ans - tmp + mod) % mod;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1792
T = int(input())
K = []
for i in range(T):
    a = list(map(int,input().split()))
    K.append(a)

def pay(N):
    if N == 0:
        return 0
    if N == 1:
        return D
    if N in memo:
        return memo[N]

    m = float("inf")
    if N % 2 == 0:
        m = min(m, A + pay(N // 2))
    else:
        m = min(m, A + pay(N // 2) + D)
        m = min(m, A + pay(N // 2 + 1) + D)

    if N % 3 == 0:
        m = min(m, B + pay(N // 3))
    else:
        m = min(m, B + pay(N // 3) + D*(N%3))
        m = min(m, B + pay(N // 3 + 1) + D*(3 - N%3))

    if N % 5 == 0:
        m = min(m, C + pay(N // 5))
    else:
        m = min(m, C + pay(N // 5) + D*(N%5))
        m = min(m, C + pay(N // 5 + 1) + D*(5 - N%5))

    m = min(m, D*N)
    memo[N] = m
    return m

for i in range(T):
    memo = {}
    N, A, B, C, D = K[i]
    print(pay(N))


Measured memory_bytes: 89068
N=parse(Int,readline())
function isp(p)
	i=2
	while i*i<=p
		if p%i==0
			return false
		end
		i+=1
	end
	true
end
now=2
while N>0
	if isp(now)
		println(now)
		N-=1
	end
	now+=5
end


Measured memory_bytes: 108156
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,A,X=0,number,numbers[51]={};
	ll dp[51][10000]={};

	cin>>N>>A;

	FOR(i,1,N+1){
		cin>>number;
		chmax(X,number);
		numbers[i]=number-A;
	}
	chmax(X,A);

	REP(t,2*N*X+1){
		if(t==N*X) dp[0][t]=1;
		else dp[0][t]=0;
	}

	FOR(j,1,N+1){
		REP(t,2*N*X+1){
			if(t-numbers[j]<0||(t-numbers[j])>2*N*X)
				dp[j][t]=dp[j-1][t];
			else
				dp[j][t]=dp[j-1][t]+dp[j-1][t-numbers[j]];
		}
	}

	print(dp[N][N*X]-1);
	return 0;
}



Measured memory_bytes: 4224
#include <iostream>

int main()
{
    int A,B,C;
    std::cin >> A >> B >> C;
    bool check = false;
    if(A == 5){
        if(B == 5 || C ==5){
            if(B == 7 || C ==7){
                check = true;
            }
        }
    } 
    else if(B == 5){
        if(A == 5 || C ==5){
            if(A == 7 || C ==7){
                check = true;
            }
        }
    }
    if(check){
        std::cout << "YES" << std::endl;
    }
    else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, M = MI()
    H = LI()
    E = [[] for _ in range(N)]
    for i in range(M):
        a, b = MI1()
        E[a].append(b)
        E[b].append(a)

    used = [-1] * N
    for v in range(N):
        if used[v] == 0: continue
        h = H[v]
        for nv in E[v]:
            nh = H[nv]
            if h > nh:
                used[nv] = 0
            elif h < nh:
                used[v] = 0
                break
            else:
                used[v] = 0
                used[nv] = 0
                break
        else:
            used[v] = 1
    print(sum(used))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 95128
n=int(input())
s=input()
 
count = 0
for i in range(n-3+1):
#	print(s[i],s[i+1],s[i+2])
	if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
		count = count + 1
print(count)

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if ((a + b == c) || (a + c == b) || (b + c == a))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#define sqr(x) ((x)*(x))

int main(void)
{
  int n, d;
  int x[10][10];
  int i, j, k;
  int sum, cnt = 0;
  
  scanf("%d %d", &n, &d);
  
  for (i = 0; i < n; i++)
    for (j = 0; j < d; j++)
      scanf("%d", &x[i][j]);
  
  for (i = 0; i < n-1; i++)
    for (j = i+1; j < n; j++) {
      sum = 0;
      for (k = 0; k < d; k++)
        sum += sqr(x[i][k] - x[j][k]);
      
      if (sum == sqr((int)sqrt(sum)) || sum == sqr((int)sqrt(sum)+1))
        cnt++;
    }
  
  printf("%d", cnt);
  
  return 0;
}


Measured memory_bytes: 128
A, B, C, X, Y = map(int, input().split())

ret = float('inf')
for ab in range(0, max(X, Y) * 2 + 1, 2) :
    ret = min(ret, A * max(0, (X - ab // 2)) + B * max(0, (Y - ab // 2)) + C * ab)
    
print(ret)

Measured memory_bytes: 39280
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;

int main(void){
 int ans1=0;
 int ans2=0;
 char S[200000];
 char S1[200000];

 cin>>S;
 strcpy(S1,S);
 
 if(S[0]=='1'){
  ans1++;
  S[0]='0';
 }
 for(int i=1; i<strlen(S); i++){
  if(S[i]!=S[i-1]);
  else{
   if(S[i]=='0')S[i]='1';
   else S[i]='0';
   ans1++;
  }
 }

 if(S1[0]=='0'){
  ans2++;
  S1[0]='1';
 }
 for(int i=1; i<strlen(S1);i++){
  if(S1[i]!=S1[i-1]);
  else{
   if(S1[i]=='0')S1[i]='1';
   else S1[i]='0';
   ans2++;
  }
 }

 cout<<min(ans1,ans2)<<endl;
 return 0;
}


Measured memory_bytes: 512
n = int(input())
a = [int(i) for i in input().split()]
sum_before = 0
for i in range(n-1):
    sum_before += abs(a[i] - a[i+1])
sum_before += abs(a[0])+abs(a[n-1])
for i in range(n):
    if i == 0:
        print(sum_before-(abs(a[0])+abs(a[1]-a[0])) + abs(a[1]))
    elif i == n-1:
        print(sum_before - (abs(a[n-2]-a[n-1])+abs(a[n-1]))+abs(a[n-2]))
    else:
        print(sum_before-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]))

Measured memory_bytes: 14172
import math
import collections
import heapq
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    a, b = map(int, input().split())
    ans = 0
    k = 1
    while True:
        if k >= b:
            break
        k += a - 1
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    char c;
    cin >> c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout << "vowel" <<endl;
    }else{
        cout << "consonant" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    unsigned long long n;
    unsigned long long ans = 0, temp = 0;

    cin >> n;

    ans = (n * (n-1)) / 2;

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <vector>
#define pb push_back
#define ms(a) memset(a,0,sizeof(a))
#define ll long long
#define ull unsigned ll
using namespace std;
#define MAXN 60
#define MAXVAL (1e16+1000)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);

ll n , k;

int main(){
	fastio;

    cin >> k;
    n = 50;
    cout << n << endl;
	ll a;
    for( int i = 0 ; i < n ; i++ ){
        a = n - 1 + k / n;
        if(i < k % n){
            a += n - k % n + 1;
        }else{
            a -= k % n;
        }
        cout << a << " ";
    }
	cout << endl;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

map<pair<ll,ll>,ll> mp;

ll func(ll s,ll x)
{
	if(mp.find(MP(s,x)) != mp.end())return mp[MP(s,x)];
	if(s == 0)return 1;
	ll ret = (func(s/2,x/2)+func((s-1)/2,(x-1)/2)+(s > 1?func((s-2)/2,x/2):0))%MOD;
	return mp[MP(s,x)] = ret;
}

int main()
{
	ll n;cin >> n;
	cout << func(n,n) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define pll pair<ll,ll>
#define ld long int
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 1000000000
#define N 100005
#define LOG 17
#define M 2000000
#define EPS 0.000001
using namespace std;

int main() {

	int x,y;
	scanf("%d %d",&x,&y);
	y*=2;
	printf("%d",y-x);	

}

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

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a;
    cin >> a;
    cout << (1 + a) * a / 2;
}

Measured memory_bytes: 256