akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int h, n;
    cin >> h >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    int sum = accumulate(all(a), 0);

    yns(sum >= h);
    return 0;
}

Measured memory_bytes: 640
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let a: Vec<i32> = lines
        .nth(1)
        .unwrap()
        .unwrap()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let ans = if a.iter().all(|&x| x % 2 != 0 || x % 6 == 0 || x % 10 == 0) {
        "APPROVED"
    } else {
        "DENIED"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let mut vs = vec![get!(), get!(), get!()];
    vs.sort();
    let ans = vs[0] + vs[1];
    
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<numeric>
#include<bits/stdc++.h>

#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define REP(i,n) FOR(i,0,n)
#define endl "\n"

#define INF 9e18
#define ll long long int
 
using namespace std;
int a[10002];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	
	if (m > n) cout << -1 << endl;
	else {
		ll sum = 0;
		for (int i = 0; i < m; i++) {
			sum += a[i];
		}
		if (sum > n) cout << -1 << endl;
		else {
			cout << n - sum << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3640
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include <string.h>
using namespace std;
int bd[3][3];
int a[3], b[3];
int main() {
int n,a;
cin >> n >> a;
if(n % 500 <= a){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
}


Measured memory_bytes: 256
//プリム法とかいうのを使うらしい
//結構当たり前だから諦めずに頑張れよ、こういうところだぞ

#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;

class Edge{
public:
  ll to_Node;
  ll cost;
  Edge(ll t,ll c){
    to_Node=t;cost=c;
  }
};

//pr_queueは優先順位高い(<で右に来るやつ)のが先に取り出される
bool operator< (const Edge& a,const Edge& b){
    return a.cost > b.cost;
};

ll distance(vector<ll>& a,vector<ll>& b){
  return min({abs(a[0]-b[0]),abs(a[1]-b[1])});
}

int main(){
  ll n;cin >> n;
  vector< vector<ll> > v1(n,vector<ll>(3,0));
  vector< vector<ll> > v2(n,vector<ll>(3,0));
  //自作クラスのpr_queueどうする
  for(ll i=0;i<n;i++){
    ll x,y;cin >> x >> y;
    v1[i][0]=x;v1[i][1]=y;v1[i][2]=i;
    v2[i][0]=x;v2[i][1]=y;v2[i][2]=i;
  }
  sort(v1.begin(),v1.end(),[](vector<ll>& a,vector<ll>& b){return a[0] < b[0];});
  sort(v2.begin(),v2.end(),[](vector<ll>& a,vector<ll>& b){return a[1] < b[1];});

  //ここでそれぞれのNodeから伸びる辺をqueueに入れておく
  vector< queue<Edge> > edges_before(n);
  for(ll i=0;i<n-1;i++){
    edges_before[v1[i][2]].push(Edge(v1[i+1][2],distance(v1[i],v1[i+1])));
    edges_before[v1[i+1][2]].push(Edge(v1[i][2],distance(v1[i],v1[i+1])));
    edges_before[v2[i][2]].push(Edge(v2[i+1][2],distance(v2[i],v2[i+1])));
    edges_before[v2[i+1][2]].push(Edge(v2[i][2],distance(v2[i],v2[i+1])));
  }

  //0から始まるので0で初期化
  vector<bool> check(n,false);check[0]=true;
  priority_queue<Edge> edges;
  ll l=edges_before[0].size();
  for(ll i=0;i<l;i++){
    edges.push(edges_before[0].front());
    edges_before[0].pop();
  }

  ll cost_sum=0;
  Edge now=edges.top();
  int i=0;
  while(edges.size()!=0){
    //nowが訪問済みなのは明らか
    if(!check[now.to_Node]){
      check[now.to_Node]=true;
      cost_sum+=now.cost;
      int k=now.to_Node;
      ll l=edges_before[k].size();
      edges.pop();//
      for(ll i=0;i<l;i++){
        Edge s=edges_before[k].front();
        if(!check[s.to_Node]) edges.push(s);
        edges_before[k].pop();
      }
      now=edges.top();
      i++;
      if(i==n-1)break;
    }else{
      edges.pop();now=edges.top();
    }
  }
  cout << cost_sum << endl;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    set<char> a;
    string in;
    cin>>in;
    rep(i,in.size()){
        a.insert(in[i]);
    }
    if(in.size()==a.size()){
        cout<<"yes"<<endl;
    }else{
        cout<<"no"<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  string s;
  cin>>s;
  
  if(s=="SUN")
    cout<<"7";
  else if(s=="MON")
    cout<<"6";
  else if(s=="TUE")
    cout<<"5";
  else if(s=="WED")
    cout<<"4";
  else if(s=="THU")
    cout<<"3";
  else if(s=="FRI")
    cout<<"2";
  else
    cout<<"1";
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,ans;
vector<int>G[1<<17];
int dp[1<<17],cr[1<<17];
int dfs1(int u,int p)
{
	int mt=0;
	int get=0;
	if(G[u].size()==1&&G[u][0]==p)cr[u]=1;
	else cr[u]=0;
	for(int v:G[u])if(v!=p)
	{
		int t=dfs1(v,u);
		cr[u]+=cr[v];
		if(mt<t-cr[v])mt=t-cr[v];
		if(get<t+1)get=t+1;
	}
	dp[u]=max(cr[u]+mt,get);
	return dp[u];
}
void dfs2(int u,int p,int pcr,int pt)
{
	int sr=cr[u]+pcr;
	int mt=pt-pcr;
	if(mt<0)mt=0;
	int m1t=mt,m2t=0;
	int g1=pt+1,g2=0;
	for(int v:G[u])if(v!=p)
	{
		int t=dp[v]-cr[v];
		if(mt<t)mt=t;
		if(m1t<t)
		{
			m2t=m1t;
			m1t=t;
		}
		else if(m2t<t)m2t=t;
		if(g1<dp[v]+1)
		{
			g2=g1;
			g1=dp[v]+1;
		}
		else if(g2<dp[v]+1)g2=dp[v]+1;
	}
	ans=max(ans,sr+mt);
	for(int v:G[u])if(v!=p)
	{
		int t=dp[v]-cr[v];
		dfs2(v,u,sr-cr[v],max(max((t==m1t?m2t:m1t)+sr-cr[v],dp[v]+1==g1?g2:g1),sr-cr[v]));
	}
}
main()
{
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int u,v;cin>>u>>v;u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int root=0;
	while(root<N&&G[root].size()<=2)root++;
	if(root==N)
	{
		cout<<N<<endl;
		return 0;
	}
	dfs1(root,-1);
	dfs2(root,-1,0,0);
	cout<<ans<<endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
ll ha[1000005] = { 0 };

int main() {
	while (true) {
		ll n, m;
		ll p[1005] = { 0 };
		ll res = 0;
		int cnt = 0;
		cin >> n >> m;
		if (n == 0 && m == 0) return 0;
		for (ll i = 1; i <= n; i++) cin >> p[i];
		for (ll i = 0; i <= n; i++) {
			for (ll j = i; j <= n; j++) {
				ha[cnt++] = p[i] + p[j];
			}
		}
		sort(ha, ha + cnt);
		for (int i = 0; i < cnt; i++) {
			ll sum = ha[i];
			auto a = upper_bound(ha, ha + cnt, m - sum) - ha;
			//out(m-sum);
			if (a >= 1) if (sum + ha[a - 1] <= m) res = max(res, sum + ha[a - 1]);
		}
		out(res);
	}
	return 0;
}



Measured memory_bytes: 6956
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long A, long long B){
    if (A <= 5){
        cout << 0 << "\n";
    } else if(A <= 12) {
        cout << B/2 << "\n";
    } else {
        cout << B << "\n";
    }
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



Measured memory_bytes: 256
//ABC 098 c题
#include <iostream>
using namespace std;
 
int main(){
	int n;
	cin >> n;
	string a;
	cin >> a; 
	int se[n], sw[n];
	
	for (int i=0; i<n; i++){
		se[i]=0;
		sw[i]=0;
	} 
	
	if (a[0]=='E')
	   se[0] = 1;
	else
	   sw[0] = 1;
	
	for (int i=1; i<n; i++){
			if (a[i]=='E') {
			   se[i]=se[i-1]+1;
			   sw[i]=sw[i-1];
		    }
			else {
			   sw[i] = sw[i-1]+1;
			   se[i] = se[i-1];
		    }
	}
	
	int minv = 300005;
	
	for (int i=0; i<n; i++){
		int sum=0;
		if (i==0)  
		   sum = se[n-1]-se[0]; 
		else if (i==n-1) 
		   sum = sw[n-2];
		else
		   sum = sw[i-1] + (se[n-1]-se[i]); 
		
		minv = min(minv, sum);
	}
	
	cout << minv;
    return 0;
}

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

int main()
{
        int N, K; cin>>N>>K;
        vector<int> a(N);
        for(int i=0;i<N;i++) cin>>a[i], a[i]--;

        vector<int> cnt(K);
        int num=0, ans=N+1;
        for(int l=0, r=0;l<N;l++){
                while(r<N and num<K){
                        if(a[r]<K){
                                if(++cnt[a[r]]==1) num++;
                        }
                        r++;
                }
                if(num<K) break;
                ans=min(ans, r-l);
                if(a[l]<K) if(--cnt[a[l]]==0) num--;
        }
        cout<<(ans==N+1? 0:ans)<<endl;
        return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
        m[p[i]] = i;
    }

    ll ans = 0;
    set<ll> fow, rev;
    fow.insert(-1);  fow.insert(n);
    rev.insert(-1);  rev.insert(n);
    for (int i = n - 1; i >= 0; i--) {
        fow.insert(m[i]);  rev.insert(n - 1 - m[i]);
        //if (i == n - 1) continue;
        ll a, b, c, d;
        c = *fow.upper_bound(m[i]);
        if (c == n) d = n;
        else d = *fow.upper_bound(c);
        b = n - 1 - *rev.upper_bound(n - 1 - m[i]);
        if (b == -1) a = -1;
        else a = n - 1 - *rev.upper_bound(n - 1 - b);
        ans += (i + 1) * ((b - a) * (c - m[i]) + (m[i] - b) * (d - c));
        /*
        cerr << i _ a _ b _ m[i] _ c _ d _ ans << endl;
        for (auto &i : fow) cerr << i;
        cerr << endl;
        for (auto &i : rev) cerr << i;
        cerr << endl;*/
    }
    cout << ans << endl;

}


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

const int N=int(2e5)+10;
int H,W,n,sr,sc,suf[N];
char s[N],t[N];
bool check(char a,char b,int dis,int lim) {
	suf[n+1]=0;
	int sum=0;
	for (int i=n;i>=1;--i) {
		suf[i]=suf[i+1];
		if (s[i]==b) {
			suf[i]=std::min(suf[i],sum-1);
			--sum;
		}
		if (t[i]==a) {
			if (sum<0) ++sum;
		}
	}
	int pos=dis;
	for (int i=1;i<=n;++i) {
		if (s[i]==a) ++pos;
		if (pos>lim) return 0;
		if (t[i]==b) {
			if (pos-1+suf[i+1]>=1) --pos;
		}
	}
	return 1;
}
int main() {
	scanf("%d%d%d%d%d",&H,&W,&n,&sr,&sc);
	scanf("%s",s+1);
	scanf("%s",t+1);
	if (!check('D','U',sr,H)||!check('U','D',H-sr+1,H)||!check('R','L',sc,W)||!check('L','R',W+1-sc,W))
		puts("NO");
	else puts("YES");
}

Measured memory_bytes: 4816
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int [] inputval= inputval();
        int k = inputval[0];
        int s = inputval[1];
        int cnt = 0;
        for (int i=0; i<=k; i++){
            for (int j=0; j<=k; j++){
                if(s-(i+j)>=0 && s-(i+j)<=k){
                    cnt++;
                }
            }
        }

        System.out.println(cnt);

    }

}



Measured memory_bytes: 32568
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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,k; cin >> n >> k;
    vector<int> high(n,0);
    rep(i,n) cin >> high[i];
    int count = 0;
    rep(i,n){
        if(high[i]>=k) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main(){
	int H;
	int W;
	int j;
	int i;
	for(H=1,W=1;;){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
			cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
const int maxn=1e5+10;
int a[maxn];
inline ll read(){
	ll x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	ll i,j,k,m,n;
	k=read();
	for(i=1;i<=k;i++)a[i]=read();
	ll minans=2,maxans=2;
	for(i=k;i>=1;i--){
		ll mingp=(minans-1)/a[i]+1,maxgp=maxans/a[i];
		minans=mingp*a[i];maxans=(maxgp+1)*a[i]-1;
		if(minans>maxans)return puts("-1"),0;
	}
	printf("%lld %lld\n",minans,maxans);
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  ll Asum=0,Bsum=0;
  ll ans=0;
  ll Dnum=0;
  ll Dsum=0;
  for (int i=0;i<N;i++){
    cin>>A[i];
    Asum+=A[i];
  }
  for (int i=0;i<N;i++){
    cin>>B[i];
    Bsum+=B[i];
    C[i]=A[i]-B[i];
    if (C[i]<0){
      Dnum++;
      Dsum+=C[i];
    }
  }

  if (Asum<Bsum){
    cout<<-1<<endl;
    return 0;
  }
  if (Dsum==0){
    cout<<0<<endl;
    return 0;
  }


  ans=Dnum;



  sort(C.begin(),C.end(),greater<ll>());


  for (int i=0;i<N;i++){
    Dsum+=C[i];
    ans++;
    if (Dsum>=0){
      cout<<ans<<endl;
      return 0;
    }
  }


  cout<<N<<endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  map<int,int>M;
  M[1]=0;M[2]=0;M[3]=0;
  for(int i=0;i<N;i++){
  int a; cin>>a;
    if(a==1){
      M.at(1)++;
    }else if(a==2){
      M.at(2)++;
    }else{
    M.at(3)++;
    }
  }int A=M.at(3);
  int B=M.at(2);
  int C=M.at(1);
  double dp[301][301][301];
  for(int i=0;i<=A;i++){
  for(int j=0;j<=A+B;j++){
  for(int k=0;k<=A+B+C;k++){
  if(i==0 && j==0 && k==0)
    dp[i][j][k]=0;
    else{
      double n=(double)N;
    double I=(double)i;
      double J=(double) j;
      double K=(double) k;
      double a,b,c;
      if(1<=i)
        a=I*dp[i-1][j+1][k];
      else
        a=0;
      if(1<=j)
        b=J*dp[i][j-1][k+1];
      else
        b=0;
      if(1<=k)
        c=K*dp[i][j][k-1];
      else
        c=0;
      
      dp[i][j][k]=(a+b+c+n)/(I+J+K);
    
    }
  
  }
  }
  }cout<<fixed<<setprecision(10)<<dp[A][B][C]<<endl;
   return 0;
}

Measured memory_bytes: 213248
N,M = map(int,input().split())
LR_list = [list(map(int,input().split())) for i in range(M)]

L = [i for i,j in LR_list]
R = [j for i,j in LR_list]
maxL = max(L)
minR = min(R)
ans = minR - maxL + 1
if ans >= 0:
    print(ans)
else:
    print("0")


Measured memory_bytes: 29060
# include <iostream>


int main(){
 int a, b;
 std::cin >> a >> b;
 if( a > b)
 std::cout << "a > b" << std::endl;
 if( a < b)
 std::cout << "a < b" << std::endl;
 if( a == b)
 std::cout << "a == b" << std::endl;
 return 0;
}

Measured memory_bytes: 1160
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int v1 = h1*60+m1;
    int v2 = h2*60+m2;
    int ret = v2-v1-k;
    if (ret < 0)
        cout << ret << endl;
    else
        cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<queue>
#include<string>
using namespace std;
string S; queue<string> Q;
int main() {
	cin >> S; Q.push(S); bool flag = false;
	if (S == "ABC") { flag = true; cout << "Yes" << endl; return 0; }
	while (!Q.empty()) {
		string T = Q.front(); Q.pop();
		for (int i = 0; i < 3; i++) {
			string U = ""; int D = T.size(); bool OK = false;
			for (int j = 0; j < D; j++) {
				if (j < D - 2 && T.substr(j, 3) == "ABC") { U += (char)('A' + i); j += 2; }
				else { U += T[j]; if (T[j] == (char)('A' + i)) { OK = true; break; } }
			}
			if (OK == true)continue;
			if (U == "ABC") { flag = true; break; }
			if (T != U) Q.push(U);
		}
		if (flag == true) { cout << "Yes" << endl; break; }
	}
	if (flag == false)cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3196
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_C&lang=jp

#include <iostream>
#include <cstdio>
#include <iomanip> // setprecision
#include <complex>
#include <cmath>
using namespace std;

typedef complex<double> point;

double inner_product(point x, point y) {
  return (conj(x) * y).real();
}

double outer_product(point x, point y) {
  return (conj(x) * y).imag();
}

point normalize(point a) {
  return a * (1/abs(a)); // normはabsの2乗、absは本来のノルム。
}

point projection(point a, point b) {
  point e = normalize(b);
  return e * inner_product(a, e);
}

bool opposite(point a1, point a2, point b1, point b2) { // 直線a1a2に対し、b1とb2が反対側か否か。ただし端点は考慮しない。
  return (outer_product(a2-a1, b1-a1) * outer_product(a2-a1, b2-a1) < 0);
}

bool crossed(point a1, point a2, point b1, point b2) { // 線分a1a2と線分b1b2が交点を持つか否か。ただし端点は考慮しない。
  return ( opposite(a1, a2, b1, b2) && opposite(b1, b2, a1, a2) );
}

int n;
point P[110];
const double epsilon = 1e-11;

bool isonedge(point X1, point X2, point p) { // X1 X2 の辺上(端点含む)にpがあるかを返す。今回の場合、X1, X2, pの座標は実はすべて整数だから、割り算が出ないようにすれば問題ない。
  if ( (( X1.real() - p.real() ) * ( X2.real() - p.real() ) > 0)
       || 
       (( X1.imag() - p.imag() ) * ( X2.imag() - p.imag() ) > 0)) { 
    // ともかくx, y座標を見て、辺上にない場合を弾く。
    // (x座標だけ見るのではダメであった)
    return false;
  }
  // その後は、X1 X2 と X1 P が平行かどうかを調べる。
  // 念のためepsilonで誤差も気を使う。
  return (abs(outer_product(X1 - X2, X1 - p)) < epsilon);
}

bool isonpol(point p) {
  for (int i=0; i<n; i++) {
    if (isonedge(P[i], P[(i+1)%n], p)) return true;
  }
  return false;
}

bool isin(point p, point q) { // qには、絶対外側であって、線分pqが多角形の頂点にもひっかかる可能性がないものを扱う。
  bool ans = false;
  for (auto i=0; i<n; i++) {
    if (crossed(p, q, P[i], P[(i+1)%n])) ans = !ans;
  }
  return ans;
}

int main() {
  double x, y;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> x >> y;
    P[i] = point(x, y);
  }
  point out = point(20129, 1);
  int q;
  cin >> q;
  for (int i=0; i<q; i++) {
    cin >> x >> y;
    point p = point(x, y);
    if (isonpol(p)) {
      cout << "1" << endl;
    } else if (isin(p, p+out)) {
      cout << "2" << endl;
    } else {
      cout << "0" << endl;
    }
  }
}

Measured memory_bytes: 1232
import numpy as np

n = int(input())
arr = np.array(list(map(int, input().split())))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)

Measured memory_bytes: 48820
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
//using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;
const double PI = acos(-1.0);

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

ll gcd(ll a, ll b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

const int MOD = 1000000007;

class mint
{
  ll x;

public:
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const
  {
    return mint(-x);
  }

  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }

  mint &operator-=(const mint &a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }

  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }

  mint operator+(const mint &a)
  {
    mint res(*this);
    return res += a;
  }

  mint operator-(const mint &a)
  {
    mint res(*this);
    return res -= a;
  }

  mint operator*(const mint &a)
  {
    mint res(*this);
    return res *= a;
  }

  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(MOD - 2);
  }

  mint &operator/=(const mint &a)
  {
    return (*this) *= a.inv();
  }

  mint operator/(const mint &a)
  {
    mint res(*this);
    return res /= a;
  }

  friend ostream &operator<<(ostream &os, const mint &m)
  {
    os << m.x;
    return os;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  ll zero = 0;
  map<pair<ll, ll>, P> mp;
  for (int i = 0; i < n; i++)
  {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0)
    {
      zero++;
      continue;
    }
    ll g = gcd(x, y);
    x /= g, y /= g;
    if (y < 0)
    {
      x = -x, y = -y;
    }
    if (y == 0 && x < 0)
    {
      x = -x, y = -y;
    }
    int rot90 = false;
    if (x <= 0)
      rot90 = true;
    if (rot90)
    {
      ll tmp = x;
      x = y, y = -tmp;
    }
    if (rot90)
      mp[{x, y}].first++;
    else
      mp[{x, y}].second++;
  }

  mint ans = 1;
  for (auto p : mp)
  {
    ll s = p.second.first;
    ll t = p.second.second;
    mint now = 1;              // どちらも選ばない
    now += mint(2).pow(s) - 1; // １匹以上
    now += mint(2).pow(t) - 1;
    ans *= now;
  }
  ans -= 1;
  ans += zero;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16056
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0);
int n;
ll h[200000];
ll mx;
ll ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    rep1(i,0,n) cin >> h[i];

    mx = -10;
    rep1(i,0,n){
        if(mx >= h[i]) ans += mx - h[i];
        else mx = h[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5160
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
int main(){
    cin>>n;
    cout<<(n+1)/2<<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;
const int INF = 1001001001;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b != c) cout << "Yes" << endl;
    else if(a == c && b != c) cout << "Yes" << endl;
    else if(b == c && c != a) cout << "Yes" << endl;
    else cout << "No" << endl;
}  

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

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>



int getTheAnswer() {
    return 42;
}




// only for positive integers
int gcd(int a, int b){
  int tmp;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  while(b != 0){
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

int lcm(int a, int b){
  return abs(a*b) / gcd(a, b);
}


using namespace std;

class TaskA {
public:
  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    int a, b;
    string res = "";
    in >> a >> b;
    if (a > 1 && b > 1) {
      if (a > b) {
        res = "Alice";
      } else if (b > a) {
        res = "Bob";
      } else {
        res = "Draw";
      }
    }else{
      if (a > b) {
        res = "Bob";
      } else if (b > a) {
        res = "Alice";
      } else {
        res = "Draw";
      }
    }
    out << res << endl;
  }
};


int main() {
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int h, w;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	int ans = INF;
	for (int i = 1; i < w; i++) {
		int x = h * i;
		int y = max(h / 2 * (w - i), h*((w - i) / 2));
		int z = h * w - x - y;
		chmin(ans, max({ x,y,z }) - min({ x,y,z }));
	}
	swap(h, w);
	for (int i = 1; i < w; i++) {
		int x = h * i;
		int y = max(h / 2 * (w - i), h*((w - i) / 2));
		int z = h * w - x - y;
		chmin(ans, max({ x,y,z }) - min({ x,y,z }));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()

ruiseki = [0]

for i in range(len(S)):
    if S[i] == "I":
        ruiseki.append(ruiseki[i] + 1)
    elif S[i] == 'D':
        ruiseki.append(ruiseki[i] - 1)

print(max(ruiseki))

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

int main(){
    int K;
    string S;
  cin>>K>>S;
    if(S.size()<=K){
        cout<<S<<endl;
    }
    else
    {
        cout<<S.substr(0,K) + "..."<<endl;
    }
    
    
}

Measured memory_bytes: 3628
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        es: [(usize1, usize1); n - 1],
        m: usize,
        c: [(usize1, usize1); m]
    }
    let mut t = vec![vec![]; n];
    for i in 0..n - 1 {
        let a = es[i].0;
        let b = es[i].1;
        t[a].push((b, i));
        t[b].push((a, i));
    }
    let mut tab = vec![0; n - 1];
    for i in 0..m {
        for p in path(c[i].0, c[i].1, &t) {
            tab[p] |= 1 << i;
        }
    }
    let mut dp: Vec<Vec<usize>> = vec![vec![0; 1 << m]; n];
    dp[0][0] = 1;
    for i in 0..n - 1 {
        for j in 0..1 << m {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j | tab[i]] += dp[i][j];
        }
    }
    println!("{}", dp[n - 1][(1 << m) - 1]);
}

fn path(u: usize, v: usize, t: &Vec<Vec<(usize, usize)>>) -> Vec<usize> {
    let mut st = vec![(u, u, vec![])];
    while let Some((r, p, mut path)) = st.pop() {
        for &(c, e) in &t[r] {
            if c == p {
                continue;
            }
            path.push(e);
            if c == v {
                return path;
            }
            st.push((c, r, path.clone()));
            path.pop();
        }
    }
    vec![]
}


Measured memory_bytes: 413948
N = int(input())
# 初期状態
T = [0]
X = [0]
Y = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

# パリティに着目せよ
count = 0
for i in range(N):
    distanceSum = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i])
    T_parity = (T[i+1]-T[i]) % 2
    Distance_parity = distanceSum % 2
    if distanceSum <= (T[i+1]-T[i]) and T_parity == Distance_parity:
        count += 1

if count == N:
    print('Yes')
else:
    print('No')


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

int parent[100000];
int r[100000]; //rank

void init(int n){
  
  for(int i = 0;i < n;i++){
    parent[i] = i;
    r[i] = 0;
  }
}

int find(int x){
  
  if(parent[x] == x) return x;
  else return parent[x] = find(parent[x]);
}

void unite(int x, int y){
  
  x = find(x);
  y = find(y);
  
  if(x == y) return ;
  
  if(r[x] < r[y]) parent[x] = y;
  else{
    parent[y] = x;
    if(r[x] == r[y]) r[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
  
  int n, q, com, x, y;
  
  cin >> n;
  init(n);
  
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> com >> x >> y;
    
    if(com == 0) unite(x, y);
    if(com == 1) cout << same(x, y) << endl;
  }
  
  return 0;
}


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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputlongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long N = inputlongArray[0];
            long K = inputlongArray[1];

            var inputlong = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] A = new long[N + 1];
            long[] B = new long[N + 1];
            long[] C = new long[N + 1];
            long[] D = new long[N + 1];
            long[] E = new long[N + 1];

            for (long i=1; i < N+1; i++)
            {
                A[i] = inputlong[i-1];
                B[i] = 1;
                D[i] = 1;
            }

            long cnt = 0;
            long j = 1;
            C[1] = 1;

            for(long i = 2; i < N+1 && B[j]==1 ; i++)
            {
                B[j] = 0;
                C[i] = A[j];
                j = A[j];
                //Console.WriteLine("j=" + j);
                cnt++;
            }



            //for (long i = 1; i < cnt + 1; i++)
            //{
            //    Console.WriteLine("C"+i + "=" + C[i]);
            //}


            if (K+1 -cnt > 0) 
            {
                long cnt2 = 1;
                K = K + 1 - cnt;
                E[1] = j;

                for (long i = 2; i < N + 1 && D[j] == 1 && K > 0; i++)
                {
                    D[j] = 0;
                    E[i] = A[j];
                    j = A[j];
                    cnt2++;
                }
                cnt2 = cnt2 - 1;

                //for (long i = 1; i < cnt2 + 1; i++)
                //{
                //    Console.WriteLine("E" + i + "=" + E[i]);
                //}

                long k = (K) % cnt2;
                E[0] = E[cnt2];

                //Console.WriteLine("cnt="+cnt);
                //Console.WriteLine("cnt2="+cnt2);
                Console.WriteLine(E[k]);
            }

            else
            {
                Console.WriteLine(C[K+1]);
            }
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 50440
#include <iostream>
using namespace std;
int main(){
        int a, b;
        cin >> a >> b;
        string ans;
        if (a>b){
                ans = ">";
        } else if(a==b) {
                ans = "==";
        } else {
                ans = "<";
        }
        cout << "a " << ans << " b" << endl;
        return 0;
}


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

int main(){
    int n;
    cin>>n;
    int p[200010];
    int ans=0;
    int tmp=200010;
    rep(i, n){
        cin>>p[i];
        if(tmp>p[i]) ans++;
        tmp=min(tmp,p[i]);
    }
    cout<<ans<<endl;
}

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

const int MAXN = 2010;
std::priority_queue<int> q;
std::vector<int> to[MAXN], gr[MAXN];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int n, A[MAXN], ind[MAXN], tim[MAXN], idx;
bool vis[MAXN];
void dfs(int u) {
	vis[u] = true; tim[u] = ++idx;
	for (int i : gr[u]) if (!vis[i])
		dfs(i);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> A[i];
	std::sort(A + 1, A + 1 + n);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (gcd(A[i], A[j]) > 1) {
				gr[i].push_back(j);
				gr[j].push_back(i);
			}
	for (int i = 1; i <= n; ++i) if (!vis[i]) dfs(i);
	for (int i = 1; i <= n; ++i)
		for (auto t : gr[i])
			if (tim[i] < tim[t])
				++ind[t], to[i].push_back(t);
	for (int i = 1; i <= n; ++i) if (!ind[i]) q.push(i);
	for (int i = 1, t; i <= n; ++i) {
		std::cout << (A[t = q.top()]) << (" \n" [i == n]); q.pop();
		for (int j : to[t]) if (!--ind[j]) q.push(j);
	}
	return 0;
}


Measured memory_bytes: 23168
#include<stdio.h>
int main()
{
    int a,b,c;
    int jyuu,ichi,tas;
    int tmp;
    char s[101];
    // スペース区切りの整数の入力
    scanf("%d %d %d",&a,&b,&c);

	if(a > b) {
	tmp = a;
	ichi = b;
	}else{
	tmp = b;
	ichi = a;
	}

	if(tmp > c){
	jyuu = tmp;
	tas = c;
	}else{
	jyuu = c;
	tas = tmp;
	}


    // 出力
    printf("%d\n",jyuu*10+ichi+tas);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
vector<vector<int>> to(100000);
vector<bool> reach(100000);

int dfs(int u){
  if(reach[u]) return 0;
  reach[u] = true;
  for(int v : to[u]) dfs(v);
  return 1;
}

int main(void){
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int>> xyz;
  REP(i, m){
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    to[x].emplace_back(y);
    to[y].emplace_back(x);
  }
  int ans = 0;
  REP(i, n) ans += dfs(i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8832
import sys
imput =sys.stdin.readline
N, Q =map(int,input().split())
S =[i for i in input()]
q = [[int(i) for i in input().split()] for _ in range(Q)]
num = 0
for i in range(N-1):
    if S[i]+S[i+1]=="AC":
        num += 1
    S[i] = num
S[-1] = num
S.append(0)
for lr in q:
  print(S[lr[1]-2] -S[lr[0]-2])

Measured memory_bytes: 24348
#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

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

using namespace std;
using ll = long long;

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP




int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M, A, B;
    cin >> N >> M;
    atcoder::dsu d(N);
    for (int i = 0; i < M; ++i) {
            cin >> A >> B;
            --A; --B;
            d.merge(A, B);
          //  cout << d.size(i) << endl;
    }       

    int cnt = 0; 

        for (int i = 0; i < N; ++i) {
           if(d.leader(i) == i) ++cnt;
            //cout << i  << "  " << d.leader(i) << endl; 連結成分の各頂点の確認
    }        
    

    cout << cnt -1 << endl;
    
    return 0;
}

Measured memory_bytes: 3728
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	var s string
	fmt.Scanf("%s", &s)

	red := 0
	for _, c := range s {
		if c == 'R' {
			red++
		}
	}

	move := 0
	for i := 0; i < red; i++ {
		if s[i] == 'W' {
			move++
		}
	}

	fmt.Printf("%d\n", move)
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000
typedef long long ll;

int main(){
  string s,t;
  cin>>s>>t;
  ll S=s.size(),T=t.size();
  
  ll dp[S+1][T+1];
  rep(i,S+1)rep(j,T+1) dp[i][j] = 0;
  
  
  rep(i,S){
  	rep(j,T){
		if(s[i]==t[j]){
 
           dp[i+1][j+1] = dp[i][j]+1;
          
        }else{
           dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
        }
    }
  }
  
  int d = dp[S][T];
  int x = S;
  int y = T;
  string ans="";
  
  while(1){
  	if(d==0) break;
    if(dp[x-1][y] == d) x--;
    else if(dp[x][y-1] == d) y--;
    else {
    	ans+=s[x-1];
      	x--,y--,d--;
    }
  }
  for(int i=ans.size()-1;i>=0;i--){
  	cout<<ans[i];
  }
  
}

Measured memory_bytes: 70656