akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
nodes = (1..n).to_a
all_edges = nodes.combination(2).to_a
removed_edges = []
limit = n.even? ? n : n - 1
1.upto(limit) do |i|
  removed_edges << [i, limit + 1 - i]
end
edges = all_edges - removed_edges
puts edges.size
edges.each do |edge|
  puts edge.join(" ")
end


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int l,r;
    scn2(l,r);

    set<int>L,R;

    vector<bool>ase(2034,0);

    for(int i=l; i<=r && L.size()<2019; i++){

        if(ase[i%2019] == false) L.insert(i);
        ase[i%2019] = true;
    }
    for(int i=0; i<=2019; i++) ase[i] = 0;
    for(int i=r; i>=l && R.size()<2019; i--){

        if(ase[i%2019] == false) R.insert(i);
        ase[i%2019] = true;
    }

    int ans = inf;

    for(auto it : L){
        for(auto i : R){
                if(i == it)continue;
            ans = min(ans , ((i%2019) * (it%2019))%2019);
        }
    }
    cout<<ans;


    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 384
def main():
    N = int(input())
    A = [0] + [int(i) for i in input().split()]
    C = [0]*(N+1)
    for i in range(1, N+1)[::-1]:
        cur = 0
        for j in range(i, N+1, i):
            cur += C[j]
        if cur % 2 != A[i] % 2:
            C[i] += 1
    M = sum(C)
    print(M)
    if M:
        C = [i for i in range(1, N+1) if C[i]]
        print(*C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71388
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

int main() {
	int n;
	cpp_int a, b, sum;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		sum = a + b;
		string str = sum.str();
		if (str.length() > 80) cout << "overflow" << endl;
		else cout << a + b << endl;
	}
	return 0;
}


Measured memory_bytes: 3256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""


def make_primes(n): #nまでの素数列挙
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass  


def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

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 len(divisors)


n = onem()
po = [1 for i in range(10**7+1)]

for i in range(n+1):
	if i == 0 or i == 1:
		continue
	for j in range(i,n+1,i):
		po[j] += 1
an = 0

for i in range(n+1):
	an += po[i]*i
print(an)


Measured memory_bytes: 232040
#include<bits/stdc++.h>
using namespace std;
int n,x,sum;
bitset<2000007>f;
int main(){
    cin>>n;
    f[0]=1;
    for(int i=1;i<=n;i++){
        cin>>x;
        f|=f<<x;
        sum+=x;
    }
 //   cout<<sum<<endl;
    for(int i=(sum+1)/2;i<=sum;i++){
        if(f[i]) {cout<<i<<endl;break;}
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args)
	 {
            Scanner sc=new Scanner(System.in);
            String s=sc.next();int count=0;
            for(int i=0;i<s.length();i++) {
            	if(s.charAt(i)=='2')
            		count++;
            }
            System.out.println(count);
	 }
}

Measured memory_bytes: 22996
#include<iostream>
#include<stdio.h>
#include<algorithm>

using namespace std;
int n;
int m[101][101]; 
int s[101][101];
int q;
//連鎖行列積
int mco(int p[]) {
	for (int i = 1; i < n + 1; i++) {
		m[i][i] = 0; 
	}
	for (int l = 2; l < n + 1; l++) {
		for (int i = 1; i < n - l + 2; i++) {
			int j = i + l - 1;
			m[i][j] = 2000000;
			for (int k = i; k < j ; k++) {
				q = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
				m[i][j] = min(q, m[i][j]);
				
			}
		}

	}return m[1][n];
	

}
int main() {
	cin >> n;
	int p[101];
	for (int i = 0; i < n; i++) {
		cin >> p[i] >> p[i + 1];
	}
	cout << mco(p) << endl;
	return 0;
	
	
}


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

const int MAXN = 1e4+10;
ll n, a[MAXN], b[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];
	ll suma=0, sumb=0;
	for(int i=0;i<n;i++) suma+=a[i];
	for(int i=0;i<n;i++) sumb+=b[i];
	ll ops = sumb-suma;
	ll oa=0;
	ll ob=0;
	for(int i=0;i<n;i++) {
		if (a[i] < b[i]) {
			oa+=(b[i]-a[i])/2;
			if (a[i]%2 != b[i]%2) {
				ob++; oa++;
			}
		}
		else if (a[i] > b[i]) {
			ob+=(a[i]-b[i]);
		}
	}
//	cerr << ops << " " << oa << " " << ob <<endl;
	if (ops>=oa && ops>=ob && (ops-oa)*2 == (ops-ob)) cout << "Yes" <<endl;
	else cout << "No" <<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  
int main(){
    ll n;
    cin>>n;
    ll cmax = 100/4;
    ll dmax = 100/7;
    
    for(ll i = 0; i<=cmax; i++){
        for(ll j = 0; j<=dmax; j++){
            if(i*4 + j*7 == n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}
    
    



Measured memory_bytes: 256
def main():
    
    h,k = map(int, input().split())

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

    h_list.sort(reverse=True)
    ans = 0
    for i in range(len(h_list)):
        if k > 0:
            k -= 1
        else:
            ans += h_list[i]

    print(ans)


if __name__ == '__main__':
    main()



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

using namespace std;

bool solve(int N, int K, vector<vector<int>> &g)
{
	int P = (N - 1) * (N - 2) / 2;
	if (K > P) {
		return false;
	}
	for (int i = 1; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			if (P > K) {
				g[i][j] = 1;
				g[j][i] = 1;
				--P;
			}
		}
	}
	return true;
}

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

	vector<vector<int>> g(N, vector<int>(N, 0));
	for (int i = 1; i < N; ++i) {
		g[0][i] = g[i][0] = 1;
	}

	if (solve(N, K, g)) {
		int M = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				if (g[i][j]) {
					++M;
				}
			}
		}
		cout << M << endl;
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				if (g[i][j]) {
					cout << i + 1 << " " << j + 1 << endl;
				}
			}
		}
	}
	else {
		cout << -1 << endl;
	}
}


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

int main(){
	unsigned long long int n, ans=0, temp=10;
	cin>>n;
	if(n%2){
		cout<<"0\n";
		return 0;
	}
	while(1){
		if(n/temp==0)
			break;
		ans+=n/temp;
		temp=temp*5;
	}
	cout<<ans<<endl;
	return 0;
}

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

int f(vector<vector<int> > &v,int n,vector<vector<int> > &dp)
{
    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];
    for (int i=1;i<n;i++)
        for (int j=0;j<3;j++)
        {
            if(j==0)
                dp[i][j]=max(dp[i-1][1],dp[i-1][2]);
            else if(j==1)
                dp[i][j]=max(dp[i-1][0],dp[i-1][2]);
            else if(j==2)
                dp[i][j]=max(dp[i-1][0],dp[i-1][1]);
            dp[i][j]+=v[i][j];
        }
    int mx=0;
    mx=max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    return mx;
}

int main()
{
    int n,k;
    cin >> n;
    vector<vector<int> > v(n,vector<int> (3,0));
    for (int i=0;i<n;i++)
        for (int j=0;j<3;j++)
            cin >> v[i][j];
    vector<vector<int> > dp(n+1,vector<int> (3,0));
    cout << f(v,n,dp) << endl;

    /*for (int i=0;i<n;i++, cout << endl)
        for (int j=0;j<3;j++)
            cout << dp[i][j] << " ";*/
}


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

const int N = 511;

struct Num {
  int val, pos;
  bool operator < (Num t) { return pos < t.pos; }
};

int n, res[N * N];
Num num[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    num[i].val = i;
    scanf("%d", &num[i].pos);
  }
  sort(num + 1, num + n + 1);
  for (int i = 1, sum = 0; i <= n; ++i) {
    sum += num[i].val;
    if (num[i].pos < sum) return !puts("No");
  }
  for (int i = n, sum = 0; i >= 1; --i) {
    sum += n - num[i].val;
    if (n * n - num[i].pos < sum) return !puts("No");
  }
  for (int i = 1, t = 0; i <= n; ++i) {
    res[num[i].pos] = num[i].val;
    for (int j = 1; j < num[i].val; ++j) {
      while (res[++t]);
      if (t > num[i].pos) return !puts("No");
      res[t] = num[i].val;
    }
  }
  for (int i = n, t = n * n + 1; i >= 1; --i) {
    for (int j = 1; j <= n - num[i].val; ++j) {
      while (res[--t]);
      if (t < num[i].pos) return !puts("No");
      res[t] = num[i].val;
    }
  }
  puts("Yes");
  for (int i = 1; i <= n * n; ++i) printf("%d ", res[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[1]=='R'){
    if(s[0]=='R' && s[2]=='R'){
      cout << 3;
    }
    else if(s[0]=='R' || s[2]=='R'){
      cout << 2 ;
    }
    else{
      cout << 1;
    }
  }
  else{
    if(s[0]=='R' || s[2]=='R'){
      cout << 1;
    }
    else {
      cout << 0;
    }
  }
   return 0;
}
    
    
    
    
    
    
    
    

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rt(i,b,e) for(int i=b;i<e;i++)
int main(){
  int n;double s=0,d;cin>>n;vector<pair<int,int>>a(n);
  rt(i,0,n)cin>>a.at(i).first>>a.at(i).second;
  rt(i,0,n-1){
    rt(j,i+1,n){
      d=sqrt((a.at(i).first-a.at(j).first)*(a.at(i).first-a.at(j).first)+(a.at(i).second-a.at(j).second)*(a.at(i).second-a.at(j).second));
      s+=d;
    }
  }
  cout<<fixed<<s*2.0/n<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define mkp make_pair
#define cerr if (0) cerr

void solve() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int d = h2 * 60 + m2 - h1 * 60 - m1;
    cout << d - k;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 3648
var
a:array [1..10000] of longint;
n,k,i,j,y,h:longint;
begin
read(n,k);
for i:=1 to n do read(a[i]);
for i:=1 to n do
for j:=1 to i do
if a[j]<a[i] then begin y:=a[j]; a[j]:=a[i]; a[i]:=y; end;
for i:=1 to k do
h:=h+a[i];
write(h);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int n, m, a[100], b[100], path[10][10], cnt = 0;

void solve(int i) {
  if(i == n - 1) {
    ++cnt;
    return;
  }
  if(path[v[i]][v[i + 1]] != -1) { solve(i + 1); }
}

int main(void) {
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j) path[i][j] = -1;
  cin >> n >> m;
  for(int i = 0; i < n; ++i) v.push_back(i + 1);
  for(int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    path[a[i]][b[i]] = 1;
    path[b[i]][a[i]] = 1;
  }
  do {
    if(v[0] != 1) break;
    solve(0);
  } while(next_permutation(v.begin(), v.end()));
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(H.begin(), H.end());
    ll atk_cnt = 0;
    for (int i = 0; i < N - K; i++) {
        atk_cnt += H[i];
    }
    cout << atk_cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C
 */
#include <iostream>
#include <string>
#include <vector>

using namespace std;

constexpr int
getindex(const char c)
{
    return c == 'T' ? 4 : c == 'G' ? 3 : c == 'C' ? 2 : 1;
}

int
gethash(const string &s, const int st)
{
    int hash = 0;
    for (int i = st; i < s.length(); i++) {
        hash = getindex(s.at(i)) + (hash * 5);
    }
    return hash;
}

int
main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    vector<bool> dict(244140625);
    for (int i = 0; i < n; i++) {
        string line;
        getline(cin, line);

        if (line[0] == 'f') {
            cout << (dict[gethash(line, 5)] ? "yes" : "no") << endl;
        } else {
            dict[gethash(line, 7)] = true;
        }
    }

    return 0;
}

Measured memory_bytes: 32680
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Radix32(int A[],const int sz)
{
  static int temp[200001];const int bit=8;
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[A[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&((1<<bit)-1)]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&((1<<bit)-1)]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),c=CH(),p=0,m=0,z=0,A[200000];
  long K=0,count=0,l=-2e18,r=-l,mid,x;while(c>47&&c<58){K=K*10+c-48,c=CH();}
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;x=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=x;if(count>=K){r=mid-1l;continue;}
      rep(i,p){while(i<plus&&1l*A[i]*A[plus]>mid){plus--;}if(i==plus){break;}count+=1l*plus-i;}if(count>=K){r=mid-1l;continue;}
      rep(i,m){while(i<minus&&1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i==minus){break;}count+=1l*minus-i;}
    }
    else{int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return OUT(l),0;
}

Measured memory_bytes: 3044
#include <cstdio>

int main() {
  //入力
  int a,b;
  std::scanf("%d %d",&a,&b);
  
  if(a<b) {
    std::printf("a < b");
  }
  else if(a>b) {
    std::printf("a > b");
  }
  else if(a==b) {
      std::printf("a == b");
  }
  std::printf("\n");
  
  return 0;
}


Measured memory_bytes: 2680
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int tmp;
  int ans = 0;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(i%2==0 && tmp%2==1) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n;
P p[222222];
signed main() {
	cin >> n;
	rep(i, n)cin >> p[i].second >> p[i].first;
	sort(p, p + n);
	int now = 0;
	rep(i, n) {
		now += p[i].second;
		if (now > p[i].first) {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
}

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



int main() {
  ll n;
  string s;
  cin>>n>>s;
  int ans=1;
  char c=s[0];
  rep(i,n){
    if (c==s[i])continue;
    ans++;
    c=s[i];
  }
  cout<<ans;





}


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

int main(){
  int N,V[21],C[21],X[21],ans=0;
  cin >> N;
  for (int i=0;i<N;i++)cin >> V[i];
  for (int i=0;i<N;i++)cin >> C[i];
  for (int i=0;i<N;i++)X[i] = V[i]-C[i];
  for (int i=0;i<N;i++){
    if(X[i] >= 0){
      ans += X[i];
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a+b == c || b+c == a || c+a == b)
    {
      printf("Yes");
    }
    else
    {
      printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int W,H,N;
char str[1000];
bool t[1001][1001];
bool u[101][101];
bool v[101][101];
ull T[1001][1001];

map< ull , bool > mp;

ull A=9999973,B=950527;
ull C,D;

int change(char ch){
  if('A'<=ch&&ch<='Z')return ch-'A';
  if('a'<=ch&&ch<='z')return 26+ch-'a';
  if('0'<=ch&&ch<='9')return 52+ch-'0';
  if(ch=='+')return 62;
  if(ch=='/')return 63;
  return 100;
}

void ro(){
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)v[i][j]=u[i][j];
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)u[i][j]=v[N-1-j][i];
}

void re(){
  for(int i=0;i<N;i++)
    for(int j=0;j<N/2;j++)
      swap(u[i][j],u[i][N-1-j]);
}
               
ull getKey(){
  ull res=0;
  for(int i=0;i<N;i++){
    ull cnt=0;
    for(int j=0;j<N;j++)cnt=cnt*A+(u[i][j]+1);
    res=res*B+cnt;
  }
  return res;
}

int solve(){
  for(int i=0;i<8;i++){
    if(i==4)re();
    ro();
    mp[getKey()]=true;
  }
                       
  int res=0;
  for(int i=0;i<H;i++){
    ull cnt=0;
    for(int j=0;j<W;j++){
      cnt=cnt*A+(t[i][j]+1);
      if(0<=j-N)cnt-=C*(t[i][j-N]+1);
      T[i][j]=cnt;
    }
  }
  
  for(int j=N-1;j<W;j++){
    ull cnt=0;
    for(int i=0;i<H;i++){
      cnt=cnt*B+T[i][j];
      if(0<=i-N)cnt-=D*T[i-N][j];
      if(N-1<=i){
        if(mp.count(cnt)==1)res++;
      }
    }
  }
  return res;
}

void init(){
  mp.clear();
  C=D=1;
  for(int i=0;i<N;i++){
    C*=A;D*=B;
  }
}

int main(){
  while(1){
    cin>>W>>H>>N;
    if(W==0&&H==0&&N==0)break;
    init();
    for(int i=0;i<H;i++){
      scanf("%s",str);
      for(int j=0;j<W;j++){
        int k=5-j%6;
        t[i][j]=( change(str[j/6]) & (1<<k) );
      }
    }
    for(int i=0;i<N;i++){
      scanf("%s",str);
      for(int j=0;j<N;j++){
        int k=5-j%6;
        u[i][j]=( change(str[j/6]) & (1<<k) );
      }
    }
    cout<<solve()<<endl;
  }
  return 0;
}

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

int main() {
    int N = 0, K = 0;
    cin >> N >> K;
    int num = 1;

    for(int i = 0; i < N; i++) {
        if(num*2 < num+K) {
            num *= 2;
        } else {
            num += K;
        }
    }
    cout << num << endl;
}

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

using namespace std;

int main() {
    int N, A, B, C, D;cin >>N>> A >> B >> C >> D;
    A -= 1; B-=1; C-=1; D-=1;
    string S; getline(cin, S); getline(cin, S);
    if (S[A] != '.' || S[B] != '.' || S[C] != '.' || S[D] != '.') {
        cout << "No" << endl;
        return 0;
    }
    int t, e;
    t = min(A, B); e = min(C, D);
    for (int i=t; i <= e-1; ++i) {
        if (S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    t = max(A, B); e = max(C, D);
    for (int i=t; i <= e-1; ++i) {
        if (S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if ((A > B && C > D) || (B > A && D > C))  {
        cout <<"Yes" << endl;
        return 0;
    }else {
        t = max(A, B); e = min(C, D);
        for (int i=t; i <= e; ++i) {
            if (S[i-1] == '.' && S[i+1] == '.' && S[i] == '.') {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout <<"No" <<endl;
        return 0;
    }
}



Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);


        int n=scan.nextInt();
        int []rab=new int[n];
        int cnt=0;
        for(int i=0;i<n;i++){
            rab[i]=scan.nextInt();
        }

        for(int i=0;i<n;i++){
            if(rab[rab[i]-1]==i+1)
                cnt++;
        }

        System.out.println(cnt/2);
    }

}

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

int main(){
    int a, b;
    int i;
    int res[10];

    cin >> a >> b;
    
    if(a == b){
        for(i=0;i<a;i++){
            res[i] = a;
            cout << res[i];
        }
    }
    else if(a > b){
        for(i=0;i<a;i++){
            res[i] = b;
            cout << res[i];
        }
    }
    else{
        for(i=0;i<b;i++){
            res[i] = a;
            cout << res[i];
        }
    } 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program{
    public static void Main(){
        long number = long.Parse(Console.ReadLine());
        List<int> result = new List<int>();
        int baseNumber = 26;
        
        while (number != 0){
            number--;
            result.Add((int)(number % baseNumber));
            number = number / baseNumber;
        }
        
        foreach (int item in result.AsEnumerable().Reverse()){
            Console.Write((char)(item + (int)'a'));
        }
    }
}


Measured memory_bytes: 28068
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 


int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    if (a+2 >= b || k <= a) {
        cout << k+1 << endl;
    } else {
        ll ret = b;
        ll rest = k - (a+1);
        ret += (rest/2)*(b-a);
        if (rest%2) ret++;
        cout << ret << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int ans=0;
	rep(i,n)if(s[i]!=t[i])ans++;
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3804
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

from collections import defaultdict

dp = defaultdict(lambda : 10**100)
dp[0] = 0
for w, v in WV:
  ndp = defaultdict(lambda : 10**100)
  for k in dp:
    ndp[k] = min(dp[k], ndp[k])
    if dp[k] + w <= W:
   	  ndp[k+v] = min(dp[k] + w, ndp[k+v])
  dp = ndp
print(max(dp.keys()))

Measured memory_bytes: 132052
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
LL read(){
	LL nm=0,fh=1; LL cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
LL n,T,m,p[M],N,G[M],F[M],K[M],fs[M*30],nt[M*30],to[M*30],len[M*30],tmp;
void link(LL x,LL y,LL dst){nt[tmp]=fs[x],fs[x]=tmp,to[tmp]=y,len[tmp++]=dst;}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),T=read(),memset(fs,-1,sizeof(fs));
	while(T--){LL x=read(); while(m&&p[m]>=x) m--; p[++m]=x;}
	if(m&&p[1]<n){N=n,n=p[1];for(LL i=1;i<m;i++) p[i]=p[i+1];m--;}
//	for(LL i=1;i<=m;i++) printf("%lld\n",p[i]);
//	printf("n = %lld\n",n);
	G[0]=p[0]=n,F[m]=1;
	for(LL i=1;i<=m;i++){
		LL res=p[i],now=i-1;
		while(res>n){
			LL k=res/p[now]; link(i,now,k),res-=k*p[now];
			now=upper_bound(p,p+now,res)-p-1;
		} G[i]=res;
	}
	for(LL i=m;i>=0;i--){
		for(LL j=fs[i];j!=-1;j=nt[j]) F[to[j]]+=F[i]*len[j];
		K[1]+=F[i],K[G[i]+1]-=F[i];
	}
	for(LL i=1;i<=n;i++) K[i]+=K[i-1],printf("%lld\n",K[i]);
	while(n<N) n++,putchar('0'),putchar('\n');
	return 0;
}

Measured memory_bytes: 76672
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= 1e7; ++i) {
        ll x = n / i;
        ans += x * (i + i * x) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int a,b;
  cin >> a >> b;
  cout << a * b << " " << 2 * (a+b) << endl;

    return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    float ans = a[0];
    rep(i,n-1) ans = (ans+a[i+1])/2;
    cout << ans << endl;
}

Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int main(){
  int n;
  int p[21];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i];
  }
  int cnt=0;
  for(int i=2;i<=n-1;i++){
    if(p[i-1]<p[i] && p[i]<p[i+1])cnt++;
    else if(p[i+1]<p[i] && p[i]<p[i-1])cnt++;
    else if(p[i]>p[i-1] && p[i-1]==p[i+1])cnt++;
  }
  
  cout<<cnt<<"\n";
  
  return 0;
}


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

int main() {
  int time1, time2;
  int rate1, rate2;

  cin >> time1 >> time2 >> rate1 >> rate2;

  if(rate1 == -1 || rate2 == -1) {
    if(time1 < time2) {
      cout << "Alice" << endl;
    }
    else if(time1 > time2) {
      cout << "Bob" << endl;
    }
    else {
      cout << "Draw" <<	endl;
    }
  }
  else {
    if(rate1 > rate2) {
      cout << "Alice" << endl;
    }
    else if(rate1 < rate2) {
      cout << "Bob" << endl;
    }
    else {
      cout << "Draw" <<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3092
a,b=map(int,input().split())
c=list(map(lambda x:(int(x)+1)/2,input().split()))
i=0
summ=0
maxx=0
for j in range(b):
  summ+=c[i]
  i+=1
maxx=summ
for j in range(a-b):
  summ+=c[i]
  summ-=c[i-b]
  i+=1
  if maxx<summ:maxx=summ
print(maxx)

Measured memory_bytes: 23588
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if arr[i]<arr[j] and arr[j]<arr[k]:
        if arr[i]+arr[j]>arr[k]:
          ans+=1
print(ans)


Measured memory_bytes: 67964
#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()

//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 <db, db> pdd;

int in[105];
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d", &in[i]);
	if (M == 1) {
		if (in[1] == 1) {
			printf("1\n1\n1\n");
			return 0;
		}
		printf("%d\n", in[1]);
		printf("2\n");
		printf("%d %d\n", in[1] - 1, 1);
		return 0;
	}

	int c = 0;
	for (i = 1; i <= M; i++) if (in[i] % 2 == 1) c++;

	if (N % 2 == 0 && c > 2) return !printf("Impossible\n");
	if (N % 2 == 1 && c > 1) return !printf("Impossible\n");

	if (N % 2 == 1 && c == 1) {
		int p = 0;
		for (i = 1; i <= M; i++) if (in[i] % 2 == 1) p = i;
		swap(in[1], in[p]);
	}
	if (N % 2 == 0 && c == 2) {
		int p1 = 0, p2 = 0;
		for (i = 1; i <= M; i++) {
			if (in[i] % 2 == 1) {
				if (p1 == 0) p1 = i;
				else p2 = i;
			}
		}
		swap(in[1], in[p1]);
		swap(in[M], in[p2]);
	}
	for (i = 1; i <= M; i++) printf("%d ", in[i]);
	if (in[1] != 1) {
		printf("\n%d\n", M);
		in[1]--, in[M]++;
		for (i = 1; i <= M; i++) printf("%d ", in[i]);
	}
	else {
		printf("\n%d\n", M - 1);
		in[M]++;
		for (i = 2; i <= M; i++) printf("%d ", in[i]);
	}
	return !printf("\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

int main() {
    int n;
    cin>>n;
    vector<int> v(n);

    rep(i,n){
        int p;
        cin>>p;
        p--;
        v[p]=i;
    }

    //rep(i,n) cout<<v[i]<<" ";
    //cout<<endl;

    int ans=1,tmp=1;
    rep(i,n-1){
        if(v[i]<v[i+1]){
            tmp++;
            ans=max(ans,tmp);
        }
        else{
            tmp=1;
        }
    }   

    cout<<n-ans<<endl;
}

Measured memory_bytes: 4004
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
Q = int(input())
ans = sum(A)
for q in range(Q):
  B, C = map(int, input().split())
  count = c[B]
  c[B] -= count
  c[C] += count
  ans += (C-B)*count
  print(ans)


Measured memory_bytes: 23928
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
    ll n, m, t;
    cin >> n >> m >> t;

    ll cR[n + 1] = {0} , cW[m + 1] = {0};

    ll x[t] , y[t];
    set <pair<ll,ll>> st;

    for (ll i = 0 ; i < t ; ++i) {
        cin >> x[i] >> y[i];
        cR[x[i]]++;
        cW[y[i]]++;
        st.insert({x[i] , y[i]});
    }

    ll mr = *max_element(cR , cR + n + 1);
    ll mw = *max_element(cW , cW + m + 1);
    // dbg2(mr,mw);

    vell candr , candw;

    for(ll i= 1 ; i <= n ; ++i) {
          if(cR[i] == mr)
            candr.pb(i);
    }

    for(ll i= 1 ; i <= m ; ++i) {
          if(cW[i] == mw)
            candw.pb(i);
    }

    ll f = mr + mw;

    for(auto it : candr) {
        for(auto ii : candw) {
           if(!st.count({it,ii})) {
            cout << f;
            return;
           }
        }
    }

    cout << f - 1;




}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    //TEST
    solve();
}



Measured memory_bytes: 39724
using System;

class AOJ {
    static void Main(string[] args) {
        const int MAX_N = 1000001;
        bool[] IsPrime = new bool[MAX_N];
        int[] cnt = new int[MAX_N];
        for (int i = 0; i < MAX_N; i++) {
            IsPrime[i] = true;
            cnt[i] = 0;
        }
        IsPrime[0] = IsPrime[1] = false;
        for (int i = 2; i*i < MAX_N; i++) {
            if (IsPrime[i]) {
                for (int j = i*i; j < MAX_N; j += i) {
                    IsPrime[j] = false;
                }
            }
        }

        for (int i = 0; i < MAX_N; i++) {
            if (IsPrime[i]) { cnt[i]++; }
        }
        for (int i = 1; i < MAX_N; i++) {
            cnt[i] += cnt[i-1];
        }
        string s;
        while ((s = Console.ReadLine()) != null) {
            int n = int.Parse(s);
            Console.WriteLine(cnt[n]);
        }
    }
}


Measured memory_bytes: 13936
import math

if __name__ == "__main__":
	N = int(input())
	ans = 1000000000000
	for i in range(int(math.sqrt(N)) + 1, 0, -1):
		if N % i == 0 and i + (N // i) - 2 < ans:
			ans = i + (N // i) - 2

	print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>

using namespace std;

// ?´???°
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C&lang=jp
int main(int argc, char const* argv[])
{
    int n, x, t = 0, rt;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x <= 3) {
            t++;
            continue;
        }
        if (x % 2 == 0) continue;

        rt = sqrt(x) + 1;
        int els = 1;
        for (int i = 3; i <= rt; i+=2) {
            if(x % i == 0){
                els = 0;
                break;
            }
        }
        if(els) t++;
    }

    cout << t << endl;

    return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int L = sc.nextInt();
        long[][] A = new long[N][M];
        long[][] B = new long[M][L];
        long[][] C = new long[N][L];
        for (int n = 0; n < N; n++) {
            for (int m = 0; m < M; m++) {
                A[n][m] = sc.nextInt();
            }
        }
        for (int m = 0; m < M; m++) {
            for (int l = 0; l < L; l++) {
                B[m][l] = sc.nextInt();
            }
        }
        for (int n = 0; n < N; n++) {
            StringBuilder sb = new StringBuilder();
            for (int l = 0; l < L; l++) {
                for (int m = 0; m < M; m++) {
                    C[n][l] += A[n][m] * B[m][l];
                }
                sb.append(C[n][l]);
                if (l < L - 1) sb.append(' ');
                else System.out.println(sb);
            }
        }
    }
}



Measured memory_bytes: 52608
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;
    Vi a(n);
    REP(i, n) cin >> a[i];

    V<Mii> m(2);
    m[0][0] = 0;
    m[1][0] = 0;
    REP(i, n) {
        if (m[i%2].count(a[i]) == 0) {
            m[i%2][a[i]] = 1;
        } else {
            m[i%2][a[i]]++;
        }
    }

    V<V<Pii>> v;
    REP(i, 2) {
        V<Pii> u;
        for (auto x: m[i]) {
            u.push_back({x.second, x.first});
        }
        sort(ALL(u), greater<Pii>());
        v.push_back(u);
    }
    if (v[0][0].second != v[1][0].second) {
        cout << (n - v[0][0].first - v[1][0].first) << '\n';
    } else {
        cout << min(n - v[0][1].first - v[1][0].first, n - v[0][0].first - v[1][1].first) << '\n';
    }

    return 0;
}


Measured memory_bytes: 6640
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int a,b;
    cin>>a>>b;

    if(a >= 13) {
        cout<<b<<endl;
    } else if(a >= 6 && a <= 12) {
        cout<<b/2<<endl;
    } else { 
        cout<<0<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char x,ch;
	int n,y,i,S,H,C,D,j,p;
	bool cards[4][13]={false};
	cin>>n;
	for(i=0;i<n;i++){
	cin>>x>>y;
	if(x=='S'){
		cards[0][y-1]=true;
	}
	else if(x=='H'){
	cards[1][y-1]=true;
	}
	else if(x=='C'){
		cards[2][y-1]=true;
	}
	else if(x=='D'){
		cards[3][y-1]=true;
	}
	}
	for(j=0;j<4;j++){
		for(p=0;p<13;p++){
		if(cards[j][p]==false){
			switch (j){
			case 0: ch='S';break;
			case 1: ch='H';break;
			case 2: ch='C';break;
			case 3: ch='D';break;
			}
			cout<<ch<<" "<<p+1<<endl;
		}
		}
	}
return 0;
}

Measured memory_bytes: 3004
n = int(input())
s = [input() for i in range(n)]

nac = 0
nwa = 0
ntle = 0
nre = 0

for i in s:
    if i == 'AC':
        nac += 1
    if i == 'WA':
        nwa += 1
    if i == 'TLE':
        ntle += 1
    if i == 'RE':
        nre += 1

print("AC x ", nac)
print("WA x ", nwa)
print("TLE x ", ntle)
print("RE x ", nre)





Measured memory_bytes: 16332
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;


fn main() {
    input! {
        H: usize,
        W: usize,
    }

    let mut Cs: Vec<Vec<i64>> = Vec::new();

    for _i in 0..10 {
        input! {
            tmp: [i64; 10],
        }

        let mut arr: Vec<i64> = Vec::new();
        arr.extend_from_slice(&tmp);
        Cs.push(arr);
    }

    let mut As: Vec<Vec<i64>> = Vec::new();

    for _h in 0..H {
        input! {
           tmp: [i64; W],
        }

        let mut arr: Vec<i64> = Vec::new();
        arr.extend_from_slice(&tmp);
        As.push(arr);
    }

    // まずi => jの最小コストを求めておく
    // Cost[i][j][n] : i から j へ n回以下のステップで行った時の最小コスト
    let mut Cost: Vec<Vec<Vec<i64>>> = Vec::new();
    for _ in 0..10 {
        let mut arr2: Vec<Vec<i64>> = Vec::new();

        for _ in 0..10 {
            // コストの最大値は10^3を10回積み重ねた10^4
            // なので、それを上回る10^6としておこう
            let arr1 = vec![1000_000i64; 10];
            arr2.push(arr1);
        }

        Cost.push(arr2);
    }

    // まずn == 1 の場合
    for i in 0..10 {
        for j in 0..10 {
            Cost[i][j][1] = Cs[i][j];
        }
    }

    for n in 2..10 {
        for i in 0..10 {
            for j in 0..10 {
                // 直接行くか、kを経由して行くか

                let mut cand: i64 = Cs[i][j];

                for k in 0..10 {
                    cand = min(cand, Cs[i][k] + Cost[k][j][n - 1]);
                }

                Cost[i][j][n] = cand;
            }
        }
    }

    let mut ans = 0;

    for h in 0..H {
        for w in 0..W {
            if As[h][w] == 1 || As[h][w] == -1 {
                continue;
            }

            let a = &As[h][w];
            ans += Cost[*a as usize][1][9];
        }
    }

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


Measured memory_bytes: 2512
A,B,C,D,E=int(input()),int(input()),int(input()),int(input()),int(input())
orders = {'A': A, 'B': B, 'C': C, 'D': D, 'E': E}
orders = sorted(orders.items(), key=lambda item: (10 if item[1] % 10 == 0 else item[1] % 10), reverse=True)
res = 0
while orders:
  if res % 10 != 0:
    res += (10 - res % 10)
  order = orders.pop(0)
  res += order[1]
print(res)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <bitset>
using namespace std;

const int N = 404;
const int M = 1e5 + 50;

bitset <N> tur[N], res;
int x[M], y[M], n, m;
bool die[N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i ++) tur[i][i] = 1;
  for (int i = 1; i <= m; i ++) scanf("%d%d", x + i, y + i);
  for (register int j = m, a, b; j; j --) {
    a = x[j]; b = y[j];
    for (register int i = 1; i <= n; i ++) {
      if (tur[i][a] && tur[i][b]) die[i] = 1;
      else if (tur[i][a] ^ tur[i][b]) tur[i][a] = tur[i][b] = 1;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i ++)
    if (!die[i])
      for (int j = i + 1; j <= n; j ++)
        if (!die[j]) {
          res = tur[i] & tur[j];
          if (!res.count()) cnt ++;
        }
  printf("%d\n", cnt);
  return 0;
}


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

#define ll long long int
#define pb push_back
#define mp make_pair
#define all(X) X.begin(), X.end()
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

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

    long long int ans = (n * (n - 1)) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256