akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>

int main() {
		
	// recieve |V| and |E|
	int V, E; std::cin >> V >> E;
	std::vector<std::vector<std::pair<int, int>>> G(V);
	
	for(int i = 0; i < E; i++) {
		// recieve edges
		int u, v, d; std::cin >> u >> v >> d;
		u--; v--;
		G[u].push_back({v, d});
		G[v].push_back({u, d});
	}
	
	int Tmax; std::cin >> Tmax;

	// recieve info
	for(int i = 0; i < Tmax; i++) {
		int Nnew; std::cin >> Nnew;
		for(int j = 0; j < Nnew; j++) {
			int new_id, dst; std::cin >> new_id >> dst;
		}
	}

  // insert your code here to get more meaningful output
	// all stay
	for(int i = 0; i < Tmax; i++) std::cout << -1 << std::endl;
	return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,a[100010];
int cnt1[100010],cnt2[100010];

signed main(){
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
        if(i%2==0)cnt1[a[i]]++;
        else cnt2[a[i]]++;
    }
    int x=0,y=0;
    int cntx=0,cnty=0;
    rep(i,0,100010){
        if(x<cnt1[i]){
            x=cnt1[i];
            cntx=i;
        }
        if(y<cnt2[i]){
            y=cnt2[i];
            cnty=i;
        }
    }
    
    sort(cnt1,cnt1+100010,greater<int>());
    sort(cnt2,cnt2+100010,greater<int>());
    if(cntx==cnty){
        if(cnt1[0]+cnt2[1]>cnt1[1]+cnt2[0]){
            cout<<n-cnt1[0]-cnt2[1]<<endl;
        }
        else cout<<n-cnt1[1]-cnt2[0]<<endl;
        
        return 0;
    }
    int ans=n-cnt1[0]-cnt2[0];
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;


int main() {
    int x,y,s;
    int max;
    int a,b,c,d,e;
    int aa,bb;
    scanf ("%d %d %d",&x,&y,&s);
    while(x!=0){
      max=0;
      for(int i=1;i<s;i++){
        a=0;
        aa=0;
        b=0;
        bb=0;
        c=0;
        d=0;
        e=0;
        aa=(i*100)%(100+x);
        a=(i*100)/(100+x);
        if(aa!=0){
          a++;
        }
        bb=((s-i)*100)%(100+x);
        b=(s-i)*100/(100+x);
        if(bb!=0){
          b++;
        }
        aa=a*(100+x)/100;
        bb=b*(100+x)/100;
        if((aa+bb)==s){
        c=a*(100+y)/100;
        d=b*(100+y)/100;
        /*cc=a*(100+y)%100;
        dd=b*(100+y)%100;
        if(cc!=0){
          c++;
        }
        if(aa!=0){
          a++;
        }*/
        e=c+d;
        if(max<e){
          max=e;
        }
      }
      }
      printf("%d\n",max);
      scanf ("%d %d %d",&x,&y,&s);
    }
}




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

const ll MOD = 1000000007;

ll mod_add(ll a, ll b){
    return ((a % MOD) + (b % MOD)) % MOD;
}
 
ll mod_mul(ll a, ll b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll mod_pow(ll x, ll r){
    if (r == 0) return 1;

    else if (r == 1) return x % MOD;

    else if (r % 2 == 0){
        ll t = mod_pow(x, r/2) % MOD;
        return mod_mul(t, t);
    }

    else{
        ll t = mod_pow(x, r/2) % MOD;
        ll k = mod_mul(t, t);
        return ((k % MOD) * (x % MOD)) % MOD;
    }
}

ll mod_div(ll a, ll b){
    return mod_mul(a, mod_pow(b, MOD - 2));
}

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

    ll n, m;
    cin >> n >> m;

    ll res = mod_pow(n, m);
    cout << res << endl;

    return 0;
}


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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	int x,y;
	cin>>x>>y;
	
	if(y%2==1) cout<<"No";
	else{
		if(y>x*4 || y<x*2) cout<<"No";
		else cout<<"Yes";
	}
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int INF = 1e8;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-9;
const long double pi = acos(-1.0);
using namespace std;

int n, k;
vector <int> g[MAXN];
int d[3001][3001];
void dis(){

}
void dis(int x){
    for (int i = 1; i <= n; i++) d[x][i] = -1;
    d[x][x] = 0;
    deque <int> q;
    q.pb(x);

    while (!q.empty()){
        int v = q.front();
        q.pop_front();
        for (auto u : g[v]){
            if (d[x][u] != -1) continue;
            d[x][u] = d[x][v] + 1;
            q.pb(u);
        }
    }

}
void solve(){
    cin >> n >> k;

    for (int i = 1; i <= n - 1; i++){
        int x, y;
        cin >> x >> y;
        g[x].pb(y); g[y].pb(x);
    }
    for (int i = 1; i <= n; i++)
        dis(i);


    int ans = n;


    for (int v = 1; v <= n; v++){
        int kol = 0;
        if (k % 2 == 0) {
            for (int i = 1; i <= n; i++) if (d[v][i] > k / 2) kol++;
            ans = min(ans, kol);
        }else {
            for (auto u : g[v]){
                kol = 0;
                for (int i = 1; i <= n; i++) if (min(d[v][i], d[u][i]) > k / 2) kol++;
                ans = min(ans, kol);
            }
        }
    }

    cout << ans << endl;
}
/*
 6 1
 1 2
 2 3
 3 4
 4 5
 5 6
 */
int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(7);
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout)
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();

}

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

int main(void){
    
    int N;
    cin >> N;
    vector<int> L(N+1);
    
    for(int i = 1; i <= N; i++){
        cin >> L[i];
    }
    
    sort(L.begin(), L.end());
    
    int ans = 0;
    for(int i = 1; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            for(int k = j+1; k <= N; k++){
                if(L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]) {
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3152
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
 
*/
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>


using namespace std;



#define ll long long
#define ld long double
#define null NULL
#define prev prev228
#define next next228
#define index index228
#define count count228



signed main() {
	ll a, b, c, d;
	cin >> a 
	>> b >> c >> d;
	ll n;
	cin >> n;
	c = min(c, min(b * 2, a * 4));
	d = min(d, 2 * c);
	ll res = 0;
	res += d * (n / 2);
	n %= 2;
	if (n == 1) {
		res += c;
	}
	cout << res << endl;
    return 0;
}












Measured memory_bytes: 764
import sys
from collections import defaultdict
input = sys.stdin.readline
H, W, N = map(int, input().split())

board = defaultdict(int)
black = []
for _ in range(N):
    a, b = map(int, input().split())
    black.append((a - 1, b - 1))
    board[(a-1) * W + (b - 1)] = 1

num = [0] * 10
for p in black:
    for ch in range(max(p[0] - 1, 1), min(p[0] + 2, H - 1)):
        for cw in range(max(p[1] - 1, 1), min(p[1] + 2, W - 1)):
            count = 0
            for h in range(ch - 1, ch + 2):
                for w in range(cw - 1, cw + 2):
                    if board[h * W + w] == 1:
                        count += 1
            num[count] += 1
for i in range(1, 10):
    num[i] //= i
print((H - 2) * (W - 2) - sum(num))
for i in range(1, 10):
    print(num[i])


Measured memory_bytes: 199156
#include<stdio.h>
void sort(int left,int right);
int strcom(char *pword1,char *pword2);
char *pstr[100];

int main(){
  int N,L;
  int i,j;
  char str[101];
  scanf("%d %d",&N,&L);
  char word[N*(L+1)];
  for(i=0;i<N;i++){
    scanf("%s",str);
    for(j=0;j<L+1;j++){
      word[(L+1)*i+j]=str[j];
    }
    pstr[i]=&word[(L+1)*i];
  }
  sort(0,N-1);
  for(i=0;i<N;i++)printf("%s",pstr[i]);
}

void sort(int left,int right){
  char *bor;
  char *high[100],*low[100];
  int i,h=0,l=0,len=right-left;
  bor=pstr[left];
  for(i=left+1;i<=left+len;i++){
    if(strcom(bor,pstr[i])==1){
      low[l++]=pstr[i];
    }else if(strcom(bor,pstr[i])==-1){
      high[h++]=pstr[i];
    }
  }
  for(i=0;i<l;i++)pstr[i+left]=low[i];
  for(i=0;i<len-h-l+1;i++)pstr[left+l+i]=bor;
  for(i=0;i<h;i++)pstr[left+len-h+1+i]=high[i];
  if(l>1)sort(left,left+l-1);
  if(h>1)sort(right-h+1,right);
}
int strcom(char *pword1,char *pword2){
  int i;
  if(*pword1>*pword2)return 1;
  else if(*pword1<*pword2)return -1;
  else if(*pword1==*pword2){
    if(*(pword1+1)!='\0')return strcom(pword1+1,pword2+1);
    else return 0;
  }
}
  
  


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

int dp[3005][3005];

int lcs(string x, string y){
    for (int i = 1; i <= x.size(); i++){
        for (int j = 1; j <= y.size(); j++)
        {
            if(x[i-1] != y[j-1])
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            else
                dp[i][j] = dp[i-1][j-1] + 1;
        }
    }
    return dp[x.size()][y.size()];
}

int main()
{
    string x, y;
    char ans[3005];
    cin >> x >> y;
    int ans_end = lcs(x, y);
    int k = ans_end;
    int j = y.size();
    
    // for (int i = 0; i < 10; i++)
    // {
    //     for (int j = 0; j < 10; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    for (int i = x.size(), j = y.size(); i > 0 && j > 0; )
    {
        if (dp[i][j] == dp[i-1][j-1]+1 && dp[i][j-1] == dp[i-1][j-1] && dp[i-1][j] == dp[i-1][j-1])
        {
            i--;
            j--;
            ans[--k] = x[i];
        }
        else if (dp[i-1][j] < dp[i][j-1])
        {
            j--;
        }
        else if (dp[i-1][j] >= dp[i][j-1])
        {
            i--;
        }
    }
    for (int i = 0; i < ans_end; i++)
    {
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 35456
//
// Created by Hideaki Imamura on 2020-03-07.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll N, A, B;

int main() {
    cin >> N >> A >> B;
    cout << (N / (A+B)) * A + min(A, N % (A+B)) << endl;
    return 0;
}

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

void func1(int N, int divisor_num, int *ans)
{
    int i, j, count;

    for (i = 1; i <= N; i += 2) //O(N/2)
    {
        count = 0;
        for (j = 1; j * j <= i; j++) //O(√i)
        {
            if (i == j * j)
            {
                count++;
            }
            else if (i % j == 0)
            {
                count += 2;
            }
        }
        if (count == divisor_num)
        {
            *ans += 1;
        }
    }
}

int main(void)
{

    int N, ans = 0;
    scanf("%d", &N);

    func1(N, 8, &ans);

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

    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<ll> h,b;
ll dfs(ll n, ll x){
    if(n == 0)return 1;
    if(x == 1)return 0;
    if(x == h[n-1] + 2)return b[n-1] + 1;
    if(x == h[n])return b[n];
    if(x < h[n-1] + 2){
        return dfs(n-1, x - 1);
    }else{
        return b[n-1] + 1 + dfs(n-1, x - h[n-1] - 2);
    }
}
main(){
    ll N,X;
    cin >> N >> X;
    h.resize(N+1);
    b.resize(N+1);
    h[0] = b[0] = 1;
    rep(i,1,N+1){
        h[i] = h[i-1] * 2 + 3;
        b[i] = b[i-1] * 2 + 1;
    }
    cout << dfs(N,X) << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n = sc.nextInt();
				int m = sc.nextInt();
				if(n+m == 0) break;
				
				int[] x = new int[n];
				int[] c = new int[m];
				for(int i=0; i<m; i++) {
					c[i] = sc.nextInt();
				}
				for(int i=0; i<n; i++) {
					x[i] = sc.nextInt();
				}
				
				int[][] dp = new int[2][256];
				Arrays.fill(dp[0], 1<<30);
				dp[0][128] = 0;
				int t = 0;
				for(int i=0; i<n; i++) {
					Arrays.fill(dp[1-t], 1<<30);
					for(int j=0; j<256; j++) {
						for(int k=0; k<m; k++) {
							int next = j + c[k];
							if(next < 0) next = 0;
							if(next > 255) next = 255;
							dp[1-t][next] = Math.min(dp[1-t][next], dp[t][j] + (x[i]-next) * (x[i]-next));
						}
					}
					t = 1 - t;
				}
				int min = Integer.MAX_VALUE;
				for(int i=0; i<256; i++) {
					min = Math.min(min, dp[t][i]);
				}
				System.out.println(min);
			}
		}
	}
}



Measured memory_bytes: 74724
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,ans=0; cin>>n;
    rep(i,n){
        if((i+1)%3!=0 && (i+1)%5!=0) ans+=i+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  int i,num,j,alt,count=0;
  scanf("%d",&num);
  int buf[num];
  for(i=0;i<num;i++){

    scanf("%d",&buf[i]);
  }
  for(i=0;i<num;i++){
    for(j=num-1;j>=i+1;j--){
      if(buf[j]<buf[j-1]){
	alt=buf[j];
	buf[j]=buf[j-1];
	buf[j-1]=alt;
	count++;
      }

    }


  }
  for(i=0;i<num;i++){
    if(i!=num-1)printf("%d ",buf[i]);
    else printf("%d\n",buf[i]);
  }
  printf("%d\n",count);
}



Measured memory_bytes: 2140
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private final static String NEGATIVE = "NO\n";
	private final static String AFFIRMATIVE = "YES\n";

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1024);
		int number = Integer.parseInt(br.readLine());
		int sides[] = new int[3];
		StringTokenizer tknz;
		StringBuilder builder = new StringBuilder();

		for (; 0 < number; number--) {
			tknz = new StringTokenizer(br.readLine());
			for (int i = 0; i < 3; i++) {
				sides[i] = Integer.parseInt(tknz.nextToken());
			}
			Arrays.sort(sides);
			if (sides[0] * sides[1] * sides[2] % 60 != 0) {
				builder.append(NEGATIVE);
			} else if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) != Math.pow(sides[2], 2)) {
				builder.append(NEGATIVE);
			} else {
				builder.append(AFFIRMATIVE);
			}
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 18368
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<iomanip>
#include<cstring>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int INF=0x3f3f3f3f;
int mode=1e9+7;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		cout<<"x";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

int main() {
	vll a(7);
	Loop(i, 7) cin >> a[i];
	ll ans = 0;
	vll b = { a[0],a[3],a[4] };
	ans += a[1];
	if (a[0] > 0 && a[3] > 0 && a[4] > 0) {
		int cnt = 0;
		Loop(i, 3) {
			if (b[i] % 2 == 1) cnt += 1;
		}
		if (cnt == 0 || cnt == 3) {
			ans += b[0] + b[1] + b[2];
		}
		else if (cnt == 1 || cnt == 2) {
			ans += b[0] + b[1] + b[2] - 1;
		}
	}
	else {
		Loop(i, 3) {
			ans += (b[i] / 2 * 2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Exawizards2019_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
	ll N;
	cin >> N;
    string S;
	cin >> S;
    
    // calculation
    ll R = 0, B = 0;
	REP(i, N) {
		if (S[i] == 'R') R++;
		else B++;
	}
    
	if (R > B) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	
    return 0;
}

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

int a[1000][1000];
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n-1; j++) {
      cin>>a[i][j];
      --a[i][j];
    }
  }
  int d = 0;
  int idx[n];
  for (int i=0; i<n; i++) idx[i] = 0;
  queue<int> changed;
  for (int i=0; i<n; i++) changed.push(i);
  while (true) {
    ++d;
    set<int> selected;
    queue<int> new_changed;
    while (!changed.empty()) {
      int i = changed.front();
      changed.pop();
      if (selected.find(i) != selected.end()) {
        continue;
      }
      int e = a[i][idx[i]];
      if (selected.find(e) != selected.end()) {
        continue;
      }
      if (idx[e] == n - 1) {
        continue;
      }
      if (i == a[e][idx[e]]) {
        ++idx[i];
        ++idx[e];
        selected.insert(i);
        selected.insert(e);
        if (idx[i] != n - 1) {
          new_changed.push(i);
        }
        if (idx[e] != n - 1) {
          new_changed.push(e);
        }
      }
    }
    changed = new_changed;
    if (changed.size() == 0) {
      break;
    }
  }
  for (int i=0; i<n; i++) {
    if (idx[i] != n - 1) {
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<d<<endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#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 ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n;
    cin >> n;
    vector<int> l(n);
    int max_line = -100;
    int sum_line = 0;
    REP(i,n){
        cin >> l.at(i);
        sum_line += l.at(i);
        max_line = max(max_line, l.at(i));
    }
    /*
    cout << "max_line: " << max_line << endl;
    cout << "sum_line: " << sum_line << endl;
    */
    if(sum_line - max_line > max_line) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let n: usize = getline().trim().parse().unwrap();
    let s = getline();
    let vec: Vec<_> = s.trim().split(' ').collect();

    let mut num_cnt = HashMap::new();
    for i in 0..n {
        let a: i32 = vec[i].parse().unwrap();
        if num_cnt.contains_key(&a) {
            let old = *num_cnt.get(&a).unwrap();
            num_cnt.insert(a, old + 1);
        } else {
            num_cnt.insert(a, 1);
        }
    }

    let mut ans = 0;

    for x in 0..100001 {
        let mut cand = 0;
        if num_cnt.contains_key(&(x - 1)) {
            cand += *num_cnt.get(&(x - 1)).unwrap();
        }

        if num_cnt.contains_key(&x) {
            cand += *num_cnt.get(&x).unwrap();
        }

        if num_cnt.contains_key(&(x + 1)) {
            cand += *num_cnt.get(&(x + 1)).unwrap();
        }

        if cand > ans {
            ans = cand;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 11956
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]


ans=0

from operator import mul
from functools import reduce
import itertools
def cmb(n,r):
    if n<r: return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

#各竹への竹の割り振り方は10000通り弱。
#各割り振りでの最小コストを求めればよい。（使わない竹がある場合も含め）

def mp(x,y,z): #割り振りをx,y,zと決めた場合の最小MP…
  ans=float("inf")
  rng=list(range(n))
  for ptn in itertools.combinations(rng,x):
    cost=0
    cost+=10*(x-1) #まず接続コストを追加
    wa=0
    copy=rng[:]
    for i in ptn:
      wa+=l[i]
      copy.remove(i)
    #print(wa)
    cost+=abs(wa-a) #出来た長さをaに調整する分の費用追加
    for ptn2 in itertools.combinations(copy,y):
      #print(ptn2)
      cost1=cost+10*(y-1) #まず接続コストを追加
      wa=0
      copy2=copy[:]
      for i in ptn2:
        wa+=l[i]
        copy2.remove(i)
      cost1+=abs(wa-b)
      for ptn3 in itertools.combinations(copy2,z):
        cost2=cost1+10*(z-1)
        wa=0
        for i in ptn3:
          wa+=l[i]
        cost2+=abs(wa-c)
        ans=min(ans,cost2)
  return(ans)

final=float("inf")
for i in range(1,n-1):
  for j in range(1,n-i):
    for k in range(1,n+1-i-j):
      final=min(final,mp(i,j,k))
print(final)

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CTests {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int N, X;
    int b[100005];
    int l[100005];
    int u[100005];
    int aoki = 0;
    vector<P> v;

    bool check(int p) {
        int k = p / X;
        int d = p % X;

        int sum = 0;
        REP(i, k) {
            sum += v[i].first;
        }

        if (d == 0) {
            return sum >= aoki;
        }

        REP(t, N) {
            int tmp = sum;
            int i = v[t].second;
            if (t < k) tmp += v[k].first - v[t].first;
            if (d > b[i]) {
                tmp += u[i] * (d - b[i]) + l[i] * b[i];
            } else {
                tmp += l[i] * d;
            }
            if (tmp >= aoki) {
                return true;
            }
        }

        return false;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> X;

        REP(i, N) {
            cin >> b[i] >> l[i] >> u[i];
            aoki += l[i] * b[i];
        }
        v.resize(N);
        REP(i, N) {
            v[i] = {u[i] * (X - b[i]) + l[i] * b[i], i};
        }
        sort(v.begin(), v.end(), greater<P>());

        int low = -1;
        int high = N * X;
        while (high - low > 1) {
            int mid = (high + low) / 2;
            if (check(mid)) {
                high = mid;
            } else {
                low = mid;
            }
        }
        cout << high << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CTests solver;
    solver.solve(in, out);
    return 0;
}


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

typedef long long ll;

int N;
int A[500010];
ll dp[500010][2];

int Log(int x) {
    int ret = 0;
    int p = 1;
    while(p < x) ret++, p *= 2;
    return ret;
}

int f(int i, int j, int k) {
    int l = Log(A[i - 1]);
    int r = Log(A[i]);
    if((1 << l) != A[i - 1] && !k) l--;
    if((1 << r) != A[i] && j) r--;
    return min(l, r);
}

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

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    dp[0][0] = Log(A[0]);
    dp[0][1] = Log(A[0]);
    for(int i = 1; i < N; i++) {
        for(int j = 0; j < 2; j++) {
            dp[i][j] = 1e18;
            for(int k = 0; k < 2; k++) {
                dp[i][j] = min(dp[i][j], dp[i - 1][k] + Log(A[i]) - f(i, j, k));
            }
        }
    }

    printf("%lld", min(dp[N - 1][0], dp[N - 1][1]));
}


Measured memory_bytes: 3840
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
MOD2 = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()

    edge = [[] for _ in range(n)]
    for i in range(m):
        a, b = ns()
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)

    visited = [-1 for _ in range(n)]

    que = queue.Queue()
    que.put(0)
    visited[0] = 0

    while que.qsize() > 0:
        current = que.get()

        for next in edge[current]:
            if visited[next] == -1:
                visited[next] = current
                que.put(next)

    if min(visited) > -1:
        print("Yes")
        for i in range(1, n):
            print(visited[i] + 1)
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 101940
#include<stdio.h>
#include<cmath>
using namespace std;
typedef long long llong;
const int MOD = 1000000007;
const int charNum = 26;

llong product(llong a, llong b) {
    a = a * b;
    if (a >= MOD) a = a % MOD;
    return a;
}

llong sub(llong a, llong b) {
    a = a - b;
    if (a < 0) a += MOD;
    return a;
}

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

    char s[N];
    scanf("%s", s);

    llong count[charNum];
    for (int i = 0; i < charNum; i++){
        count[i] = 0;
    }

    char aChar = 'a';
    for (int i = 0; i < N; i++){
        count[(int)s[i] - (int)aChar]++;
    }

    llong ans = 1;
    for (int i = 0; i < charNum; i++){
        ans = product(ans, (count[i] + 1));
    }
    ans = sub(ans, 1);

    // 出力
    printf("%lld\n", ans);
    return 0;
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


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




// --------- library end - //


int main(){

  int N, M;
  cin >> N >> M;

  vector<ll> xs(N);
  vector<ll> ys(N);
  vector<ll> zs(N);
  rep(i, N) cin >> xs[i] >> ys[i] >> zs[i];

  vector<ll> pm = {-1, 1};
  // x, y, z について、プラスにするかマイナスにするかを固定して貪欲
  ll ans = 0;
  rep(xpm, 2) rep(ypm, 2) rep(zpm, 2){
    vector<ll> scores(N);
    rep(i, N) scores[i] = xs[i] * pm[xpm] + ys[i] * pm[ypm] + zs[i] * pm[zpm];
    sort(begin_end(scores));
    reverse(begin_end(scores));
    
    ll tmp = 0;
    rep(i, M) tmp += scores[i];
    chmax(ans, tmp);
  }

  cout << ans << endk;

}

Measured memory_bytes: 3632
use std::cmp::{self, Ordering};
use std::collections::*;
use std::io::{self, Read};

const MOD: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let r: usize = sc.read().unwrap();
    match r {
        0...1199 => println!("ABC"),
        1200...2799 => println!("ARC"),
        _ => println!("AGC"),
    }
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1777777777;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

//debug処理
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n, m, ans;
int p[114514];
int memo[114514];
signed main() {
	UnionFind uf(114514);
	cin >> n >> m;
	rep(i, n)cin >> p[i];
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		uf.unite(x, y);
	}
	rep(i, n)memo[p[i]] = i + 1;
	for (int i = 1; i <= n; i++) {
		if (uf.same(memo[i], i))ans++;
	}
	cout << ans << endl;
	ggr
}

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

#define int long long
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF=1e11;

void op(int& a,int& b) {
    int div=a/b;
    a-=div*b;
}

signed main() {
    int n,k;
    cin>>n>>k;
    if(n>k) {
        op(n,k);
    }
    cout<<min(n,abs(n-k))<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll S,W;
	cin >> S >> W;
	
	if (W >= S) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}

	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select((x, i) => new { x, i }).Where(x => x.x == "0").Select(x => x.i + 1).ToArray()[0];
        WriteLine(n);
    }
}


Measured memory_bytes: 19136
import sys
from decimal import Decimal

input = sys.stdin.readline

def main():
    a,b = map(int, input().split())
    
    s = int(a//b)
    r = int(a%b)
    f = Decimal(a/b)
    
    print(s,r,'{:.8f}'.format(f))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 6420
#include <iostream>
using namespace std;
using ll = long long;

string N; int n;
int dfs(int keta, int rest, bool lower) {
  // あとrest個数字を選べて、残りketa桁決めれるときの場合の数
  if (rest < 0)
    return 0;
  if (keta == n)
    return rest > 0 ? 0 : 1;

  if (lower) {
    return 9 * dfs(keta+1, rest-1, lower) + dfs(keta+1, rest, lower);
  }

  // まだ未確定
  int D = N[keta] - '0';
  int ans = dfs(keta+1, rest, (D > 0)); // 0を使う
  if (D > 0) {
    ans += (D-1) * dfs(keta+1, rest-1, true);
    ans += dfs(keta+1, rest-1, false);
  }
  return ans;
}

int main() {
  int K;
  cin >> N >> K;

  n = N.size();

  // まず、Nより桁数が小さい場合をカウントしたい。
  ll ans = 0;
  ans += dfs(1, K, true);
  ans += ((N[0]-'0')-1) * dfs(1, K-1, true);
  ans += dfs(1, K-1, false);

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n,a[20],z=0;
    cin >> n;
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    for (int i = 1; i < (n-1); i++) {
        if (a[i] > a[i - 1] && a[i] < a[i + 1])z++;
        if (a[i] < a[i - 1] && a[i] > a[i + 1])z++;
        
    }
    cout << z;
   
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,a[25][25],dp[5000000];
const int MOD=1e9+7;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)
		cin>>a[i][j];
	dp[0]=1;
	for(int i=0;i<(1<<n);i++)
	{
		int x=__builtin_popcount(i);
		for(int j=0;j<n;j++)
		{
			if(a[x][j]==1&&!(i&1<<j))
			{
				int m2=i^1<<j;
				dp[m2]+=dp[i];
				dp[m2]%=MOD;	
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

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

int main() {
  int x;
  cin>>x;
  if (400<=x and x<=599) cout<<"8"<<endl;
  if (600<=x and x<=799) cout<<"7"<<endl;
  if (800<=x and x<=999) cout<<"6"<<endl;
  if (1000<=x and x<=1199) cout<<"5"<<endl;
  if (1200<=x and x<=1399) cout<<"4"<<endl;
  if (1400<=x and x<=1599) cout<<"3"<<endl;
  if (1600<=x and x<=1799) cout<<"2"<<endl;
  if (1800<=x and x<=1999) cout<<"1"<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j,n,flg;
	char s[27];
	scanf("%s",s);
	n=strlen(s);
	flg=0;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(s[i]==s[j]){
				flg=1;
			}
		}
	}
	if(flg==1)	printf("no\n");
	else	printf("yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <stack>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;

int main(){
	int64_t A, B, C,K;
	cin >> A >> B >> C >> K;
	cout << ((K % 2 == 0) ? (A - B) : (B - A));
 	return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (B - A > D - C) {
    if (D <= A) cout << 0 << endl;
    else if (C <= A) cout << D - A << endl;
    else if (D <= B) cout << D - C << endl;
    else if (C <= B) cout << B - C << endl;
    else cout << 0 << endl;
  } else {
    if (D <= A) cout << 0 << endl;
    else if (D <= B) cout << D - A << endl;
    else if (C <= A) cout << B - A << endl;
    else if (C <= B) cout << B - C << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>				//edit by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    scanf("%lld",&a)
#define sc2(a,b)    scanf("%lld%lld",&a,&b)
#define pr(a)	    printf("%lld ",a)
#define pr2(a,b)    printf("%lld %lld",a,b)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)

double const eps = 1e-6;	//dung trong sai so
ll const Base=1e9+7;
ll arr[100005],prevx[100005],siz[100005];
vi dske[100005];
ll Solves(){
	//INPUT;
	ll n,k,cnt=0,ans=0,x,u,v,cur;
	// PROCESSING IN HERE
	sc(n);
	if(n==1)re cout<<"First",0;
	
	fu(i,1,n){
		sc2(u,v);
		dske[u].pb(v);
		dske[v].pb(u);
	}
	queue<ll> qu;		//white pos
	fu(i,1,n+1){
		siz[i]=sz(dske[i]);
		if(sz(dske[i])==1)qu.push(dske[i][0]),prevx[dske[i][0]]=i;				
	}
	
	while(qu.size()){
		cur=qu.front(); qu.pop();
		if(arr[cur]==1 or arr[cur]==-1)continue;
		arr[cur]=1;				//white
		arr[prevx[cur]]=-1;		//black
		siz[prevx[cur]]=0;
		siz[cur]=0;

		fu(j,0,sz(dske[cur])){
			x=dske[cur][j];
			if(siz[x]){
				if(--siz[x]==1){
					fu(q,0,sz(dske[x])){
						if(arr[dske[x][q]]==0){
							qu.push(dske[x][q]);
							prevx[dske[x][q]]=x;
						}
					}
				}
			}
		}
		
	}
	fu(i,1,n+1){
		if(arr[i]!=-1){
			fu(j,0,sz(dske[i])){
				if(arr[dske[i][j]]==-1)break;
				if(j+1==sz(dske[i]))re cout<<"First",0;
			}
		}
	}
	
	cout<<"Second";
	re 0;
}


int main(){
	Solves();
}

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll dp[110][10][5][2];

int main() {
	string N;
	int K;
	cin >> N >> K;
	dp[0][0][0][0]=1;
	for(int i=0; i<N.size(); ++i){
		for(int j=0; j<10; ++j){
			for(int k=0; k<K; ++k){
				dp[i+1][0][k][1] += dp[i][j][k][1];
				for(int d=1; d<10; ++d){
					dp[i+1][d][k+1][1] += dp[i][j][k][1];
				}
			}
			dp[i+1][0][K][1] += dp[i][j][K][1];
			int dg=N[i]-'0';
			for(int d=0; d<dg; ++d){
				if(d==0){
					for(int k=0; k<=K; ++k){
						dp[i+1][d][k][1] += dp[i][j][k][0];
					}
				}else{
					for(int k=0; k<K; ++k){
						dp[i+1][d][k+1][1] += dp[i][j][k][0];
					}
				}
			}
			if(dg==0){
				for(int k=0; k<=K; ++k){
					dp[i+1][dg][k][0] += dp[i][j][k][0];
				}
			}else{
				for(int k=0; k<K; ++k){
					dp[i+1][dg][k+1][0] += dp[i][j][k][0];
				}
			}
		}
	}
	ll ans=0;
	for(int i=0; i<10; ++i){
		ans += dp[N.size()][i][K][0]+dp[N.size()][i][K][1];
	}
	cout << ans << endl;
	return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v(M);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    sort(ALL(v), [](auto x, auto y){return x.second < y.second;});
    int res = 1;
    int cut = v[0].second;
    FOR(i, 1, M) {
        if(cut <= v[i].first) {
            cut = v[i].second;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1024
s = input()
n = len(s)
k = 10**9
if not "1" in s:
    print(n)
elif not "0" in s:
    print(n)
else:
    for i in range(n-1):
        if s[i] != s[i+1]:
            k = min(k,max(i+1,n-(i+1)))
    if k > n:
        print(n)
    else:
        print(k)


Measured memory_bytes: 40048
def islow(a):
    if 97 <= ord(a) < 123:
        return 1
    return 0

s = input()
t = 0
if s[0] == "A":
    t += 1
for i in range(1, len(s)):
    if 2<=i<=len(s)-2 and s[i] == "C":
        t += 10
    elif not islow(s[i]):
        t += 100
    
print("AC" if t == 11 else "WA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int hv[1000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;

    rep(i,k){
        int d; cin>>d;
        rep(i, d){
            int a;
            cin>>a;
            hv[a] = 1;
        }
    }
    int ans = 0;
    for(int i=1;i<=n; i++) if(hv[i]==0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
n=int(input())
c=[int(input()) for _ in range(n)]
x=[c[0]]
for i in range(1,n):
    if c[i]!=c[i-1]:
        x.append(c[i])
#print(x)

dp=[0 for _ in range(n)]
res=[[] for _ in range(max(x)+1)]
res[x[0]].append(0)
res2=[0 for _ in range(max(x)+1)]
for i in range(1,len(x)):
    if len(res[x[i]])>0:
        if res[x[i]][-1]==0:#左端スタートで１つ目の場合
            dp[i]=dp[i-1]+1
        else:
            dp[i]=dp[i-1]+len(res[x[i]])+res2[x[i]]
            #print(res2[x[i]])
    else:
        dp[i]=dp[i-1]
    res[x[i]].append(i)
    res2[x[i]]+=dp[i-1]
    #print(dp,res2)
print((dp[len(x)-1]+1)%(10**9+7))
#print(res)

Measured memory_bytes: 773640