akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

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

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

using namespace std;

int main(){
    int h, n;
    cin >> h >> n;

    int tmp = 0;
    int sum = 0;
    for(int i = 0; i<n; i++){
        cin >> tmp;
        sum += tmp;
    }

    if(sum >= h){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e5+5;
const ll mod = 1e9+7;
ll dp[N];
vector<ll>v[N];
void solve(){
    int n;
    cin>>n;
    int x,y;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ll ans = 1;
    dp[1] = 1;
    for(ll i=2;i<=n;i++){
        dp[i] = dp[i-1]+i;
        for(int x:v[i]){
            if(x<i)dp[i]-=x;
        }
        assert(dp[i]>0);
        ans+=dp[i];
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

signed main(){
  string S;
  cin >> S;
  
  bool fg = 0;
  for( int i = 0; i < S.size(); i++ ){
    if( fg == 0 && S.at(i) == 'h' ){
      fg = 1;
    }else if( fg == 1 && S.at(i) == 'i' ){
      fg = 0;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  if( fg == 0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::collections::*;
use std::cmp::Ordering;

fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let d: usize = iter.next().unwrap().parse().unwrap();
    let g: i64 = iter.next().unwrap().parse().unwrap();
    let mut p: Vec<i64> = Vec::with_capacity(d);
    let mut c: Vec<i64> = Vec::with_capacity(d);
    
    for _ in 0..d {
        p.push(iter.next().unwrap().parse().unwrap());
        c.push(iter.next().unwrap().parse().unwrap());
    }

    let mut best_eff: Vec<i64> = Vec::with_capacity(d);
    let mut complete: Vec<i64> = Vec::with_capacity(d);
    
    for i in 0..d {
        best_eff.push((i as i64 +1)*100*(p[i] - 1));
        complete.push((i as i64 +1)*100*p[i] + c[i]);
    }

    let mut hset = (0..d).collect::<HashSet<_>>();

    println!("{}", calc(d, g, &mut hset, &best_eff, &complete, &p));
}

fn calc(d: usize, rest_score: i64, problems: &mut HashSet<usize>, best_eff: &[i64], complete: &[i64], p: &[i64]) -> i64 {
    if rest_score <= 0 {
        return 0;
    }

    let mut min = 1i64 << 60;

    let mut max_best_eff = 0;
    let mut max_bset_eff_p = 0i64;
    for &prob in problems.iter() {
        if max_best_eff < best_eff[prob] {
            max_best_eff = best_eff[prob];
            max_bset_eff_p = prob as i64;
        }
    }
    if max_best_eff >= rest_score {
        min = std::cmp::min(min, 
            if rest_score % (100 * (max_bset_eff_p + 1)) == 0 {
                rest_score / (100 * (max_bset_eff_p + 1))
            } else {
                rest_score / (100 * (max_bset_eff_p + 1)) + 1
            }
        );
    }
    let problems_clone: Vec<_> = problems.iter().cloned().collect();
    for prob in problems_clone {
        problems.remove(&prob);
        min = std::cmp::min(
            min,
            p[prob] + calc(d,rest_score - complete[prob],problems,best_eff,complete,p)
        );
        problems.insert(prob);
    }
    min
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <string.h>
#include <cmath>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define max3(A,B,C) max((A),max((B),(C)))
#define popcount(X) __builtin_popcount(X)
#define popcountl(X) __builtin_popcountl(X)
#define getbit(x,i) (1&((x)>>(i)))
#define setbit(x,i,bit) ((x)|=((bit)<<(i)))
#define getbitl(x,i) (1&((x)>>((ll)i)))
#define setbitl(x,i,bit) ((x)|=((bit)<<((ll)i)))
#define log2(x) (32 - __builtin_clz(x))
#define log2l(x) (32 - __builtin_clzl(x))

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int INF = 0x3f3f3f3f;
const long long int INFL = 0x3f3f3f3f3f3f3f3f;
const double pi = atan(1.0)*4.0;
const int N = 3e5 + 500;

int dist[N], mrc[N];
vii v[N];
set<ii> st;

void Dijkstra(int o, int n) {
	memset(dist,INF,sizeof(dist));
	st.clear();
	st.insert(mp(0,o));
	dist[o] = 0;
	for(int i = 0; i < n; i++) if(i != o) st.insert(mp(INF,i));
	memset(mrc,0,sizeof(mrc));
	while(!st.empty()) {
		set<ii>::iterator it = st.begin();
		if(mrc[it->s] == 0) {
			mrc[it->s] = 1;
			for(int i = 0; i < v[it->s].size(); i++) {
				if(dist[it->s] + v[it->s][i].s < dist[v[it->s][i].f]) {
					st.erase(mp(dist[v[it->s][i].f], v[it->s][i].f));
					dist[v[it->s][i].f] = dist[it->s] + v[it->s][i].s;
					st.insert(mp(dist[v[it->s][i].f], v[it->s][i].f));
				}
			}
		}
		st.erase(it);
	}
}


int main(void) {
	int n;
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++) {
		int u, k;
		scanf("%d %d", &u, &k);
		for(int j = 0; j < k; j++) {
			int vt, c;
			scanf("%d %d", &vt, &c);
			v[u].pb(mp(vt,c));
		}
	}
	Dijkstra(0,n);
	for(int i = 0; i < n; i++) {
		printf("%d %d\n", i, dist[i]);
	}
	
	return 0;
}


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

int main()
{
	int x, i;
	i = 1;

while(i)
{
	cin >> x;
	if (x == 0)
	{
		break;
	}
	cout << "Case " << i << ": " << x << endl;
	i++;
}
return 0;
}

Measured memory_bytes: 3072
program ABC_053_B_AtoZString
    implicit none
	integer i, starts, ends
    character(200000) s
    read(*, *) s
    do i = 1, len_trim(s)
		if(s(i:i) == 'A') then
			starts = i
			exit
		end if
	end do
    do i = 1, len_trim(s)
		if(s(len_trim(s)+1-i:len_trim(s)+1-i) == 'Z') then
			ends = len_trim(s)+1-i
			exit
		end if
	end do
	write(*, *) ends - starts + 1
end program ABC_053_B_AtoZString

Measured memory_bytes: 1084
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt = 0;
    int hmax = 0;
    REP(i, N) {
        int h; cin >> h;
        if (hmax <= h) cnt++;
        hmax = max(hmax, h);
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll a;
	cin >> a;
	double b;
	cin >> b;
	float ib = b * 100;
	ll x = ib;
	a *=x;
	a /= 100;
	cout << a << endl;
	return 0;
}


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

int main(){
    int n,q;

    
    cin >>n>>q;
    vector<vector<int>> adj(n+1);
    bool visit[n+1];
    int px[n+1]={};

    for (int i = 0; i < n-1; i++){
        visit[i]=false;
        
        int a,b;
        cin>>a>>b;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    visit[n-1]=false;visit[n]=false;
    
    for (int i = 0; i < q; i++){
        int p,x;
        cin >>p>>x;
        px[p] += x;
    }
    

    queue<int> que;
    que.push(1);

    while(que.size()){
        int cur=que.front();
        visit[cur]=true;
        que.pop();

        //cout << cur<<"::"<<px[cur]<< endl;//

        for (int j = 0; j < (int)adj[cur].size(); j++){
            

            int nex=adj[cur][j];
            if(visit[nex]==true)continue;


            px[nex] += px[cur];

            que.push(nex);

            //cout << cur<<"--"<<nex<< endl;//
        }
        

    }


    for (int i = 1; i <= n; i++){
        cout << px[i] << " ";
    }
    std::cout << '\n';


    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  ll c[3];
  cin >> c[0] >> c[1] >> c[2] >> n;
  sort(c,c+3);
  ll count = 0;
  REP(i,n/c[2]+1){
    ll rem1 = n - i*c[2];
    REP(j,rem1/c[1]+1){
      ll rem2 = rem1 - j*c[1];
      if(rem2%c[0]==0)count++;
    }
  }
  cout << count << endl;
  return 0;
}


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

typedef long long ll;
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
ll dp[102][100009],wt[102],v[102];

ll knapsack(ll n,ll s,ll w)
{
    ll a,b;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=s; j++){
            if(i==0) dp[i][j]=-1;
            else if(j==0) dp[i][j]=0;
            else if(v[i]>j){
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                a=dp[i-1][j];
                b= dp[i-1][j-v[i]]==-1? -1:wt[i]+dp[i-1][j-v[i]];
                if(a==-1 && b==-1)
                {
                    dp[i][j]=-1;
                }
                else if(a==-1)
                {
                    dp[i][j]=b;
                }
                else if(b==-1){
                    dp[i][j]=a;
                }
                else{
                    dp[i][j]=min(a,b);
                }
            }
        }
        dp[0][0]=0;
    }
    
    for(int j=s; j>=0; j--){
        if(dp[n][j]<=w && dp[n][j]!=-1) return j;
    }
}
int main()
{
   ll n,w,i,s=0;
   scanf("%lld %lld",&n,&w);
   for(i=1; i<=n; i++){
        scanf("%lld %lld",&wt[i],&v[i]);    
        s+=v[i];
   }
 
   ll ans=knapsack(n,s,w);
   printf("%lld\n",ans);
   return 0;
}

Measured memory_bytes: 82600
#include<iostream>
using namespace std;
int b[105];
int main(void)
{
    int n,sum=0;
    cin >> n;
    for(int i=1;i<=n-1;i++)
        cin >> b[i];
    sum=b[1]+b[n-1];
    for(int i=2;i<=n-1;i++)
        sum+=min(b[i-1],b[i]);
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  n <- readLn
  ws <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve ws

solve :: U.Vector Int -> Int
solve ws = U.minimum $ U.map (\x -> abs (2 * x - s)) $ U.scanl' (+) 0 ws
  where
    s = U.sum ws

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
 
    int N;
    int ans = 0;
    cin >> N;
    
    
    
    for(int i = 1; i <= N; i++){
        string S = to_string(i);
        if( (S.size() % 2) != 0 ){
            ans++;
        }
    }
    
    cout << ans << endl;
    
    
}


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

int main() {
    // input
    int k; scanf("%d", &k);
    vector<int> a(k); REP (i, k) scanf("%d", &a[i]);
    // solve
    reverse(ALL(a));
    ll l = 2, r = 3;
    for (int a_i : a) {
        l = (l + a_i - 1) / a_i * a_i;
        r = (r + a_i - 1) / a_i * a_i;
    }
    // output
    if (l == r) {
        printf("-1\n");
    } else {
        printf("%lld %lld\n", l, r - 1);
    }
    return 0;
}


Measured memory_bytes: 640
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut v = (0..n)
        .map(|i| (sc.read::<String>(), -sc.read::<i64>(), i))
        .collect::<Vec<_>>();
    v.sort();
    for (_, _, i) in v.into_iter() {
        println!("{}", i + 1);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 15;
int n, m;
int f[maxn][1 << maxn];
int edge[maxn][maxn];
int g[1 << maxn];
inline void up(int & x,int y) {
	if(x < y) {
		x = y;
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	int sum = 0;
	rep(i, 1, m) {
		int a, b, c;
		cin >> a >> b >> c;
		-- a, -- b;
		edge[a][b] = c;
		edge[b][a] = c;
		for(int j = 0;j < 1 << n;++j) if(j >> a & j >> b & 1) {
			g[j] += c;
		}
		sum += c;
	}
	for(int i = 0;i < n;++i) {
		for(int j = 0;j < 1 << n;++j) {
			f[i][j] = -1e9;
		}
	}
	for(int i = 1;i < 1 << n;i += 2)
		f[0][i] = g[i];
	for(int j = 0;j < 1 << n;++j) {
		for(int i = 0;i < n;++i) if(f[i][j] >= 0) {
			for(int l = 0;l < n;++l) if(edge[i][l] && !(j >> l & 1)) {
				for(int s = ~(j | 1 << l) & (1 << n) - 1, k = s;k;k = k - 1 & s) {
					up(f[l][k | j | 1 << l], f[i][j] + edge[i][l] + g[k | 1 << l]);
				}
				up(f[l][j | 1 << l], f[i][j] + edge[i][l]);
			}
		}
	}
	cout << sum - f[n - 1][(1 << n) - 1] << '\n';
}


Measured memory_bytes: 2304
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int L = 10395+10;
const int N = 13;
const int M = (1<<12)+1;

bitset<L>cp[N][N],f[M];
int n,m;
char s[N][N];
bool bz[N];
int tp[L][N];
int k;
int ct[N];

void dfs(int x,bool tg){
	if (x>m){
		k++;
		fo(i,1,m)tp[k][i]=ct[i];
		return;
	}
	if (bz[x]){dfs(x+1,tg);return;}
	fo(i,x+1,m)
	if (!bz[i]){
		bz[x]=bz[i]=1;
		ct[x]=i,ct[i]=x;
		dfs(x+1,tg);
		ct[x]=ct[i]=0;
		bz[x]=bz[i]=0;
	}
	if (!tg&&(m&1)>0){
		bz[x]=1;
		ct[x]=x;
		dfs(x+1,1);
		ct[x]=x;
		bz[x]=0;
	}
}

int cnt[M];

int main(){
	//freopen("data.in","r",stdin);
	n=get();m=get();
	fo(i,1,n)scanf("%s",s[i]+1);
	dfs(1,0);
	fo(i,1,n){
		fo(j,i,n){
			fo(w,1,k){
				bool pd=1;
				fo(x,1,m)pd&=(s[j][tp[w][x]]==s[i][x]);
				if (pd)cp[i][j][w-1]=1;
			}
		}
	}
	if (n&1){
		fo(st,1,n)
			f[(1<<(st-1))]=cp[st][st];
	}
	else
	fo(i,0,k-1)f[0][i]=1;
	fo(i,1,(1<<n)-1)cnt[i]=cnt[i-(i&-i)]+1;
	fo(i,0,(1<<n)-1)
	if (cnt[i]+2<=n){
		int x;
		fo(w,1,n)
		if (((1<<(w-1))&i)==0){x=w;break;}
		fo(y,x+1,n)
		if (((1<<(y-1))&i)==0)f[i|(1<<(x-1))|(1<<(y-1))]=f[i|(1<<(x-1))|(1<<(y-1))]|(f[i]&cp[x][y]);
	}
	bool ans=0;
	fo(i,0,k-1)ans=ans|f[(1<<n)-1][i];
	if (ans)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,n)cin>>a[i];
  set<ll> s;
  vll b(0);
  b.pb(1);
  s.insert(1);
  ll i=0;
  ll cu;
  while(1){
    if(s.count(a[i])){
      cu=a[i];
      break;
    }
    s.insert(a[i]);
    b.pb(a[i]);
    i=a[i]-1;
  }
  ll l;
  rep(i,sz(b)){
    if(b[i]==cu){
      l=i;
    }
  }
  if(k>=l){
    k-=l;
    COUT(b[k%(sz(b)-l)+l]);
  }
  else{
    COUT(b[k]);
  }
}

Measured memory_bytes: 15576
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
  t[i+1], x[i+1], y[i+1] = map(int, input().split())
is_able = True
 
for i in range(N):
  dt = t[i+1] - t[i]
  dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if dt < dist:
    is_able = False
  if dt % 2 != dist % 2:
    is_able = False
  
if is_able:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 11636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j;
	char a[100];
	cin>>a;
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]=='C')
		{
			for(j=i+1;j<strlen(a);j++)
			{
				if(a[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
 	return 0;
}


Measured memory_bytes: 256
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   string str1,str2;
   cin >> str1;
   cin >> str2;
   int len = str1.length();
   for(int i=0; i < len; ++i){
	   if(str1[i] != str2[i]){
		   cout << "No";
		   return;
	   }
   }
   cout << "Yes";
}

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



Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	vs cur{ "a" };
	for (int i = 1; i < n; i++)
	{
		vs next;
		for (auto s : cur)
		{
			char maxc = 'a';
			for (auto c : s)
				maxc = max(maxc, c);
			for (char c = 'a'; c <= 'z'; c++)
			{
				if (c <= maxc + 1)
					next.push_back(s + c);
			}
		}
		cur = next;
	}
	sort(all(cur));
	for (auto s : cur)
		cout << s << "\n";
	return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

constexpr int N = (int)2e5 +15496;
constexpr int mod = (int)1e9 + 7;
vector<int> g[N];
int fac[N+1],ifac[N+1], ans[N], dp[N], sz[N];

int powmod(int64_t a, int64_t b) {
  int64_t res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}

void init() {
  fac[0] = ifac[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = (int64_t) fac[i - 1] * i % mod;
  }
  ifac[N - 1] = powmod(fac[N - 1], mod - 2);
  for (int i = N - 2; i >= 1; --i) {
    ifac[i] = (int64_t) ifac[i + 1] * (i + 1) % mod;
  }
}

void dfs1(int v, int p = -1) {
  int prod = 1;
  for (int u : g[v]) if (u != p) {
    dfs1(u, v);
    prod = (int64_t) prod * dp[u] % mod * ifac[sz[u]] % mod;
    sz[v] += sz[u];
  }
  sz[v] += 1;
  dp[v] = (int64_t) prod * fac[sz[v] - 1] % mod;
}

void dfs2(int v, int p = -1) {
  ans[v] = dp[v];

  for (int u : g[v]) if (u != p) {
    dp[v] = (int64_t) dp[v] * ifac[sz[v] - 1] % mod;
    dp[v] = (int64_t) dp[v] * fac[sz[u]] % mod;
    dp[v] = (int64_t) dp[v] * powmod(dp[u], mod - 2) % mod;
    dp[u] = (int64_t) dp[u] * ifac[sz[u] - 1] % mod;

    sz[v] -= sz[u];
    sz[u] += sz[v];
    dp[v] = (int64_t) dp[v] * fac[sz[v] - 1] % mod;

    dp[u] = (int64_t) dp[u] * fac[sz[u] - 1] % mod;
    dp[u] = (int64_t) dp[u] * dp[v] % mod;
    dp[u] = (int64_t) dp[u] * ifac[sz[v]] % mod;


    dfs2(u, v);

    dp[u] = (int64_t) dp[u] * fac[sz[v]] % mod;
    dp[u] = (int64_t) dp[u] * powmod(dp[v], mod - 2) % mod;
    dp[u] = (int64_t) dp[u] * ifac[sz[u] - 1] % mod;

    dp[v] = (int64_t) dp[v] * ifac[sz[v] - 1] % mod;
    sz[u] -= sz[v];
    sz[v] += sz[u];

    dp[u] = (int64_t) dp[u] * fac[sz[u] - 1] % mod;
    dp[v] = (int64_t) dp[v] * dp[u] % mod;
    dp[v] = (int64_t) dp[v] * fac[sz[v] - 1] % mod;
    dp[v] = (int64_t) dp[v] * ifac[sz[u]] % mod;
  }
}

void solve(std::istream &in, std::ostream &out) {
  init();
  int n;
  in >> n;
  for (int i = 0, a, b; i < n - 1; ++i) {
    in >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs1(0);
  dfs2(0);
  for (int i = 0; i < n; ++i) {
    out << ans[i] << '\n';
  }
}



Measured memory_bytes: 18420
n, m = list(map(int, input().split(' ')))

bridges = []

for i in range(m):
    bridges += list(map(int, input().split(' ')))
    
counter  = [0] * n
for i in range(m * 2):
    counter[bridges[i] - 1] += 1

for i in range(n):
    print(counter[i])


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

#define ll long long 

int main() {
  
  int N;
  cin >> N;
  
  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  
  
  ll ans = 1;
  
  for (int i = 0; i < N; i++) {
    if (A[i] <= 1000000000000000000 / ans) {
      ans *= A[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4404
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-27 15:39:39
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; ++i) {
    int x, l; cin >> x >> l;
    v.emplace_back(x - l, x + l);
  }

  sort(all(v), [](const pair<int, int>& p, const pair<int, int>& q) {
    return p.second < q.second;
  });

  int cur = v[0].second;
  int ans = 1;

  for (int i = 1; i < n; ++i) {
    if (v[i].first >= cur) {
      ++ans;
      cur = v[i].second;
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define REP(i,m,n) for(int i=(int)m; i < (int) n; ++i)
#define rep(i,n) REP(i,0,n)

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

  string s; cin >> s;
  int N = s.size();
  int ans = 1e9;

  for(char c = 'a'; c <= 'z'; c++) {
    int cnt = 0, tmp = 0;
    rep(i, N) {
      if(s[i] == c) {
        tmp = max(tmp, cnt);
        cnt = 0;
      } else {
        cnt++;
      }
    }
    tmp = max(tmp, cnt);
    ans = min(ans, tmp);
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan= new Scanner(System.in);
        int N= scan.nextInt();
        int M= scan.nextInt();
        int answer=0;
        if(N>=1) {
            answer = (N * (N - 1));
        }
        if(M>=1){
            answer+= (M*(M-1));
        }
        System.out.println(answer/2);
    }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#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 <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N;
   cin >> N;
   int ans[10001];
   memset(ans,0,sizeof(ans));
   for(int i = 1; i <= 100; i++){
      for(int j=1;j<=100;j++){
         for(int k=1;k<=100;k++){
            int cur = i*i+j*j+k*k+i*j+j*k+k*i;
            if(cur>10000){
               break;
            }
            ans[cur]++;
         }
      }
   }
   for(int i = 1;i<=N;i++){
      cout << ans[i]<<endl;
   }
   return 0;
}


Measured memory_bytes: 3660
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val Array(w, h, x, y) = readLine.trim.split(' ').map(_.toLong)
  println(s"${"%.1f".format(w * h * 0.5)} ${if (x * 2 == w && y * 2 == h) 1 else 0}")
  implicit class Scope[T](val receiver: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(receiver)
    def tap(@inline func: T ⇒ Unit): T = {
      func(receiver)
      receiver
    }
  }
}


Measured memory_bytes: 25524
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn f(h: usize) -> usize {
    if h == 1 {
        1
    } else {
        1 + 2 * f(h / 2)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();

    // input
    let h: usize = read(&mut stdin_lock, &mut buf, b' ');

    println!("{}", f(h));
}


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string S;
    cin >> S;
    bool is_pro = true;
    int is_C = false;
    int cap_count = 0;
    for(int i = 0; i < (int)S.size(); i++){
        if(i == 0){
            if(S[i] == 'A'){
                cap_count++;
                continue;
            }else{
                is_pro = false;
                break;
            }
        }
        if(S[i] >= 'A' && S[i] <= 'Z'){
            cap_count++;
        }
        if(i >= 2 && i <= (int)S.size()-2){ 
            if(S.at(i) == 'C') is_C = true;
        }
    }
    if(cap_count == 2 && is_pro && is_C){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    set<string> s;
    for(int i=0;i<n;i++){
        char l[6],r[12];
        scanf("%s %s",&l,&r);
        string k=r;
        if(l[0]=='i'){
            s.insert(k);
        }else{
            if(s.find(k)!=s.end()){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 27036
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, k, l;

class dsu {
public:
    vector<int> p;
    int n;
    
    dsu(int _n) : n(_n) {
        p.resize(n);//n nodes, 0 ~ n-1
        iota(p.begin(), p.end(), 0);
    }
    
    inline void re_init(){
        iota(p.begin(), p.end(), 0);
    }
    
    inline int findset(int x) {
        return (x == p[x] ? x : (p[x] = findset(p[x])));
    }
    
    inline bool unite(int x, int y) {
        x = findset(x);
        y = findset(y);
        if (x != y) {
            p[x] = y;
            return true;
        }
        return false;
    }
    int num_of_component(){
        int ans = 0;
        for (int i = 0; i < n; i++){
            if(i == findset(i)) ans++;
        }
        return ans;
    }
    
    void every_component_size(){
        map<int, int> cnt;
        for (int i = 0; i < n; i++){
            cnt[findset(i)] ++;
        }
        
        int num_comp = cnt.size();
        for (int i = 0; i < n; i++){
            cout<<cnt[findset(i)]<<' ';//每个节点所属连通分量的节点数量
        }
    }
};

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k>>l;
    dsu d1(n), d2(n);
    
    int u,v;
    for (int i = 0; i < k; i++){
        cin>>u>>v;
        u--,v--;
        d1.unite(u, v);
    }
    
    for (int i = 0; i < l; i++){
        cin>>u>>v;
        u--, v--;
        d2.unite(u, v);
    }
    
    map<pair<int, int>, int> cnt;
    
    for (int i = 0; i < n; i++){
        cnt[{d1.findset(i), d2.findset(i)}] ++;
    }
    
    for (int i = 0; i < n; i++){
        cout<<cnt[{d1.findset(i), d2.findset(i)}]<<" \n"[i==n-1];
    }
    
    
    return 0;
}



Measured memory_bytes: 13568
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    ll ans = M;
    for (ll i = 0; i + t.size() < s.size() + 1; i++)
    {
        ll x = 0;
        for (ll j = 0; j < t.size(); j++)
            x += s[i + j] != t[j];
        ans = min(ans, x);
    }
    cout << ans;
}

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

for i in range(M):
	del X[i][0]

count = 0
for i in range(2**N):
	check = True
	for j in range(M):
		on = 0
		for k in X[j]:
			if (i >> (k-1)) & 1 == 1:
				on += 1
		if on%2 != p[j]:
			check = False
	if check:
		count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int K;
  long long int* A;
  long long int* B;
  A = new long long int;
  B = new long long int;
  cin >> K >> *A >> *B;
  long long int n = (K - *A + 1) / 2;
  long long int C = *B - *A;
  delete A;
  delete B;
  if (C <= 2 ){
    cout << K + 1 << endl;
  } else{
    cout << K + 1 + (C - 2) * n << endl;
  }
}

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

class seg_node {
public:
	using T1 = int;
	using T2 = int;

	static const T1 id = INT_MAX;
	static T1 op(const T1& l, const T1& r) { return min(l, r); }

	T1 get() const {
		if (!flag) return val;
		return lazy;
	}
	bool is_updated() const {
		return flag;
	}
	void update(T2 v) {
		if (!flag) {
			lazy = v;
			flag = true;
			return;
		}
		lazy = v;
	}
	void update_up(const seg_node& l, const seg_node& r) {
		val = op(l.get(), r.get());
	}
	void push(seg_node& l, seg_node& r) {
		if (!flag) return;
		l.update(lazy);
		r.update(lazy);
		val = get();
		flag = false;
	}
	void init(const seg_node& l, const seg_node& r) {
		val = op(l.val, r.val);
	}
	void init(const T1& v) {
		val = v;
	}
	seg_node() : val(id), flag(false) {}

private:
	T1 val;
	T2 lazy;
	bool flag;

};

template <typename M>
class segment_tree {
	using T1 = typename M::T1;
	using T2 = typename M::T2;
	const int h, n;
	vector<M> data;
	void push(int node) {
		data[node].push(data[node << 1], data[(node << 1) | 1]);
	}
	void update(int node) {
		data[node].update_up(data[node << 1], data[(node << 1) | 1]);
	}
public:
	segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {}
	segment_tree(int n_, T1 v1)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		for (int i = 0; i < n_; i++) {
			data[i + n].init(v1);
		}
		init();
	}
	segment_tree(const vector<T1>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2) {
		for (int i = 0; i < (int)data_.size(); i++) {
			data[i + n].init(data_[i]);
		}
		init();
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) {
			data[i].init(data[i << 1], data[(i << 1) | 1]);
		}
	}
	void update(int l, int r, T2 val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) data[l++].update(val);
			if (r & 1) data[--r].update(val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (!data[tl].is_updated()) update(tl);
			if (!data[tr].is_updated()) update(tr);
		}
	}
	T1 find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T1 res1 = M::id, res2 = M::id;
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++].get());
			if (r & 1) res2 = M::op(data[--r].get(), res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	segment_tree<seg_node> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}



Measured memory_bytes: 6108
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    vector<int> a;
    vector<int> b;
    vector<int> c;

    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        b.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long count = 0;
    for (int i = 0; i < n; i++) {
        long a_num = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        long c_num = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        count += a_num * c_num;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 2416
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll aa[MAX_N], bb[MAX_N], ab[MAX_N], abinv[MAX_N];
ll n, a, b, c;

const int MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

int main() {
    COMinit();
    
    cin >> n >> a >> b >> c;
    aa[0] = 1;
    bb[0] = 1;
    ab[0] = 1;
    abinv[0] = modinv(ab[0],MOD);
    srep(i,1,MAX_N){
        aa[i] = aa[i-1] * a % MOD;
        bb[i] = bb[i-1] * b % MOD;
        ab[i] = ab[i-1] * (a + b) % MOD;
        abinv[i] = modinv(ab[i], MOD);
    }

    ll ans = 0;

    srep(i,n,n*2){
        ll ii = i;
        ll tmp1 = ii * aa[n] % MOD * bb[i-n] % MOD * abinv[i] % MOD * COM(i-1, n-1) % MOD;
        ll tmp2 = ii * bb[n] % MOD * aa[i-n] % MOD * abinv[i] % MOD * COM(i-1, n-1) % MOD;
        ans += tmp1 + tmp2;
        ans %= MOD;
    }

    ans = ans * (a+b+c) % MOD * modinv(a + b, MOD) % MOD;

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



Measured memory_bytes: 18560
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int main(){
  int n;
  cin>>n;
  rep(repeat, n){
    char rule[10];
    scanf("%s", rule);
    string s;
    cin>>s;

    int sz=s.size();
    for(int i=strlen(rule)-1; i>=0; i--){
      switch(rule[i]){
      case 'J':
	s = s.substr(sz-1,1) + s.substr(0, sz-1);
	break;
      case 'C':
	s = s.substr(1, sz-1) + s.substr(0,1);
	break;
      case 'E':
	s = s.substr((sz+1)/2, sz/2) + s.substr(sz/2, sz%2)
	  + s.substr(0, sz/2);
	break;
      case 'A':
	reverse(all(s));
	break;
      case 'P':
	rep(j,sz){
	  if(s[j]>='1' && s[j]<='9') s[j]--;
	  else if(s[j]=='0') s[j]='9';
	}
	break;
      case 'M':
	rep(j,sz){
	  if(s[j]>='0' && s[j]<='8') s[j]++;
	  else if(s[j]=='9') s[j]='0';
	}
	break;
      default:
	cout<<"BUG"<<endl;
      }
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
N,M,Q = map(int, input().split())
 
arr=[list(map(int,input().split())) for _ in range(Q)]
 
# Aの数列を作る。長さがMAX=Nだからとりあえず全探索
 
ans = 0
 
for i1 in range(1, M+1):
    for i2 in range(i1, M+1):
        for i3 in range(i2, M+1):
            for i4 in range(i3, M+1):
                for i5 in range(i4, M+1):
                    for i6 in range(i5, M+1):
                        for i7 in range(i6, M+1):
                            for i8 in range(i7, M+1):
                                for i9 in range(i8, M+1):
                                    for i10 in range(i9, M+1):
                                        tmp = 0
                                        arrs = [0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        for a, b, c, d in arr:
                                            if arrs[b] - arrs[a] ==c:
                                                tmp += d
                                        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 9256
#include<stdio.h>
#include<stdlib.h>
  int compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
      }
  int main(){
    int N,median,i;
    int A[200000];
    long long int mixsum = 0;
    scanf("%d",&N);
    for(i = 0; i < N;i++){
      scanf("%d",&A[i]);
      A[i] += -(i + 1);
    }
    qsort(A,N,sizeof(int),compare);

    median = A[N/2];
    for(i = 0;i < N;i++)mixsum += abs(A[i] - median);
    printf("%lld\n",mixsum);
    return 0;
  }


Measured memory_bytes: 1788
char*w,s[1025],*p;
main(f){
	for(w=p=s;*p=getchar(),*p+1;p++){
		if(*p==32||*p==46||*p==44){
			if(p-w>2&&p-w<7){
				*p=0;
				f||putchar(32);
				printf(w);
				f=0;
			}
			w=p+1;
		}
	}
	exit(!puts(""));
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n;
int a[200005];
map<int,int> d;

bool can(int b){
	d.clear();
	fore(i,1,n){
		if(a[i]<=a[i-1]){
			if(b==1)return false;
			while(!d.empty()&&d.rbegin()->fst>=a[i])d.erase(d.rbegin()->fst);
			int k=a[i]-1;
			while(k>=0&&d[k]==b-1)d[k]=0,k--;
			if(k<0)return false;
			d[k]++;
		}
	}
	return true;
}

int main(){
	scanf("%d",&n);
	fore(i,0,n)scanf("%d",a+i);
	int s=1,e=200005;
	while(e-s>1){
		int m=(s+e)/2;
		if(can(m-1))e=m;
		else s=m;
	}
	printf("%d\n",s);
	return 0;
}

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

int main()
{
	int a, b;
	unsigned long long int c;
	cin >> a >> b;
	std::vector<unsigned int> vec(a);
	for (int i = 0; i < a; i++) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	c = 0;
	for (int i = 0; i < a - b; i++) {
		c = c + vec[i];
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int c=1;
	while(true){
	int a = sc.nextInt();
	if(a!=0) System.out.println("Case "+c+": "+a);
	else break;
	c = c + 1;
	}
}
}

Measured memory_bytes: 33040
import sys
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(m)]
di = []
new = []
for i in range(m):
    if ls[i][0] == 1:
        di.append(ls[i][1])
    if ls[i][1] == n:
        new.append(ls[i][0])
f = list(set(di) & set(new))
if len(f) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 61032
#include<iostream>
#include<cmath>

using namespace std;

int main() {
  long long x;
  cin >> x;
  
  if(x <= 2) {
    cout << 2 << "\n";
  } else {
    int status = 0;
    while(1) {
      status = 0;
    	for(int i=2; i<=sqrt(x); i++) {
         	if(x%i == 0) {
           		status = 1;
           		break;
            }
         }
      	if(status == 0) {
        	cout << x << "\n";
        	break;
      } else {
        ++x;
    	}
    }
    }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
map<LL,LL>Map;
LL N,M,Sum,Ans;
int main(){
	LL I,J,K;
	scanf("%lld%lld",&N,&M);
	Map[0]++;
	for(I=1;I<=N;I++){
		LL Num;
		scanf("%lld",&Num);
		Sum=(Num+Sum)%M;Ans+=Map[Sum]++;
	} 
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 4224