akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

int main()
{
    string s;
    int flag=0;
    int now=0;
    cin>>s;
    int lngth=s.length();

    if(lngth<=3)
    {
        for(int i=0; i<lngth; i++)
        {
            if(s[i]=='R')
            {
                flag++;
            }
            else
            {
                flag=0;
            }
           now=max((now),(flag));
        }
        cout<<now<<endl;
    }
    else
        return 0;
}


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

namespace AtCoder_ABC089_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            int x = int.Parse(s[3]);
            int y = int.Parse(s[4]);


            int tmpSum = a * x + b * y;

            int tmpSum2 = 0;
            int tmpSum3 = 0;

            if (x > y)
            {
                tmpSum2 = c * y * 2 + a * (x - y);
                tmpSum3 = c * x * 2;
            }
            else
            {
                tmpSum2 = c * x * 2 + b * (y - x);
                tmpSum3 = c * y * 2;
            }

            if (tmpSum > tmpSum2)
            {
                tmpSum = tmpSum2;
            }
            if (tmpSum > tmpSum3)
            {
                tmpSum = tmpSum3;
            }

            Console.WriteLine(tmpSum);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n, x, count;
    
    while(true){
        count = 0;
        cin >> n >> x;
        if(n == 0 and x == 0) break;
        
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if(i + j + k == x) count++;
                }
            }
        }
        std::cout << count << std::endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int,int>;
const int INF = 1e18;
const int MOD = 1e9+7;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

signed main(){
    string s,t;
    cin >> s >> t;

    map<char,char> mp;

    for(int i=0;i<s.size();i++){
        if(!mp.count(t[i])){ mp[t[i]] = s[i];}
        else if(mp[t[i]] != s[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    mp.clear();

    for(int i=0;i<s.size();i++){
        if(!mp.count(s[i])){ mp[s[i]] = t[i];}
        else if(mp[s[i]] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 776
A, B, C = gets.split.map(&:to_i).sort
even_group = [A, B, C].select{|i| i%2==0}
odd_group = [A, B, C].select{|i| i%2==1}
if even_group.length == 1
  odd_group[0] += 1
  odd_group[1] += 1
  a, b, c = even_group.concat(odd_group).sort
  puts (c-a)/2 + (c-b)/2 + 1
elsif even_group.length == 2
  even_group[0] += 1
  even_group[1] += 1
  a, b, c = even_group.concat(odd_group).sort
  puts (c-a)/2 + (c-b)/2 + 1
else
  puts (C-A)/2 + (C-B)/2
end

Measured memory_bytes: 1788
from scipy.sparse.csgraph import dijkstra
n=int(input())
g=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
d1=[-1]*n
d2=[-1]*n
q1=[0]
d1[0]=0
while q1:
  x=q1.pop()
  for t in g[x]:
    if d1[t]==-1:
      d1[t]=d1[x]+1
      q1.append(t)
q2=[n-1]
d2[n-1]=0
while q2:
  x=q2.pop()
  for t in g[x]:
    if d2[t]==-1:
      d2[t]=d2[x]+1
      q2.append(t)
cnt=0
for i in range(n):
  if d1[i]<=d2[i]:
    cnt+=1
if cnt>n//2:
  print('Fennec')
else:
  print('Snuke')

Measured memory_bytes: 39676
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#define ini ll_MAX
#define inl LLONG_MAX
#define MOD 1000000007
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define pbds tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
 
ll mod(ll a,ll b)
{
    return (b+a%b)%b;
}
 
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
 
double sqdist(double a,double b,double c,double d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}
ll fact(ll n)
{
    if(n==0)return 1;
    ll ans = 1;
    FOR(i,1,n+1)ans*=i;
    return ans;
}
 


void solve()
{
    int n,m;
    cin>>n>>m;
    vector<int> arr[n+1];
    vector<int> visited(n+1,0),dist(n+1,0);
    while(m--)
    {
        int a,b;cin>>a>>b;
        arr[a].pb(b);
        arr[b].pb(a);
    }
    queue<int> q;
    q.push(1);dist[1]=0;visited[1]=1;int c=5;n--;

    while(!q.empty())
    {
        // if(!c--)break;
        int curr = q.front();
        q.pop();
        
        // cout<<n<<' '<<curr<<endl;
        n--;
        for(auto i:arr[curr])
        {
            if(!visited[i])
            {
                q.push(i);
                visited[i]++;
                dist[i]= curr;
            }
        }
    }    
    // for(auto i:visited)cout<<i<<' ';cout<<endl;
    // for(auto i:dist)cout<<i<<' ';cout<<endl;
    if(n>0){cout<<"No";return;}
    cout<<"Yes"<<endl;
    for(int i=2;i<dist.size();i++)
        cout<<dist[i]<<endl;

}   
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();
}

Measured memory_bytes: 10724
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
 
void setIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line

int main(){
    setIO();
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; ++i){
        if(i % d == 0) ++ans;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
using namespace std;
#define int long long

int n, m;

bool check(int k) {
	return (max(0LL, k - n) + k) * 2 <= m;
}

signed main() {
	cin >> n >> m;
	
	int st = 0, ed = 10000000000000, mid;	//[st, ed)
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (check(mid)) { st = mid; }
		else { ed = mid; }
	}
	cout << st << endl;
	return 0;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
e = 0
o = 0
ans = 1
for i in a:
    if i%2==0:
        e += 1
    else:
        o += 1
if o==3 or e==3:
    ans = 0
elif e > o:
    for i in range(3):
        if a[i]%2==0:
            a[i] += 1
else:
    for i in range(3):
        if a[i]%2==1:
            a[i] += 1
a = sorted(a,reverse=True)
ans += (a[0]-a[1])//2 + (a[0]-a[2])//2
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int r,p,s;
int score(char x){
    if (x == 'r') return p;
    else if (x == 'p') return s;
    else return r;
}
int main(){
    int n,k;
    scanf("%d%d%d%d%d",&n,&k,&r,&s,&p);
    string t;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (i >= k && t[i] == t[i-k]){
            t[i] = '?';
        }
        else{
            ans += score(t[i]);
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

string f[50];
int maxX[26], maxY[26], minX[26], minY[26];
bool on[26][26];

void check() {
	memset(on, 0, sizeof on);
	for(int i = 0; i < 26; i++) {
		if(maxX[i] == -1) continue;
		for(int y = minY[i]; y <= maxY[i]; y++) {
			for(int x = minX[i]; x <= maxX[i]; x++) {
				if(f[y][x] == '.') {
					cout << "SUSPICIOUS" << endl;
					return;
				}
				if(f[y][x] != 'A' + i) {
					on[i][f[y][x] - 'A'] = true;
				}
			}
		}
	}

	for(int k = 0; k < 26; k++) {
		for(int i = 0; i < 26; i++) {
			for(int j = 0; j < 26; j++) {
				on[i][j] |= on[i][k] & on[k][j];
			}
		}
	}

	for(int i = 0; i < 26; i++) {
		for(int j = 0; j < 26; j++) {
			if(on[i][j] && on[j][i]) {
				cout << "SUSPICIOUS" << endl;
				return;
			}
		}
	}
	cout << "SAFE" << endl;
}

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

	int T, H, W;
	cin >> T;
	while(T--) {
		cin >> H >> W;
		for(int i = 0; i < H; i++) {
			cin >> f[i];
		}

		for(int i = 0; i < 26; i++) {
			maxX[i] = maxY[i] = -1;
			minX[i] = minY[i] = 100000;
		}

		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				if(f[y][x] == '.') continue;
				int c = f[y][x] - 'A';
				maxX[c] = max(maxX[c], x);
				maxY[c] = max(maxY[c], y);
				minX[c] = min(minX[c], x);
				minY[c] = min(minY[c], y);
			}
		}

		check();
	}
}

Measured memory_bytes: 3212
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, k, i, ans = 0;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for(i = 0; i < n; i++) {
    	cin >> a[i];
    }
    for(i = 0; i < m; i++) {
    	cin >> b[i];
    }
    for(i = 1; i < n; i++) {
    	a[i] = a[i] + a[i-1];
    }
    for(i = 1; i < m; i++) {
    	b[i] = b[i] + b[i-1];
    }
    for(i = 0; i < n; i++) {
    	if(a[i] > k) {
    		break;
    	}
    	ll read = i + 1;
    	ll rem = k - a[i];
    	ll ind = upper_bound(all(b), rem)- b.begin();
    	if(ind > 0) {
    		ind--;
    	}
    	if(ind != m && b[ind] <= rem) {
    		read = read + ind + 1;
    	}
		ans = max(ans, read);
    }
    for(i = 0; i < m; i++) {
    	if(b[i] <= k) {
    		ans = max(ans, i + 1);
    	}
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6368
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
    int key;
    Node *next, *prev; //Node型のポインタ変数を宣言
};

Node *nil; //番兵の宣言

Node* listSearch(int key){
    Node *cur = nil->next; //番兵の次の要素から辿る
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

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

void deleteNode(Node *t){
    if(t == nil) return; //tが番兵の場合は処理しない
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

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

void deleteKey(int key){
    //検索したノードを削除
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    //番兵の直後に要素を追加
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

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

    printList();

    return 0;
}


Measured memory_bytes: 33848
#include <iostream>

using namespace std;

int main()
{
	int n, s, t, x, y, p, q, u, v;
	
	cin >> n;
	while(n--){
		x = y = p = q = u = 0;
		while(1){
			cin >> s >> t;
			if(s == 0 && t == 0){
				break;
			}
			x += s;
			y += t;
			v = x*x+y*y;
			if((v > u) || (u == v && x > p)){
				p = x;
				q = y;
				u = v;
			}
		}
		cout << p << " " << q << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>
#include <sstream>

using namespace std;

class arc090_d {
private:
    bool dfs(const int u, const vector<vector<pair<int, int>>>& g, vector<int>& x) {
        for (const auto &p : g[u]) {
            int v = p.first, d = p.second;
            if (x[v] == -1) {
                x[v] = x[u] + d;
                if (!dfs(v, g, x)) {
                    return false;
                }
            } else if (x[v] != x[u] + d) {
                return false;
            }
        }
        return true;
    }
public:
    void solve(istream& in, ostream& out) {
        int N, M;
        in >> N >> M;
        vector<tuple<int, int, int>> lrd(M);
        vector<int> L(M), R(M), D(M);
        vector<vector<pair<int, int>>> g(N);
        for (int i = 0; i < M; ++i) {
            in >> L[i] >> R[i] >> D[i];
            lrd[i] = make_tuple(L[i], R[i], D[i]);
            g[L[i] - 1].emplace_back(R[i] - 1, D[i]);
            g[R[i] - 1].emplace_back(L[i] - 1, -D[i]);
        }
        vector<int> x(N, -1);
        constexpr int MID = 100'000'000;
        for (int u = 0; u < N; ++u) {
            if (x[u] == -1) {
                x[u] = MID;
                if (!dfs(u, g, x)) {
                    out << "No\n";
                    return;
                }
            }
        }
        out << "Yes\n";
    }
};


int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc090_d solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool compare_by_a(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    else return a.second<b.second;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> l(m),r(m);
    rep(i,m) cin>>l[i]>>r[i];
    sort(ALL(l));
    sort(ALL(r));
    if(r[0]-l[m-1]>=0) cout<<r[0]-l[m-1]+1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;

struct Vec{
	int ind;
	int val;
};

bool valDesc( const Vec& left, const Vec& right ) {
    return left.val == right.val  ? left.val> right.val: left.val > right.val;
}

bool valAsc( const Vec& left, const Vec& right ) {
    return left.val == right.val  ? left.val <  right.val: left.val < right.val;
}

int main(void){
	int N,a,b;
	long ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++){
		scanf("%d", &a);
		ans+=long(a-1);
	}
	printf("%ld\n",ans);
	fflush(stdout);

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val k = sc.nextLong()
    println(problem156b(n, k))
}

fun problem156b(n: Long, k: Long): Int {
    var n = n
    var num = ""
    while (n != 0L) {
        num = (n % k).toString() + num
        n /= k
    }
    return num.length
}

Measured memory_bytes: 31132
#include <stdio.h>
int main(){
  long long n,a,b,c,d;
  scanf("%lld %lld %lld",&n,&a,&b);
  c=n/(a+b);
  d=c*(a+b);
  if(n-d<a){
    printf("%lld",c*a+(n-d));
  }else{
    printf("%lld",(c+1)*a);
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<math.h>
#include<stdio.h>


int main()
{
	std::string n, k;
	std::cin >> n >> k;
	int kosuu = 0;
	for (int i = 0; i < n.size(); i++) {
		if (n[i] != k[i])
		{
			kosuu++;
		}
	}std::cout << kosuu << std::endl;
}

Measured memory_bytes: 3888
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
ll n, k, mx;
vector<ll> a(100005), b(100005);
ll calc(ll x) {
  ll i, j, ret = 0;
  for(i=0;i<n;i++) {
    for(j=0;j<=30;j++) if(!(x & (1<<j)) && (a[i] & (1 << j))) break;
    if(j>30) ret += b[i];
  }
  return ret;
}
int main() {
  ll t;
  cin >> n >> k;
  for(ll i=0;i<n;i++) cin >> a[i] >> b[i];
  mx = calc(k);
  for(ll i=0;i<=30;i++) {
    if(!(k & (1 << i))) continue;
    t = k;
    for(ll j=0;j<i;j++) t|= 1<<j;
    t ^= 1<<i;
    mx = max<ll>(mx, calc(t));
  }
  cout << mx << endl;
}


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

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  deque<int> d;
  for (int i = 0; i < n; i++) {
    int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
    // cout << "p:" << p << endl;
    if (p == 0) {
      d.push_front(a[i]);
    } else {
      d[p - 1] = a[i];
    }
    // for (int i = 0; i < d.size(); i++) {
    //   cout << d[i] << " ";
    // }
    // cout << endl;
  }
  cout << d.size() << endl;
  return 0;
}

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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  ll ans = 0, sum = 0;
  rep(i, 0, n) {
    cin >> a[i];
    sum += a[i];
  }
  rep(i, 0, n) {
    double t = (double)sum / (4 * m);
    if (a[i] >= t) {
      ans++;
    }
  }
  if (ans >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>

using namespace std;
int main(){
    char S[4];
    cin >> S;
    if(!strncmp(S,"AAA",4)){
        cout << "No" <<endl;
    }
    else{
        if(!strncmp(S,"BBB",4)){
        cout << "No" << endl;
        }
        else{
        cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 256
const maxn = 100050;
var n,i,now,ans:longint;
    st:ansistring;
    f:array[0..maxn] of longint;
begin
  readln(st); n:=length(st); now:=0; ans:=0;
  for i:=1 to n do begin
    if st[i]='g' then begin
      if (now+1)<=(i>>1) then begin inc(now); inc(ans); end;
      continue;
    end;
    if (now+1)<=(i>>1) then inc(now) else dec(ans);
  end;
  writeln(ans); 
end.


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))


def solve(a):
    min_a = min([elem for elem in a if elem != 0])
    new_a = [elem % min_a for elem in a]
    if len([elem for elem in new_a if elem == 0]) == len(a):
        return min_a
    new_a[new_a.index(0)] = min_a
    return solve(new_a)


print(solve(A))


Measured memory_bytes: 14224
h, w = map(int, input().split())
a = []
for i in range(h):
  a.append(list(map(lambda x:int(x)%2,input().split())))
  
ans = []
for i in range(h):
  if i%2==0:
    for j in range(w):
      if a[i][j]==1:
        if j==w-1 and i==h-1:
          pass
        elif j==w-1:
          ans.append(' '.join(map(str,[i+1,j+1,i+2,j+1])))
          a[i+1][j]=(a[i+1][j]+1)%2
        else:
          ans.append(' '.join(map(str,[i+1,j+1,i+1,j+2])))
          a[i][j+1]=(a[i][j+1]+1)%2
  else:
    for j in range(w-1, -1, -1):
      if a[i][j]==1:
        if j==0 and i==h-1:
          pass
        elif j==0:
          ans.append(' '.join(map(str,[i+1,j+1,i+2,j+1])))
          a[i+1][j]=(a[i+1][j]+1)%2
        else:
          ans.append(' '.join(map(str,[i+1,j+1,i+1,j])))
          a[i][j-1]=(a[i][j-1]+1)%2
          
print(len(ans))
for i in range(len(ans)):
  print(ans[i])

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

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i=0; i<n; i++)
        cin >> a[i] >> b[i] >> c[i];

    int dp[n+1][3] = {0};
    for (int i=1; i<=n; i++) {
        dp[i][0] = a[i-1] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i-1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i-1] + max(dp[i-1][0], dp[i-1][1]);
    }

    cout << max(max(dp[n][0], dp[n][1]),dp[n][2]);
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  rep(i, 0, n) {
    int a;
    cin >> a;
    mp[a]++;
  }

  int siz = mp.size();
  if (siz <= k)
    cout << 0 << endl;
  else {
    int shortage = siz - k;
    vector<int> v;
    for (auto m : mp) {
      v.push_back(m.second);
    }
    sort(v.begin(), v.end());

    int ans = 0;
    rep(i, 0, v.size()) {
      ans += v[i];
      shortage--;
      if (shortage <= 0)
        break;
    }
    cout << ans << endl;
  }
}


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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int main() {
	string s;
	cin >> s;

	int ans = 0, rain = 0, sun = 0;
	rep(i,3) {
		if (s[i] == 'R') rain++;
		else sun++;
	}
	ans = rain;
	if (rain == 2 and s[1] == 'S') ans = 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
max=sum(b)

for i in range(N-1):
    if a[i]==a[i+1]-1:
            max+=c[a[i]-1]
print(max)

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

using namespace std;

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

#define pb push_back
#define ff first
#define ss second
#define SIZE 200001
#define INF int(2e9 + 9)
#define BIG_INF ll(1e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

//#pragma GCC optimize("Ofast")



int n, a[SIZE];
ll k;


vector<int> path;

bool used[SIZE];


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);



    cin >> n >> k;

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        --a[i];
    }

    ll K = k;
    int i = 0;

    vector<int> way(0);
    while(k >= 0)
    {
        path.pb(i);
        used[i] = 1;
        if(a[i] == i)
        {
            cout << i + 1;
            return 0;
        }
        i = a[i];
        if(used[i])
        {
            k--;
            while(path.back() != i)
            {
                way.pb(path.back());
                path.pop_back();
            }
            way.pb(path.back());
            path.pop_back();
            break;
        }
        k--;
    }
    reverse(all(way));
//    for(int& p: way) cout << p + 1 << ' ';


    if(k < 0)
    {
        if(way.size())
            cout << way.back() + 1;
        else cout << path.back() + 1;
        return 0;
    }

//    cout << "\n";
    ll sz = (ll)way.size();

    ll kol = k % sz;

    cout << way[kol] + 1;



    return 0;
}


Measured memory_bytes: 6208
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>

using namespace std;

int n;
int a[22][22];
int dp[22][1<<21];

int MOD = 1000000007;

int main(int argc, char **argv) {

	cin.tie(0);
   	ios::sync_with_stdio(false);

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int bit = 0; bit < 1 << n; bit++) {
			if (__builtin_popcount(bit) != i) continue;
			for (int j = 0; j < n; j++) {
				if ((bit >> j & 1) == 0 && a[i][j] == 1) {
					dp[i+1][bit | 1 << j] += dp[i][bit];
					dp[i+1][bit | 1 << j] %= MOD;
				}
			}
		}
	}

	cout << dp[n][(1<<n)-1] << endl;

}


Measured memory_bytes: 162048
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        try {
            InputReader in;
            PrintWriter out;
            boolean useOutput = false;
            // if (System.getProperty("ONLINE_JUDGE") == null) useOutput = true;
            if (useOutput) {
                FileInputStream fin = new FileInputStream(new File("src/testdata.in"));
                in = new InputReader(fin);
                FileOutputStream fout = new FileOutputStream(new File("src/testData.out"));
                out = new PrintWriter(fout);
            } else {
                InputStream inputStream = System.in;
                in = new InputReader(inputStream);
                OutputStream outputStream = System.out;
                out = new PrintWriter(outputStream);
            }
            Solver solver = new Solver();
            solver.solve(in, out);
            out.close();
            // fin.close();
            // fout.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class Solver
    {

        public void solve (InputReader cin, PrintWriter cout)
        {
            try {
                int a, b;
                a = cin.nextInt(); b = cin.nextInt();
                cout.println(Math.max(Math.max(a + b, a - b), a * b));
            } catch (RuntimeException e) {
                e.printStackTrace();
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong () {
            return Long.parseLong(next());
        }

        public double nextDouble () {
            return Double.parseDouble(next());
        }

    }

}

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

int main() {
    int n, k; cin >> n >> k;
    vector<ll> h(n);

    rep(i, n) cin >> h.at(i);
    sort(h.begin(), h.end());

    ll ans = 0;
    rep(i, n - k) {
        ans += h.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n),visited(n,false);
    for(int i=0;i<n;i++)
    cin>>v[i];
    int index=0;
    bool no=false;
    int count=0;
    while(index!=1){
        if(visited[index]==true){
            no=true;
            break;
        }
        
        visited[index]=true;
        index=v[index]-1;
        count++;
    }
    if(!no){
        cout<<count;
    }
    else{
        cout<<"-1";
    }

}

Measured memory_bytes: 4004
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	d = LI()
	d.sort()
	print(d[n//2]-d[n//2-1])


if __name__ == '__main__':
	main()

Measured memory_bytes: 14428
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define llong long long
using namespace std;

llong n,a,b;

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	printf("%lld\n",(n-a+1ll)*(n-b+1ll));
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_9_C
{
    class Program
    {

        static IEnumerable<string> ReadLines()
        {
            while (true)
            {
                yield return Console.ReadLine();
            }
        }


        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var count = int.Parse(input);

            var taro = 0;
            var hanako = 0;
            foreach (var n in ReadLines().Take(count)) 
            {
                var m = n.Split(' ');

                var order = m[0].CompareTo(m[1]);
                if (order == 0)
                {
                    taro += 1;
                    hanako += 1;
                }
                if (order < 0)
                {
                    hanako += 3;
                }
                if (0 < order)
                {
                    taro += 3;
                }
            }

            Console.WriteLine("{0} {1}", taro, hanako);
        }
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 073_abc_c / Link: https://abc073.contest.atcoder.jp/tasks/abc073_c?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	map<LL, LL>Map;
	FOR(i, 0, N) {
		LL a; cin >> a;
		Map[a]++;
	}

	for (map<LL, LL>::iterator it = Map.begin(); it != Map.end(); it++) {
		if ((*it).second % 2 == 1)ans++;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<pair<ll, ll>> R(n);
  rep(i, n) {
    ll x, l; cin >> x >> l;
    R[i].first = x-l;
    R[i].second = x+l;
  }
  sort(all(R));
  vector<int> dp(n);
  dp[0] = 1;
  rep(i, n) {
    int ne = lower_bound(all(R), make_pair(R[i].second, 0LL)) - begin(R);
    dp[ne] = max(dp[i]+1, dp[ne]);
    dp[i+1] = max(dp[i], dp[i+1]);
  }
  cout << dp[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 5268
from collections import deque

k = int(input())

dq = deque(range(1, 10))
cnt = 9
li = []
while cnt < 10 ** 5 + 10:
    num = dq.popleft()
    li.append(num)
    lst = num % 10
    if lst == 0:
        dq.append(num * 10)
        dq.append(num * 10 + 1)

    elif lst == 9:
        dq.append(num * 10 + 8)
        dq.append(num * 10 + 9)

    else:
        for i in range(lst - 1, lst + 2):
            dq.append(num * 10 + i)

    cnt += 1

ans = li[k-1]
print(ans)


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




int main(){
    //int arr[110] = {1,5,3,3,7};
    //int arr[110] = {1,3,5,3,4};
    char arr[10];
    scanf("%s",arr);
    if(arr[2] == arr[3] && arr[4] == arr[5]) cout << "Yes";
    else cout << "No";
    return 0;
}


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

using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
	int n;
	cin>>n;
	int a[n],b[n-1];
	for(int i=0;i<n;i++)    a[i]=INT_MAX;
	for(int i=0;i<n-1;i++) cin>>b[i];
	long long ans=0;
	for(int i=0;i<n-1;i++){
	    a[i]=min(a[i],b[i]);
	    a[i+1]=min(a[i+1],b[i]);
	}
	for(int i=0;i<n;i++)    ans+=a[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#参考：https://beta.atcoder.jp/contests/abc113/submissions/3806710


if __name__ == "__main__":
    N, M = map(int, input().split())
    city_list = []
    for i in range(M):
        p, y = map(int, input().split())
        city_list.append([i, p, y])

    city_count = {}
    order_dic = {}
    for i, p, y in sorted(city_list, key = lambda x: x[2]):
        if not p in city_count:
            city_count[p] = 0
        city_count[p] += 1
        order_dic[i, p] = city_count[p]

    for i, p, y in city_list:
        print("{:06}{:06}".format(p, order_dic[i,p]))


Measured memory_bytes: 44492
n = int(input())
cnt = [0]*4
for i in range(n):
    s = input()
    if s == 'AC':
        cnt[0] += 1
    elif s == 'WA':
        cnt[1] += 1
    elif s == 'TLE':
        cnt[2] += 1
    else:
        cnt[3] += 1

print("AC x {}".format(cnt[0]))
print("WA x {}".format(cnt[1]))
print("TLE x {}".format(cnt[2]))
print("RE x {}".format(cnt[3]))


Measured memory_bytes: 9212
package main
import (
  "fmt"
  // "math"
)

func main() {
  var (
    X string
    Y string
  )
  fmt.Scan(&X)
  fmt.Scan(&Y)

  if X[0] > Y[0] {
    fmt.Println(">")
  } else if X[0] < Y[0] {
    fmt.Println("<")
  } else {
    fmt.Println("=")
  }

}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int one, four,two;
int N;
int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		int a;
		cin >> a;
		if (a % 4 == 0)
		{
			++four;
		}
		else if (a % 2 == 0) { ++two; }
		else
		{
			++one;
		}
	}
	if (one > four)
	{
		if (two == 0 && one - four == 1)
		{
			cout << "Yes\n";
		}
		else
		{
			cout << "No\n";
		}
	}
	else
	{
		cout << "Yes\n";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();

      long[] arr = new long[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();

      Arrays.sort(arr);
      long[] prefixSum = new long[n];
      prefixSum[0] = arr[0];
      for(int i = 1; i < n; i++) {
        prefixSum[i] = prefixSum[i-1] + arr[i];
      }
      int i = n - 2;
      while(i >= 0) {
        if(prefixSum[i] * 2 < arr[i + 1])
          break;
        i--;
      }

      System.out.println(n - 1 - i);
  }
}

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

using namespace std;

#define ll long long

const ll mod  = 1e9 + 7;
const ll INF = 1e14;


void solve(){

    int n, k; cin >> n >> k;
    vector<int> arr (n, 0);
    while(k--){
        int d; cin >> d;
        while(d--){
            int x; cin >> x;
            ++arr[x-1];
        }
    }
    cout << count(arr.begin(), arr.end(), 0);

}


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

    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define mp(a, b) make_pair((a), (b))
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

ll dp[3005][3005][4];
vvll ar(3005, vll(3005));

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int r, c, k;
    cin >> r >> c >> k;
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            for (int k = 0; k < 4; k++) {
                dp[i][j][k] = 0;
            }
        }
    }
    for (int i = 0; i < k; i++) {
        int r, c, v;
        cin >> r >> c >> v;
        ar[r][c] = v;
    }
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            for (int k = 2; k >= 0; k--) {
                dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + ar[i][j]);
            }

            for (int k = 0; k <= 3; k++) {
                if (i + 1 <= r) {
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                }
                if (j + 1 <= c) {
                    dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                }
            }
        }
    }
    cout << max({dp[r][c][0], dp[r][c][1], dp[r][c][2], dp[r][c][3]}) << '\n';
    return 0;
}

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

int main()
{
  int a;
  cin >> a;
  int ans = 0;
  for (int i = 0; a != 0; i++) {
    if(a % 10 == 2) ans++;
    a /= 10;
  }
  cout << ans << endl;
}


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

#define INF 0x3fffffff

struct Edge {
  int to;
  int len;
};

typedef pair<int, int> Data;
typedef pair<int, Data> Pair;
int n;
int m;
int c;
int res[100];
int cnt[100];
int ss[1145];
int ts[1145];
int cs[1145];
int mind[114][114];
vector<Edge> es[100];

int main() {
  while (1) {
    scanf("%d%d%d", &n, &m, &c);
    if ((n|m|c) == 0) return 0;

    for (int i=0; i<n; i++) {
      for (int j=0; j<=n; j++) {
        mind[i][j] = INF;
      }
      es[i].clear();
    }

    for (int i=0; i<m; i++) {
      scanf("%d%d%d", &ss[i], &ts[i], &cs[i]);
      --ss[i];
      --ts[i];
      es[ss[i]].emplace_back(Edge{ts[i], cs[i]});
    }

    priority_queue<Pair, vector<Pair>, greater<Pair>> que;
    mind[0][0] = 0;
    que.push(Pair(0, Data(0, 0)));
    while (!que.empty()) {
      Pair p = que.top(); que.pop();
      int cost = p.first;
      Data d = p.second;
      int v = d.first;
      int cnt = d.second;
     
      if (mind[v][cnt] < cost) continue;
      for (Edge &e : es[v]) {
        int u = e.to;
        int l = e.len;
        if (cnt+1 <= n && mind[u][cnt+1] > cost) {
          mind[u][cnt+1] = cost;
          que.push(Pair(mind[u][cnt+1], Data(u, cnt+1)));
        }

        if (mind[u][cnt] > cost+l) {
          mind[u][cnt] = cost+l;
          que.push(Pair(mind[u][cnt], Data(u, cnt)));
        }
      }
    }

    for (int i=0; i<=n; i++) {
      if (mind[n-1][i] <= c) {
        printf("%d\n", i);
        break;
      }
    }
  }
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
string s;
int main (){
       int n;
       cin >> n;
       cin >> s;
       
       int x = 0,ans = 0;
       for (int i =0 ;i < s.size(); i++)
              if (s[i] == 'D') x-=1,ans = max(ans,x);
              else x+=1,ans= max(ans,x);
              
       cout<<ans;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

vector<int> xmov;
vector<int> ymov;

const int limit = 32010;
const int offset = 16005;

bool dp[2][limit];

bool calc(vector<int> &mov, int tar) {
	const int n = mov.size();
	rep(i, 2)rep(j, limit) dp[i][j] = false;
	dp[0][offset] = true;

	rep(i, n) {
		rep(j, limit) {
			if (dp[0][j] == false) continue;
			if (j + mov[i] < limit) dp[1][j + mov[i]] = true;
			if (j - mov[i] >= 0) dp[1][j - mov[i]] = true;
		}
		rep(j, limit) {
			dp[0][j] = dp[1][j];
			dp[1][j] = false;
		}
	}

	return dp[0][tar + offset];
}

int main(void) {
	bool xdir = true, start = true;
	string s;
	cin >> s;
	s += "T";
	const int n = s.size();

	int sx = 0, sy = 0, cnt = 0;
	rep(i, n) {
		if (s[i] == 'F') {
			cnt++;
		} else {
			if (start) {
				sx = cnt;
			} else if (xdir) {
				xmov.push_back(cnt);
			} else {
				ymov.push_back(cnt);
			}
			xdir ^= true;
			cnt = 0;
			start = false;
		}
	}


	int gx, gy;
	cin >> gx >> gy;

	if (calc(xmov, gx - sx) and calc(ymov, gy - sy))
		puts("Yes");
	else
		puts("No");


	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

using namespace std;

int n, i, times, x;

int main()
{
    scanf("%d", &n);

    for(i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        while(x %2 == 0)
        {
            x /= 2;
            times ++;
        }
    }

    printf("%d", times);

    return 0;
}


Measured memory_bytes: 256
/*
    ____       ____                 _
   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___
   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define db1(x) cout << #x << "=" << x << '\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << '\n'
#define rep(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(x) scanf("%s", x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", x)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define F first
#define S second
#define pb push_back
#define ll long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 200000+7, M = N, OO = 1e9 + 7;
const ll LLOO = 1e18 + 7;
//=======================

vi g[N];
int a[N];
char buff[N];
void solve()
{
    // code here :)
    ss(buff);
    string str = (string)buff;
    int sum = 0;
    for(auto c:str)
    {
		sum = (sum+c-'0')%9;
	}
	
	if (sum == 0) printf("Yes\n");
	else printf("No\n");
}

int main()
{
    // uncomment if file :
    // freopen("in","r",stdin);
    // freopen("out","w",stdout);
    int t = 1;
    // si(t); // uncomment if testcases
    while (t--)
        solve();
    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int u, v;
    while (m--)
    {
        scanf("%d %d", &u, &v);
        g[u - 1].pb(v - 1);
        g[v - 1].pb(u - 1);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 8568