akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>

#include <algorithm>
using std::max;
using std::min;

int countAB(char * s)
{
    int i,res=0;
    for(i=0;s[i+1];i++)
    {
        if(s[i]=='A' && s[i+1]=='B')
            res+=1;
    }
    return res;

}
int main(void)
{
    int i,N,tailA=0,headB=0,res,tailHeadAB=0;
    char msg[13];
    scanf("%d",&N);
    res=0;
    for(i=0;i<N;i++)
    {
        scanf("%s",msg);
        res+=countAB(msg);
        if(msg[strlen(msg)-1]=='A' && msg[0]=='B')
            tailHeadAB+=1;
        else{
           if(msg[0]=='B')
           {
               headB+=1;
           }
           else if(msg[strlen(msg)-1]=='A')
           {
               tailA+=1;
           }
        }
//        printf("%d\t%d\t%d\t%d\n",res,tailA,headB,tailHeadAB);
    }
    
    if(tailA>0)
    {
        tailHeadAB+=1;
        tailA-=1;
    }
    if(headB>0)
    {
        tailHeadAB+=1;
        headB-=1;
    }
    printf("%d\n",res+max(0,(tailHeadAB-1))+max(0,min(tailA,headB)));
    return 0;
}


Measured memory_bytes: 128
// 解説AC(予定)
//
// 気づくべきこと
// dist(s, i) + cost(i, j) = dist(s, j)のとき、edge(i, j)は最短経路に含まれる
// よって、各辺について、上式を満たす始点sが存在するかを調べればよい

#include <bits/stdc++.h>

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

struct Edge{
	int to;
	int cost;
	bool used;
};
vector<Edge> g[100];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		g[a].push_back({b, c, false});
		g[b].push_back({a, c, false});
	}

	vector<vector<int>> d(n, vector<int>(n, INF));
	for(int s = 0; s < n; ++s){
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
		d[s][s] = 0;
		que.push({int(0), s});
		
		while(!que.empty()){
			int c = que.top().first;
			int v = que.top().second;
			que.pop();
			
			for(auto && e : g[v]){
				if(d[s][e.to] > c + e.cost){
					d[s][e.to] = c + e.cost;
					que.push({d[s][e.to], e.to});
				}
			}
		}
	}
	
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		for(auto && e : g[i]){
			bool f = false;
			for(int s = 0; s < n; ++s){
				if(d[s][e.to] == d[s][i] + e.cost){
					f = true;
					break;
				}
			}
			if(!f)++cnt;
		}
	}
	cout << cnt / 2 << "\n";
	return 0;
}

Measured memory_bytes: 384
def listDivisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n = int(input())

divisors = listDivisors(n)

if len(divisors) % 2 == 1:
    a = divisors[-1]
    b = divisors[-1]
else :
    a = divisors[-1]
    b = divisors[-2]
    
answer = a + b - 2

print(answer)

    



Measured memory_bytes: 3272
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

const int N = 500;
int dp[N][N];

int main() {
  int n, A, B;
  scanf("%d%d%d", &n, &A, &B);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  int sumA = 0, sumB = 0;
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    sumA += a;
    sumB += b;
    for (int i = sumA; i >= a; --i) {
      for (int j = sumB; j >= b; --j) {
        if (dp[i - a][j - b] != INF && (dp[i - a][j - b] + c < dp[i][j] || dp[i][j] < 0)) {
          dp[i][j] = dp[i - a][j - b] + c;
        }
      }
    }
  }
  int ret = INF;
  for (int i = 0; i <= sumA; ++i) {
    for (int j = 0; j <= sumB; ++j) {
      if (i == 0 && j == 0) continue;
      if (i * B == j * A) {
        ret = min(ret, dp[i][j]);
      }
    }
  }
  if (ret == INF) ret = -1;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 1280
//g++  5.4.0

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

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

signed main()
{
    fast;
    int n;
    cin >> n;
    int h[n] , dp[n];
    for(int i=0 ; i<n ; i++ ) cin>>h[i];
    dp[0] = 0;
    dp[1] = abs( h[0]-h[1] );
    for(int i=2 ; i<n ; i++ )
        dp[i] = min( dp[i-2] + abs( h[i-2] - h[i] ) , dp[i-1] + abs( h[i-1]-h[i] ) );
    cout << dp[n-1];
}





Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define x first
#define y second
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
const ll m=1e9+7;
const ll N=1e6;
bool prime[N];
vector<int> p;
void sieve(int n)
{
	fill(prime, prime+n, true);
	for(int i=2;i<n;i++)
	{
		if(prime[i])p.pb(i);
		for(int j=0;j<p.size() and i*p[j]<n;j++)
		{
			prime[i*p[j]]=false;
			if(i%p[j]==0)break;
		}
	}
}
ll col(ll n)
{
	ll res=0;
	while(n>1)
	{
		if(n&1)
		n=3*n+1;
		else n=n>>1;
		res++;
		
	}
	return res;
}
ll modp(ll a, ll b)
{
	if(b==0)return 1;
	ll u=modp(a, b>>1);
	u=(u*u)%m;
	if(b&1)
	return (u*a)%m;
	return u;
}
int main()
{
   ll n;
cin>>n;
ll x[n];
//ll ans=0;
for(int i=0;i<n;i++){cin>>x[i];}
ll ans=INT_MAX;
for(int i=1;i<=100;i++)
{
	ll P=i;ll total=0;
	for(int j=0;j<n;j++)
	{
		ll s=(x[j]-P)*(x[j]-P);
		total+=s;
		
	}
	//ll net=abs(ans1-total);
	ans=min(ans,total);
	//ans1=min(ans,net);
}
cout<<ans;
	




}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll G = 0;
	ll X = 0;
	//double a[100000] = {};
	//double b[100000] = {};
	//ll v[100] = {};
	ll *p, *c, *d;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;

	
	//char p;
	cin >>A >> B;
	//cin >> D >> G;
	//vector<pair<float, float>> is(D);
	//sort(is.begin(), is.end());
	//p = (ll *)malloc(D * sizeof(ll));
	//c = (ll *)malloc(D * sizeof(ll));
	//d = (ll *)malloc(D * sizeof(ll));

	//rep(i, 0, D) {
	//	cin >> is[i].first >> is[i].second;
	//	//cin >> p[i] >>c[i];

	//	//d[i] = (p[i] + 1) * 100;
	//}
	



	cout << (A-1)*(B-1) << endl;

	//sort(l,l+N);


	return 0;

}



Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!{
        n: i32,
        a: i32,
        b: i32,
    }

    let sum = (1..(n + 1)).filter(|&i| {
                              let sum = get_digit_sum(i);
                              a <= sum && sum <= b
                          })
                          .sum::<i32>();
    println!("{}", sum);
}

fn get_digit_sum(n: i32) -> i32 {
    let mut n = n;
    let mut sum = 0;
    while n > 0 {
        sum += n % 10;
        n /= 10;
    };
    sum
}


Measured memory_bytes: 2156
import sys
from collections import Counter
from sys import stdin

n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip() for _ in range(n)]
c_data = Counter(data)
if len(c_data.keys()) < n:
    print('No')
    sys.exit()
for i, d in enumerate(data):
    if i == 0:
        continue
    if list(d)[0] != list(data[i-1])[-1]:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 3316
N = int(input())
a = list(map(int, input().split()))

ans = 100 * 100 * 100

for y in range(min(a), max(a) + 1):
        sum = 0
        for x in a:
            sum = sum + (x - y) * (x - y)
        if sum < ans:
            ans = sum

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans = 0;
  int tmp;
  for(int l=0;l<S.size();++l) {
    tmp = 0;
    for(int i=0;i+l<S.size();++i) {
      if(S[i]==S[i+l]) tmp++;
      else {
        ans = max(ans, min(l, tmp));
        tmp = 0;
      }
    }
    ans = max(ans, min(l, tmp));
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;


#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
#include <list>
list<char>theList;
const int maxn = 1e5 + 20;
char str[maxn];
void work() {
    scanf("%s", str + 1);
    int lenstr = strlen(str + 1);
    for (int i = 1; i <= lenstr; ++i) {
        theList.push_back(str[i]);
    }
//    for (list<char> :: iterator it = theList.begin(); it != theList.end(); ++it) {
//        cout << *it;
//    }
    int ans = 0;
    while (theList.size() > 2) {
        if (theList.size() == 3 && theList.front() == theList.back()) break;
        list<char> :: iterator itBegin = theList.begin();
        itBegin++;
        list<char> :: iterator itEnd = theList.end();
        itEnd--;
        list<char> :: iterator itBeginPre = theList.begin();
        list<char> :: iterator itBeginNext = itBegin; itBeginNext++;
        bool flag = false;
        while (itBegin != itEnd) {
            if (*itBeginPre == *itBeginNext) {
                itBeginPre++;
                itBegin++;
                itBeginNext++;
            } else {
                theList.erase(itBegin);
                flag = true;
                break;
            }
        }
        if (!flag) break;
        ans++;
    }
//    cout << ans << endl;
    if (ans & 1) {
        cout << "First" << endl;
    } else cout << "Second" << endl;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


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

struct UnionFind{
  int num;//連結成分の数
  vector<int> r,p;//そのグループのサイズ,自分の親っぽいやつ
  UnionFind(){}
  UnionFind(int n):num(n),r(n,1),p(n,0){iota(p.begin(),p.end(),0);}

  int find(int x){//どのグループに所属するか
    return (x==p[x]?x:p[x]=find(p[x]));//xがグループの名前と一致するまでxを親にする
  }

  bool same(int x,int y){//同じグループかどうか
    return find(x)==find(y);
  }

  void unite(int x,int y){//xとyを同じグループにする
    x=find(x);y=find(y);//xとyのグループの名前をどっちかが変える
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);//サイズが大きい方をxとする
    r[x]+=r[y];//yの親をxにする（今までyだったグループ名がxになる）
    p[y]=x;
    num--;
  }

  int size(int x){//グループの大きさ
    return r[find(x)];
  }

  int count() const{//グループの数
    return num;
  }
};

signed main(){
  int n,m;cin>>n>>m;
  vector<int> edge[n];
  UnionFind uf(n);
  while(m--){
    int u,v;cin>>u>>v;u--;v--;
    uf.unite(u,v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  vector<int> arr(n,-1);
  vector<int> ni,no,si;
  for(int i=0;i<n;i++){
    if(uf.size(i)==1){
      si.push_back(i);
      continue;
    }
    if(~arr[i])continue;
    arr[i]=0;
    bool out=false;
    queue<int> que;
    que.push(i);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:edge[p]){
        if(~arr[q]){
          if(arr[q]==arr[p])out=1;
        }
        else{
          arr[q]=arr[p]^1;
          que.push(q);
        }
      }
    }
    if(out)no.push_back(uf.size(i));
    else ni.push_back(uf.size(i));
  }
  int ans=0;
  int a=ni.size(),c=no.size(),e=si.size();
  ans=2*a*a+2*a*c+c*c+2*e*n-e*e;
  cout<<ans<<endl;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	RED,
	GREEN,
	WHITE,
};

struct Info{
	Info(Type arg_type,ll arg_value){
		type = arg_type;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{

		return value < arg.value; //価値の降順(PQ)
	}
	Type type;
	ll value;
};

int X,Y,A,B,C;

int main(){

	scanf("%d %d %d %d %d",&X,&Y,&A,&B,&C);

	priority_queue<Info> Q;

	ll tmp;
	for(int i = 0; i < A; i++){

		scanf("%lld",&tmp);
		Q.push(Info(RED,tmp));
	}
	for(int i = 0; i < B; i++){

		scanf("%lld",&tmp);
		Q.push(Info(GREEN,tmp));
	}
	for(int i = 0; i < C; i++){

		scanf("%lld",&tmp);
		Q.push(Info(WHITE,tmp));
	}

	ll ans = 0;
	int num_R = 0,num_G = 0,num_W = 0;

	while(!Q.empty()){

		switch(Q.top().type){
		case RED:
			if(num_R < X){
				ans += Q.top().value;
				num_R++;
			}
			break;
		case GREEN:
			if(num_G < Y){
				ans += Q.top().value;
				num_G++;
			}
			break;
		case WHITE:
			ans += Q.top().value;
			num_W++;
			break;
		}
		if(num_R+num_G+num_W == X+Y){
			break;
		}

		Q.pop();
	}

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

	return 0;
}


Measured memory_bytes: 10476
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

vector<int> graph[410];
#define min(a,b) a > b ? b : a
#define max(a,b) a > b ? a : b

int h,w;

int bfs(int i){
    queue<int> que;
    vector<bool> flag(400,false);
    vector<int> dis(400,1e9);
    dis[i] = 0;
    que.push(i);
    int M = 0;

    while(!que.empty()){
        int v = que.front();
        que.pop();
        if(flag[v]) continue;
        flag[v] = true;

        for(auto e : graph[v]){
            dis[e] = min(dis[e],dis[v]+1);
            M = max(M,dis[e]);
            if(!flag[e]) que.push(e);
        }
    }

    return M;
}

int main(){
    cin >> h >> w;
    vector<string> str(h);

    rep(i,h){
        cin >> str[i];
    }
int u,v;
    rep(i,h){
        rep(j,w){
            if(str[i][j] == '.'){
                u = i * w + j;
                if(i < h-1){
                    if(str[i+1][j] == '.'){
                        v = (i+1) * w + j;
                        graph[u].push_back(v);
                        graph[v].push_back(u);
                    }
                }
                if(j < w-1){
                    if(str[i][j+1] == '.'){
                        v = i * w + j + 1;
                        graph[u].push_back(v);
                        graph[v].push_back(u);
                    }
                }
            }
        }
    }
    
int ans = 0;
    rep(i,h){
        rep(j,w){
            int num = i * w + j;
            ans = max(ans,bfs(num));
        }
    }

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

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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

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

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}



int main()
{
    ll X,a,b,len=140;
    cin >>  X;

    ll pow5[len+1];

    rep(i,len+1){

        pow5[i]=i*i*i*i*i;
    }


    rep(i,len+1){
        rep(j,len+1){
            if( pow5[i]+pow5[j]==X){
                a=i;
                b=-1*j;
            }
            if(pow5[i]-pow5[j]==X){
                a=i;
                b=j;
            }
            
        }
    }

    cout << a << " " << b <<endl; 
 
    return 0;

}

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

int n,fou,sec,zer;

int main(){
	cin>>n;
	fou=sec=zer=0;
	for (int i=1;i<=n;i++){
		int k;
		cin>>k;
		if (k%4==0) fou++;
		else if (k%2==0) sec++;
		else zer++;
	}
	if (sec==0){
		if (fou>=zer-1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	else{
		if (fou>=zer) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>s;
    if(s[0]==s[Size(s)-1]){
        pos=Size(s)-2;
        if(pos%2==1)Cout("Second");
        else Cout("First");
    }
    else{
        pos=Size(s)-2;
        if(pos%2==1)Cout("First");
        else Cout("Second");
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int n,m,num = 0,a;
  cin >> n >> m;
  std::vector<int> K(n);
  int A[m];
  for (int i = 0; i < m; i++) {
    A[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> K[i];
    for (int j= 0; j < K[i]; j++) {
      cin >> a;
      A[a-1] += 1;
    }
  }
  for (int i = 0; i < m; i++) {
    if(A[i] == n) {
      num++;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N, manum=-1, minum=1000000000, ans = 0;
    int A[100]={};
    cin >> N;
    HAIRETU(N, A);
    for (int i = 0; i < N; i++) {
        manum = max(manum, A[i]);
        minum = min(minum, A[i]);
    }
    ans = manum - minum;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define print(x) cout<<x<<"\n"
#define For(i,start,end) for(int i=start;i<end;i++)
#define cases() int tc;scanf("%d",&tc);For(sc,1,tc+1)
#define pb push_back
#define fastaf ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sorta(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<int>())

int n,m;
int deg[100005];
int dp[100005];
queue<int> q;

int t_sort(vector<int> arr[]){
	int ans=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		For(i,0,arr[curr].size()){
			int child=arr[curr][i];
			deg[child]--;
			dp[child]=max(dp[child],dp[curr]+1);
			ans=max(ans,dp[child]);
			if(deg[child]==0) q.push(child);
		}
	}
	return ans;
}

int main(){
fastaf;
#ifndef ONLINE_JUDGE
freopen("C:/Users/vnagp/Documents/I_O/input.txt", "r", stdin);
freopen("C:/Users/vnagp/Documents/I_O/output.txt", "w", stdout);
#endif

cin>>n>>m;
vector<int> arr[n+1];
memset(deg,0,sizeof(deg));
memset(dp,0,sizeof(deg));

For(i,0,m){
	int u,v;
	cin>>u>>v;
	arr[u].pb(v);
	deg[v]++;
}

For(i,1,n+1) if(deg[i]==0) q.push(i);
print(t_sort(arr));

return 0;
}

Measured memory_bytes: 9820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string S;
	cin >> S;
	vector<int> sum(n);
	int cnt_migi = 0;
	int cnt_hidari = 0;
	rep(i, n) {
		if (S[i] == 'E') cnt_migi++;
	}

	int ans = 1000000007;
	rep(i, n) {
		if (S[i] == 'E') cnt_migi--;
		ans = min(ans, cnt_migi + cnt_hidari);
		if (S[i] == 'W') cnt_hidari++;
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 1812
def resolve():
    a, b, c, x, y = list(map(int, input().split()))
    p1 = a * x + b * y
    p2 = y * 2 * c + abs(x - y) * a
    p3 = x * 2 * c + abs(y - x) * b
    p4 = max(x, y) * 2 * c
    print(min(p1, p2, p3, p4))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 38384
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
darr = []
for i in range(len(X) - 1):
    darr.append(X[i + 1] - X[i])

darr.sort(reverse=True)
ans = sum(darr[min(N-1, len(darr)):])
print(ans)

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

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

	long long s = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) {
			s += i;
		}
	}

	cout << s;
	
	return 0;
}
	

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	string S;
	cin >> S;
	vector< int > A, B;
	M = 0;
	int l = 1, c = 0;
	rep(i, N + 1) {
		if (i < N && l == S[i] - '0') {
			c++;
		} else {
			if (l == 0) {
				B.push_back(c);
			} else {
				A.push_back(c);
			}
			c = 1;
			if (i < N)
				l = S[i] - '0';
			else if (l == 0)
				A.push_back(0);
		}
	}
	//cout << A << B;
	M = A.size();
	int ans = A[0], tmp = A[0];
	rep(i, M - 1) {
		tmp += A[i + 1];
		tmp += B[i];
		chmax(ans, tmp);
		if (i >= K - 1) {
			tmp -= A[i + 1 - K];
			tmp -= B[i + 1 - K];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1404
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	var count, m, pre int
	for i := 0; i < N; i++ {
		if i > 0 {
			count += pre / 2
			pre = pre % 2
			m = min(pre, A[i])
			count += m
		}
		pre = A[i] - m
	}
	count += pre / 2

	fmt.Println(count)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}


Measured memory_bytes: 3072
#include<iostream>

using namespace std;

int main(){
    long a,b,c,d;
    long long v,x,y,z;

    cin >> a >> b >> c >>d;

    v = a*c;
    x = a*d;
    y = b*c;
    z = b*d;

    x = max(v,x);
    y = max(y,z);
    x = max(x,y);

    cout << x << endl;

    return 0;

}

Measured memory_bytes: 3632
import java.util.Scanner;


public class Main {
    public static void main(String[] args)throws Exception{

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        int hm = h*60 + m;

        System.out.println(Math.sqrt((double)a*a + (double)b*b - 2.0*a*b*Math.cos(Math.toRadians((double)hm/(12.0*60.0)*360.0 - (double)m/60.0*360.0))));
    }
}

Measured memory_bytes: 35968
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll a, b; cin >> a >> b;
    cout << Yes(a * b % 2) << endl;
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, M, K, A[200001], B[200001];
    cin >> N >> M >> K;
    REP(i, N) cin >> A[i + 1];
    REP(i, N) A[i + 1] += A[i];
    REP(i, M) cin >> B[i + 1];
    REP(i, M) B[i + 1] += B[i];

    ll ans = 0;
    REP(i, N + 1) {
        if (A[i] > K) break;
        ll count = upper_bound(B, B + M + 1, K - A[i]) - B - 1;
        ans = max(ans, count + i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,T;
    cin >>A>>B>>T;


    
    cout << B*(T/A) << endl;


    return 0;
    

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

  ll N,K,A;
  cin>>N>>K>>A;
  ll p=A*mod_pow(100,mod-2)%mod;
  p*=mod_pow(N,mod-2);
  p%=mod;
  vector<ll> dp(K,0);
  dp[0]=1;
  ll sum=1;
  repl(i,1,K){
    if(i-(N+1)>=0){
      sum=(sum-dp[i-(N+1)]+mod)%mod;
    }
    dp[i]=sum*p%mod;
    sum+=dp[i]; sum%=mod;
  }
  ll res=0;
  rep(i,K){
    ll y=max(0LL,N-K+i+1);
    ll q=mod_pow(N,mod-2)*y%mod;
    (res+=dp[i]*q%mod)%=mod;
  }
  cout<<res<<endl;

  return 0;
}



Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, K = map(int, input().split(" "))
	A = list(map(int, input().split(" ")))
	
	if K >= N:
		print(1)
		sys.exit()
		
	K -= 1
	tmp = 0
	if K != 1:
		if N % K == 0:
			tmp = N // K
		else:
			tmp = N // K
			tmptmp = N - (tmp * K)
			if tmptmp != 1:
				tmp += 1
	else:
		tmp = (N // K) -1
	
	print(tmp)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 23864
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int K = 26;

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

    int d;
    cin >> d;
    vector<int> c(K);
    for (int i = 0; i < K; ++i) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(K));
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < K; ++j) {
            cin >> s[i][j];
        }
    }
    vector<int> ans;
    vector<int> last(26, -1);
    for (int i = 0; i < d; ++i) {
        vector<double> x;
        for (int j = 0; j < K; ++j) {
            x.push_back((double) s[i][j] * s[i][j] * s[i][j] * sqrt(c[j] * (i - last[j])));
        }

        double sum = 0;
        for (int j = 0; j < K; ++j) {
            sum += x[j];
        }
        for (int j = 0; j < K; ++j) {
            x[j] /= sum;
        }

        double prob = (double) (rand() % RAND_MAX) / (double) RAND_MAX;
        double cur = 0;
        for (int j = 0; j < K; ++j) {
            if (cur + x[j] <= prob) {
                cur += x[j];
                continue;
            }
            ans.push_back(j);
            last[j] = i;
            break;
        }
    }

    for (auto u : ans) {
        cout << u + 1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N,A,B,C;
    cin >> N >> A >> B >> C;
    int l[N];
    for(int i = 0;i<N;i++){
        cin >> l[i];
    }  
    int k[N];
    long long e;
    int p = 0;
    int pp = 0;
    int f = 0;
    int g = 0;
    int tem = 5000000;
    bool flag = true;
    for(long long i = 0;i<pow(4,N);i++){
        e = i;
        for(int j = 0;j<N;j++){
            k[j] = e % 4;
            if(k[j] != 0){
                p = p + 1;
            }
            e = e / 4;
        }
        for(int z = 0;z<N;z++){
            if(k[z] == 1){
                f = f + l[z];
                pp++;
            }
        }
        if(pp >= 1){
        g = g + abs(f - A) + 10*(pp - 1); 
        }
        else{
            flag = false;
        }
        //cout << f << endl;
        f = 0;
        pp = 0;
        for(int z = 0;z<N;z++){
            if(k[z] == 2){
                f = f + l[z];
                pp++;
            }
        }
        if(pp >= 1){
        g = g + abs(f - B) + 10*(pp - 1); 
        }
        else{
            flag = false;
        }
        f = 0;
        pp = 0;
        for(int z = 0;z<N;z++){
            if(k[z] == 3){
                f = f + l[z];
                pp++;
            }
        }
        if(pp >= 1){
        g = g + abs(f - C) + 10*(pp - 1); 
        }
        else{
            flag = false;
        }
        f = 0;
        pp = 0;
        if(p < 3){
            flag = false;
        }
        if(flag == true){
            if(g < tem){
                tem = g;
                //cout << tem << endl;
            }
        }
        g = 0;
        flag = true;
        p = 0;
    }
    cout << tem << endl;
}

Measured memory_bytes: 256
var a: array[1..1000] of longint;
    dp, p: array[-10..150, -110000..200000] of longint;    
    i, j, N, K: longint;
begin
    readln(N, K);
    for i:=1 to N do
        read(a[i]);
    for i:=0 to a[1] do
    begin
        dp[1,i]:=1;
    end;
    for i:=0 to K do
        p[1,i]:=p[1,i-1]+dp[1,i];
    for i:=2 to N do
    begin
        for j:=0 to K do
        begin
            dp[i,j]:=(p[i-1,j]-p[i-1,j-a[i]-1]) mod 1000000007;
            if dp[i,j]<0 then
                dp[i,j]:=dp[i,j]+1000000007;
            p[i,j]:=(p[i,j-1]+dp[i,j]) mod 1000000007;
//            write(dp[i,j], ' ');
        end;
//        writeln;
    end;
    writeln(dp[N,K]);
end.


Measured memory_bytes: 245888
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int G = 2e5+5;
ll a;
vec<ll> h, c;
ll BIT[G];

ll pref_mx(int p){
    ll o = 0;
    for(; p>0; p -= p&-p) o = max(o, BIT[p]);
    return o;
}

void upd(int p, ll val){
    for(; p<G; p += p&-p) BIT[p] = max(BIT[p], val);
}

int main() {
    fast;
    memset(BIT, 0, sizeof(BIT));
    cin>>a;
    h = vec<ll>(a);
    c = vec<ll>(a);
    for(int q=0; q<a; q++) cin>>h[q];
    for(int q=0; q<a; q++) cin>>c[q];
    vec<ll> dp(a);
    for(int q=0; q<a; q++){
        dp[q] = c[q] + pref_mx(h[q]);
        upd(h[q], dp[q]);
    }
    ll o = 0;
    for(ll i : dp) o = max(o, i);
    cout<<o;
}

Measured memory_bytes: 6656
import sys
input = sys.stdin.readline

def main():
    while True:
        n,m,t,p = map(int,input().split())
        if [n,m,t,p] == [0,0,0,0]:
            exit()
        dp = [[0]*(m*m+1) for i in range(n*n+1)]
        
        
        sx = 0
        sy = 0
        ex = n
        ey = m

        
        for i in range(n):
            for j in range(m):
                dp[sx+i][sy+j] = 1
        
        for i in range(t):
            d,c = map(int,input().split())
            if d == 1:
                for k in range(c):
                    for j in range(sy,ey):
                        dp[sx+c+k][j] += dp[sx+c-k-1][j]
                sx += c
                ex = max(ex,sx+c)
            else:
                for k in range(c):
                    for j in range(sx,ex):
                        dp[j][sy+c+k] += dp[j][sy+c-k-1]
                sy += c
                ey = max(ey,sy+c)
        res = 0
        for i in range(p):
            x,y = map(int,input().split())
            res = dp[sx+x][sy+y]
            print(res)
            
            
main()


Measured memory_bytes: 15768
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(2 ** 3):
    lst = [0] * N
    for j in range(3):
        if (i >> j) & 1:
            for k in range(N):
                lst[k] += xyz[k][j]
        else:
            for k in range(N):
                lst[k] -= xyz[k][j]
    lst.sort(reverse = True)
    ans = max(ans, sum(lst[:M]))

print (ans) 



Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <map>
#include <vector>
#include <cmath>
#include <string> // これがないとstringの出力がエラー
#include <sstream>
#include <algorithm>
#include <bitset>
#include <list>
using namespace std;

void pA()
{
	string str; cin >> str;
	cout << str.substr(0, str.size() - 8) << endl;
}

void pB()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << A * 1728 + B * 144 + C * 12 + D << endl;
}

unsigned bit_count(unsigned n)
{
	unsigned i = 0;

	while (n) {
		i += n & 1;
		n >>= 1;
	}

	return i;
}

void pC()
{
	int N, C; cin >> N >> C;
	list<int> stick;
	for (int i = 0; i < N; ++i) {
		int in;
		cin >> in;
		stick.push_back(in);
	}

	stick.sort();

	int Cnum = 0;
	auto itr = stick.rbegin();
	while (true) {
		int value = *itr;
		int plus = 0;
		for (auto i = stick.begin(); i != stick.end(); ++i) {
			if (*i + value < C && plus != *i)
				plus = *i;
			else {
				auto deli = i; 
				if (deli != stick.begin()) {
					deli--;
					//cout << "delete " << *deli << endl;
					i = stick.erase(deli);
					//cout << "next " << *i << endl;
				}
				break;
			}
		}

		Cnum++;
		stick.erase(--(itr.base()));
		if (itr == stick.rend() || stick.size() == 0)
			break;
	}

	cout << Cnum << endl;
}

int main()
{
	pA();

	return 0;
}

Measured memory_bytes: 256
while True:
    mid, fin, ree = map(int, input().split())
    if mid == -1 and fin == -1 and ree == -1:
        break
    if mid == -1 or fin == -1:
        print('F')
        continue
    score = mid + fin
    if   score >= 80:
        print('A')
    elif score >= 65:
        print('B')
    elif score >= 50:
        print('C')
    elif score >= 30:
        if ree >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

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

	ll a=2,b=1;
	string s;
	cin >> s;
	ll l = s.size();

	FOR(i,1,l){
		if(s[i]=='0')b*=3;
		else{
			b = b*3+a;
			a *= 2;
		}
		a %= MOD;
		b %= MOD;
	}
	cout << (a+b) % MOD << endl;

	
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b>=c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    if(a+b+1!=s.size()){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<a+b+1;i++){
        if(i==a){
            if(s[i]!='-'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            if(!('0'<=s[i]&&s[i]<='9')){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;cin>>n>>a>>b;
  string s;cin>>s;
  int sa=0,sb=0;
  for(int i=0;i<n;i++){
    if(s[i]=='a'){
      if(sa+sb<a+b){
        sa++;
        cout<<"Yes"<<endl;
        continue;
      }
    }
    else if(s[i]=='b'){
      if(sa+sb<a+b&&sb<b){
        sb++;
        cout<<"Yes"<<endl;
        continue;
      }
    }
    cout<<"No"<<endl;
  }
}
    
        


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <chrono>

using namespace std;

int main() {
	long long H, N;

	cin >> H >> N;

	long long sum = 0;
	for(int i=0;i<N;i++){
		long long a;
		cin >> a;
		sum += a;
	}

	if( sum >= H ){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}



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

using namespace std;

const int R = 1e9 + 7; string s; int n, p; long long dp[ 2 ][ 4 ];

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr ), cin >> s, n = s.size(), dp[ 0 ][ 3 ] = 1;

    for( int i = n, j = n - 1, q = 1; i > 0; i = j--, p = q, q = 1 - p )
        for( int k = 4, l = 3; k > 0; k = l-- )
        {
            auto &x = dp[ q ][ l ];  x = dp[ p ][ l ]; auto &y = s[ j ];

            if ( y == '?' )
                x *= 3, x %= R;

            if( k < 4 and ( y == '?' or ( y - 'A' ) == l ) )
                x += dp[ p ][ k ], x %= R;
        }

    cout << dp[ p ][ 0 ];
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#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++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;

int main() {
    char s;
    cin >> s;
    if (s <= 'Z') {
        cout << "A" << endl;
        return 0;
    }
    else {
        cout << "a" << endl;
        return 0;
    }
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(void){
  int a;
  scanf("%d",&a);
  for(int i = 1;i <= 9;i++){
    for(int j = 1;j <= 9;j++){
      if(a == i * j){
	printf("Yes");
	return 0;
      }
    }
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 128
num,total=[int(str) for str in input().split()]

nums_result=[-1,-1,-1]

for i in range(num+1):
    for j in range(num+1-i):
        k=num-(i+j)
        if total==10000*i+5000*j+1000*k:
            nums_result=[i,j,k]

print("{} {} {}".format(nums_result[0],nums_result[1],nums_result[2]))

Measured memory_bytes: 40812
#include <cstdio>
#pragma warning(disable : 4996)
int N, Q, X[200009], D[200009], L[200009]; long long bit[2][262156];
void add(int t, int p, int x) {
	for (int i = p + 1; i <= 262144; i += i & (-i)) {
		bit[t][i] += x;
	}
}
long long sum(int t, int p) {
	long long ret = 0;
	for (int i = p; i >= 1; i -= i & (-i)) {
		ret += bit[t][i];
	}
	return ret;
}
int bs(int t, long long x) {
	if (x <= 0) return 0;
	int cur = 0;
	for (int i = 17; i >= 0; i--) {
		if (bit[t][cur + (1 << i)] < x) {
			cur += 1 << i;
			x -= bit[t][cur];
		}
	}
	return cur + 1;
}
int main() {
	scanf("%d %d", &N, &Q);
	for (int i = 0; i < Q; i++) scanf("%d %d %d", &X[i], &D[i], &L[i]);
	for (int i = 1; i < N; i++) add(0, i, 1), add(1, i, 1);
	long long cs = 0, ct = 0;
	for (int i = Q - 1; i >= 0; i--) {
		if (D[i] == 1) {
			int pr = bs(0, X[i] + ct) - 1;
			if(pr != -1) add(1, pr, 2 * L[i]);
			else cs -= 2 * L[i];
			cs += 2 * L[i];
		}
		else {
			int pr = bs(1, X[i] + cs) - 1;
			if(pr != -1) add(0, pr, 2 * L[i]);
			else ct -= 2 * L[i];
		}
	}
	for (int i = 0; i < N; i++) {
		long long px = sum(0, i + 1), py = sum(1, i + 1);
		printf("%lld\n", (px - py + cs - ct) / 2);
	}
	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int w,a,b;

    Scd3(w,a,b);

    int leng = abs(a-b);

    leng -= w;

    if( leng < 0 ) leng = 0;

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

    return 0;
}



Measured memory_bytes: 256
<?php
$S = str_split(trim(fgets(STDIN)));
$count = count($S);

if($count == 1){
echo $S[0] . PHP_EOL ;
}else{
for($i = 0;$i < $count;$i++){
$copy = $S;
$n = $count - 1 - $i;
$copy[$n] *= 2;
$sum = array_sum($copy);
$pow = pow(2,$n - 1);
$rank = pow(10,$i);
$all[$i] = $sum * $pow * $rank;
unset($S[$n]);
}
echo array_sum($all) . PHP_EOL ;
}

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

int main()
{
    int n, val;
    long min = 1000000, max = -1000000, sum = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> val;
        if (val < min)
            min = val;
        if (val > max)
            max = val;
        sum += val;
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3088