akhauriyash/Code-Regression huggingface dataset:
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    in >> s;
    REP(i, SIZE(s)){
        if (i % 2 == 0){
            out << s[i];
        }
    }
    out << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, l, r, cnt;
bool a[N];
int sum[N];
void init() {
    fill(a, a + N, true);
    a[1] = false;
    for (int i = 2; i <= N; ++i) {
        if (a[i]) {
            for (int j = i + i; j <= N; j += i) {
                a[j] = false;
            }
        }
    }
    for (int i = 1; i <= N; ++i) {
        if ((i + 1) % 2 == 0 && a[i] && a[(i + 1) / 2]) {
            ++cnt;
        }
        sum[i] = cnt;
    }
}

int main() {
    init();
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }
    return 0;
}


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

int main()
{
    string S;
    cin >> S;
    int ACGT_length = 0, count = 0, judge = 0;

    rep(i, S.size()) {
        if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
            count++;
            judge = 0;
        } else {
            ACGT_length = max(ACGT_length, count);
            count = 0;
            judge = 1;
        }
        if (i == S.size() - 1 && judge == 0) {
             ACGT_length = max(ACGT_length, count);
        }
    }

    cout << ACGT_length << endl;
    
}

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

#define MAX 100000

int main() {
	int N;
	cin >> N;
	int t[MAX + 1], x[MAX + 1], y[MAX + 1];
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	bool flg = true;
	for (int i = 1; i <= N; i++) {
		int dt = t[i] - t[i - 1];
		int dx = abs(x[i] - x[i - 1]);
		int dy = abs(y[i] - y[i - 1]);
		if (dx + dy > dt || (dx + dy) % 2 != dt % 2) {
			flg = false;
		}
	}
	cout << (flg ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF 1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second
#define setprecision(d) cout << fixed << setprecision(d);

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

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


signed main(){

	string s;
	cin >> s;
	rep(i,0,s.size()){
		if((i % 2 && s[i] != 'i') ||(i % 2 == 0 && s[i] != 'h')){
			cout << "No" << endl;
			return 0;
		}
		
	}

	if(s.size() % 2) cout << "No" << endl;
	else cout << "Yes" << endl;
    return 0;
}

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

//var 
long long n,k,nx[200001], col[200001], st, ep = 0, g, in;
vector<long long> cy;

void dfs(long long g){
	if(col[g] == 1){
		col[g] = 2; st = g;
		return;
	}
	col[g] = 1;  
	dfs(nx[g]);
}

int main(){
	cin >> n >> k;
	for(long long i = 1; i<=n; i++)cin >> nx[i];
	dfs(1); cy.pb(st); g = nx[st];
	while(g!=st){cy.pb(g); g = nx[g];}
	g = 1; while(g!=st){
		ep++; g = nx[g];
		if(ep == k){
			cout << g << endl;
			return 0;
		}
	}
	//cout << ep << endl;
	k -= (ep);
	//for(int u : cy)cout << u << " ";
		//cout << endl;
	k%=cy.size();
	cout << cy[k%cy.size()] << endl;
	return 0;
}

Measured memory_bytes: 8344
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
	LL x = 0, f = 1; char ch = getchar();
	while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
	return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e5 + 7;
int n, ans;
int low[N], pri[N], pc, a[N];
void sieve(int n) {
	int to;
	rep(i, 2, n) {
		if(!low[i]) low[i] = i, pri[++pc] = i;
		for(int j = 1; j <= pc && (to = i * pri[j]) <= n; ++j) {
			low[to] = pri[j];
			if(i % pri[j] == 0) break;
		}
	}
}
map<LL, int> cnt;
int main() {
	sieve(2159);
	n = gi();
	rep(i, 1, n) {
		LL x, now = 1, r = 1;
		scanf("%lld", &x);
		rep(j, 1, pc) if(x % pri[j] == 0) {
			int cnt = 0;
			while(x % pri[j] == 0) ++cnt, x /= pri[j];
			if(cnt % 3 == 1) now *= pri[j], r *= pri[j] * pri[j];
			if(cnt % 3 == 2) now *= pri[j] * pri[j], r *= pri[j];
		}
		if((LL) sqrt(x) * (LL) sqrt(x) == x)
			r *= (LL) sqrt(x);
		else 
			r *= x * x;
		++cnt[now *= x];
		if(now != 1 && cnt[now] > cnt[r]) ++ans;
	}
	if(cnt[1] >= 1) ans ++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int x=0,f=0;
	char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) f^=(ch=='-');
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return f ? -x :x ;
}
const int maxn=1e5+20;
int n,a[maxn],pos[maxn],c[maxn],m,k,s[maxn],top,ans[maxn];
bool vis[maxn];
signed main(){
	n=read();
	for (int i=1;i<=n;++i) {
		a[i]=read();
		pos[i]=i;
	}
	for (int i=1;i<=n;++i) c[i]=a[i]-a[i-1];
	m=read();
	k=read();
	for (int i=1,x;i<=m;++i) {
		x=read();
		swap(pos[x],pos[x+1]);
	}
	for (int i=1;i<=n;++i) {
		if (!vis[i]) {
			top=0;
			for (int j=i;!vis[j];j=pos[j]) {
				s[++top]=j;
				vis[j]=1;
			}
			for (int j=1;j<=top;++j) {
				ans[s[j]]=c[s[(k+j-1)%top+1]];
			}
		}
	}
	for (int i=1;i<=n;++i) {
		ans[i]+=ans[i-1];
		printf("%lld",ans[i]);
		putchar('.');
		putchar('0');
		putchar('\n');
	}
 	return 0;
}

Measured memory_bytes: 5504
/*
 * ########### name : NOORA ##########
 *
 *
 *
 *
 *
 * #include<bits/stdc++.h>
 * using namespace std;
 * int main()
 * {
 * while( you_are_alive)
 * {
 * code;
 * code;
 * code;
 * code;
 * }
 *
 *
 *
 * ########## THANK YOU :)  :) #########
 */

#include<bits/stdc++.h>
using namespace std;
void lcs( char *X, char *Y, int m, int n )
{
    int L[m+1][n+1];

    for (int i=0; i<=m; i++)
    {
        for (int j=0; j<=n; j++)
        {
            if (i == 0 || j == 0)
                L[i][j] = 0;
            else if (X[i-1] == Y[j-1])
                L[i][j] = L[i-1][j-1] + 1;
            else
                L[i][j] = max(L[i-1][j], L[i][j-1]);
        }
    }

    int index = L[m][n];

    char lcs[index+1];
    lcs[index] = '\0';

    int i = m, j = n;
    while (i > 0 && j > 0)
    {

        if (X[i-1] == Y[j-1])
        {
            lcs[index-1] = X[i-1];
            i--; j--; index--;
        }


        else if (L[i-1][j] > L[i][j-1])
            i--;
        else
            j--;
    }


    cout << lcs;
}


int main()
{
    char X[3000] ;
    char Y[3000] ;
    cin>>X>>Y;
    int m = strlen(X);
    int n = strlen(Y);
    lcs(X, Y, m, n);
    return 0;
}







Measured memory_bytes: 35456
#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, K, X, Y;
  cin >> A >> B >> K;
  if(A-K<0) X=0;
  else X=A-K;
  if(K-A<0) K=0;
  else K-=A;
  if(B-K<0) Y=0;
  else Y=B-K;
  cout << X << " " << Y << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,n;
  
  scanf("%d",&n);
  a = n/2;
  
  if(n%2==0){
    printf("%d\n",a*a);
  }else{
    printf("%d\n",a*(a+1));
  }
  
  return 0;
}

Measured memory_bytes: 128
h = int(input())
MAXN = 10 ** 6

dn = [None for _ in range(MAXN + 1)]


def n_attack(i):
    if i == 1:
        return 1
    elif i > MAXN:
        return 1 + 2 * n_attack(i // 2)
    elif dn[i] is not None:
        return dn[i]
    else:
        n = 1 + 2 * n_attack(i // 2)
        dn[i] = i
        return n

answer = n_attack(h)
print(answer)


Measured memory_bytes: 17008
#include<bits/stdc++.h>
using namespace std;
int main() {
	cin.sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if(n % 2) {
		cout << b[n/2] - a[n/2] + 1 << endl;
	}else{
		cout << (int)(((b[n/2] + b[n/2-1]) /2.0 - (a[n/2] + a[n/2-1]) /2.0) * 2 + 1)<< endl;
	}
    return 0;
}


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

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

    ll ans = 0;
    rep(a, k) rep(b, k) rep(c, k) { ans += __gcd(a, __gcd(b, c)); }

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


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n, m, k, flag;
int main()
{
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 0; i <= n; i++)
	{
		for(int j = 0; j <= m; j++)
		{
			int pp;
			pp = i * m + j * n - 2 * i * j;
			if(k == pp) {
				printf("Yes\n");
				flag = 1;
				break;
			}
		}
		if(flag == 1) break;
		if(i == n) printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int n,y;
    cin>>n>>y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            int k=n-i-j;
            if(10000*i+5000*j+1000*k==y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<int>> edges(200010);
vector<bool> used(200010,false);
vector<P> cnt(200010,P(0,0));

int main() {
    int n,m;
    string s;
    unordered_set<int> st;
    cin >> n >> m >> s;
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        if (u != v) edges[v].push_back(u);
    }
    for (int i = 0;i < n;++i) {
        for (int& j : edges[i]) {
            if (s[j] == 'A') cnt[i].first++;
            else cnt[i].second++;
        }
        if (cnt[i].first == 0 || cnt[i].second == 0) {
            st.insert(i);
            used[i] = true;
        }
    }
    while (!st.empty()) {
        unordered_set<int> next_st;
        for (auto& it : st) {    
            if (s[it] == 'A') for (int& i : edges[it]) cnt[i].first--;
            else for (int& i : edges[it]) cnt[i].second--;
        }
        for (auto& it : st) {
            for (int& i : edges[it]) if (i != it && !used[i]) {
                if (cnt[i].first == 0 || cnt[i].second == 0) {
                    next_st.insert(i);
                    used[i] = true;
                }
            }
        }
        st.clear();
        st = next_st;
    }
    bool ans = false;
    for (int i = 0;i < n;++i) if (cnt[i].first && cnt[i].second) ans = true;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<string> W(N);
    rep(i, N) cin >> W[i];

    map<string, int> mp;
    bool res = true;
    mp[W[0]]++;
    for(int i=1; i<N; i++) {
        if(mp[W[i]] > 0 || W[i-1][W[i-1].size()-1] != W[i][0]) {
            res = false;
            break;
        } else {
            mp[W[i]]++;
        }      
    }
    
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

import scala.annotation.tailrec

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val Array(n, k) = input.nextLine().split(" ").map(_.toInt)

      if (k % 2 == 1) {
        val p = 1.to(n).count { i =>
          i % k == 0
        }
        output.println(Math.pow(p, 3).toLong)
      } else {
        val p = 1.to(n).count { i =>
          i % k == k / 2
        }
        val q = 1.to(n).count { i =>
          i % k == 0
        }
        output.println(Math.pow(p, 3).toLong + Math.pow(q, 3).toLong)
      }

    }

    @tailrec
    final def gcd(m: Int, n: Int): Int = {
      val (x, y) = if (m > n) (m, n) else (n, m)
      if (y != 0) gcd(y, x % y)
      else x
    }

  }

}


Measured memory_bytes: 30336
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first

int main() {
	int N;
	scanf("%d", &N);

	if (N == 3) return !printf("2 5 63\n");
	if (N == 4) return !printf("2 5 20 63\n");
	if (N == 5) return !printf("2 3 4 6 9\n");
	if (N == 6) return !printf("2 3 4 6 9 12\n");
	if (N == 7) return !printf("2 3 4 6 8 9 10\n");
	
	int x = N / 8;
	for (int i = 0; i < x; i++) printf("%d %d %d %d %d %d %d %d ", i * 12 + 2, i * 12 + 3, i * 12 + 4, i * 12 + 6, i * 12 + 8, i * 12 + 9, i * 12 + 10, i * 12 + 12);

	int t = x * 12;
	if (N % 8 == 0);
	else if (N % 8 <= 2) {
		printf("%d ", t + 6);
		if (N % 8 == 2) printf("%d ", t + 12);
	}
	else if (N % 8 <= 4) {
		printf("%d %d %d ", t + 3, t + 6, t + 9);
		if (N % 8 == 4) printf("%d ", t + 12);
	}
	else if (N % 8 <= 6) {
		printf("%d %d %d %d %d ", t + 2, t + 3, t + 4, t + 6, t + 9);
		if (N % 8 == 6) printf("%d ", t + 12);
	}
	else printf("%d %d %d %d %d %d %d ", t + 2, t + 3, t + 4, t + 6, t + 8, t + 9, t + 10);
	return !printf("\n");
}

Measured memory_bytes: 384
import sys
s = list(input())
# s = ['R', 'U', 'D', 'L', 'U', 'D', 'R']
for i in range(len(s)):
    if (i + 1) % 2 == 0:
        if s[i] == 'R':
            print('No')
            sys.exit(0)
    else:
        if s[i] == 'L':
            print('No')
            sys.exit(0)
print('Yes')


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int grid[1010][1010];

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i < B) {
                if (j < A)
                    cout << 0;
                else
                    cout << 1;
            } else {
                if (j < A)
                    cout << 1;
                else
                    cout << 0;
            }
        }
        cout << endl;
    }
}

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

using namespace std;

typedef long long ll;

int main() {
  string s;
  cin >> s;
  int sm = 0;
  for (int i = 0; i < (int) s.size(); i++) {
    sm += (s[i] - '0');
  }
  cout << (sm % 9 == 0 ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3724
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)



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

  int n;
  cin >> n;

  vint d(n);
  REP(i, n) scan(d[i]);

  sort(ALL(d));

  cout <<  d[n/2] - d[n/2-1] << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long t,ac,we,re,tle;
string s;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>s;
		if(s=="AC")
		{
			ac++;
		}
		if(s=="WA")
		{
			we++;
		}
		if(s=="RE")
		{
			re++;
		}
		if(s=="TLE")
		{
			tle++;
		}
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<we<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  rep(i,3) rep(j,N){
    if(i==0) cin >> A[j];
    else if(i==1) cin >> B[j];
    else cin >> C[j];
  }
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  ll ans = 0;
  rep(i,N){
    ll nowB= B[i], la = -1, ra = N, lc = -1, rc = N;
    while(ra-la>1){
      ll m = (la+ra) / 2;
      if(nowB>A[m]) la = m;
      else ra = m;
    }
    while(rc-lc>1){
      ll m = (lc+rc) / 2;
      if(nowB<C[m]) rc = m;
      else lc = m;
    }
    ans += (la+1)*(C.size()-rc);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10 ** 6)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
  X,Y,Z = map(int, input().split())
  X -= 1
  Y -= 1
  G[X].append(Y)
  G[Y].append(X)
#print(G)

def dfs(u,v):
  for t in G[u]:
    #if t != v:
    if not Visited[t]:
      Visited[t] = True
      dfs(t,u)

Visited = [False for _ in range(N)]
ans = 0
for i in range(N):
  if not Visited[i]:
    Visited[i] = True
    ans += 1
    dfs(i,-1)
print(ans)


Measured memory_bytes: 110376
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#define SIZE 100005

using namespace std;
typedef long long int ll;

ll X[SIZE],P[SIZE];

int main()
{
	int n;
	ll S;
	scanf("%d %lld",&n,&S);
	for(int i=0;i<n;i++) scanf("%lld %lld",&X[i],&P[i]);
	ll ret=0;
	int s=0,t=n-1;
	while(s<=t)
	{
		if(S<=X[s])
		{
			ret+=X[t]-S;
			break;
		}
		if(X[t]<=S)
		{
			ret+=S-X[s];
			break;
		}
		if(P[s]>=P[t])
		{
			ret+=X[t]-X[s];
			while(s<t&&P[s]>=P[t])
			{
				P[s]+=P[t];
				t--;
			}
		}
		else
		{
			ret+=X[t]-X[s];
			while(s<t&&P[s]<P[t])
			{
				P[t]+=P[s];
				s++;
			}
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 1664
class Tree {
  static get Node() {
    return class {
      constructor(id, parent, children) {
        this.id = id;
        this.parent = parent;
        this.children = children;
      }

      get type() {
        if (this.parent === null) return 'root';
        if (this.children.length === 0) return 'leaf';
        return 'internal node';
      }

      get depth() {
        const getDepth = (node, i) => {
          return node.parent === null ? i : getDepth(node.parent, i + 1);
        };
        return getDepth(this, 0);
      }

      toString() {
        return `node ${this.id}: parent = ${this.parent !== null ? this.parent.id : -1}, depth = ${this.depth}, ${this.type}, [${this.children.map(n => n.id).join(', ')}]`;
      }
    };
  }

  constructor(n) {
    this.nodes = [];
    let Node = Tree.Node;
    for (let i = 0; i < n; i++) this.nodes[i] = new Node(i, null, []);
  }

  add(id, childrenIds) {
    let node = this.find(id);
    childrenIds.forEach((cid) => {
      let c = this.find(cid);
      c.parent = node;
      c.id = cid;
      node.children.push(c);
    })
  }

  find(id) { return this.nodes[id]; }

  print() { console.log(this.nodes.sort((a, b) => a.id - b.id).map(n => n.toString()).join('\n')); }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new Tree(n);
  let id, k, childrenIds;
  lines.map(l => l.split(' ')).forEach(function(line) {
    id = Number(line.shift());
    k = Number(line.shift());
    childrenIds = line.map(Number);
    tree.add(id, childrenIds);
  });
  tree.print();
})();



Measured memory_bytes: 158408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();

		int num = Integer.parseInt(a + b);

		if(Double.compare(Math.sqrt(num), Math.floor(Math.sqrt(num))) == 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e5 + 5;
const int mod = 998244353; 
using namespace std;

int n, m, fac[N], inv[N], cnt[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int C(int n, int m)
{
	if(n < m || n < 0 || m < 0) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod; 
}

int main()
{
	m = read <int> (), n = read <int> (); 
	for(int i = (fac[0] = 1); i <= n + m; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n + m] = fpow(fac[n + m], mod - 2);
	for(int i = n + m - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
	for(int i = 1; i <= m; i++) cnt[i + 1]++, cnt[i + m + 1]--;
	for(int i = 1; i <= 2 * m; i++) cnt[i] += cnt[i - 1];
	for(int ans, tmp, i = 2; i <= 2 * m; i++)
	{
		ans = 0, tmp = (cnt[i] + 1) / 2;
		for(int op = 1, j = 0; j <= tmp; j++, op = mod - op)
		{
			if(n - 2 * j < 0) break; 
			ans = (1ll * op * C(tmp, j) % mod * C(n - 2 * j + m - 1, m - 1) + ans) % mod;
		}
		printf("%d\n", ans); 
	}
	return 0; 
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n ,k; cin >> n >> k;
    int cur = ((n-1) * (n-2)) >> 1;
    if (k > cur) {
        cout << -1 << endl;
        return 0;
    }

    vpp ans;
    for (int i = 0; i < n-1; ++i) {
        ans.pb({1,i+2});
    }

    int i = 2, j = 3;
    while (cur > k) {
        ans.pb({i,j});
        if (j == n) i += 1, j = i;
        j += 1;
        cur -= 1;
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }
}



Measured memory_bytes: 384
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
  
   int a[5];
 
   for(int i = 0;i<5;i++){
     
     cin >> a[i];
     
   }
  
   int b;
    
   cin >> b;
   int flag = 0;
  
   for(int i = 0;i<5;i++){
     
      for(int j = 0;j<5;j++){
     
         int ab = a[i]-a[j];
         ab = abs(ab);
   
          if(b<ab){
            
            flag = 1;
            
            break;
          }
     
      }
   
   }
  
  if(flag == 1){
    cout << ":(" << endl;
    
  }else{
    cout << "Yay!" << endl;
  }
   //cout << b << endl;
   
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;

#define solve imAwesome
#define for0(i,n) for(int i=0; i<(int)n; i++)
#define forn(i,n) for(int i=1; i<=(int)n; i++)
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define endl cout << "\n";
#define debug cout << "Aqui\n";
#define deb(i) cout << "Aqui " << (ll) i << "\n";
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	
	ll k;
	cin >> k;
	string s;
	cin >> s;
	if(k<s.size()){
		for (int i = 0; i < k; i++) cout << s[i];
		cout << "...\n";
	}else{
		cout << s << "\n";
	}
	
	return 0;

}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
template<typename T> 
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT(){init(-1,(T)0);}
  BIT(int n_,T d):n(n_),bit(n_+1,d){}
  T sum(int i){
    T s=0;
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
  
  int lower_bound(int w){
    if(w<=0) return 0;
    int x=0,r=1;
    while(r<n) r<<=1;
    for(int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
	w-=bit[x+k];
	x+=k;
      }
    }
    return x+1;
  }
  
  T sum0(int i){
    return sum(i+1);
  }
  void add0(int i,T a){
    add(i+1,a);
  }
};
//END CUT HERE

signed main(){
  int n,q;
  cin>>n>>q;
  BIT<int> bit(n+100,0);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<bit.sum(y)-bit.sum(x-1)<<endl;
    else bit.add(x,y);
  }
  return 0;
}
/*
verified on 2017/09/22
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
 */

Measured memory_bytes: 3532
n,m,l = map(int,input().split())
A=[]
B=[]
for i in range(n): A.append(list(map(int,input().split())))
for j in range(m): B.append(list(map(int,input().split())))
for A_r in A:
    print(" ".join(map(str,[sum([x*y for x,y in zip(A_r,[B_r[k] for B_r in B])]) for k in range(l)])))

Measured memory_bytes: 8504
#include <iostream>
using namespace std;
 
int main() {
    int a, b, c;
    int cnt = 0;

    cin >> a >> b >> c;

    for (int i = a; i < b + 1; ++i) {
        if (c % i == 0) ++cnt;
    }

    cout << cnt << "\n";
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n; cin>>n;
	map<string,int> m;
	while(n--){
		string x; cin>>x;
		m[x]++;
	}	
	cout<<"AC x "<<m["AC"]<<"\n";	
	cout<<"WA x "<<m["WA"]<<"\n";	
	cout<<"TLE x "<<m["TLE"]<<"\n";	
	cout<<"RE x "<<m["RE"]<<"\n";

	return 0;	
}


Measured memory_bytes: 3648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

struct Xorshift{
    unsigned int x, y, z, w, t;

    unsigned int rand(){
        t = x ^ (x << 11);
        x = y; y = z; z = w;
        return w = ( (w ^ (w>>19)) ^ (t ^ (t>>8)));
    }

    Xorshift():x(123456789U), y(362436069U), z(521288629U), w(88675123U){}
};
Xorshift rnd;

int main(){
    std::ios::sync_with_stdio(false);

    int n,winAll = -1,out;
    bool flag;
    cin >> n;
    char t[n][n],c;
    for(int i=0;i<n;i++){
        flag = true;
        for(int j=0;j<n;j++){
            cin >> t[i][j];
            if(t[i][j] == 'x') flag = false;
        }
        if(flag) winAll = i+1;
    }
    for(int i=0;i<1000;i++){
        out = winAll > 0?winAll:rnd.rand() % n + 1;
        cout << out << endl;
        cin >> c;
    }
}

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

int main() {
    ll s = 0;
    cin >> s;
    if(s < 3){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> dp(s+1, 0);
    dp[3] = 1;
    for(int i = 4; i <= s; i++) 
        dp[i] = (dp[i-1] + dp[i-3]) % 1000000007;
    cout << dp[s] << endl;
    return 0;
}


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

void solve(string &s, string &ans, vector<char> op, int index){
  // ベースケース
  if (index == s.size()-1)
  {
    int sum = s.at(0) - '0';
    string current;
    current += s.at(0);
    for (int i = 0; i < op.size(); i++)
    {
      if(op.at(i) == '+')
      {
        sum += s.at(i+1) - '0';
        current += '+';
        current += s.at(i+1);
      }
      else
      {
        sum -= s.at(i+1) - '0';
        current += '-';
        current += s.at(i+1);
      }
    }
    if(sum == 7) ans = current + "=7";
    return;
  }
  // 再帰ステップ
  op.at(index) = '+';
  solve(s, ans, op, index+1);
  op.at(index) = '-';
  solve(s, ans, op, index+1);
}

int main(){
  string s;
  cin >> s;
  vector<char> op(s.size() - 1);
  string ans;
  solve(s, ans, op, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(_) for _ in input().split()] 
b = [-1] * N

for i in reversed(range(N)):
#    print(i, a[i], b[i::(i+1)])
    b[i] = (sum(b[i::(i+1)]) -b[i] + a[i]) % 2

print(sum(b))

#print(b)
res = []
for i in range(N):
    if b[i] == 1:
        res.append(str(i+1))
print(" ".join(res))
    



Measured memory_bytes: 73564
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
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 = 2
N = 10 ** 6 + 2
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)
'''


#a = list(map(int, input().split()))

def c2(x):
    return x*(x-1)//2

n = int(input())

a = list(map(int, input().split()))

num = [0 for i in range(n+1)]

for i in range(n):
    num[a[i]]+=1
    
ans = 0
anslist = []
for i in range(n+1):
    b = num[i]*(num[i]-1)//2
    anslist.append(b)
    ans += b

for i in range(n):
    print(ans - c2(num[a[i]]) + c2(num[a[i]]-1))





















Measured memory_bytes: 115272
#include <iostream>
    #include <algorithm>
    using namespace std;
    int main() {
    	long long N, A, B, C, D, E;
    	cin >> N >> A >> B >> C >> D >> E;
    	cout << max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;
    	return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

set <pair <int, int> > s;
set <pair <int, int> > checked;
int cnt[10];
namespace fastinput
{
	/** Interface */

	inline int readChar();
	template <class T = int> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(int x);
	inline void writeWord(const char *s);

	/** Read */

	static const int buf_size = 16384;

	inline int getChar() {
		static char buf[buf_size];
		static int len = 0, pos = 0;
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline int readChar() {
		int c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		int s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static int write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(int x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		int n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;

int main()
{
	::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int h = readInt(), w = readInt(), n = readInt();
	for (int i = 0; i < n; ++i)
	{
		int x = readInt();
		int y = readInt();
		--x, --y;
		s.insert({ x, y });
	}
	for (auto lr : s)
	{
		int x = lr.first;
		int y = lr.second;
		for (int i = max(0, x - 2); i <= x && i + 2 < h; ++i)
			for (int j = max(0,y - 2); j <= y && j + 2 < w; ++j)
			{
				if (checked.count({ i, j }))
					continue;
				int cntsum = 0;
				for (int x1 = i; x1 <= i + 2; ++x1)
					for (int y1 = j; y1 <= j + 2; ++y1)
						cntsum += s.count({ x1, y1 });
				checked.insert({ i, j });
				++cnt[cntsum];
			}
	}

	int sum = 0;
	for (int i = 1; i <= 9; ++i)
		sum += cnt[i];

	cout << (h - 2LL) * (w - 2LL) - sum << "\n";
	for (int i = 1; i <= 9; ++i)
		cout << cnt[i] << "\n";
	
	return 0;
}

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

double pi = acos(-1);

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double theta = abs((H * 30 - M * 5.5)) / 180 * pi;
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(theta));
    cout << setprecision(12) << ans << "\n";
    return 0;
}

Measured memory_bytes: 4208
n, m = map(int,input().split())
h = list(map(int, input().split()))
e = [[] for _ in range(n)]
for i in range(m):
    u, v = map(int,input().split())
    u -= 1
    v -= 1
    e[u].append(h[u]- h[v])
    e[v].append(h[v]- h[u])

cnt = 0
for i in range(n):
    if not e[i]:
        cnt += 1
    elif min(e[i]) > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 29548
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  long long int sum = 1;
  for(int i = 1; i <= N; i++) {
    sum = (sum * i) % 1000000007;
  }
  cout << sum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

const int N = 100010;
int n,a[N];
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int main(){
	scanf("%d",&n);
	int cnt = 0;
	bool pd =false;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		if(a[i]&1) {
			cnt++;
			if(a[i]>1) pd=true;
		}
	}
	int now = 1;
	while(cnt==1 && pd && (n-cnt)%2==0){
		now^=1;
		cnt = 0;
		pd = false;
		int t = a[1]>>1;
		for(int i =0;i<n;i++){
			a[i]>>=1;
			t = gcd(t,a[i]);
		}
		for(int i =0;i<n;i++) a[i]/=t;
		for(int i =0;i<n;i++){
			if(a[i]&1) {
				cnt++;
				if(a[i]>1) pd=true;
			}
		}
	}
	if(((n-cnt)&1)==now) puts("First"); else puts("Second");
	return 0;
}

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

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

    int p[n];
    for(int i = 0; i < n; i++)  cin >> p[i];

    int ans = INT_MAX;
    for(int i = 0; i <= p[0]; i++){
        int tmp = i, before = i;
        for(int j = 0; j < n-1; j++){
            tmp += 2 * max(0, p[j]-before);
            before = max(0, p[j] - before);
        }
        tmp += max(0, p[n-1]-before);
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iA - (iB >= iA ? 0 : 1);

            // 出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int dp[1010010];
int foo(int a){
	if(dp[a]>=0) return dp[a];
	if(a%2){
		return dp[a]=foo(a*3+1)+1;
	}
	return dp[a]=foo(a/2)+1;
}

void mainmain(){
	int n;
	rep(i,1010010) dp[i]=-1;
	dp[1]=0;
	while(cin>>n,n){
		cout<<foo(n)<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 5100
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int m,d,count=0,i,d1,d2,temp;
    cin>>m>>d;
    for(i=22;i<=d;i++)
    {
        temp=i;
        d1=temp%10;
        temp=temp/10;
        d2=temp;
        if((d1*d2 <= m)&&(d1>=2)&&(d2>=2))
            count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A =sc.nextLong();
		long B =sc.nextLong();
		long ans = N%(A+B);
		long ans1 = N/(A+B);
	    if(ans>A) {
	    	ans = ans-(ans-A);
	    }
		System.out.println(A*ans1+ans);
	}
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int inf=7+1e9;
int main(){
	long long n; cin >> n; 
    vector<long long> a(n);
    long long mx=0;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        //mx = max(mx,a[i]);
    }

    long long ans=0, x=1;
    mx=60;//=log2(mx);
    for(int i=0; i<=mx; ++i){
        long long cnt=0;
        for(int j=0; j<n; ++j){
            if(1&a[j]) ++cnt;
            a[j] >>= 1;
        }
        ans = (ans+x%inf*cnt%inf*(n-cnt)%inf)%inf;
        x <<= 1;
    }
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main() {
	int w;

	while(cin >> w, w!=-1) {
		int cost = 0;
		
		if(w > 30) {
			cost += (w-30)*160;
			w = 30;
		}
		if(w > 20) {
			cost += (w-20)*140;
			w = 20;
		}
		if(w > 10) {
			cost += (w-10)*125;
			w = 10;
		}
		cost += 1150;

		cout << 4280-cost << endl;
	}
}

Measured memory_bytes: 1160
n=int(input())
a=0
b=0
c=0
d=0
for i in range(n):
    x=input()
    if x =="AC":
        a = a+1
    if x =="WA":
        b = b+1
    if x =="TLE":
        c = c+1
    if x =="RE":
        d = d+1
print("AC x "+str(a))
print("WA x "+str(b))
print("TLE x "+str(c))
print("RE x "+str(d))

Measured memory_bytes: 69852
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

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

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


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


Measured memory_bytes: 256