akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int n;
  cin>>n;
  int d[n];
  for(int i = 0; i<n; i++) cin>>d[i];
  sort(d,d+n);
  int counter = 1;
  for(int i = 0; i<n-1; i++){
      if(d[i]!=d[i+1]) counter++;
  }
  cout<<counter<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;

int N;
int a[MAX_N];

int main() {
  cin >> N;
  rep(i,N) cin >> a[i];

  int A = 0, B = 0;
  sort(a, a+N, greater<int>());

  for (int i = 0; i < N; ++i) {
    if (i%2==0) A += a[i];
    else B += a[i];
  }

  cout << A-B << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	string s;
	cin >> s;
	bool ans = true;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == 'L')ans = false;
		}
		else {
			if (s[i] == 'R')ans = false;
		}
	}
	Yes(ans);
	return 0;
}

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

typedef pair<long, long> pl;
int main() {
  long long n, d, a;
  cin>>n>>d>>a;
  pair<long long, long long> xh[n];
  for (int i=0; i<n; i++) cin>>xh[i].first>>xh[i].second;
  queue<pl> q;
  sort(xh, xh + n);
  long long ans = 0;
  long long acc = 0;
  for (int i=0; i<n; i++) {
    while (!q.empty()) {
      auto front = q.front();
      if (xh[i].first > front.first) {
        acc -= front.second;
        q.pop();
      } else {
        break;
      }
    }
    long long h = xh[i].second - acc;
    if (h <= 0) {
      continue;
    }
    long long cnt = (h - 1) / a + 1;
    q.push(make_pair(xh[i].first + d * 2, 1LL * cnt * a));
    ans += cnt;
    acc += 1LL * cnt * a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef pair<int,int> P;
typedef pair<int,P> PP;
bool infected[20000];
vector<PP> vc;
int main(){
	while(true){
		int N,M;
		cin>>N>>M;
		if(N==0) break;
		rep(i,N) infected[i]=0;
		infected[0]=true;
		int cnt=0;
		vc.clear();
		rep(i,M){
			int t,s,d;
			cin>>t>>s>>d;
			vc.pb(PP(t,P(s-1,d-1)));
		}
		sort(all(vc));
		rep(i,M){
			int s=vc[i].sc.fs,t=vc[i].sc.sc;
			if(infected[s]) infected[t]=true;
		}
		rep(i,N) if(infected[i]) cnt++;
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1696
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll n;
cin>>n;
ll ans=n;
ll sum=0;
while(n>9){
sum+=n%10;
n=n/10;
}
sum+=n;
if(ans%sum==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int m;
    cin>>m;
    vector<ll>d(m),c(m);
    ll sum=0,ans=0,cnt=0;
    rep(i,m){
        cin>>d[i]>>c[i];
        sum+=d[i]*c[i];
        cnt+=c[i];
    }
    ans+=cnt-1LL;
    ans+=(sum-1)/9LL;
    cout<<ans<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}




 
    
void test_case() {

    string s;
    cin>>s;

    if(s[2] == s[3] && s[4] == s[5]) {
        yes;
    } else {
        no;
    }


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3548
N = int(input())

cnt = [0] + [26 ** i for i in range(1, 11)]
for i in range(10):
    cnt[i + 1] += cnt[i]

ans = ""
x = N - 1
for i in reversed(range(1, 11)):
    if x >= cnt[i]:
        v = (x - cnt[i]) // 26 ** i
        ans += chr(ord("a") + v)
        x -= (v + 1) * (26 ** i)

ans += chr(ord("a") + x % 26)
print(ans)
    

Measured memory_bytes: 61936
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
void solve(){
    int n;
    cin>>n;
    vector<int> arr(n),dp(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0; dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    cout<<dp[n-1];
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    solve(); cout<<endl;
    return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=1e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e4+10;
	//------------------FIXED------------------
	char str[N];int n;vc<int> pos;
	bool check(int st,int wt)
	{
		bitset<N+N> bs;bs[N]=1;int m=sz(pos);
		for(int i=st;i+1<m;i+=2)
		{
			int len=pos[i+1]-pos[i]-1;
			if(i==0) bs=(bs<<len);//debug
			else bs=(bs<<len)|(bs>>len);
		}return bs[N+wt];
	}
	void main()
	{
		scanf("%s",str+1);n=strlen(str+1);
		pos.PB(0);fo(i,1,n) if(str[i]=='T') pos.PB(i);pos.PB(n+1);
		int X=qread(),Y=qread();puts(check(0,X) and check(1,Y)?"Yes":"No");
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 23808
n, m = map(int, input().split())

if m % 2 == 0 or m % 4 == 0:
  if (n * 4) >= m:
    if (n*2) <= m:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 9176
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
double d;
main()
{
	cin>>d;
	int a=d*1000+0.5;
	double ans=0;
	for(int x=0;x<=a;x++)
	{
		int y=sqrt(0.5+a*a-x*x);
		if(x%1000==0&&y<1000)ans=max(ans,x+1000.);
		if(y%1000==0&&x<1000)ans=max(ans,y+1000.);
		ans=max(ans,(double)x+y);
	}
	ans=max(ans,sqrt(2)*a);
	cout<<setprecision(15)<<ans/1000<<endl;
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

//Node treeMinimum(Node x){


//}

//Node treeMaximum(Node x){


//}

//Node treeSearch(Node u, int k){


//}

//Node treeSuccessor(Node x){


//}

//void treeDelete(Node z){
//  Node y; // node to be deleted
//  Node x; // child of y



//}

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

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

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

  z->parent = y;

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

}

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


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

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

    //    if ( com[0] == 'f' ){
    //     scanf("%d", &x);
    //   Node t = treeSearch(root, x);

    // if ( t != NIL ) printf("yes\n");
    // else printf("no\n");

    //} 
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
    //else if ( com[0] == 'd' ){
    //   scanf("%d", &x);
    //  treeDelete(treeSearch(root, x));
    //}
  }

  return 0;
}

Measured memory_bytes: 24040
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		chrs := strings.Split(line, " ")
		ws, hs := chrs[0], chrs[1]
		w, _ := strconv.Atoi(ws)
		h, _ := strconv.Atoi(hs)
		fmt.Println(w*h, 2*(w+h))
	}

	if err := scanner.Err(); err != nil {
		// log.Println(err)
		return
	}
}



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

#define all(x) begin(x), end(x)
typedef long long ll;
using namespace std;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> S;
    vector<ll> ans(S.size() + 1);
    ll curVal = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (S[i] == '<') {
            ans[i + 1] = ans[i] + 1;
        }
    }
    for (ll i = S.size(); i >= 0; i--) {
        if (S[i] == '>') {
            ans[i] = max(ans[i], ans[i + 1] + 1);
        }
    }
    cout << accumulate(all(ans), 0ll) << endl;
}

Measured memory_bytes: 4764
import sys
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]


W, H, x, y = [int(x) for x in input().split()]

area = H * W / 2

num = 0

e = 0.000001
if abs(x - W / 2) < e and abs(y - H / 2) < e:
    num = 1

print("{} {}".format(area, num))


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

int main() {
   int H1,M1,H2,M2,K;
   cin >> H1 >> M1 >> H2 >> M2 >> K;
   cout << H2*60+M2-H1*60-M1-K << endl;
}

Measured memory_bytes: 3632
n, m = map(int , input().split())
start = []
goal = []
for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        start.append(b)
    elif b == n:
        goal.append(a)
if len(set(start) & set(goal)) >= 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 71896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s;
	cin >> s;

	int n = s.size();
	bool ok = true;
	rep(i, n - 1) {
		if (s[i] == s[i + 1])
			ok = false;
	}
	if (ok) cout << "Good" << endl;
	else cout << "Bad" << endl;
}

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

	solve();
}


Measured memory_bytes: 256
def main():
	N = int(input())
	S = input()
	ans = 0
	for i in range(1, N-1):
		this_ans = 0
		appear = set()
		for j in range(i):
			appear.add(S[j])
		
		already = set()
		for j in range(i, N):
			if S[j] in appear and not S[j] in already:
				this_ans += 1
				already.add(S[j])
		ans = max(ans, this_ans)

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int k,n;
  cin >> k >> n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin >> a[i];
  }
  int min = a[n-1]-a[0];
	for(int i=1; i<n; i++)
  {
		int d = k-(a[i]-a[i-1]);
		if(d<min)
    {
			min = d;
		}
  }
  cout << min;
return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		Integer val = Integer.parseInt(tokens[0] + tokens[1]);
		for (int i = 1;; ++i) {
			int v = i * i;
			if (v > val) {
				System.out.println("No");
				break;
			} else if (v == val) {
				System.out.println("Yes");
				break;
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 20436
#include <iostream>
#include <bits/stdc++.h>
#include<string>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <fstream>
#include <vector>

#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define SPACE " "
#define nLINE '\n'
#define ss second
#define ff first
//scanf("%d",&x) ,s.insert(x);
using namespace std;

ll GCD(ll a, ll b) {
	//Euclidian
	if (!b) return a;
	else return GCD(b, a % b);
}
const ll MAX = 51;
bool prime[MAX];
void sieve() {
	for (int p = 2; p * p <= MAX; p++)
		if (prime[p] == false)
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = true;
}

int comb(int a, int b)
{
	if (a < b) return 0;
	if (a == b) return 1;
	if (b == 0) return 1;
	return comb(a - 1, b) + comb(a - 1, b - 1);
}
int x[30];
long long int y[30];
long long int func(int s, int t)
{
	if (t == 0) return 1;
	if (s == 0) return 1;

	if (x[s] == 0) return func(s - 1, t);
	else
	{
		long long int sum = 0;
		for (int i = 0;i <= t;i++) sum += comb(s - 1, i) * y[i];

		long long int s1 = sum;

		sum = 0;
		for (int i = 0;i <= t - 1;i++) sum += comb(s - 1, i) * y[i];
		long long int s2 = (x[s] - 1) * sum;
		long long int s3 = func(s - 1, t - 1);
		return s1 + s2 + s3;
	}
}



int dp[13][1 << 13];
double arr[20][20];
int n;
int dvds[13],svs[13];
vector<double> sssp(int);
vector<double> minDis[20];
int Size;

double solve(int current, int mask) {
    if(mask == ((1 << Size) - 1)) return -arr[dvds[current]][0];

    if(dp[current][mask] != -1)
        return dp[current][mask];


    double Max = -arr[dvds[current]][0];
    for(int i= 0; i< Size; i++)
        if((mask & (1 << i)) == 0)
            Max = max(Max, svs[i] - arr[dvds[current]][dvds[i]]+ solve(i, mask | (1 << i)));

    return dp[current][mask]= Max;
}

int nextMin(int,int);
int lis[100001];
int main() {
	string s,t;
	int d=0;
	cin >> s >> t;
	for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])
            d++;
	}
	cout << d;
}

bool used[20];
vector<double> sssp(int src) {
	vector<double> disSource(n);
	fill(disSource.begin(), disSource.end(), INT_MAX);
	disSource[src] = 0;
	int curr = src;
	memset(used, false, sizeof used);
	used[curr] = true;
	while (curr != -1) {
		for (int j = 0;j < n;j++) {
			if (arr[curr][j] != -1) {
				if (disSource[j] == INT_MAX) disSource[j] = arr[curr][j] + disSource[curr];
				else disSource[j] = std::min(disSource[j], disSource[curr] + arr[curr][j]);
			}
		}
		used[curr] = true;
		curr = nextMin(curr,src);
	}
	return disSource;
}

int nextMin(int curr,int src) {
	int indx = -1;
	double Min = 1e9;
	for (int i = 0;i < n;i++) {
		if (arr[curr][i]!=-1 && arr[curr][i] <= Min && used[i] == false) {
			Min = arr[curr][i];
			indx = i;
		}
	}
	if (indx == -1){
        for(int i=0;i<n;i++)
            if(arr[src][i]!=-1 && arr[curr][i] <= Min && used[i]== false)
                indx = i , Min = arr[curr][i];
	}
	if (indx == -1) return -1;
	return indx;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 5010;
const int MOD = (int)1e9 + 7;

int mult(int a, int b){
  return (a * 1ll * b) % MOD;
}

void add(int &a, int b){
  a += b;
  if(a >= MOD) a -= MOD;
  else if(a < 0) a += MOD;
}

int powr(int n, int k){ 
  if(k == 0) return 1;
  int p = powr(n, k/2);
  p = (p * 1ll * p) % MOD;
  if(k % 2 == 1)
    p = (p * 1ll * n) % MOD;
  return p;
}

vector<int> T[N];
bool open[N];
bool vis[N];

int sz;
int root;

void dfs(int u){
  vis[u]=true;
  sz ++ ;
  if(open[u])root=u;
  for(auto x : T[u]){
    if(!vis[x])dfs(x);
  }
}

int dp[N][N];

int main(){
  fastIO;
  int n;
  cin >> n;
  int p;
  int k = 0;
  for(int i = 1; i <= n; i ++ ){
    cin >> p;
    if(p == -1){
      open[i]=true;
      k ++ ;
    }
    else{
      T[i].push_back(p);
      T[p].push_back(i);
    }
  }
  int ans = mult(n, powr(n - 1, k));
  vector<int> gg;
  for(int i = 1; i <= n; i ++ ){
    if(vis[i]) continue;
    sz = 0, root = 0;
    dfs(i);
    if(root == 0){
      add(ans, -powr(n - 1, k));
    }
    else{
      gg.push_back(sz);
    }
  }
  dp[0][0]=1;
  for(int i = 0 ; i < gg.size() ; i ++ ){
    for(int j = 0 ; j <= i ; j ++ ){
      add(dp[i + 1][j], dp[i][j]);
      add(dp[i + 1][j + 1], mult(dp[i][j], gg[i]));
    }
  }
  int m = gg.size();
  int fac = 1;
  for(int i = 2; i <= m; i ++ ){
    fac = mult(fac, i - 1);
    add(ans, -mult(mult(dp[m][i],fac),powr(n - 1, k - i)));
  }
  for(int i = 0 ; i < m ; i ++ ){
    add(ans, -mult(gg[i] - 1, powr(n - 1, k - 1)));
  }
  cout << ans << "\n";
  return 0; 
}


Measured memory_bytes: 70644
#include<iostream>
#include<cmath>
#include<iomanip>
#define PI 3.14159265
using namespace std;
int main(){
  double a,b,c,r;
  double S,L,h;
  cin >> a >> b >> c;
  r = c * PI /180;
  S = a * b * sin(r) / 2;
  L = a + b + sqrt(a*a+b*b-2*a*b*cos(r));
  h = S / a * 2;
  cout << fixed << setprecision(4) << S << endl;
  cout << fixed << setprecision(4) << L << endl;
  cout << fixed << setprecision(4) << h << endl;
  return 0;
}

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

int main() {
  int a;
  string s;

  cin >> a >> s;

  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
x = int(input())


def Prime(x):
    if x == 2:
        return 2
    if x % 2 == 0:
        return False
    else:
        sqrtx = x**(1/2)
        for i in range(3,int(sqrtx+1),2):
            if x % i == 0:
                return False
        return True

while True:
    if Prime(x):
        print(x)
        break
    x+=1


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	char s[11];
	char t[12];
	int lens = 0;
	int lent = 0;
	
	scanf("%s", s);
	scanf("%s", t);
	
	while(s[lens]){
		lens++;
	}
	
	while(t[lent]){
		lent++;
	}
	
	if(strncmp(s,t,lens) == 0 && lent - lens == 1){
		puts("Yes");
		return 0;
	}
	
	puts("No");
	
	return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B,C,D;
    string S,T;
int main(){
    cin>>A>>B>>C;
    cout<<(A+B>=C&&A<=C?"YES":"NO")<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int price;
	int change;
	int coin[6] = {500, 100, 50, 10, 5, 1};
	int i;
	int cnt;
	
	while (scanf("%d", &price)){
		
		if (price == 0){
			break;
		}
		
		cnt = 0;
		change = 1000 - price;
		
		for (i = 0; i < 6; i++){
			cnt += change / coin[i];
			change %= coin[i];
		}
		
		printf("%d\n", cnt);
	}
	
	return (0);
}

Measured memory_bytes: 600
def gcd(a, b) :
    while True :
        if a < b :
            a, b = b, a
        amari = a % b
        if amari == 0 :
            break
        else :
            a, b = b, amari
    return(b)

n = int(input())
c = list(map(int, input().split()))
for i in range(n-1, 0, -1) :
    c[i-1] = int(c[i] * c[i-1] / gcd(c[i], c[i-1]))
print(c[0])



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

#define ll long long

#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    int r; cin>>r;
    int ans = 3*r*r;
    printf("%d\n",ans);
    return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long A[100000];
int N;
int minOver(long X){
	int bf = 0;
	int bl = N;
	while(bf != bl){
		long bc = (bf+bl)/2;
		if(bc == N || (A[bc] >= X)){
			bl = bc;
		}
		else{
			bf = bc+1;
		}
	}
	return bf;
}
int maxBelow(long X){
	int bf = -1;
	int bl = N-1;
	while(bf != bl){
		long bc = (bf+bl+1)/2;
		if(bc == -1 || (A[bc] <= X)){
			bf = bc;
		}
		else{
			bl = bc-1;
		}
	}
	return bf;
}
long evensum[100001];
long oddsum[100001];
void Calc(){
	N = rei();
	int Q = rei();
	for(int i=0;i<N;i++){
		A[i] = rel();
	}
	for(int i=0;i<N;i++){
		if(i % 2){
			oddsum[i+1] = A[i];
		}
		else{
			evensum[i+1] = A[i];
		}
		oddsum[i+1] += oddsum[i];
		evensum[i+1] += evensum[i];
	}
	for(int query=0;query<Q;query++){
		long X = rel();
		int bf = 1;
		int bl = (N+1)/2;
		while(bf != bl){
			int bc = (bf+bl+1)/2;
			if(max(A[N-2*bc+1]-X,X-A[N-2*bc+1]) <= max(A[N-bc]-X,X-A[N-bc])){
				bf = bc;
			}
			else{
				bl = bc-1;
			}
		}
		long ans = oddsum[N] + evensum[N]- oddsum[N-bf] - evensum[N-bf];
		if(N > 2*bf){
			if(N % 2 == 0){
				ans += oddsum[N-2*bf];
			}
			else{
				ans += evensum[N-2*bf];
			}
		}
		cout << ans << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

void addEdge(int* count, int** list, int to) {
	int* newList = realloc(*list, sizeof(int) * (*count + 1));
	newList[*count] = to;
	(*count)++;
	*list = newList;
}

int N;
int u, v;
int edgeNums[114514];
int* edges[114514];

int highBridge[114514], blueTree[114514];

void dfs_a(int node, int parent, int current) {
	int i;
	blueTree[node] = current;
	for (i = 0; i < edgeNums[node]; i++) {
		if (edges[node][i] != parent) {
			dfs_a(edges[node][i], node, current + 1);
		}
	}
}

void dfs_t(int node, int parent, int current) {
	int i;
	if (current > blueTree[node]) return;
	highBridge[node] = current + 1;
	if (current >= blueTree[node]) return;
	for (i = 0; i < edgeNums[node]; i++) {
		if (edges[node][i] != parent) {
			dfs_t(edges[node][i], node, current + 1);
		}
	}
}

int main(void) {
	int i;
	int answer = 0;
	if (scanf("%d%d%d", &N, &u, &v) != 3) return 1;
	for (i = 1; i < N; i++) {
		int A, B;
		if (scanf("%d%d", &A, &B) != 2) return 1;
		addEdge(&edgeNums[A], &edges[A], B);
		addEdge(&edgeNums[B], &edges[B], A);
	}
	dfs_a(v, 0, 0);
	dfs_t(u, 0, 0);
	for (i = 1; i <= N; i++) {
		/* そこで捕まる可能性があるかを判定 */
		if (highBridge[i] > 0) {
			if (answer < blueTree[i] - 1) answer = blueTree[i] - 1;
		}
	}
	printf("%d\n", answer);
	return 0;
}

/*
高橋君は逃げる → 青木君は同じ速さで追いかける
→積む時は高橋君が飛び込むしかない
*/


Measured memory_bytes: 10368
sx, sy, tx, ty = map(int, input().split())

higth = ty - sy
width = tx - sx

ans = ''
ans += 'U' * higth
ans += 'R' * width
ans += 'D' * higth
ans += 'L' * width
ans += 'L' + 'U' * (higth + 1)
ans += 'R' * (width + 1) + 'D'
ans += 'R' + 'D' * (higth + 1)
ans += 'L' * (width + 1) + 'U'
print(ans)

Measured memory_bytes: 61880
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

void solve(){
    int n, l;
    cin >> n >> l;
    int sum = 0;
    for(int i = 0; i < n; i++) sum += (l+i);
    int taste = INF;
    int ans=0;
    for(int i = 0; i < n; i++){
        int selected = l+i;
        if(abs(selected) < taste){
            taste = abs(selected);
            ans = sum-selected;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int>A(n);
  for(int i = 0; i < n ;i++)cin>>A[i];
  int cnt = 0;
  int ans;
  auto itr = find(A.begin(),A.end(),1);
  if(itr == A.end()){
      ans = -1;
  }
  else{
      for(int i=1;i<n;i++){
          for(int j = i-1+cnt; j<n ;j++){
              if(A[j] != i)cnt++;
              if(A[j] == i)break;
          }
      }
      ans = cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M,ans=INF;
  cin>>N>>M;
  ll A[N][M],L[M+1];
  REP(i,N){
    REP(j,M){
      cin>>A[i][j];
    }
  }
  bool CAN[M+1];
  REP(i,M+1) CAN[i]=true;
  
  for(int i=1; i<=M; ++i){
    for(int j=1; j<=M; ++j) L[j]=0;
    for(int j=0; j<N; ++j){
      for(int k=0; k<M; ++k){
        if(CAN[A[j][k]]){
          L[A[j][k]]++;
          break;
        }
      }
    }
    ll mx=0,t=0;
    for(int j=1; j<=M; ++j){
      if(L[j]>0){
        if(mx<L[j]){
          mx=L[j];
          t=j;
        }
      }
    }
    CAN[t]=false;
    chmin(ans,mx);
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 896
import sys
sys.setrecursionlimit(10**6)

class Union_find:
    
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rank=[0]*(n+1)

    def find_root(self,x):# 頂点xのroot(根)頂点を見つける
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.find_root(self.root[x])
            return self.root[x]

    def unite(self,x,y):#頂点xと頂点yを繋ぐ辺を追加
        x=self.find_root(x)
        y=self.find_root(y)

        if x==y:
            return 
        elif self.rank[x]>self.rank[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y

            if self.rank[x]==self.rank[y]:
                self.rank[y]+=1

    def same(self,x,y):#頂点xと頂点yが連結であるか判定
        return self.find_root(x)==self.find_root(y)

    def count(self,x):#頂点xが属する木のサイズ
        return -self.root[self.find_root(x)]

n,q=map(int,input().split())
gragh=Union_find(n+1)
for i in range(q):
    c,x,y=map(int,input().split())
    if c:
        print(1 if gragh.same(x,y) else 0)
    else:
        gragh.unite(x,y)


Measured memory_bytes: 5828
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int ans = 0;
		int n = scan.nextInt();
		int m = scan.nextInt();
		int p[] = new int [m];
		List<Integer>[] button = new ArrayList[n];
		for(int i=0;i<n;i++) {
			button[i] = new ArrayList<>();
		}
		
		for(int i=0;i<m;i++) {
			int k = scan.nextInt();
			for(int j=0;j<k;j++) {
				int s = scan.nextInt()-1;
				button[s].add(i);
			}
		}
		
		
		for(int i=0;i<m;i++) {
			p[i] = scan.nextInt();
		}
		
		for(int i=0;i<(1<<n);i++) {
			int on[] = new int[m];
			boolean check = true;
			for(int j=0;j<n;j++) {
				if((1 & i>>j)==1) {
					for(int l : button[j]) {
						on[l] += 1;
					}
				}
			}
			
			
			for(int j=0;j<m;j++) {
				if(on[j]%2 != p[j]) {
					check = false;
					break;
				}
			}
			
			if(check) {
				ans += 1;
			}
		}
		
		System.out.println(ans);
		
		
		
	}	
}
 

Measured memory_bytes: 23892
/**
    In the name of Allah, the Most Gracious, the Most Merciful.
**/

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

typedef long long ll;
const int N = 2e5 + 5;

map<ll, ll> dp;

ll cal(ll n) {
        if( n == 1 ) return 1;
        if( dp[n] ) return dp[n];
        ll res = 0;
        ll half = n / 2LL;
        res = 1LL + cal(half) + cal(half);
        dp[n] = res;
        return dp[n];
}

int main() {
        #ifdef _OFFLINE_
                freopen("in.txt", "r", stdin);
        #endif /// _OFFLINE_


        ll n;
        cin >> n;
        cout << cal(n) << "\n";


        return 0;
}


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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var tminus = 25 - int.Parse(input);

            var greeting = "Christmas";

            for (var i = tminus; i > 0; i--)
            {
                greeting += " Eve";
            }

            Console.WriteLine(greeting);

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;
#define BUF (1000)

int N;
void input(void){
	cin >> N;
}

int main(void){
	input();

	for(int h=1;h<=3500;h++){ //h>n>w	
		for(int n=1;n<=3500;n++){
			long long cu = (long long)N*h*n;
			long long cd = (long long)4*h*n-(long long)h*N-(long long)n*N;
			long long w;
		//	cout << cu << cd ;
			if(cd==0) break;
			
			if(cu%cd==0 && cu/cd>0) {
				w=cu/cd;
				cout <<h << " " << n << " " << w << endl;
				return 0;
			}
			/*
			int l=n;
			if(l>N*3/4)l=N*3/4;
			for(int w=r;w<=l;w++){
				//cout << h << n << w;
				long long  temp = (long long)4*h*n*w - (long long)N*(n*w+h*w+h*n);
				if(temp==0){
				cout <<h << " " << n << " " << w << endl;
					return 0;	
				}
			}
			*/
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   char s[5];
   int i,c=0,j;
   gets(s);
    for(i=0;i<4;i++){
     for(j=0;j<4;j++){
        if(s[i]==s[j+1]){
            c++;
        }
        j++;
     }

     }
    if(c==4)
        printf("Yes\n");
        else
            printf("No\n");
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	ll a,b,tmp;
	cin >> a >> b;
	set<ll> st1,st2;

	tmp = a;
	st1.insert(1);
	for(ll i = 2; i*i <= tmp; i++){
		while(a%i == 0){
			a /= i;
			st1.insert(i);
		}
	}
	st1.insert(a);

	tmp = b;
	st2.insert(1);
	for(ll i = 2; i*i <= tmp; i++){
		while(b%i == 0){
			b /= i;
			st2.insert(i);
		}
	}
	st2.insert(b);

	int ans = 0;
	for(auto x: st1){
		for(auto y: st2){
			if(x == y) ans++;
		}
	}
	cout << ans << endl;

 	return 0;
}

Measured memory_bytes: 256
//#############################################################################
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define vec vector
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
#define sum(v) accumulate(all(v),0LL)
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
#ifdef LOCAL_TESTING
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
template <typename T>
void print_matrix(vector<vector<T>> mat){
    for(auto row: mat){
        for(auto e : row){cout << e << " ";}
        cout << endl;
    }
}
template <typename T>
void print_vector(vector<T> v){
    for(auto e : v){cout<< e <<" ";}
    cout<<endl;
}
template <typename T>
map<T,T> get_count(vector<T> v){
    map<T,T> count;
    for(auto e: v){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
void add_self(ll &a, ll b){
    a = a+b; if (a>=MOD){a -= MOD;}
}
ll sub_mod(ll a, ll b){
    a = (a-b+MOD)%MOD;
    return a;
}
//#############################################################################
//Solution
void solve(){
    ll n,k;
    cin>>n>>k;
    vec<vec<ll>> dp(n+1,vec<ll>(k+1,0LL));
    dp[0][0] = 1LL;
    vec<ll> arr(n);
    for(ll i = 0LL; i<n; i++){
        cin>>arr[i];
    }
    /*
        dp[i][j] = ways to distribute j candies among [1,i] kids    
    */
    for(ll i = 1LL; i<=n; i++){
        vec<ll> pre(all(dp[i-1]));
        for(ll j = 1LL; j<=k; j++){
            add_self(pre[j],pre[j-1]);
        }
        for(ll j = 0LL; j<=k; j++){
            ll pre_sum = sub_mod(pre[j],((j-min(arr[i-1LL],j)-1LL)>=0LL?
                pre[j-min(arr[i-1LL],j)-1LL]:0LL));
            add_self(dp[i][j],pre_sum);
        }
    }
    cout<<dp[n][k]<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
#ifdef LOCAL_TESTING
    cout << "⏰ Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
//#############################################################################


Measured memory_bytes: 80256
# input
X,Y,A,B,C = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)

#solve
d_list = a_list[:X] + b_list[:Y] + c_list
d_list.sort(reverse = True)
print(sum(d_list[:X+Y]))

Measured memory_bytes: 23340
#include <bits/stdc++.h>
using namespace std;
int n, m;

struct indata {
    int ina;
    int inb;
};

bool cmp(const indata &id1, const indata id2) {
    return id1.ina < id2.ina;
}

int main() {
    cin >> n >> m;
    vector<indata> abdata(n);
    for(int i = 0; i < n; ++i) {
        cin >> abdata.at(i).ina >> abdata.at(i).inb;
    }
    sort(abdata.begin(), abdata.end(), cmp);

    int sum = 0;
    int now = 0;
    priority_queue<int> que;
    for(int i = 1; i <= m; ++i) {
        while(now < n && abdata.at(now).ina <= i) {
            que.push(abdata.at(now).inb);
            now++;
        }
        if(!que.empty()) {
            sum += que.top();
            que.pop();
        }
    }

    cout << sum << endl;
}

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

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

    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (auto &s : A) cin >> s;

    vector<int> X, Y;
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if (A.at(y).at(x) == '#') {
                X.push_back(x);
                Y.push_back(y);
            }
        }
    }
    vector<int> TX = X, TY = Y;
    sort(TX.begin(), TX.end());
    sort(TY.begin(), TY.end());
    TX.erase(unique(TX.begin(), TX.end()), TX.end());
    TY.erase(unique(TY.begin(), TY.end()), TY.end());
    int R = TY.size();
    int C = TX.size();
    vector<vector<char> > B(R, vector<char>(C, '.'));
    for (int i = 0; i < X.size(); ++i) {
        int y = lower_bound(TY.begin(), TY.end(), Y.at(i)) - TY.begin();
        int x = lower_bound(TX.begin(), TX.end(), X.at(i)) - TX.begin();
        B.at(y).at(x) = '#';
    }

    for (auto &V : B) {
        for (auto &c : V) {
            cout << c;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;

vll factorize(ll n) {
    vll res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(0);
        while (n % i == 0) {
            n /= i;
            res.back()++;
        } 
    }
    if (n != 1) res.emplace_back(1);
    return res;
}
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll n,m,ans=1;
  cin>>n>>m;
  COMinit();
  vll mm=factorize(m);
  rep(i,0,SIZE(mm)){
    ans*=COM(n-1+mm[i],mm[i]);ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12160