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

template <class Cost = int>
struct Edge {
    int from, to;
    Cost cost;
    Edge(int from = -1, int to = -1, Cost cost = 1)
        : from(from), to(to), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
class Graph {
public:
    int size;
    std::vector<std::vector<Edge<Cost>>> path;

    explicit Graph(int N = 0) : size(N), path(size) {}
    void span(int from, int to, Cost cost = 1) {
        path[from].push_back(Edge<Cost>(from, to, cost));
    }
    std::vector<Edge<Cost>>& operator[](int v) { return path[v]; }
};

template <class Cost = int>
class HeavyLightDecomposition {
private:
    Graph<Cost> graph;
    std::vector<int>
        size,       // 部分木の頂点数
        in, rev,    // 行きがけ順と復元
        par, head;  // 1つ上とパスの根の頂点
    int time;       // inを埋めるのに使う

    // par, sizeを埋める
    int sz_dfs(int v, int r) {
        par[v] = r;
        size[v] = 1;

        // 先頭が親だと不便なので末尾と交換
        if (!graph[v].empty() && graph[v].front().to == r) {
            std::swap(graph[v].front(), graph[v].back());
        }

        for (auto& e : graph[v]) {
            if (e.to == r) continue;
            size[v] += sz_dfs(e.to, v);
            // graph[v]の先頭に一番sizeが大きい子が来るようにする
            if (size[graph[v][0].to] < size[e.to]) std::swap(graph[v][0], e);
        }
        return size[v];
    }

    // in, rev, headを埋める
    void in_dfs(int v, int r) {
        in[v] = time++;
        rev[in[v]] = v;

        for (auto& e : graph[v]) {
            if (e.to == r) continue;
            // 先にgraph[v]の先頭に一番sizeが大きい子が来るようにした
            // よって先頭の子をvのパスに加える
            head[e.to] = (graph[v][0].to == e.to ? head[v] : e.to);
            in_dfs(e.to, v);
        }
    }

public:
    HeavyLightDecomposition(const Graph<Cost>& g, int root)
        : graph(g), size(g.size), in(g.size), rev(g.size), par(g.size), head(g.size) {
        sz_dfs(root, -1);
        time = 0;
        in_dfs(root, -1);
    }

    int lca(int u, int v) {
        while (true) {
            if (in[u] > in[v]) std::swap(u, v);
            if (head[u] == head[v]) break;
            v = par[head[v]];
        }
        // u, vは同じパス上にある
        // in[u] <= in[v]よりuはvより上にあるため、uがLCAとなる
        return u;
    }
};


int main() {
    int N;
    std::cin >> N;
    Graph<> tree(N);
    for (int v = 0; v < N; ++v) {
        int k;
        std::cin >> k;
        for (int i = 0; i < k; ++i) {
            int c;
            std::cin >> c;
            tree.span(v, c);
        }
    }

    HeavyLightDecomposition<int> hld(tree, 0);

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int u, v;
        std::cin >> u >> v;
        std::cout << hld.lca(u, v) << std::endl;
    }
    return 0;
}



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

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> H(N+1);
    vector<bool> bad_hill(N+1, false);
    for (int i = 1; i <= N; i++) {
        cin >> H[i];
    }
    for (int i = 1; i <= M; i++) {
        int A, B;
        cin >> A >> B;
        if (H[A] == H[B]){
            bad_hill[A] = true;
            bad_hill[B] = true;
        } else if (H[A] < H[B]) {
            bad_hill[A] = true;
        } else {
            bad_hill[B] = true;
        }
    }
    int count = 0;
    for (int i = 1; i <= N; i++) {
        if (!bad_hill[i]) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read(), ans;
    vector<int> A(N), L(N), R(N);
    for (auto &a:A) a = read();
    L[1] = A[0];
    for (int i = 2; i<N; i++) L[i] = __gcd(L[i-1], A[i-1]);
    R[N-2] = A[N-1];
    for (int i = N-3; i>=0; i--) R[i] = __gcd(R[i+1], A[i+1]);
    ans = R[0];
    for (int i = 1; i<N-1; i++) ans = max(ans, __gcd(L[i], R[i]));
    ans = max(ans, L[N-1]);
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int d = Integer.parseInt(sa[1]);
		int a = Integer.parseInt(sa[2]);
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.x = Integer.parseInt(sa[0]);
			o.h = Integer.parseInt(sa[1]);
			arr[i] = o;
		}
		br.close();

		Arrays.parallelSort(arr, (o1, o2) -> o1.x - o2.x);

		int start = arr[0].x + d;
		int end = arr[n - 1].x - d;
		if (start > end) {
			int max = 0;
			for (int i = 0; i < n; i++) {
				max = Math.max(max, arr[i].h);
			}
			System.out.println((max + a - 1) / a);
			return;
		}

		long ans = 0;
		long now = 0;
		TreeMap<Integer, Long> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			Obj o = arr[i];
			Map<Integer, Long> map2 = map.headMap(o.x - d);
			for (Long val : map2.values()) {
				now -= val;
			}
			map2.clear();
			long rem = Math.max(o.h - now, 0);
			long cnt = (rem + a - 1) / a;
			ans += cnt;
			rem = a * cnt;
			now += rem;
			map.put(o.x + d, rem);
		}
		System.out.println(ans);
	}

	static class Obj {
		int x, h;
	}
}


Measured memory_bytes: 76588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<string> vstr;
void print() {cout<<'\n';}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<'\n';}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    vint P = input_to_vector(n);
    sort(all(P));
    P[n-1] = P[n-1] / 2;
    print(accumulate(all(P), 0));
}


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

int main(){
  int n, k;

  cin>>n>>k;
  int x, c[200000]={}, cnt=0;
  for(int i=0;i<n;i++){
    cin>>x;
    c[x-1]++;
    if(c[x-1]==1) cnt++;
  }

  sort(c, c+n);

  int ans=0;
  for(int i=0, j=0;i<cnt-k;i++, j++){
    if(c[j]==0) i--;
    ans+=c[j];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
using System;

class HorD
{
	static public void Main(string[] args)
	{
		string[] vals;
		vals = Console.ReadLine().Split(' ');
		if(vals[0] == "H")
		{
			Console.WriteLine(vals[1]);
		}
		else
		{
			if(vals[1] == "D")
			{
				Console.WriteLine("H");
			}
			else
			{
				Console.WriteLine("D");
			}
		}
	}
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
    char chs[101]{};
    cin.getline(chs, 101);
    int count{0};
    for (int i = 0; i < strlen(chs)/2; i++) {
        if (chs[i] != chs[strlen(chs) - i - 1])
            count++;
    }
    cout << count;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N){
        cin >> p[i];
        p[i]--;
    }
    static const int Max = 40010;
    vector<int> A(N),B(N);
    rep(i,N){
        A[i] = B[N-1-i] = Max * i + 1;
    }
    rep(i,N){
        A[p[i]] += i;
    }
    rep(i,N)cout << A[i] << endl;
    rep(i,N)cout << B[i] << endl;
}

Measured memory_bytes: 896
package main

import "fmt"

func main() {
	var n int

	for {
		result := 0
		_, err := fmt.Scanf("%d", &n)
		if err != nil {
			return
		}

		if n <= 36 {
			for a := 9; a >= 0; a-- {
				for b := 9; b >= 0; b-- {
					for c := 9; c >= 0; c-- {
						for d := 9; d >= 0; d-- {
							if a+b+c+d == n {
								// fmt.Println(a, b, c, d)
								result++
							}
						}
					}
				}
			}
		}
		fmt.Println(result)
	}
}



Measured memory_bytes: 1092
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
 
 
void func()
{
  ll n;
  cin>>n;
  char s[n],t[n];
  f(i,0,n)  cin>>s[i];
  f(i,0,n)  cin>>t[i];
  f(i,0,n)  cout<<s[i]<<t[i];
  cout<<endl;
}
 
int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    
    ll q=1;
    //cin>>q;
    while(q)
    {
      func();
      q--;
    }
 
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=[""]*N
for i in range(N):
    S[i]=input()

H=0
A,B,C=0,0,0
for s in S:
    for j in range(len(s)-1):
        if s[j:j+2]=="AB":
            H+=1

    if s[0]=="B" and s[-1]=="A":
        C+=1
    elif s[0]=="B":
        B+=1
    elif s[-1]=="A":
        A+=1

if C==0:
    D=min(A,B)
else:
    if A+B!=0:
        D=C+min(A,B)
    else:
        D=C-1
        
print(H+D)


Measured memory_bytes: 75392
N, *A = map(int, open(0).read().split())

A = [a - 1 for a in A]
cur = 0
cnt = 0
for _ in range(N):
    nxt = A[cur]
    cnt += 1
    if nxt == 1:
        print(cnt)
        break
    cur = nxt
else:
    print(-1)


Measured memory_bytes: 20220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  ll n = SZ(s);

  ll z = 0;
  REP(i, n) {
    if (s[i] == '0') {
      z++;
    }
  }
  cout << 2 * min(z, n - z) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,A,B;
  cin >> N >> A >> B;
  cout << min(N*A,B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,k;
	cin>>n>>k;
	vi a(n);
	rep(i,n){
		int z;cin>>z;z--;
		a[i]=z;
	}

	int now=0;
	int cnt=0;
	vi visit[200200];
	visit[0].pb(0);

	bool f=1;
	rep(i,k){
		now=a[now];
		cnt++;
		visit[now].pb(cnt);

		if(f&&visit[now].size()==2){
			f=0;
			int t=visit[now][1]-visit[now][0];
			i+=(k-cnt)/t*t;
		}
	}
	cout<<now+1<<endl;

	return 0;
}



Measured memory_bytes: 14616
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int INF=1<<29;
int N,M,R,G[205][205];

int main()
{
	vector<int>r;
	scanf("%d%d%d",&N,&M,&R);
	for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)G[i][j]=i==j?0:INF;
	for(int i=0;i<R;i++)
	{
		int p;
		scanf("%d",&p);
		r.push_back(p-1);
	}
	for(int i=0;i<M;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		if(G[a][b]>c)
			G[a][b]=G[b][a]=c;
	}
	for(int k=0;k<N;k++)
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
	ll res=INF;
	sort(r.begin(),r.end());
	do
	{
		ll t=0;
		for(int i=1;i<R;i++)
			t+=G[r[i-1]][r[i]];
		res=min(res,t);
	} while(next_permutation(r.begin(),r.end()));
	printf("%d\n",res);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define x first
#define y second


using namespace std;

const int mx = 3123;

double p[mx];

double dp[mx][mx];
int n;
double solve(int on = 0, int x = 0) {
  if (on == n) return x <= n/2;
  double &ans = dp[on][x];
  if (ans != -1) return ans;
  ans = p[on] * solve(on+1, x+1) + (1-p[on]) * solve(on+1, x);
  return ans;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < mx; i++)
    for (int j = 0; j < mx; j++) dp[i][j] = -1;
  cout << fixed << setprecision(10) << 1-solve() << endl;
}






Measured memory_bytes: 76672
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define pb push_back
#define e1 first
#define e2 second
#define x first
#define y second
#define tysiac 1010
#define milion 1000100
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define OUT(x) { cout << x; return 0; }
#define PRINT(x, y) {printf("%d %d\n", x, y); return;} 
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <ld, ld> PDD;
typedef pair <PII, PII> PP;
typedef pair <ll, int> PLI;
typedef pair <double, int> PDI;

const int mod = 1e9+7;
const int inf = 1e9+9;
const int MOD = 1e9+696969;
const ll INF = 1e18+3;
int T, n, m, K, a, b, c, k, d, g, Q, DL;
#define maxn 100100
vector <int> v[maxn];
int t[maxn], wyn = 0, len[maxn];
bool odw[maxn];
 
void dfs(int x) {
	odw[x] = 1;
	len[x] = 1;
	for (auto u : v[x]) {
		if (!odw[u]) {
			dfs(u);
			if (x == 1 && len[u] > k) {
				++wyn;
				len[u] = -1;
			}
			else if (x != 1)
			if (len[u] >= k) {
				++wyn;
				len[u] = -1;
			}
			len[x] = max(len[u] + 1, len[x]);
		}
	}
}

int main() {
	boost;
	cin >> n >> k;
	wyn = 0;
	FOR(i ,1, n) {
		cin >> t[i];
		if (i == 1) {
			if (t[i] != 1) wyn++;
		}
		else {
			v[t[i]].pb(i);
		}
	}
	
	dfs(1);
	//FOR(i, 1, n) cout << len[i] << ' ';
	cout << wyn;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];

ll score(vector<int>& t)
{
  vector<int> last(30, 0);
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    last[t[i]] = (i+1);
    REP(j,26){
      s -= C[j] * (i+1-last[j]);
    } 
  }
  return s;
}

void init(vector<int>& t)
{
  REP(i,D) t[i] = (i%26);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  vector<int> T(D);
  //init(T);
  REP(i,D) T[i] = rand26(mt);
  ll max_score = max(base+score(T), 0LL);
  int ti = clock();
  while(clock() - ti < 180 * CLOCKS_PER_SEC / 100){ 
    int d = rand365(mt);
    int q = rand26(mt);
    int old = T[d];
    T[d] = q;
    ll tmp = max(base + score(T), 0LL);
    if(max_score<tmp){
      max_score = tmp;
    }else{
      T[d] = old;
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>

int main(void){
    int num,i,sum,price;
    for(;sum=0,scanf("%d",&num),num;){
        for(i=0;i<num*(num-1)/2;sum+=price,i++)
            scanf("%d",&price);
        printf("%d\n",sum/(num-1));
    }
    return 0;
}

Measured memory_bytes: 600
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int n;
vector<pair<int, int>> p;
pair<int, int> P;
ll t = 0, a = 0;

int main() {

	t = 1; a = 1;

	cin >> n;
	rep(i, 0, n) {
		int x, y;
		cin >> x >> y;
		P.first = x; P.second = y;
		p.push_back(P);
	}
	
	ll time = 1;
	ll a = p[0].second, t = p[0].first;

	rep(i, 1, n) {
		
		int f = p[i].first, s = p[i].second;
		ll tdiv = t / f;
		ll adiv = a / s;
		if (t%f != 0)tdiv++;
		if (a%s != 0)adiv++;
		time = max(tdiv, adiv);
		t = f * time, a = s * time;
	}

	cout <<(ll)( t + a )<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (b - a == c - b ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 166
//C - Peaks
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()

using ll = long long;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
    int n, m;

    cin >> n >> m;

    ll h[n];
    bool good[n];
    rep(i, n) {
        cin >> h[i];
        good[i] = true;
    }

    int a[m], b[m];

    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int ans = 0;

    rep(j, m){
        if (h[a[j]] <= h[b[j]]) {
            good[a[j]] = false;
        }
        if (h[a[j]] >= h[b[j]]) {
            good[b[j]] = false;
        }
    }

    rep(i, n) {
        if (good[i]) ans++;
        //cout << good[i] << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5240
import itertools

n = int(input())
l1 = list(map(int, input().split()))
l2 = []
for i in range(0,len(l1),1):
  for j in range(i+1,len(l1),1):
    for k in range(j+1,len(l1),1):
      l2.append(sorted([l1[i],l1[j],l1[k]]))
count = 0
for i in range(len(l2)):
  if l2[i][0]+l2[i][1] > l2[i][2] and (l2[i][0] != l2[i][1] and l2[i][0] != l2[i][2] and l2[i][1] != l2[i][2]):
    count += 1
print(count)
    

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

class BIT{
public:
  typedef long long ll;
  ll n;
  vector<ll> bit0, bit1;
  BIT(){n=-1;}
  BIT(ll n_){
    n=1;
    while(n<n_)n*=2;
    bit0.resize(n+1,0);
    bit1.resize(n+1,0);
  }
  
  ll sum(vector<ll> &b,ll i){
    ll s=0;
    while(i>0){
      s=(s+b[i]);
      i-=i&-i;
    }
    return s;
  }

  void add(vector<ll> &b,ll i,ll v){
    while(i<=n){
      b[i]=(b[i]+v);
      i+=i&-i;
    }
  }

  //[a,b]にxを加算(1<=a)
  void add (ll a,ll b,ll x){
    assert(a > 0 && n >= 0);

    add(bit0,a,-x*(a-1));
    add(bit1,a,x);
    add(bit0,b+1,x*b);
    add(bit1,b+1,-x);
  }

  //[a,b]のsumを得る(1<=a)
  ll sum(ll a,ll b){
    assert(a > 0 && n >= 0);
    ll res=0;
    res+=sum(bit0,b)+sum(bit1,b)*b;
    res-=sum(bit0,a-1)+sum(bit1,a-1)*(a-1);
    return res;
  }
};

vector<int> G[100005];
vector<int> order;
int s[100005], t[100005];

void dfs(int x){
  
  s[x]=(int)order.size()+1;
  
  order.push_back(x);
  
  for(int i=0;i<G[x].size();i++) dfs(G[x][i]);

  t[x]=(int)order.size();
}

signed main(){
  
  int n;  
  cin>>n;
  
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int c;
      cin>>c;
      G[i].push_back(c);
  
    }
  }

  dfs(0);

  BIT bit=BIT(n);
  
  int q;
  cin>>q;
  
  while(q--){
    
    int a;
    cin>>a;

    if(a==0){
      int v, w;
      cin>>v>>w;
      bit.add(s[v], t[v], w);
    }
    else{
      int u;
      cin>>u;
      cout<<bit.sum(s[u], s[u])<<endl;
    }
    
  }
  
  return 0;
}



Measured memory_bytes: 15824
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        int N = int.Parse(Console.ReadLine());
        string[] readSome = new string[N];
        readSome = Console.ReadLine().Split(' ');
        int[] T = new int[N];
        for (int i = 0; i < N; i++) {
            T[i] = int.Parse(readSome[i]);
        }
        int M = int.Parse(Console.ReadLine());
        string[] readSome2 = new string[2];
        int[] P = new int[M];
        int[] X = new int[M];
        for (int i = 0; i < M; i++) {
            readSome2 = Console.ReadLine().Split(' ');
            P[i] = int.Parse(readSome2[0]);
            X[i] = int.Parse(readSome2[1]);
        }
        int times = 0;
        for (int i = 0; i < M; i++) {
            times = 0;
            for (int j = 0; j < N; j++) {
                if (j == P[i]-1) {
                    times += X[i];
                } else {
                    times += T[j];
                }
            }
            Console.WriteLine(times);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>

using namespace std;

int main(void) {
	int n;
	long long int l[87];

	cin >> n;

	l[0] = 2;
	l[1] = 1;

	for (int i = 2; i <= n; i++) {
		l[i] = l[i - 1] + l[i - 2];
	}

	cout << l[n] << endl;

	return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

vector <int> ans;

void fun(int pre,int post,int num,int in){
	if (in==10) return;
	for (int i=pre;i<=post;i++){
		int h=num*10+i;
		ans.pb(h);
		fun(max(0LL,i-1),min(i+1,9LL),h,in+1);
	}
}

inline void solve(){
	ans.pb(0);
	fun(1,9,0,0);
	sort(ans.begin(),ans.end());
	int n; cin>>n;
	cout << ans[n] << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 5172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

long long int gcd(long long int a, long long int b) {
    if (a < b)swap(a, b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int T; cin >> T;
    REP(i,T){
        LL A,B,C,D; cin >>A>>B>>C>>D;
        if(A < B){
            cout << "No" << endl;
            continue;
        }
        if(B > D){
            cout << "No" << endl;
            continue;
        }
        if(C >= B){
            cout << "Yes" << endl;
            continue;
        }

        LL g = gcd(B,D);
        LL tmax = (A % g) + g*((B-1-A%g) / g);
        if(tmax > C){
            cout << "No" << endl;
            continue;
        }else{
            cout << "Yes" << endl;
            continue;
        }

    }

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
  int n; cin >> n;
  map<string, int> mp;
  vector<int> v(n);
  rep(i,n){
  	string s; cin >> s;
    cin >> v[i];
    mp[s] = i;
  }
  string x; cin >> x;
  int id = mp[x];
  int ans = 0;
  for(int i=id+1; i<n;i++) ans += v[i];
  cout << ans << endl;
  return 0;
}
 


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<P> v;
    int a, b;
    rep(i,m){
        cin >> a >> b;
        a--; b--;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    int left = -1, right = 1e9, ans = 0;
    rep(i,m){
        if(v[i].second <= left || right <= v[i].first){
            ans++;
            left = -1;
            right = 1e9;
        }
        chmax(left, v[i].first);
        chmin(right, v[i].second);
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 1400
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

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

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
//#define int ll

using namespace std;
//using namespace __gnu_pbds;

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

const int N = 3e3 + 40, T = 4 * N, inf = 1e9 + 7;

int n, m, r, l, e, w, o, z, test, id, x, y;
double a[N], d[N][N], f;

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

void boos()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

main()
{
    //freop();
    boos();
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    d[1][1] = a[1];
    d[1][0] = 1 - a[1];
    for (int i = 2; i <= n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            if (!j) d[i][j] = d[i - 1][j] * (1 - a[i]);
            else d[i][j] = d[i - 1][j - 1] * a[i] + d[i - 1][j] * (1 - a[i]);
        }
    }
    for (int i = n / 2 + 1; i <= n; i++)
    {
        f += d[n][i];
    }
    printf("%.9lf", f);
}




Measured memory_bytes: 70272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) {
        cin >> v[i];
    }
  	ll ans=0;
    rep(i, n) {
	  ans += v[i]-1;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;cin>>n>>k;
  vector<int >nos(200001,0);
  set<int >s;
  for(int i=0,a;i<n;i++){cin>>a;s.insert(a);nos[a]++;}
  //what we need is a priority queue
  //first find different integers
  if(s.size()<=k)cout<<0;
  else{
  priority_queue<int, vector<int >,greater<int > >pq;
    for(int i=1;i<200001;i++){
    	if(nos[i]!=0)pq.push(nos[i]);
    }
    int tot=0;
    for(int i=0;i<((int)s.size()-k);i++){
    	tot+=pq.top();
        pq.pop();
    }
    cout<<tot;
  }
}

Measured memory_bytes: 14320
#include <stdio.h>
#include <stddef.h>
#include <string.h>

int main() {
    char s[101];
    scanf("%100s", s);

    int ret = 0;
    size_t slen = strlen(s);
    for (int i = 0; i < (slen / 2); ++i)
        if (s[i] != s[slen - i - 1])++ret;

    printf("%d\n", ret);
}


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

const double pi = 3.14159265358979323846;

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int r;
	sf("%d", &r);
	printf("%.20f", 2 * pi * r);

	return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,x,y,z,d,s,z1,d1,g;
int main()
{
    cin>>a>>b>>c>>x>>y;
    z=min (x,y);
    z*=2;
    d=z*c;
    if (x<y)
    {
        d+=(y-x)*b;
    }
    else if (x>y)
    {
        d+=(x-y)*a;
    }
    s=(a*x)+(b*y);
    z1=max (x,y);
    z1*=2;
    d1=z1*c;
    g=min (s,d);
    cout<<min (g,d1);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}


Measured memory_bytes: 27228
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	vector<int> A;
	for(int i=0;i<N;i++){
		llint a;
		cin >> a;
		A.push_back(a);
	}

	int cnt=0;
	for(const auto& a : A){
		llint num=a;
		while(num%2==0){
			cnt++;
			num/=2;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(A: int, B: int, C: int):
    if A <= C <= B:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 100005;

struct segmenttree {
	vector<int> st;
	int n;
	void init(int _n) {
		n = _n;
		st.clear();
		st.resize(4 * _n);
	}
	void build(int l, int r, int node) {
		if (l == r) {
			return;
		}
		int mid = (l + r) / 2;
		build(l, mid, node * 2 + 1);
		build(mid + 1, r, node * 2 + 2);
		st[node] = max(st[2 * node + 1], st[2 * node + 2]);
	}

	void update(int l, int r, int indup, int val, int node) {
		if (l == r) {
			st[node] = val;
			return;
		}
		else {
			int mid = (l + r) / 2;
			if (indup >= l && indup <= mid) {
				update(l, mid, indup, val, node * 2 + 1);
			}
			else {
				update(mid + 1, r, indup, val, node * 2 + 2);
			}
			st[node] = max(st[2 * node + 1], st[2 * node + 2]);
		}
	}

	int query(int si, int se, int l, int r, int node) {
		if (se < l || si > r || l > r) {
			return INT_MIN;
		}
		if (si >= l && se <= r) {
			return st[node];
		}
		int mid = (si + se) / 2;
		int q1 = query(si, mid, l, r, node * 2 + 1);
		int q2 = query(mid + 1, se, l, r, node * 2 + 2);
		return max(q1, q2);
	}
	void build(int n) {
		init(n);
		build(0, n - 1, 0);
	}
	int query(int l, int r) {
		return query(0, n - 1, l, r, 0);
	}
	void update(int index, int val) {
		update(0, n - 1, index, val, 0);
	}
} tree;

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	int a[n], b[n];
	P c[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
		c[i] = {a[i], i};
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	sort(c, c + n);
	tree.init(n);
	for (i = 0; i < n; i++) {
		int idx = c[i].S;
		int val = c[i].F;
		ans = tree.query(0, idx) + b[idx];
		tree.update(idx, ans);
	}
	cout << tree.query(0, n - 1);
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
using ll=long long;

ll dp[110][4][4][4];//A0 C1 G2 T3

ll dfs(int size,int i,int j,int k){
  if(dp[size][i][j][k]!=-1) return dp[size][i][j][k];
  if(size==3){
    if(i==0 && j==1 && k==2) return dp[3][i][j][k]=0;
    if(i==0 && j==2 && k==1) return dp[3][i][j][k]=0;
    if(i==1 && j==0 && k==2) return dp[3][i][j][k]=0;
    return dp[3][i][j][k]=1;
  }
  ll sum=0;
  for(int l=0;l<4;l++){
    if(i==0 && j==1 && k==2) continue;
    if(i==0 && j==2 && k==1) continue;
    if(i==1 && j==0 && k==2) continue;
    if(i==0 && k==1 && l==2) continue;
    if(i==0 && j==1 && l==2) continue;
    sum+=dfs(size-1,j,k,l);
    sum%=MOD;
  }
  
  return dp[size][i][j][k]=sum;
}

int main(){
  int n; cin>>n;
  memset(dp, -1, sizeof(dp));
  cout<<dfs(n+3, 3, 3, 3)<<endl;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> A(N);
    for(int i=1; i<N; ++i) {
        int a, b;
        cin >> a >> b;
        A[a - 1].push_back(b - 1);
        A[b - 1].push_back(a - 1);
    }

    vector<int> count(N, 0);
    for(int i=0; i<Q; ++i) {
        int p, x;
        cin >> p >> x;
        count[p - 1] += x;
    }

    queue<int> que;
    vector<bool> visited(N, false);
    que.push(0);
    visited[0] = true;
    while(!que.empty()) {
        int cur = que.front(); que.pop();
        visited[cur] = true;
        for(int to : A[cur]) {
            if(visited[to]) continue;
            count[to] += count[cur];
            que.push(to);
        }
    }

    for(int i=0; i<N; ++i) cout << count[i] << (i+1==N ? '\n' : ' ');
}

Measured memory_bytes: 15604
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b,c,ans=0;
    cin >> a >> b >> c;
    for (ll i=a;i<=b && ans<c;i+=a){
        ++ans;
        if (i>b){
            --ans;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()

if (s[0] == s[1]) and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
//
//  main.cpp
//  ATcode131
//
//  Created by didi on 2020/1/16.
//  Copyright © 2020年 didi. All rights reserved.
//

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cassert>
#include <queue>
#include <list>
using namespace std;

#define ll long long

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    bool flag = s[0] == s[1] && s[2] == s[3] && s[1] != s[2];
    if (flag) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int tmp;
  set<int>s;
  rep(i,3){
    cin>>tmp;
    s.insert(tmp);
  }
  if(s.size()==2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m, i, j, x, A[100][100], b[100], c;
	
	scanf("%d%d%*c", &n, &m);
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d", &x);
			A[i][j] = x;
		}
	}
	for(j = 0; j < m; j++){
		scanf("%d", &x);
		b[j] = x;
	}
	
	for(i = 0; i < n; i++){
		c = 0;
		for(j = 0; j < m; j++){
			c += (A[i][j] * b[j]);
		}
		printf("%d\n", c);
	}
	
	return(0);
}



Measured memory_bytes: 1864
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;
 
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
 
typedef long long ll;

const int MAX_N = 101;
int N, k;
int a[MAX_N];

void solve() {
	sort(a, a+N);
	int c = 0;
	int l = 0;
	int r = N-1;
	do {
		c++;
		int mid = (l + r) / 2;
		if(a[mid] == k) {
			break;
		}
		else if(a[mid] < k) {
			l = mid+1;
		}
		else if(a[mid] > k) {
			r = mid-1;
		}
	} while(l <= r);
	printf("%d\n", c);
}

int main() {
	while(scanf("%d", &N), N) {
		rep(i,N) scanf("%d", &a[i]);
		scanf("%d", &k);
		solve();
	}
}

Measured memory_bytes: 1204
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n;
	cin >> n;
	int a[n][3];
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			cin >> a[i][j];
		}
	}
	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1; i<n; i++){
		for(int j=0; j<3; j++){
			dp[i][j]=0;
			for(int k=0; k<3; k++){
				if(j!=k){
					dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i][j]);
				}
			}
		}
	}
	int ans=0;
	for(int i=0; i<3; i++)ans=max(ans, dp[n-1][i]);
		cout << ans << endl;
 
	return 0;
}  

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	string s;cin>>s;
	cout<<string(s.size(),'x')<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(std::vector<long long> x) {
    rep(i, x.size()) {
        if (x[i] == 0) cout << i + 1 << endl;
    }
}

int main() {
    std::vector<long long> x(5);
    for (int i = 0; i < 5; i++) {
        scanf("%lld", &x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3660
N, K, Q = map(int, input().split())
A = []
P = [0] * N
for _ in range(Q):
    A.append(int(input()))
    P[A[-1]-1] += 1

# 全員終了時はK - Q + （個人の正解数）とする
# K - Q + 正解数 > 0の人は勝ち残る
for i in range(N):
    if K - Q + P[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8620
N = int(input())
s = list(input())

o = "o"
for a in [0, 1]:
  for b in [0, 1]:
    L = ["" for _ in range(N)]
    L[0] = a
    L[1] = b
    for i in range(1, N - 1):
      if s[i] == o:
        if L[i] == 0:
          L[i + 1] = L[i - 1]
        else:
          L[i + 1] = 1 - L[i - 1]
      else:
        if L[i] == 0:
          L[i + 1] = 1 - L[i - 1]
        else:
          L[i + 1] = L[i - 1]
    if s[-1] == o:
      if L[-1] == 0:
        if L[-2] != L[0]:
          continue
      else:
        if L[-2] == L[0]:
          continue
    else:
      if L[-1] == 0:
        if L[-2] == L[0]:
          continue
      else:
        if L[-2] != L[0]:
          continue
    if s[0] == o:
      if L[0] == 0:
        if L[1] != L[-1]:
          continue
      else:
        if L[1] == L[-1]:
          continue
    else:
      if L[0] == 0:
        if L[1] == L[-1]:
          continue
      else:
        if L[1] != L[-1]:
          continue
    t = ""
    for i in range(N):
      if L[i] == 0:
        t += "S"
      else:
        t += "W"
    print(t)
    exit()

print(-1)

Measured memory_bytes: 5548