akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	string s;	
	cin >> s;
	if(s.length() == 1){
		cout << s << '\n';
	}
	else{
		ll ans = 0;
		cu(i,0,1 << (s.length() - 1)){
			ll cur = s[0] - '0';
			cu(j,0,s.length() - 1){
				if((i >> j) & 1){
					ans += cur;
					cur = 0;
				}
				cur = 10 * cur + s[j+1] - '0';
			}
			ans += cur;
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int H,W;
	int i,j;

	while(1){
	cin >> H >> W;
	if (H==0&&W==0) break;

	
	for (i=0;i<H;i++){
		for (j=0;j<W;j++){
			if(i==0||i==H-1){
				cout << "#";
			}
			else{
				if(j==0||j==W-1){
					cout << "#";
				}
				else cout << ".";
			}
		}
		cout << endl;
	}
	cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3104
A,B = map(int,input().split())
S = input()

judge = True
for i in range(A+B+1):
    if i == A:
        if S[i] != "-":
            judge = False
    else:
        if S[i] == "-":
            judge = False
if judge:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    rep(i, 5)
    {

        ll cur = 81 + 9 * i;
        int j = 0;
        while ((cur + 63 * j) % 11 != k)
        {
            j++;
        }
        ans += (n - 2 - j + 10) / 11;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  string a,b; cin >> a >> b;
  int n=a.length(),m=b.length();
  string ans="EQUAL";
  if(n>m) ans="GREATER";
  else if(n<m) ans="LESS";
  else{
    for(int i=0;i<n;i++){
      if(a[i]>b[i]) {ans="GREATER"; break;}
      else if(a[i]<b[i]) {ans="LESS"; break;}
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
int main()
{
	int N, M;
	std::cin >> N >> M;
	std::map<int, int> height;
	for (int i = 0; i < N; ++i) {
		int H;
		std::cin >> H;
		height.insert(std::map<int, int>::value_type(i+1,H));
	}
	std::multimap<int, int> route;
	for (int i = 0; i < M; ++i) {
		int A, B;
		std::cin >> A >> B;
		route.insert(std::multimap<int, int>::value_type(A,B));
		route.insert(std::multimap<int, int>::value_type(B,A));
	}
	int count = 0;
	for (int i = 0; i < N; ++i) {
		const int H = height.find(i + 1)->second;
		auto range = route.equal_range(i + 1);
		bool found = false;
		for (auto itr = range.first; itr != range.second; ++itr) {
			if (height.find(itr->second)->second >= H) {
				found = true;
				break;
			}
		}
		if (!found) {
			++count;
		}
	}
	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 17600
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) cin >> a[i];
    Int sum = 0;
    for (Int i = 0; i < n; i++) sum += a[i];
    //dump(sum);
    vector<Int> f;
    for (Int i = 1; i * i <= sum; i++) {
        if (sum % i == 0) {
            if (i * i == sum) {
                f.emplace_back(i);
            }
            else {
                f.emplace_back(i);
                f.emplace_back(sum / i);
            }
        }
    }
    sort(f.begin(), f.end());
    //dump("PO");
    Int res = 1;
    for (Int i = 0; i < (Int)f.size(); i++) {
        Int cnt = 0;
        vector<Int> b;
        for (Int j = 0; j < n; j++) {
            b.emplace_back(a[j] % f[i]);
        }
        sort(b.begin(), b.end());
        Int l, r;
        l = 0;
        r = n - 1;
        Int c = 0;
        while (l < r) {
            c += b[l];
            cnt += b[l];
            l++;
            while (l < r && f[i] - b[r] <= c) {
                c -= f[i] - b[r];
                r--;
            }
        }
        //cout << cnt << " " << f[i] << endl;
        if (cnt <= k) {
            res = max(res, f[i]);
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t[300000];
int solve(){
  int l=0;
  for(int i=0;i<n;i++){
    if(l<i*10)return 0;
    l=max(l,i*10+t[i]);
  } return 1;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  int a=solve();
  reverse(t,t+n);
  int b=solve();
  if(a==1&&b==1)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}


Measured memory_bytes: 4300
S = int(input())

cnt = S//3

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 2000  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
for i in range(1,cnt+1):
    #print("hoge", cmb(S-2*i-1, S-3*i, p), S-2*i-1, S-3*i)
    ans += cmb(S-2*i-1, S-3*i, p)

print(ans%p)

Measured memory_bytes: 9376
A,B,C,D=map(int,input().split())
arr=[0]*101

for i in range(0,101):
    if i>=A and i<=B:
        arr[i]+=1
    if i>=C and i<=D:
        arr[i]+=1
ans=arr.count(2)
print(ans-1 if ans>1 else 0)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main()
{
    
    string p;
    cin >> p;

    long long int ans = 0;
    int t = 0;
    long long int c[2023] = {};
    c[t] = 1;
    int n = p.size();
    
    reverse(p.begin(), p.end());
    int d = 1;
    for (int i = 0; i < n; i++) {
        t = t + (p[i] - '0') * d;
        t %= 2019;
        ans+=c[t];

        c[t]++;
        d *= 10;
        d %= 2019;
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3728
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        String[] siritori = new String[a];
        String end="";
        String head="";
        HashSet<String> hs = new HashSet<String>();
        int tmp;
        boolean chkFlg=true;
        for(int i=0;i<a;i++) {
        	siritori[i]=scanner.next();
        	tmp = hs.size();
    		hs.add(siritori[i]);
        	// 単語の1つ目は任意の単語なので、チェックを行わず、ループの2回目から判定を行う
        	if(i!=0) {
        		// headに今の単語の最初の1文字を入れる
        		head=siritori[i].substring(0,1);

        		// 今の単語の頭文字と前の単語の末尾の文字が不一致の場合、しりとりにならないので終了
        		if(!head.equals(end)){
        			System.out.println("No");
        			chkFlg=false;
        			break;
        		}
        		// 今の単語が今より前に出現していた場合、しりとりにならないので終了
        		/*
        		for(int j=0;j<i;j++) {
        			if(siritori[j].equals(siritori[i])) {
        				System.out.println("No");
        				chkFlg=false;
        				break;
        			}
        		}
        		*/
        		if(tmp==hs.size()) {
        			System.out.println("No");
    				chkFlg=false;
    				break;
        		}
        	}
        	// endに今の単語の最後の1文字を入れる
        	end=siritori[i].substring(siritori[i].length()-1, siritori[i].length());
        }
        // 最後までループが回る場合はしりとり成功
        if(chkFlg) {
        	System.out.println("Yes");
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int amari = n % 1000;
		if (amari != 0) {
			System.out.println(1000 - amari);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 27088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n; cin>>n;
	ll sum=0ll;
	for(ll i=1; i<=n; i++){
		if(i%3==0 || i%5==0);
		else sum+=i;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	double no=0;
	ll anssuw=0;
	ll anssu=0;
	for(ll i=0;i<=30;i++){
		for(ll j=0;j<=30;j++){
			for(ll k=0;k<=3000;k++){
				ll sum=a*i*100+b*j*100+k*c;
				if(sum>f){
					continue;
				}
				ll w=a*i*100+b*j*100;
				ll ok=w/100*e;
				if(ok<k*c){
					continue;
				}
				ll D=((ok-k*c)/d)*d;
				D=min(D,f-sum);
				double su=k*c+D;
				double nonow=100*su/(w+su);
				if(nonow>=no){
					no=nonow;
					anssuw=w+su;
					anssu=su;
				}
			}
		}
	}
	cout <<anssuw<<" "<<anssu;
	// your code goes here
	return 0;
}

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

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

int main() {
	long long a,b,v,w,t;
	cin >> a >> v >> b >> w >> t;
	if (a <= b) {
		if (a + v * t >= b + w * t)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else {
		if (a - v * t <= b - w * t)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
  int x,y;cin>>x>>y;
  vector<string> maze(x);
  for(int i=0;i<x;++i)cin>>maze[i];

  vector< vector<int> > down(x+2,vector<int>(y+2,0));
  for(int i=1;i<=x;++i){
    for(int j=1;j<=y;++j){
      if(maze[i-1][j-1]=='#'){
        down[i][j] = 0;
      }else{
        down[i][j] = down[i-1][j]+1;
      }  
    }
  }
  
  vector< vector<int> > right(x+2,vector<int>(y+2,0));
  for(int i=1;i<=x;++i){
    for(int j=1;j<=y;++j){
      if(maze[i-1][j-1]=='#'){
        right[i][j] = 0;
      }else{
        right[i][j] = right[i][j-1]+1;
      }  
    }
  }

  vector< vector<int> > up(x+2,vector<int>(y+2,0));
  for(int i=x;i>=1;--i){
    for(int j=y;j>=1;--j){
      if(maze[i-1][j-1]=='#'){
        up[i][j] = 0;
      }else{
        up[i][j] = up[i+1][j]+1;
      }  
    }
  }

  vector< vector<int> > left(x+2,vector<int>(y+2,0));
  for(int i=x;i>=1;--i){
    for(int j=y;j>=1;--j){
      if(maze[i-1][j-1]=='#'){
        left[i][j] = 0;
      }else{
        left[i][j] = left[i][j+1]+1;
      }  
    }
  }

  int result = 0;
  for(int i=1;i<=x;++i){
    for(int j=1;j<=y;++j){
      if(maze[i-1][j-1]=='.'){
      	result = max(result,down[i][j]+right[i][j]+up[i][j]+left[i][j]-3);
      }
    }
  }
  
  cout<<result<<endl;
  
  return 0;
}

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

int main(void){
    int N, M;
    vector<int> A;
    vector<int> B;

    cin >> N >> M;
    vector<int> voted(N);
    for(int i=0; i < N; i++){
        int tmp; cin >> tmp;
        A.push_back(tmp);
    }
    for(int i=0; i < M; i++){
        int tmp; cin >> tmp;
        B.push_back(tmp);
    }
    for(int i=0; i < M; i++){
        for(int j=0; j < N; j++){
            if(B[i] >= A[j]){
                voted[j]++;
                break;
            }
        }
    }

    cout << max_element(voted.begin(), voted.end()) - voted.begin() + 1<< endl;
    return 0;
}

Measured memory_bytes: 1232
import collections as C
n = int(input())
a = list(map(int, input().split()))
q = int(input())
d = C.Counter(a)
ans = sum(a)

for _ in range(q):
  b, c = map(int, input().split())
  ans -= d[b]*b
  ans += d[b]*c
  print(ans)
  d[c] += d[b]
  d[b] = 0

  

Measured memory_bytes: 24136
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;


int main(){
	char c; cin >> c;
	if (c == 'A') cout << 'T' << endl;
	else if (c == 'T') cout << 'A' << endl;
	else if (c == 'C') cout << 'G' << endl;
	else cout << 'C' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    i64 h, w;
    cin >> h >> w;
    i64 ans = w * (h / 2);
    if (h % 2 == 1) {
        ans += (w + 1) / 2;
    }
    if (h == 1 || w == 1) ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int a, b;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a < b) {
        FOR(b)
        cout << a;
    } else {
        swap(a, b);
        FOR(b)
        cout << a;
    }
    cout << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n; cin >> n;
	vl S(n);
	REP(i,n) cin >> S[i];
	int q; cin >> q;
	vl T(q);
	REP(i,q) cin >> T[i];
	int res = 0;
	REP(i,q) {
		auto l = lower_bound(ALL(S), T[i]);
		auto u = upper_bound(ALL(S), T[i]);
		if (u - l >= 1) ++res;
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 4152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());
            int h = S / 3600;
            int a = S % 3600;
            int m = a / 60;
            int s = a % 60;
            Console.WriteLine(h+":"+m+":"+s);


        }
    }
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	string s;
	cin >> s;
	cu(i,0,s.length()){
		char c = 'a';
		if(s[i] == 'A')c = 'T';
		if(s[i] == 'T')c = 'A';
		if(s[i] == 'G')c = 'C';
		if(s[i] == 'C')c = 'G';
		cout << c;
	}
	cout << endl;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int main()
{
  int n; cin >> n;
  cout << n*n*n << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m,Q=map(int,input().split())
L=[[0 for i in range(n)] for i in range(n)]
LL=[[0 for i in range(n)] for i in range(n)] 
for i in range(m):
  l,r=map(int,input().split())
  L[l-1][r-1]+=1
LL[0][0]=L[0][0]
for i in range(1,n):
  LL[i][0]=LL[i-1][0]+L[i][0]
  LL[0][i]=LL[0][i-1]+L[0][i]
for i in range(1,n):
  for j in range(1,n):
    LL[i][j]=LL[i-1][j]+LL[i][j-1]+L[i][j]-LL[i-1][j-1]
for i in range(Q):
  p,q=map(int,input().split())
  if p==1:
    ans=LL[q-1][q-1]
  elif q==1:
    ans=LL[0][0]
  else:
    ans=LL[q-1][q-1]-LL[q-1][p-2]-LL[p-2][q-1]+LL[p-2][p-2]
  print(ans)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
vector<pair<int,int>> E[202020];
int A[101010],B[101010],C[101010],D[101010];
map<int,pair<int,ll>> memo[101010];
int num[101010];
ll dist[101010];
ll TD[101010];

int X[101010],Y[101010],U[101010],V[101010];
int P[21][200005],DD[200005];

void dfs(int cur) {
	ITR(it,E[cur]) if(it->first!=P[0][cur]) {
		TD[it->first]=TD[cur]+D[it->second];
		DD[it->first]=DD[cur]+1, P[0][it->first]=cur, dfs(it->first);
	}
}
int getpar(int cur,int up) {
	int i;
	FOR(i,20) if(up&(1<<i)) cur=P[i][cur];
	return cur;
}

int lca(int a,int b) {
	int ret=0,i,aa=a,bb=b;
	if(DD[aa]>DD[bb]) swap(aa,bb);
	for(i=19;i>=0;i--) if(DD[bb]-DD[aa]>=1<<i) bb=P[i][bb];
	for(i=19;i>=0;i--) if(P[i][aa]!=P[i][bb]) aa=P[i][aa], bb=P[i][bb];
	return (aa==bb)?aa:P[0][aa];               // vertex
}

void dfs2(int cur,int pre) {
	FORR(m,memo[cur]) {
		m.second={num[m.first],dist[m.first]};
	}
	FORR(e,E[cur]) if(e.first!=pre) {
		int v=e.second;
		num[C[v]]++;
		dist[C[v]]+=D[v];
		dfs2(e.first,cur);
		num[C[v]]--;
		dist[C[v]]-=D[v];
		
	}
}



void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,N-1) {
		cin>>A[i]>>B[i]>>C[i]>>D[i];
		A[i]--;
		B[i]--;
		E[A[i]].push_back({B[i],i});
		E[B[i]].push_back({A[i],i});
	}
	dfs(0);
	FOR(i,19) FOR(x,N) P[i+1][x]=P[i][P[i][x]];
	FOR(i,Q) {
		cin>>X[i]>>Y[i]>>U[i]>>V[i];
		U[i]--;
		V[i]--;
		memo[U[i]][X[i]]={0,0};
		memo[V[i]][X[i]]={0,0};
		x=lca(U[i],V[i]);
		memo[x][X[i]]={0,0};
	}
	dfs2(0,-1);
	FOR(i,Q) {
		x=lca(U[i],V[i]);
		ll cd=(TD[U[i]]-memo[U[i]][X[i]].second)+(TD[V[i]]-memo[V[i]][X[i]].second)-2*(TD[x]-memo[x][X[i]].second);
		int tnum=memo[U[i]][X[i]].first+memo[V[i]][X[i]].first-2*memo[x][X[i]].first;
		cout<<cd+1LL*tnum*Y[i]<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
  int W,H,N,x_min,x_max,y_min,y_max;
  cin>>W>>H>>N;
  x_min=0;
  y_min=0;
  x_max=W;
  y_max=H;
  
  vector<int> a(N);
  vector<int> x(N);
  vector<int> y(N);
  
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i)>>a.at(i);
  }
  
  for(int i=0;i<N;i++){
    if(a.at(i)==1){
      x_min=max(x_min,x.at(i));
    }
    else if(a.at(i)==2){
      x_max=min(x_max,x.at(i));
    }
    else if(a.at(i)==3){
      y_min=max(y_min,y.at(i));
    }
    else if(a.at(i)==4){
      y_max=min(y_max,y.at(i));
    }
  }
  cout<<max(0,x_max-x_min)*max(0,y_max-y_min)<<endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  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) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
 mint ans[1005][1005] ;
int main(){
  ll h,w ;cin>>h>>w ;
char A[h][w] ;
 rep(i,h){
   rep(j,w){
     cin>>A[i][j] ;
   }
 }
 ll p=INF;ll q=INF ;
 rep(i,h) {
 if(A[i][0]=='#') {
   ans[i][0]=0 ;
  p=i ;
 }
 else if(p<i){
   ans[i][0]=0 ;
 }
 else  ans[i][0]= 1;
 }
 rep(i,w) {
  if(A[0][i]=='#') {
    ans[0][i]=0 ; q=i ;
  }
  else if(q<i) ans[0][i]=0 ;
  else ans[0][i] =1 ;
 }
 rep(i,h-1){
   rep(j,w-1){
   if(A[i+1][j+1]=='#') ans[i+1][j+1]=0  ;
   else {
     
      ans[i+1][j+1]=ans[i][j+1]+ans[i+1][j] ;
    
    }
   
 }
 }
  cout<<ans[h-1][w-1]<<endl ;
    return 0;
  }

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long 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) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return 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) const {
        mint res(*this);
        return res /= a;
    }

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

//////////////////////////

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

    vector<vector<mint>> dp(N + 1, vector<mint>(B + 1, 0));

    vector<mint> frac(N + 1);
    frac[0] = 1;
    repn(i, N)frac[i] = frac[i - 1] * i;

    vector<vector<mint>> den(B + 1, vector<mint>(D + 1, 0));
    repn(i, B) {
        den[i][0] = 1;
        mint v = frac[i];
        repn(j, D) {
            den[i][j] = v * frac[j];
            v *= frac[i];
            //cout << i << j << den[i][j]<<endl;
        }
    }

    dp[0][A - 1] = 1;
    rep(i, N+1) {
        for (ll j = A; j <= B; j++) {
            dp[i][j] = dp[i][j-1];

            for (ll k = C; k <= D; k++) {
                if (i - j * k < 0) { break; }
                dp[i][j] += dp[i - j * k][j - 1] * frac[N - i + j * k] / den[j][k]/frac[N-i];
            }

            //cout << i << j << dp[i][j] << endl;
        }
    }

    cout << dp[N][B];

    

	system("PAUSE");
}

Measured memory_bytes: 16248
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n; std::string s;
    std::cin >> n >> s;
    int r = 0;
    for (auto c : s) if (c == 'R') r++;
    std::cout << (r > n - r ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
d=0
for i in b:
    d+=bisect_left(a,i)*(n-bisect_right(c,i))
print(d)

Measured memory_bytes: 22720
#include<stdio.h>

int parent(int);
int left(int);
int right(int);

#define N 20000

int h,A[N];

int parent(int i)
{
  return A[i/2];
}

int left(int i)
{
  return A[2*i];
}

int right(int i)
{
  return A[2*i+1];
}

int main()
{
  int p,r,l,i;

  scanf("%d",&h);

  for(i=1;i<=h;i++){

    scanf("%d",&A[i]);

  }


  for(i=1;i<=h;i++){

    p=parent(i);
    l=left(i);
    r=right(i);


    printf("node %d: key = %d, ",i,A[i]);
  
    if(p!=0) printf("parent key = %d, ",p);

  if(l!=0) printf("left key = %d, ",l);

  if(r!=0) printf("right key = %d, ",r);

  printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    string s,t,x;
    ll s1,t1;
    cin>>s>>t;
    cin>>s1>>t1>>x;
    if(x==s) s1--;
    else if(x==t) t1--;
    cout<<s1<<" "<<t1<<endl;

    return 0;
}




Measured memory_bytes: 3636
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(x>a) a=x-a;
	else a=a-x;
	if(x>b) b=x-b;
	else b=b-x;
	if(a>b) printf("B\n");
	else printf("A\n");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
//木構造グラフ
struct edge{
  struct treev* to;
  ll length;
  int num;
  int color;
  vector<edge> :: iterator pair;
};
struct treev{
  int num;
  vector<edge> nexts;
};
vector<treev*> vs;

vi colors;
int cmax=0;
treev* createtreenode(int num){
  treev* newt=new treev;
  if(newt==NULL){
    cout << "memory error" << endl;
    while(1){
      num=1;//メモリエラー対策
    }
  }
  newt->num=num;
  newt->nexts={};
  return newt;
}
void insertree(ll len,int Va,int Vb,int num){//結ぶ頂点を
  vs[Va]->nexts.push_back({vs[Vb],len,num,-1});
  vs[Vb]->nexts.push_back({vs[Va],len,num,-1});
  auto e1 = vs[Va]->nexts.end(); 
  auto e2 = vs[Vb]->nexts.end(); 
  e1--;
  e2--;
  e1->pair=e2;
  e2->pair=e1;
  return;
}
void DFS(treev* root,ll depth,treev* pre, int precol){
  //ここにやりたい処理を書く
  int ncnt=0;
  for(auto i:root->nexts){
    if(pre==i.to){
      continue;
    }
    while(1){
      if(ncnt==precol){
        ncnt++;
        continue;
      }
      //i.color=ncnt;
      //(i.pair)->color=ncnt;
      colors[i.num]=ncnt;
      
      DFS(i.to,depth+i.length,root,ncnt);
      ncnt++;
      break;
    }
  }
  return;
}

  
int main(void){
  ll n;
  cin>>n;
  rep(i,n){
    vs.push_back(createtreenode(i));
  }
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    insertree(1,a-1,b-1,i);
  }
  colors=vi(n-1,-1);
  DFS(vs[0],0,NULL,-1);
  int cmax=0;
  rep(i,n-1){
    cmax=max(cmax,colors[i]);
    if(i>=colors.size()){
        cout<<"error";
      }
  }
  cout<<cmax+1<<endl;
  rep(i,n-1){
    cout<<colors[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 15092
#include <cstdio>
#include <algorithm>
using namespace std;
pair<int, int> p[101];
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second > b.second;
}
int main(){
    int n;
    for (int i = 0; i <= 100; i++) p[i] = {i, 0};
    while(scanf("%d", &n) != EOF) {
        p[n].second++;
    }
    sort(p, p+101, comp);
    int minv = p[0].second;
    for (int i = 0; i <= 100; i++) {
        if (p[i].second < minv) break;
        printf("%d\n", p[i].first);
    }
}



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

int main(){
    int N;
    cin >> N;
    std::vector<long> edges(N);
    for(int i=0; i < N; i++){
        cin >> edges.at(i);
    }
    sort(edges.begin(), edges.end());
    long count = 0;
    for(int i=0; i < N-2; i++){
        for(int j=i+1; j < N-1; j++){
            for(int k=j+1; k < N; k++){
                if(edges.at(i) + edges.at(j) > edges.at(k)){
                    count ++;
                }else{
                    break;
                }
            }
        }
    }
    cout << count << endl;
    return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 1000000007
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 400005
int fac[N],inv[N];
int qpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}
int Inv(int x)
{
	return qpow(x,mod-2);
}
int C(int x,int y)
{
	return fac[x]*inv[x-y]%mod*inv[y]%mod;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n,k;
	cin>>n>>k;
	fac[0]=1; for(int i=1;i<=400003;i++) fac[i]=fac[i-1]*i%mod;
	inv[0]=inv[1]=1; for(int i=2;i<=400003;i++) inv[i]=mul(mod-mod/i,inv[mod%i]);
	for(int i=1;i<=400003;i++) inv[i]=mul(inv[i],inv[i-1]);
	
	if(k>=n-1)
	{
		cout<<C(n*2-1,n-1)<<endl;
		return 0;
	}
	
	int ans=0;
	for(int i=0;i<=k;i++)
	{
		ans=add(ans,mul(C(n-1,n-i-1),C(n,i)));
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



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

A = [0]*(N+1)

for i in range(M):
    A[data[i][1]] = max(A[data[i][1]],data[i][0])

ans = 0
a = 0
for i in range(1,N+1):
    if A[i] == 0:
        continue
    else:
        if A[i] >= a:
            ans += 1
            a = i

print(ans)

Measured memory_bytes: 28160
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int n, m;
vector<int> G[55], vs;
lint path[55], c[20];

void dfs(int v, int pv, lint S){
        S ^= 1LL<<v;
        path[v]=S;
        for(int nv: G[v])if(nv!=pv){
                dfs(nv, v, S);
        }
        S ^= 1LL<<v;
}

int main(){
        scanf("%d", &n);
        rep(i, n-1){
                int a, b;
                scanf("%d%d", &a, &b);
                --a; --b;
                G[a].push_back(b);
                G[b].push_back(a);
        }
        dfs(0, -1, 0);
        scanf("%d", &m);
        rep(i, m){
                int u, v;
                scanf("%d%d", &u, &v);
                --u; --v;
                c[i]=path[u]^path[v];
        }

        lint ans=0;
        rep(S, 1<<m){
                lint T=0;
                rep(i, m)if(S>>i&1) T|=c[i];
                lint sgn=(__builtin_popcount(S)%2==0 ? 1LL : -1LL);
                lint tmp=1LL<<(n-1-__builtin_popcountll(T));
                ans+=sgn*tmp;
        }
        printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> a(N+1);
	for (int i=1; i<=N; i++)
		cin>>a[i];
	vector<int> b(N+1,-1);
	int ret=0;
	for (int i=N; i>=1; i--) {
		int cur=0;
		for (int j=2*i; j<=N; j+=i)
			cur=(cur+b[j])%2;
		if(cur!=a[i]) b[i]=1, ret++;
		else b[i]=0;
	}
	cout<<ret<<"\n";
	for (int i=1; i<=N; i++)
		if(b[i])
			cout<<i<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
S = []
T = []
for i in range(N):
  s, t = input().split()
  S.append(s)
  T.append(int(t))
X = input()

if S.index(X) == 0:
  time = sum(T) - T[S.index(X)]
else:
  time = sum(T[S.index(X) + 1:])

print(time)

Measured memory_bytes: 3064
import sys

count = 0

number = int(input())

for line in sys.stdin:
    n = int(line)
    if n == 2:
        count += 1
        continue

    if n % 2 == 0:
        continue

    jdg = True
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i == 0:
            jdg = False
            break
    if jdg:
        count += 1

print(count)



Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
int S(int a){
  int sum=0;
  while(a>0){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(){
  int N,mi=45;
  cin>>N;
  for(int i=1;i<N/2+1;i++){
      mi=min(mi,S(i)+S(N-i));
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 256
// 2014/07/25 Tazoe

#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
{
	string s;
	getline(cin, s);

	for(int i=0; i<s.size(); i++){
		if(islower(s[i])){
			s[i] = toupper(s[i]);
		}
		else if(isupper(s[i])){
			s[i] = tolower(s[i]);
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
struct node{
  int key;
  node *next;
};
node L;
node* nil=&L;
int root;
node t[100000];

int main(){
  int n,par[100000];
  cin>>n;
  for(int i=0;i<n;i++)par[i]=-1;
  for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b;
    node* pre=&t[a];
    for(int j=0;j<b;j++){
      cin>>c;
      node *p;
      p=(node *)malloc(sizeof(node));
      pre->next=p;
      pre->key=c;
      pre=p;
      par[c]=a;
    }
    pre->next=nil;
  }
  for(int i=0;i<n;i++)if(par[i]==-1)root=i;
  for(int i=0;i<n;i++){
    int dep=0;
    for(int j=par[i];j!=-1;j=par[j])dep++;
    cout<<"node "<<i<<": parent = "<<par[i]<<", depth = "<<dep<<", ";
    if(!dep)cout<<"root";
    else if(t[i].next==nil)cout<<"leaf";
    else cout<<"internal node";
    cout<<", [";
    for(node* j=&t[i];j->next!=nil;j=j->next){
      if(j!=&t[i])cout<<", ";
      cout<<j->key;
    }
    cout<<"]"<<endl;
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;
ll sl();

int main() {
  string s;
  cin >> s;
  cout << (unique(s.begin(), s.end()) == s.end() ? "Good" : "Bad") << endl;
}

ll sl() {
  ll x;
  cin >> x;
  return x;
}

struct init {
  init() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} init;


Measured memory_bytes: 764
N,X,Y = map(int, input().split())

li = [0 for k in range(N)]
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if i <= X:
            if j <= X:
                li[j-i] += 1
            elif j < Y:
                d_to_x = min(j - X, Y - j + 1)
                li[X - i + d_to_x] += 1
            else:
                li[(X - i) + (j - Y) + 1] += 1
        elif i < Y:
            if j < Y:
                li[min(j - i, (i - X) + (Y - j) + 1)] += 1
            else:
                d_to_y = min(Y - i, i - X + 1)
                li[j - Y + d_to_y] += 1
        else:
            li[j - i] += 1
for i in range(1,N):
    print(li[i])

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

using namespace std;

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

    int a[N] = {0};
    int ans[N+1] = {0};

    for(int i = 1; i < N; i++) {
        cin >> a[i];
    }


    for(int p = 1; p <= N; p++) {
        /*
        for(int i = 1; i < N; i++) {
            if(p == a[i]) ans[p]++;
        }
        */

       ans[a[p-1]]++;

    }

    for(int i = 1; i <= N; i++) {
        cout << ans[i] << endl;
    }



    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    bool ans = true;

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        if (A.at(i) % 2 == 0) {
            if (A.at(i) % 3 && A.at(i) % 5) {
                ans = false;
            }
        }
    }

    cout << (ans ? "APPROVED" : "DENIED") << endl;
}

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


int main(void){
	int k,a,b,i;
	scanf("%d %d %d",&k,&a,&b);
	
	for(i=a;i<=b;i++){
		if(i%k == 0)
		 break;
	}
	
	if(i==b+1)
		printf("NG\n");
	else
		printf("OK\n");
	
	return 0;
}

Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll evalNow(vector<vector<int>> s, vector<int> c, vector<int> t, int d, vector<int>& last) {
    ll ans = 0;
    ans += s[d][t[d]-1];
    last[t[d]-1] = d+1;
    rep(j, 26) {
        ans -= c[j]*(d+1 - last[j]);
    }
    return ans;
}

ll evalAll(vector<vector<int>> s, vector<int> c, vector<int> t, int d) {
    ll ans = 0;
    vector<int> last(26,0);
    rep(i, d) {
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, 26) {
            ans -= c[j]*(i+1 - last[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(26,0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    ll ans = 0;
    vector<int> last(26,0);

    rep(i, d) {
        cin >> t[i];
        ans += evalNow(s,c,t,i, last);
        cout << ans << endl;
        // cout << evalAll(s, c, t, i+1) << endl;
    }
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
using Tree = vector<pair<int, int>>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<ll>> a(n, vector<ll>(3));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
    }
    ll ma = -100;
    for (int i = 0; i < 8; i++)
    {
        vector<ll> tmp;
        for (int j = 0; j < n; j++)
        {
            ll hoge = 0;
            for (int k = 0; k < 3; k++)
            {
                hoge += a[j][k] * ((i & (1 << k)) ? 1 : -1);
            }
            tmp.push_back(hoge);
        }
        sort(tmp.begin(), tmp.end(), greater<ll>());
        ll ans = 0;
        for (int j = 0; j < m; j++)
        {
            ans += tmp[j];
        }
        ma = max(ma, ans);
    }
    cout << ma << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a = 0, b = 0; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == 'B') {
			b++;
		}
		if (s[h] == 'W') {
			a += b;
		}
	}
	cout << a << endl;
	cin >> n;
}

Measured memory_bytes: 640
s,t=[0]*26,[0]*26
for a,b in zip(input(),input()):
  s[ord(a)-ord('a')]+=1
  t[ord(b)-ord('a')]+=1
u,v=[],[]
for a,b in zip(s,t):
  if a!=b:
    u.append(a)
    v.append(b)
print('YNeos'[sorted(u)!=sorted(v)::2])

Measured memory_bytes: 3632
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    lint n;
    cin >> n;
    vector<lint> a(n);
    for(lint i = 0 ; i < n ; i++){
        cin >> a[i];
        a[i] -= (i + 1);
    }
    sort(a.begin(), a.end());
    lint b;
    if(n % 2 == 1){
        b = a[n/2];
    }else{
        b = (a[n/2] + a[n/2 - 1]) / 2;
    }
    lint ans = 0;
    for(lint i = 0 ; i < n ; i++){
        ans += abs(a[i] - b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792