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

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }

using LL = long long;
using PII = pair<int, int>;

int mod = 998244353;
int mul(int a, int b) { return (LL) a * b % mod; }
int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
int qpow(int a, int n) {
	if(n == 0) return 1;
	if(n % 2 == 1) return mul(qpow(a, n - 1), a);
	return qpow(mul(a, a), n / 2);
}

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

	int n;
	cin >> n;

	vector<int> rev(n + 1, 1);
	int fac = 1;
	FOR(i, 1, n) fac = mul(fac, i);
	rev[n] = qpow(fac, mod - 2);
	for(int i = n; i >= 2; i--)
		rev[i - 1] = mul(rev[i], i);
	auto choose_k = [&](int k) {
		int res = fac;
		res = mul(res, rev[k]);
		res = mul(res, rev[n - k]);
		return res;
	};

	int ans = qpow(3, n);
	int bad = 0, p = 1;
	for(int i = n; i * 2 > n; i--) {
		int res = mul(choose_k(i), p);
		bad = add(bad, res);
		p = mul(p, 2);
	}

	bad = mul(2, bad);
	bad = add(mod, -bad);
	ans = add(ans, bad);

	cout << ans << "\n";
}


Measured memory_bytes: 39296
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int INF = (int)1e9;
#define DEBUG(x) cerr << #x << " = " << x << endl
struct Edge {
  int to, cap, cost, rev;
  Edge(int to_, int cap_, int cost_, int rev_) : to(to_), cap(cap_), cost(cost_), rev(rev_) { }
};
struct MinCostFlow {
  int V;
  vector<vector<Edge>> G;
  vector<int> dist;
  vector<int> prevv, preve;
  MinCostFlow(int v) : V(v), G(v), dist(v), prevv(v), preve(v) { }
  void add_edge(int from, int to, int cap, int cost) {
    G[from].emplace_back(to, cap, cost, G[to].size());
    G[to].emplace_back(from, 0, -cost, G[from].size()-1);
  }
  int min_cost_flow(int s, int t, int f) {
    int res = 0;
    while(f > 0) {
      fill(dist.begin(), dist.end(), INF);
      dist[s] = 0;
      bool update = true;
      while(update) {
        update = false;
        for(int v = 0; v < V; ++v) {
          if(dist[v] == INF) continue;
          for(int i = 0; i < (int)G[v].size(); ++i) {
            const Edge &e = G[v][i];
            if(e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
              dist[e.to] = dist[v] + e.cost;
              prevv[e.to] = v;
              preve[e.to] = i;
              update = true;
            }
          }
        }
      }
      if(dist[t] == INF) return -1;
      int d = f;
      for(int v = t; v != s; v = prevv[v]) {
        d = min(d, G[prevv[v]][preve[v]].cap);
      }
      f -= d;
      res += d * dist[t];
      for(int v = t; v != s; v = prevv[v]) {
        Edge &e = G[prevv[v]][preve[v]];
        e.cap -= d;
        G[v][e.rev].cap += d;
      }
    }
    return res;
  }
};

int main() {
  int N; cin >> N;
  int a[N];
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  MinCostFlow flow(2*N+2);
  for(int i = 0; i < N; ++i) {
    flow.add_edge(2*N, i, 1, 0);
    flow.add_edge(N+i, 2*N+1, 1, 0);
  }
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      if(a[i] != j+1) {
        flow.add_edge(i, N + j, 1, abs(i - j)*a[i]);
      }
    }
  }
  cout << flow.min_cost_flow(2*N, 2*N+1, N) << endl;
}

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

int main(){
    int h,n;
    cin >> h >> n;
    ll cnt = 0;
    for(int i = 0;i < n;i++){
    	int a;
    	scanf("%d",&a);
    	cnt += a;
	}
	if(cnt >= h) printf("Yes\n");
	else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n;
	cin >> n;
	if(n<=999) cout << "ABC" << endl;
	else cout << "ABD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,X,x,s;
ll gcd(ll d,ll e){return e?gcd(e,d%e):d;}
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  
  cout<<(c%gcd(a,b)==0?"YES":"NO")<<endl;
}



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

int n;
int MAXIMUM=100;
int M[100][100];
int INF = 123456789;
// W:未訪問
// G:訪問する候補
// B:訪問済み
int W=0,G=1,B=2;
int prim(){
  int u,minv;
  int d[MAXIMUM],p[MAXIMUM],color[MAXIMUM];
  // d[n]:Tに属する頂点と V - T に属する頂点をつなぐ辺の中で重みが最小の辺の重みを記録

  //初期化
  for(int i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=W;
  }

  d[0]=0;

  while (1) {
    minv = INF;
    u = -1;
    //訪問済みでない頂点の中で最もコストが低い辺を探す
    for(int i=0;i<n;i++){
      if(minv>d[i] && color[i]!=B){
        u=i;
        minv=d[i];
      }
    }
    // 頂点が見つからなかったら終了
    if(u==-1) break;
    // 頂点を訪問済に
    color[u] = B;
    //訪問済みでないかつ辺がつながっている頂点の中でコストが最小の辺を選択
    for(int v=0;v<n;v++){
      if(color[v]!=B && M[u][v]!=INF){
        if(d[v]>M[u][v]){
          d[v] =M[u][v];
          p[v] =u;
          color[v]=G;
        }
      }
    }
  }

  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1) sum+= M[i][p[i]];
  }
  return sum;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      cin>>e;
      // M[i][j]=(e==-1) ? INF :e;
      if(e==-1) M[i][j]=INF;
      else M[i][j]=e;
    }
  }

  int ans =prim();
  cout<<ans<<endl;
}



Measured memory_bytes: 3112
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		char[] sd = s.toCharArray();
		char[] items = t.toCharArray();

		Character[] td = new Character[items.length];
		
		for(int i=0, len=items.length; i<len; i++) {
			td[i] = Character.valueOf(items[i]);
		}
		
		Arrays.sort(sd);
		Arrays.sort(td, Collections.reverseOrder());
		
		s = String.valueOf(sd);
		
		for(int i=0, len=items.length; i<len; i++) {
			items[i] = td[i].charValue();
		}
		
		t = String.valueOf(items);
		
		
		if(s.compareTo(t) <= -1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = ll(1e18)+5;

int main() {
    ll N;
    cin >> N;
    ll A[N][N];
    ll d[N][N];
    for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        cin >> A[i][j];
        d[i][j] = A[i][j];
    }

    for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=i;j<N;j++){
        d[i][j] = min(d[i][j],d[i][k]+ d[k][j]);
    }
    ll ans =0;
    for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
        if(i==j){
            continue;
        }
        // cerr <<"i="<<i <<"j=" <<j <<"d[i][j]=" << d[i][j] << endl;
        if(d[i][j] != A[i][j]){
            cout << -1 << endl;
            return 0;
        }
        ll minV = INF;
        for(int k=0;k<N;k++){
            if(i==k || j ==k){
                continue;
            }
            minV = min(minV,A[i][k]+A[k][j]);
        }
        if(minV > A[i][j]){
            ans += A[i][j];
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5084
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, m, i, j, s[2003], t[2003], dp[2003][2003] = {};

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}
	for (j = 0; j < m; j++) {
		scanf("%d", &t[j]);
	}

	for (i = 0; i <= n; i++) {
		dp[i][0] = 1;
	}
	for (j = 0; j <= m; j++) {
		dp[0][j] = 1;
	}

	for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) {
		dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		if (s[i - 1] != t[j - 1]) {
			dp[i][j] = (dp[i][j] + mod - dp[i - 1][j - 1]) % mod;
		}
	}

	printf("%d\n", dp[n][m]);

	return 0;
}

Measured memory_bytes: 15872
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define sqz main
#define ll long long
#define reg register int
#define rep(i, a, b) for (reg i = a; i <= b; i++)
#define per(i, a, b) for (reg i = a; i >= b; i--)
#define travel(i, u) for (reg i = head[u]; i; i = edge[i].next)
const ll INF = 1e15;
const int N = 800000;
const double eps = 1e-6, phi = acos(-1);
ll mod(ll a, ll b) {if (a >= b || a < 0) a %= b; if (a < 0) a += b; return a;}
ll read(){ ll x = 0; int zf = 1; char ch; while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
if (ch == '-') zf = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;}
void write(ll y) { if (y < 0) putchar('-'), y = -y; if (y > 9) write(y / 10); putchar(y % 10 + '0');}
int x[N / 4 + 5];
struct node
{
    ll val[2][N + 5];
    int left[N + 5], right[N + 5];
    ll tag[N + 5];
    inline void down(int u)
    {
        val[0][u + u] += tag[u], val[0][u + u + 1] += tag[u];
        val[1][u + u] += tag[u], val[1][u + u + 1] += tag[u];
        tag[u + u] += tag[u], tag[u + u + 1] += tag[u];
        tag[u] = 0;
    }
    inline void up(int u)
    {
        val[0][u] = min(val[0][u + u] , val[0][u + u + 1]);
        val[1][u] = min(val[1][u + u] , val[1][u + u + 1]);
    }
    
    void build(int u, int l, int r) 
    {
        left[u] = l, right[u] = r, val[0][u] = val[1][u] = INF, tag[u] = 0;
        if (l == r) return;
        int mid = (l + r) >> 1;
        build(u + u, l, mid);
        build(u + u + 1, mid + 1, r);
    }
    
    void modify(int u, int pos, ll v)
    {
        int l = left[u], r = right[u], mid = (l + r) >> 1;
        if (l == r)
        {
            val[0][u] = min(val[0][u], v - pos), val[1][u] = min(val[1][u], v + pos);
            return;
        }
        down(u);
        if (pos <= mid) modify(u + u, pos, v);
        else modify(u + u + 1, pos, v);
        up(u);
    }
    
    ll query(int t, int u, int x, int y)
    {
        int l = left[u], r = right[u], mid = (l + r) >> 1; ll T = INF;
        if (x <= l && y >= r) return val[t][u];
        down(u);
        if (x <= mid) T = min(T, query(t, u + u, x, y));
        if (y > mid) T = min(T, query(t, u + u + 1, x, y));
        return T;
    }
    
    ll find(int u)
    {
        int l = left[u], r = right[u], mid = (l + r) >> 1;
        if (l == r) return min(val[0][u] + l, val[1][u] - l);
        down(u);
        return min(find(u + u), find(u + u + 1));
    }
}Segment_tree;
int sqz()
{
    int n = read(), q = read(), pos = read(); x[0] = read();
    Segment_tree.build(1, 1, n);
    Segment_tree.modify(1, pos, 0);
    rep(i, 1, q)
    {
        x[i] = read();
        ll now = min(Segment_tree.query(0, 1, 1, x[i]) + x[i], Segment_tree.query(1, 1, x[i], n) - x[i]);
        Segment_tree.tag[1] += abs(x[i] - x[i - 1]), Segment_tree.val[0][1] += abs(x[i] - x[i - 1]), Segment_tree.val[1][1] += abs(x[i] - x[i - 1]);
        Segment_tree.modify(1, x[i - 1], now);
    }
    printf("%lld\n", Segment_tree.find(1));
}

Measured memory_bytes: 25600
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    sidha (i, 0, n) cin >> a[i];
    sort(bas(a));

    ll count = 1, ans = 0;
    for (auto i : a) {
        if (count == n) break;
        else if (count == n-1 or count == 1) {
            ans += i;
            count++;
        }
        else {
            ans += 2*i;
            count += 2;
        }
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 4776
// AOJ 0606: Tower of JOIOI
// 2018.1.10 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char s[1000005], *p;

int check(char *p, int m)
{
	int i, si, oi, soi, n;

	i = si = oi = soi = n = 0;
	while (*p) {
		if (*p == 'J') {
			if (soi > oi) { oi++; if (++n == m) return 1; }
		} else if (*p == 'O') {
			if (si > i && soi < m) soi++, i++;
		} else {						// *p == 'I'
			if (si < m) si++;
			else if (soi > oi) { oi++; if (++n == m) return 1; }
		}
		p--;
	}
	return 0;
}

int main()
{
	int n, i, oi, ans;
	int lo, hi, m;

	fgets(s+1, 10, stdin), n = atoi(s+1);
	fgets(s+1, 1000005, stdin);
	ans = i = oi = 0;	// i:'I'の数, oi:"OI"ペア数
	p = s+n; while (*p) {
		if (*p == 'J') {
			if (oi) ans++, oi--;
		} else if (*p == 'I') {
			i++;
		} else /* if (*p == 'O') */ {
			if (i) oi++, i--;
		}
		p--;
	}
	if (!oi) goto done;

	m = ans + (i + oi)/2;
	if (check(s+n, m)) { ans = m; goto done; }

	if (i > oi) {
		m = ans + oi;
		if (check(s+n, m)) { ans = m; goto done; }
	}

	lo = ans;
	hi = ans + 1 + (i + oi)/2;
	while (lo + 1 < hi) {
		m = (lo + hi) >> 1;
		if (check(s+n, m)) lo = m; else hi = m;
	}
	ans = lo;

done:
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define M_PI  3.14159265358979323846 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    
    cout << setprecision(6) << M_PI * 2 * n << "\n";
    return 0;
    
 }        


Measured memory_bytes: 3804
class SegmentTree:
    def __init__(self, n):
        self.tree = [0] * (2 * n)
        self.n = n

    def modify(self, pos, val):
        tree = self.tree
        pos += self.n
        tree[pos] = val
        while pos > 1:
            tree[pos//2] = max(tree[pos], tree[pos ^ 1])
            pos //= 2

    def query(self, L, R):
        res = 0
        L += self.n
        R += self.n
        while L < R:
            if L % 2 == 1:
                res = max(res, self.tree[L])
                L += 1
            if R % 2 == 1:
                R -= 1
                res = max(res, self.tree[R])

            L //= 2
            R //= 2

        return res


def solve(n, heights, beauty):
    dp = SegmentTree(n+1)
    for h, b in zip(heights, beauty):
        _max = dp.query(0, h)
        dp.modify(h, _max + b)

    return dp.query(0, n+1)


def main():
    n = int(input())
    heights = [int(c) for c in input().split()]
    beauty = [int(c) for c in input().split()]
    ans = solve(n, heights, beauty)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 122832
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll a,b,i;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b;
    rep(i,1,4) if((a * b * i) & 1){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
        String S=sc.next();

        //System.out.println(S.length());

        if(K>=S.length()){
            System.out.println(S);
        }else{
            String[] strArray=S.split("");

            int i=0;

            for(i=0;i<S.length();i++){
                if(i<K){
                    //System.out.print(i);
                    System.out.print(strArray[i]);
                }else{
                    System.out.print("...");
                    break;
                }
            }
        }

        //END

    }
}



Measured memory_bytes: 35784
fun main(args: Array<String>) {
    val (n, y) = readLine()!!.split(' ').map { it.toInt() }
    solve(n, y).ans()
}

private fun solve(n: Int, y: Int): Triple<Int, Int, Int> {
    for (i in (0..n)) {
        for (j in (0..n - i)) {
            val k = n - i - j
            if (10000 * i + 5000 * j + 1000 * k == y) {
                return Triple(i, j, k)
            }
        }
    }

    return Triple(-1, -1, -1)
}

private fun Triple<Int, Int, Int>.ans() {
    println("${this.first} ${this.second} ${this.third}")
}


Measured memory_bytes: 38256
n, m = map(int, input().split())
cs = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    cs[a][b] = 1
    cs[b][a] = 1
visited = [False] * (n + 1)
visited[0] = visited[1] = True


def dfs(k):
    count = 0
    es = [i for i in range(n + 1) if cs[k][i] == 1 and not visited[i]]
    if len(es) == 0:
        return 1 if all(visited) else 0
    for i in es:
        visited[i] = True
        count += dfs(i)
        visited[i] = False
    return count


print(dfs(1))

Measured memory_bytes: 3064
n = gets.to_i
a = gets.split.map(&:to_i)

two = 0
four = 0
odd = 0

a.each do |x|
  if x.odd?
    odd += 1
  elsif (x % 4).zero?
    four += 1
  else
    two += 1
  end
end

odd += 1 if two > 0

if four + 1 >= odd
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 9884
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 2e5 + 1;
//ll a[mxN];
ll n, x, t;
 
 
int main()
{
FIO

    cin >> n >> x >> t;
    cout << ((n+x-1) / x) * t;

    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_L 2000
typedef pair<string, string> P;
string s[3]; // a, b, c
bool match[3][3][MAX_L + 1];

bool comp(i64 i, i64 j, i64 x) {
    if (x >= s[i].length()) return true;
    for (i64 k = x; k < s[i].length(); k++) {
        i64 ji = k - x;
        if (ji >= s[j].length()) break;
        if (s[i][k] == '?' || s[j][ji] == '?') continue;
        if (s[i][k] != s[j][ji]) return false;
    }

    return true;
}

int main() {
    REP(i, 3) cin >> s[i];

    REP(i, 3)REP(j, 3) {
        if (i >= j) continue;
        REP(x, MAX_L + 1) {
            match[i][j][x] = comp(i, j, x);
            match[j][i][x] = comp(j, i, x);
        }
    }

    i64 perm[] = {0, 1, 2};
    u64 min_len = 10'000;
    do {
        REP(x, MAX_L + 1) {
            REP(y, MAX_L + 1) {
                bool ok = true;
                if (!match[perm[0]][perm[1]][x]) ok = false;
                if (!match[perm[1]][perm[2]][y]) ok = false;
                if ((x + y) < s[perm[0]].length() && !match[perm[0]][perm[2]][x + y]) ok = false;

                if (ok) {
                    u64 len = 0;
                    chmax(len, (u64)s[perm[0]].length());
                    chmax(len, x + s[perm[1]].length());
                    chmax(len, x + y + s[perm[2]].length());
                    chmin(min_len, len);
                }
            }
        }
    } while (next_permutation(perm, perm + 3));

    cout << min_len << endl;

    return 0;
}


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

#define mod 1'000'000'007
typedef long long ll;

template<typename T>
void deb(initializer_list<T> l)
{
	for (auto &e : l)
		cout << e << ' ';
	cout << endl;
}

void solve()
{
	string s;
	cin >> s;
	for (auto& e : s)
		cout << (e == '?' ? 'D' : e);
	cout << '\n';
}

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

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

	return 0;
}


Measured memory_bytes: 3784
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    S = SI()
    dp = [[0] * (N+1) for _ in range(N)]

    ans = 0
    for i in range(1,N):
        for j in range(i+1,N+1):
            if S[i-1] == S[j-1]:
                if j-i > dp[i-1][j-1]:
                    dp[i][j] = dp[i-1][j-1] + 1
                    ans = max(ans,dp[i][j])
                else:
                    dp[i][j] = 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 231176
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int countDays(int year, int month, int day)
{
    int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int cnt = day;

    if (month == 1)
    {
        return cnt;
    }

    for (int i = 0; i < month - 1; i++)
    {
        cnt += days[i];
    }

    if (month >= 3 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {
        cnt++;
    }

    return cnt;
}

int main(int argc, const char *argv[])
{
    int n, x, a[n], b[n], c[n - 1];
    // input
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a[i] = x - 1;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }

    // calculate
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += b[a[i]];

        if (i > 0 && a[i] > 0 && a[i] == a[i - 1] + 1)
        {
            sum += c[a[i - 1]];
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;

  if ( S == "Sunny" ) std::cout << "Cloudy" << std::endl;
  else if ( S == "Cloudy" ) std::cout << "Rainy" << std::endl;
  else std::cout << "Sunny" << std::endl;
  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;
 
typedef long long ll;
typedef double db;
typedef long double ld;
typedef string str;
 
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<str, str> pstr;
 
typedef vector<int> vi; 
typedef vector<ll> vll; 
typedef vector<db> vdb; 
typedef vector<ld> vld;
typedef vector<str> vstr; 
typedef vector<pi> vpi;
typedef vector<pll> vpll; 
typedef vector<pdb> vpdb; 
 
#define fi first
#define se second
#define mp make_pair
#define pf push_front 
#define pb push_back
#define ins insert 
#define eb emplace_back 
#define fbo find_by_order
#define ook order_of_key
#define rsz resize
#define lb lower_bound 
#define ub upper_bound 

#define len(s) (int)s.length()
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))

#define rep(a, b, c) for(int a=b; a<c; a++) 
#define per(a, b, c) for(int a=b; a>c; a--) //do not include boundaries on the right
#define repn(a, b, c) for(int a=b; a<=c; a++) 
#define pern(a, b, c) for(int a=b; a>=c; a--) //include boundaries on the right
 
#define yes cout << "YES"<< "\n" 
#define no cout << "NO" << "\n" 
#define out(x) cout << x << "\n"
#define outs(x) cout << x << " "
#define el cout << "\n"

#define navi ios_base::sync_with_stdio(false); cin.tie(NULL)    
 
const ll mod = 1e9+7;
const double eps = 1e-9;

int main(){
	navi;
  	int a[222222], x=0;
	int n; cin >> n;
 	rep(i,0,n){cin >> a[i]; x^=a[i];}
  	rep(j,0,n){outs((ll)(x^a[j]));}
  	el;
}


Measured memory_bytes: 4372
#include<iostream>
#define N 1000000007
typedef long long ll;
using namespace std;
ll quick_mod(ll a,ll b){
    ll ans=1;  
    a%=N;
    while (b){  
        if (b&1){ 
            ans=ans*a%N;  
    		b--;
		}
        b>>=1;
        a=a*a%N;
    }
	return ans;  
}

ll C(ll n,ll m){
	if (m>n) return 0;  
	ll ans=1;  
	for (int i=1;i<=m;i++){ 
		ll a=(n+i-m)%N;
		ll b=i%N;
		ans=ans*(a*quick_mod(b,N-2)%N)%N;
	}
	return ans;
}

int main(){
	ll n,a,b,x,y;
	cin>>x>>y;
	n=(x+y)/3;
	if (3*n!=(x+y)){
		cout<<"0";
		return 0;
	}
	a=(2*x-y)/3;
	b=(2*y-x)/3;
	if (a<0||b<0){
		cout<<"0";
		return 0;	
	}
	cout<<C(n,a);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint& operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
ostream& operator<<(ostream& os, const modint& x) {
    os << x.value();
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<modint> cnt(1001001);
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a] += 1;
    }

    vector<modint> f(1001001);
    for (int i = 1; i < 1001001; i++) f[i] = modint(1) / i;
    for (int i = 1; i < 1001001; i++) {
        for (int j = 2 * i; j < 1001001; j += i) {
            f[j] -= f[i];
        }
    }

    modint ans = 0;
    for (int d = 1; d < 1001001; d++) {
        modint x = 0, y = 0;
        for (int i = d; i < 1001001; i += d) {
            x += cnt[i] * i;
            y += cnt[i] * i * i;
        }
        x *= x;
        x -= y;
        x /= 2;
        ans += f[d] * x;
    }
    cout << ans << endl;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    ans += min(x, abs(x-k));
  }
  cout << 2 * ans << "\n";
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int N, M,X[100010],L[100010],ans=0;
	cin >> N >> M;
	for (int i = 0; i < M; i++)cin >> X[i];
	sort(X, X + M);
	for (int i = 0; i < M-1; i++) {
		L[i] = X[i + 1] - X[i];
	}
	sort(L, L + M - 1);
	for (int i = 0; i < M - N; i++)ans += L[i];
	cout << ans << endl;
}


Measured memory_bytes: 1024
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    count = 0
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                if i*500 + j*100 + k*50 == X:
                    count += 1
    return count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
io = STDIN
$hash=Hash.new{|h,k|h[k]=0}
n,$k=io.gets.chomp.split.map(&:to_i)
n.times do
a,b=io.gets.chomp.split.map(&:to_i)
$hash[a]+=b
end
def calc()
  sum=0
  $hash.keys.sort.each do |v|
    cnt=$hash[v]
    sum+=cnt
    return v if $k<=sum
  end
end
puts calc

Measured memory_bytes: 7304
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
ll n;
cin >> n;
vector<ll>a(n);
for(ll i=0;i<n;i++){
    cin >> a.at(i);
}
sort(a.begin(),a.end());
for(ll i=1;i<n;i++){
 if(a.at(i-1)==a.at(i)){
     cout <<"NO"<<endl;
     return 0;
 }   
}
cout <<"YES"<<endl;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N ;
  cin >> N ;
 
  if (N/1000==(N%1000)/100 && N/1000==(N%100)/10){
    cout << "Yes" << endl;
  }
  else if ((N%1000)/100==(N%100)/10 && (N%1000)/100==(N%10)){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import math
A, B, C = map(int,input().split())
ans = float("inf")
S = A * B * C
ans = min(ans,abs((A // 2 * B * C ) - (math.ceil(A / 2) * B * C)))
ans = min(ans,abs((B // 2 * C * A ) - (math.ceil(B / 2) * C * A)))
ans = min(ans,abs((C // 2 * A * B ) - (math.ceil(C / 2) * A * B)))
print(ans)

Measured memory_bytes: 3064
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int n, k;
    cin >> n >> k;
    double arr[n];
    for(int i = 0;i < n;i++)
    {
        double a;
        cin >> a;
        arr[i] = a * (a + 1) / 2.0 / a;
    }
    double sol = 0.0;
    double sum = 0.0;
    for(int i = 0;i < k;i++)
    {
        sum += arr[i];
    }
    sol = sum;
    for(int i = k;i < n;i++)
    {
        sum += arr[i];
        sum -= arr[i - k];
        sol = max(sol, sum);
    }
    cout <<sol;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
    int H, W, x, y;
    while(1)
    {
        scanf("%d %d",&H, &W);
        if(H == 0 && W == 0) break;
        for(y = 0; y < H; y++)
        {
            for(x = 0; x < W; x++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<string.h>
#include<queue>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=1000000000LL;
typedef long long ll;
typedef pair<ll,ll> Pa;
int N,A[200005],D[200005]={},B=0,C=INF;
ll L[55],ans=0;
int k=0,s=0;
int h;
int main(){
	cin>>N;
	for(int i=1;i<=N;++i){
		cin>>A[i];
		if(abs(k)<abs(A[i])){
			k=A[i];
			s=i;
		}
	}
	if(k==0)cout<<0<<endl;
	if(k>0){
		cout<<2*N<<endl;
		cout<<s<<" "<<1<<endl;
		cout<<s<<" "<<1<<endl;
		for(int i=1;i<N;++i){
			cout<<i<<" "<<i+1<<endl;
			cout<<i<<" "<<i+1<<endl;
		}
	}
	if(k<0){
		cout<<2*N<<endl;
		cout<<s<<" "<<N<<endl;
		cout<<s<<" "<<N<<endl;
		for(int i=N;i>1;--i){
			cout<<i<<" "<<i-1<<endl;
			cout<<i<<" "<<i-1<<endl;
		}
	}



	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = [0]
    for _ in range(N):
        A.append(int(readline()))
    used = [False]*(N+1)
    now = 1
    count = 0
    while not used[now]:
        used[now] = True
        now = A[now]
        count += 1
        if now == 2:
            print(count)
            break
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7868
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
string A="BBB";
string B="AAA";
int main(){
    string s;
    cin>>s;
    if(s!=A&&s!=B)cout<<"Yes";
    else cout<<"No";
}

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

int main(void){
  int N,a;
  cin >> N;
  char S[N];
  a = 0;
  
  for(int i = 0;i < N;i++){
    cin >> S[i];
    if(S[i] == 'Y')a = 1;
  }
  
  if(a == 1)cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;



int main(){
    int N;cin>>N;
    vector<pair<string,int>> v;
    vector<pair<string,int>> v2;
    vector<pair<string,int>>& a = v;
    vector<pair<string,int>>& b = v2;

    v.push_back(pair<string,int>{"a",1});
    for(int _ = 0; _ < N-1;_++){
        
        vector<pair<string,int>>& a = _ % 2 == 0 ? v : v2;
        vector<pair<string,int>>& b = _ % 2 == 0 ? v2 : v;
        b.clear();
        for(pair<string,int> p : a){
            for(int i = 0;i < p.second;i++){
                b.push_back(pair<string,int>{p.first + (char)('a'+i),p.second});
            }
            b.push_back(pair<string,int>{p.first + (char)('a'+p.second),p.second+1});
            // cout<<b[b.size()-1].first<<endl;
        }
    }
    for(pair<string,int> p : (N % 2 == 0 ? v2 : v)){
        cout<<p.first<<endl;
    }

}

Measured memory_bytes: 10348
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  static long[][] dp = new long[51][2];
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int p = Integer.parseInt(s[1]);
    
    s = br.readLine().split(" ");
    boolean[] even = new boolean[n];
    for (int i=0; i<n; i++) {
      int v = Integer.parseInt(s[i]);
      even[i] = (v%2==0);
    }
    System.out.println(solve(even,0,0,p));

  }

  static long solve(boolean[] arr, int index, int curr, int target) {
    if (index==arr.length && curr==target) {
      return 1;
    } else if (index==arr.length) {
      return 0;
    }
    if (arr[index]) {
      return dp[index][curr] = 2*solve(arr, index+1, curr, target);
    } else {
      return dp[index][curr] = solve(arr,index+1,1-curr, target)+solve(arr,index+1,curr,target);
    }
    
  }
}


Measured memory_bytes: 21700
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.printf("%d %d %f\n",a/b,a%b,(double)a/b);
	}
}

Measured memory_bytes: 17320
#include <cstdio>
#include <algorithm>
#define MAXN (int)(2e5+105)
using namespace std;
int a[MAXN];
int main() {
	int n, cnt, ans = 1;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a+1, a+1+n);
	int r, i = 1, j;

	while(i <= n) {
		j = i, r = a[i] + 2;
		cnt = 0;
		while(a[j] <= r && j <= n) {
			j ++;
			cnt ++;
		}
		ans = max(ans, cnt);
		j = i;
		while(a[j]==a[i] && i <= n) i++;
	}
	printf("%d\n", ans);
	return 0;
} 

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

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

  int n;
  queue<int> a[1010];
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n - 1; j++)
    {
      int x;
      cin >> x;
      a[i].push(--x);
    }

  vector<int> q, flag(n, -1);
  for (int i = 0; i < n; i++)
  {
    int j = a[i].front();
    if (flag[i] < 0 && a[j].front() == i)
    {
      q.push_back(i);
      q.push_back(j);
      flag[i] = flag[j] = 0;
    }
  }

  int day;
  for (day = 0; !q.empty(); day++)
  {
    for (int x : q)
      a[x].pop();
    vector<int> newQ;
    for (int x : q)
      if (!a[x].empty() && flag[x] <= day)
      {
        int y = a[x].front();
        if (!a[y].empty() && a[y].front() == x && flag[y] <= day)
        {
          newQ.push_back(x);
          newQ.push_back(y);
          flag[x] = flag[y] = day + 1;
        }
      }
    q = newQ;
  }

  for (int i = 0; i < n; i++)
    if (!a[i].empty())
    {
      cout << -1 << endl;
      return 0;
    }

  cout << day << endl;
}


Measured memory_bytes: 4736
//#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_set>
typedef long long LL;
using namespace std;
#define MAXN 3005
#define eps (1e-11)
#define lyh 1000000009
#define njj 1000000007
const double pi = acos(-1.0);
#define P pair<int,int> 
#define int LL


struct point {
	int x;
	int y;
};

double xmult(point p1, point p2, point p0) {
	return (p1.x - p0.x)*(p2.y - p0.y) - (p2.x - p0.x)*(p1.y - p0.y);
}

#define m 5800000//10^8的范围大概有5700000多个素数
#define m1 100000000
bool f[m1];//f来判断是否筛过,true为筛过
int cnt = 0, p[m];//第cnt个素数是p[cnt]
void oula(int n) {
	for (int i = 2; i <= n; i++) {//n是要考虑的<=!
		if (!f[i]) {
			f[i] = true;
			cnt++;
			p[cnt] = i;//记录这个天之骄子
		}
		for (int j = 1; j <= cnt && i*p[j] <= n; j++) {//固定常数i找素数p[j],n是要考虑的<=!
			f[i*p[j]] = true;
			if (i%p[j] == 0) break;//牛pi一步，确保每次筛的都是最小质数
		}
	}
}



signed main() {
	int n; 
	oula(100000000);
	scanf("%lld", &n);
	//n /= 2;
	int l = 1;int r = 1000000000;
	while (l <= r) {
		int mid = l + ((r - l) >> 1);
		if (mid*mid <= n) {
			if (l == r) break;
			l = mid + 1;
		}
		else {
			if (l == r) break;
			r = mid;
		}
	}
	if (l*l < n) {
		l++; r++;
	}
	int lst = l * l - n;
	if (lst > 1000000000) {
		lst -= l;
		r--;
	}
	int a = 1;
	point x, y, z;
	x.x = 0; x.y = 0;
	y.x = l; y.y = a;
	z.y = r; z.x = lst;
	/*if (n % 2 == 0) {
		y.y = 2;
		z.x = n / 2;
		z.y = 2;
	}
	else {
		if (n < 1000000000) {
			y.y = 1;
			z.x = n;
			z.y = 1;
		}
		else {
			for (int i = 1;; i++) {
				if (n%p[i] == 0) {
					y.y = p[i];
					z.x = n / p[i];
					z.y = p[i];
				}
			}
		}
	}*/
	printf("%lld %lld %lld %lld %lld %lld", x.x, x.y, y.x, y.y, z.x, z.y);
	return 0;
}

Measured memory_bytes: 143232
#include<bits/stdc++.h>
using namespace std;
int main(void){

   //物凄く可読性のよろしくないコードを書いてしまった気がする...
   int A, B;  cin >> A >> B;
   string S;  cin >> S;

   bool ans = true;
   for(int i = 0 ; i < A + B + 1 ; i++){
        if(i == A){
           if(S[i] != '-')  ans = false;
         }else if(S[i] < '0' || '9' < S[i])  ans = false;
   }

   cout << ((ans) ? "Yes" : "No") << endl;

   return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        boolean judge = true;

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        int A[] = new int[N];
        int sum = 0;

        for(int i=0; i<N; i++)
        {
            A[i] = Integer.parseInt(sc.next());
            sum += A[i];
        }

        Arrays.sort(A);

        for(int j=N-1; j>(N-1)-M; j--)
        {
            if(A[j]< 1.0*sum/4/M) judge = false;
        }

        if(judge) System.out.println("Yes");
        else System.out.println("No");
        sc.close();
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int tmp,a[25][25],n, d[25][1<<21];
long long f[25][1<<21];

long long dp(int i,int used)
{
    if (i>n) return 1;
    if (d[i][used]!=0) return f[i][used]; d[i][used]=1;
    long long &res=f[i][used];
    for (int j=1;j<=n;j++)
    {
        if (a[i][j]==0 || ((used>>j)&1)) continue;
        res=(res+dp(i+1,used | (1<<j)))%1000000007;
    }
    return res;
}
int main()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
            cin>>a[i][j];
    }
    cout<<dp(1,tmp);
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n,m,c,ans=0;cin>>n>>m>>c;

    vector<int>b(m);
    rep(i,m){
        cin>>b[i];
    }

    rep(i,n){
        int sum=c;
        rep(i,m){
            int a;cin>>a;
            sum+=b[i]*a;
        }
        if(sum>0){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 768