akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n,k;cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    ll sum=0;
    rep(i,n-k)sum+=v[i];
    out(sum);
}

Measured memory_bytes: 1792
abcd=list(input())
for i in range(2**3):
    if i//4==0:
        op1="+"
    else:
        op1="-"
    i=i%4
    if i//2==0:
        op2="+"
    else:
        op2="-"
    i=i%2
    if i==0:
        op3="+"
    else:
        op3="-"
    siki=abcd[0]+op1+abcd[1]+op2+abcd[2]+op3+abcd[3]
    if eval(siki)==7:
        siki+="=7"
        break
print(siki)


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;;
int main(){
     int N,sum;
     vector<int> p;
     cin >> N;
     p.resize(N);
     for(int i = 0; i < N; i++){
          cin >> p[i];
     }
     sort(p.begin(),p.end());
     sum = 0;
     for(int i = 0; i < N-1; i++){
          sum += p[i];
     }
     sum += p[N - 1] / 2;
     cout << sum << endl;
     return 0;
}

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

struct deer
{
    int t;
    int x;
    int y;
};

int main()
{

    int N;
    cin >> N;
    vector<deer> D(N+1);
    D.at(0).t = 0;
    D.at(0).x = 0;
    D.at(0).y = 0;

    for(int i = 1; i < N+1; i++)
    {
        cin >> D.at(i).t >> D.at(i).x >> D.at(i).y;
    }
    
    for(int i = 0; i < N; i++)
    {
        int dx = abs(D.at(i).x - D.at(i+1).x);
        int dy = abs(D.at(i).y - D.at(i+1).y);
        int dt = D.at(i+1).t - D.at(i).t;

        if(dt < dx + dy || (dx + dy - dt) % 2 != 0)
        {                        
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d==7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a+b+c-d==7:
    print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c+d==7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a-b+c+d==7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a-b-c+d==7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a-b+c-d==7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c-d==7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a-b-c-d==7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
            break;
        if(x>y){
            printf("%d %d\n",y,x);
        }else{
            printf("%d %d\n",x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 600
while str = STDIN.gets

  break if str == "\n"

  str.to_i.times {
    x = STDIN.gets.chomp.split(//).map(&:to_i)
    puts x.sort{|a, b| b <=> a}.join.to_i - x.sort{|a, b| a <=> b}.join.to_i
  }

end

Measured memory_bytes: 8588
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll N;
std::string s;
ll cnt[5];

int main()
{
  std::cin >> N >> s;

  rep( i, N )
    ++cnt[s[i]=='R'];

  std::cout << (cnt[1]>cnt[0]?"Yes":"No") << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

ll A,B,g,ans;

int main(){
    cin>>A>>B;
    g = gcd(A,B);
    repi(i,2,sqrt(1e12)+1){
        if(g%i==0){
            ans++;
            while(g%i==0)g/=i;
        }
    }
    if(g>sqrt(1e12))ans++;
    out(ans+1);

    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 1e5 + 5;
int a[mxN],b[mxN],c[mxN];
int cache[mxN][4];
int n,k;
int dp(int idx, int code){
	if(idx>n)
		return 0;
	int &ans = cache[idx][code];
	if(ans!=-1)
		return ans;
	int best = 0;
	if(code == 0){
		best = max(a[idx]+ dp(idx+1,1),max(b[idx] + dp(idx+1,2),c[idx] + dp(idx+1,3)));
	}
	else if(code==1){
		best = max(b[idx] + dp(idx+1,2),c[idx] + dp(idx+1,3));
	}
	else if(code == 2){
		best = max(a[idx] + dp(idx+1,1),c[idx] + dp(idx+1,3));
	}
	else if(code==3){
		best = max(a[idx] + dp(idx+1,1),b[idx] + dp(idx+1,2));
	}
	return ans = best;
}
void solve(){
	cin>>n;
	memset(cache,-1,sizeof(cache));
	for(int i = 1 ; i <= n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	cout<<dp(1,0)<<'\n';
}
int main() {	
	// IOS
	ll T;
	// cin>>T;
	
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 14068
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ins insert
#define int long long int
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i = 0 ; i < n ; i++ )
#define f1(i,n) for(int  i = 1 ; i <= n ; i++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() int t;cin>>t;while(t--)
int mpower(int x, int y, int p){int res = 1;x = x % p;while(y > 0){if(y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
int power(int x, int y){int res = 1;while (y > 0){if (y & 1) res = res*x;y = y>>1;x = x*x;}return res;}
bool isPrime(int n){if (n <= 1)  return false;if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false;int p=sqrt(n);for(int i=5;i<=p;i=i+6)if (n%i == 0 || n%(i+2) == 0)return false;return true;}

bool q(pair<int,int> a, pair<int,int> b)
{
    return a.ss > b.ss;
    
}

int32_t main()
{
	fast();

	/*test()
	{
	}*/
    int n , k ;
    cin >> n >> k ;
    int a[n+1];
    
    f1(i,n) 
        cin >> a[i];
        
    int dp[n+1] = {0};
    
    for(int i = 2 ; i<= n ; i++)
    {
        int j;
        int mn  = INT_MAX;
        for(j = i-1 ; j>=1 && j >= i-k ; j--)
        {
            mn  = min(mn , dp[j] + abs(a[j] - a[i]));
        }
        dp[i] = mn;
    }
    
    cout<<dp[n];


	return 0;
}

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

int main() {
int N,i,j,k,t,s=0;
cin>>N>>k;
int p[N];
for(i=0;i<N;i++)
{
    cin >>p[i];
}
  
for(i=0;i<N;i++)  

 {   for(j=i;j<N;j++)
    {
        if(p[i]>p[j])
        {
            t=p[i];
            p[i]=p[j];
            p[j]=t;
        }
    }}


for(i=0;i<k;i++)
{
    s+=p[i];
}
cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    string sa,sb,rem; int na,nb; cin>>sa>>sb>>na>>nb>>rem;
    if (rem == sa) --na; else --nb;
    cout << na << " " << nb << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    work();

    return 0;
}


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

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n,w;
	cin>>n>>w;

	vector<int>dp(w+1,0);
	for(int i=0;i<n;i++){
		int val,wgh;
		cin>>wgh>>val ;
		for(int j=w-wgh;j>=0;j--){
			dp[j+wgh]=max(dp[j+wgh],dp[j]+val);
		}
	}
	cout<<dp[w]<<endl;

	return 0;
}


Measured memory_bytes: 1024
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  Real a, b;
  cin >> a >> b;
  cout << (Bint)(a*b) << endl;
  return 0;
}

Measured memory_bytes: 3948
import java.util.*;
class Main{
  public static void main(String[] arg){
    Scanner stdIn=new Scanner(System.in);
    int a=stdIn.nextInt();
    int b=stdIn.nextInt();
    int c=stdIn.nextInt();
    int count=3;
    if(a==b){
      count--;
      if(a==c){
        count=1;
      }
    }
    if(a==c){
      count--;
      if(a==b){
        count=1;
      }
    }
    if(b==c){
      count--;
      if(b==a){
        count=1;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21204
S = input()
flg1 = 1 <= int(S[:2]) <= 12
flg2 = 1 <= int(S[2:]) <= 12

if flg1 and flg2:
    print('AMBIGUOUS')
elif flg1 and not flg2:
    print('MMYY')
elif not flg1 and flg2:
    print('YYMM')
else:
    print('NA')


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

int main() {
  ll H, W;
  cin >> H >> W;
  ll ans;
  if (H == 1 || W == 1) {
    ans = 1;
  } else if (W % 2 == 0)
    ans = H * W / 2;
  else if (W % 2 == 1) {
    ans = (H - 1) * W / 2;
    ans += (W + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using pii = pair<int, int>;

const int INF = 1e9 + 10;

template <typename itr> void output(itr first, itr last) {
  for (auto iter = first; iter != last; ++iter) {
    for (int i : *iter) {
      if (i == INF)
        cerr << "INF"
             << ", ";
      else
        cerr << i << ", ";
    }
    cerr << endl;
  }
  cerr << endl;
}

int main() {
  int V, E, r;
  cin >> V >> E >> r;
  vector<int> C(V, INF); // tmp
  vector<int> ans(V, INF);
  // <distance, node>
  vector<vector<pii>> dests(V);
  priority_queue<pii, vector<pii>, greater<pii>> pQ;
  C[r] = 0;
  pQ.push(make_pair(0, r));
  for (int i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    dests[s].push_back(make_pair(d, t));
  }
  while (!pQ.empty()) {
    pii smallest = pQ.top();
    pQ.pop();
    if (ans[smallest.second] == INF) {
      ans[smallest.second] = smallest.first;
      for (pii dest : dests[smallest.second]) {
        C[dest.second] = min(C[dest.second], C[smallest.second] + dest.first);
        pQ.push(make_pair(C[dest.second], dest.second));
      }
    }
  }
  for (int i : ans) {
    if (i == INF)
      cout << "INF" << endl;
    else
      cout << i << endl;
  }
}



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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H,W,N; cin>>H>>W>>N;
	cout<<min((N+W-1)/W,(N+H-1)/H)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		int n = stdIn.nextInt();

		List<String> allPermList = permutation(n, "", new ArrayList<>());

		Collections.sort(allPermList);

		stdIn.nextLine(); //改行

		String p = stdIn.nextLine().replaceAll(" ", "");
		String q = stdIn.nextLine().replaceAll(" ", "");

		int index = 0;
		int pIndex = -1;
		int qIndex = -1;

		for (String seq : allPermList) {
			if(p.equals(seq)) {
				pIndex = index;
			}

			if(q.equals(seq)) {
				qIndex = index;
			}

			if(pIndex != -1 && qIndex != -1) {
				break;
			}

			index++;

		}

		System.out.println((int)Math.abs(pIndex - qIndex));

		stdIn.close();
	}

	public static List<String> permutation(int n, String current, List<String> results) {

		if (current.length() == n) {
			results.add(current);
			return results;
		}

		int digit = current.length() + 1;

		for (int i = 0; i < digit; i++) {
			StringBuilder sb = new StringBuilder().append(current);
			sb.insert(i, digit);

			permutation(n, sb.toString(), results);
		}

		return results;
	}
}


Measured memory_bytes: 36048
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int64_t Q,H,S,D,N;
  cin>>Q>>H>>S>>D>>N;
  int64_t a=min({Q*4,H*2,S});
  int64_t b=min(2*a,D);
  cout<<N%2*a+N/2*b<<endl;
  return 0;  
}


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

typedef long long ll;
const int INF = 100100;

ll H, W;

int main() {
    cin >> H >> W;
    int c[10][10];
    rep(i, 10)rep(j, 10) cin >> c[i][j];

    int A[H][W];
    rep(i, H)rep(j, W) cin >> A[i][j];

    vector<vector<int>> dist(10, vector<int>(10, INF));
    rep(i, 10)rep(j, 10) {
        dist[i][j] = c[i][j];
    }

    rep(k, 10)rep(i, 10)rep(j, 10) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    int ans = 0;
    rep(i, H)rep(j, W) {
        if (A[i][j] == -1) continue;
        if (A[i][j] == 1) continue;

        ans += dist[A[i][j]][1];
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> I(N), J(N);
    int a, b;
    for(int i = 0; i < N; i++){
        cin >> a;
        I.at(i) = a;
    }
    for(int i = 0; i < N; i++){
        cin >> b;
        J.at(i) = b;
    }
    
    int ans = 0, num;
    for(int i = 0; i < N; i++){
        num = 0;
        for(int j = 0; j <= i; j++){
            num += I.at(j);
        }
        for(int k = i; k < N; k++){
                num += J.at(k);
            }
        ans = max(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int gcd(int a, int b)
{
    while (a != 0) {
        int r = b % a;
        b = a;a = r;
    }
    return b;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) V(N);
    READVEC(V);
    VEC(int) gcds(N);
    int g = 0;
    FORD(i, N - 1, -1) {
        gcds[i] = g;
        g = gcd(g, V[i]);
    }

    int ret = 0;
    g = 0;
    FOR(i, 0, N) {
        ret = max(ret, gcd(g, gcds[i]));
        g = gcd(g, V[i]);
    }

    cout << ret << endl;
    return 0;
};


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b; cin >> a >> b;
    cout << (a*b%2==0?"Even":"Odd") << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    string s;
    while(cin>>s)
    {
        int n=s.size();
        bool flag=true;
        int l=0,r=(n-1)/2-1;
        while(s[l]==s[r]&&l<=r){l++;r--;}
        if(l<=r)flag=false;
        l=(n+3)/2-1;r=n-1;
        while(s[l]==s[r]&&l<=r){l++;r--;}
        if(l<=r)flag=false;
        l=0,r=n-1;
        while(s[l]==s[r]&&l<=r){l++;r--;}
        if(l<=r)flag=false;
        if(flag)cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
/*  ex4_2
    Rikuta  */

#include <stdio.h>
#include <math.h>

//円周率の定義
#define PI 3.141592653589

int main(void){

    int hour_hand_length,min_hand_length,num_hour,num_min;

    //入力受け取り
    scanf("%d %d %d %d",&hour_hand_length,&min_hand_length,&num_hour,&num_min);

    //何時何分を分になおす
    int sum_mins=60*num_hour+num_min;

    //時針と分針の0:00からの弧度
    double hour_hand_radian=(double)sum_mins/360*PI;
    double min_hand_radian=(double)num_min/30*PI;

    //時針と分針の間の弧度
    double dif_radian=hour_hand_radian-min_hand_radian;

    //余弦定理をつかった答えの計算
    double ans=sqrt(pow((double)hour_hand_length,2)+pow((double)min_hand_length,2)-2*hour_hand_length*min_hand_length*cos(dif_radian));

    //ansの小数点以下9桁を含む出力
    printf("%.9lf\n",ans);

    return 0;
}

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

namespace KPCC
{
    static class MainClass
    {

        public static void Main(string[] args)
        {


            int N = int.Parse(Console.ReadLine());
            string[] input1 = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');
            var Alst = new List<long>();
            var Blst = new List<long>();
            var difflst = new List<long>();
            long negacnt = 0;
            long negasum = 0;
            long sum = 0;

            for(int i = 0; i < N; i++)
            {
                long A = long.Parse(input1[i]);
                long B = long.Parse(input2[i]);
                long diff = A - B;
                Alst.Add(A);
                Blst.Add(B);

                difflst.Add(diff);
                sum += diff;
                if (diff < 0)
                {
                    negacnt++;
                    negasum += diff;
                }

            }

            if (sum < 0)
            {
                Console.WriteLine(-1);
                return;
            }

            var ordereddifflst = difflst.OrderByDescending(a => a).ToList();



            while (negasum < 0)
            {

                negasum += ordereddifflst.First();
                negacnt++;
                ordereddifflst.RemoveAt(0);
            }



            Console.WriteLine(negacnt);

            return;


        }



        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


        public static IEnumerable<long> PF(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }




    }

}






Measured memory_bytes: 41048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main(){
    long long n,k;
    cin>>n>>k;
    vector<long long> a(n);
    for(int i=0;i<n;++i) cin>>a[i];

    long long temp=1;
    for(int i=0;i<n-k;++i){ 
        string ans;
        long long before=a[i];
        long long after=a[i+k];
        if(before<after) ans="Yes";
        else ans="No";
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4840
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<deque>
#define ll long long
using namespace std;
deque<ll>qmax,qmin;

ll n,k,p,t,a[200007],f[200007];

int main(){
    scanf("%lld%lld",&n,&k);
    for (int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
        f[i]=1;
        if (a[i]>a[i-1]) f[i]+=f[i-1];
        if (!qmax.empty()&&qmax.front()<=i-k) qmax.pop_front();
        if (!qmin.empty()&&qmin.front()<=i-k) qmin.pop_front();
        while (!qmax.empty()&&a[qmax.back()]<a[i]) qmax.pop_back();
        while (!qmin.empty()&&a[qmin.back()]>a[i]) qmin.pop_back();
        qmax.push_back(i),qmin.push_back(i);
        if (i>=k&&f[i]<k){
            ++p;
            if (i-1>=k&&f[i-1]<k&&qmax.size()==1&&a[i-k]<a[qmin.front()])
                --p;
        }
        t=max(t,f[i]);
    }
    if (t>=k) ++p;
    printf("%lld",p);
}

Measured memory_bytes: 4992
#include <stdio.h>

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int ans = 0;
	if (a == b) {
		ans = 1;
	}
	if (b == c) {
		ans = 1;
	}
	if (a == c) {
		ans = 1;
	}
	if (a == b && a == c) {
		ans = 0;
	}
	if (ans == 1) {
		printf("Yes");
	}	else  {
		printf("No");
	}
}

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

int count_bit(int f, int n) {
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    if((f & (1 << i)) != 0) {
      ans++;
    }
  }
  return ans;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ss(M);
  for(int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    for(int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      ss[i] |= (1 << (s - 1));
    }
  }
  vector<int> ps(M);
  for(int i = 0; i < M; ++i) {
    cin >> ps[i];
  }
  int ans = 0;
  for(int i = 0; i < (1 << N); ++i) {
    bool delight = true;
    for(int j = 0; j < M; ++j) {
      delight = delight && (count_bit(i & ss[j], N) % 2 == ps[j]);
    }
    if(delight)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int a,b,c;
	cin>>a>>b;
	c=a*b;
	if(c%2==1)cout<<"Odd"<<endl;
	else if(c%2==0)cout<<"Even"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

	vector< int > cards( 2 * n, 0 );

	for( int i = 0; i < 2 * n; i++ )
		cards[i] = i + 1;

	int m;
	cin >> m;

	for( int i = 0; i < m; i++ ) {
		int k;
		cin >> k;
		if( k == 0 ) {
			vector< int > tmpcards( 2 * n, 0 );
			for( int i = 0; i < cards.size() / 2 ; i++ ) {
				tmpcards[ 2 * i ] = cards[ i ];
				tmpcards[ 2 * i + 1 ] = cards[ i + n ];
			}
			for( int i = 0; i < cards.size(); i++ ) {
				cards[i] = tmpcards[i];
			}
		} else {
			vector< int > tmpcards;
			for( int i = k; i < cards.size(); i++ )
				tmpcards.push_back( cards[i] ); 
			for( int i = 0; i < k; i++)
				tmpcards.push_back( cards[i] );
			for( int i = 0; i < cards.size(); i++ ) {
				cards[i] = tmpcards[i];
			}
		}
	}

	//出力
	for( int i = 0; i < cards.size(); i++ )
		cout << cards[i] << endl;

    return 0;
}

Measured memory_bytes: 1220
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long x,y,z,s;
	x=a*c;
	y=a*d;
	z=b*c;
	s=b*d;
	if(x>y && x>z && x>s)
	{
		cout<<x;
	}
	else if(y>z && y>s )
	{
		cout<<y;
	}
	else if(z>s)
	{
	     cout<<z;
		 	
	}
	else
	{
		cout<<s;
	}
	
	return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
    int arr[101], N, i, cnt, even;
    scanf("%d", &N);
    for(i=0;i<N;i++)
        scanf("%d", &arr[i]);
    cnt=0; even=0;
    for(i=0;i<N;i++){
        if(arr[i]%2==0){
            even++;
        if(arr[i]%3==0||arr[i]%5==0)
            cnt++;
        }
    }
    if(cnt==even)
        printf("APPROVED");
    else
        printf("DENIED");
return 0;
}


Measured memory_bytes: 128
H, W = [ int(x) for x in input().split() ]
Ss = [ input() for _ in range(H) ]

ans = Ss.copy()
for y in range(H):
    for x in range(W):
        if ans[y][x] == "#":
            continue
        n = 0
        for dir in [[0, 1], [0, -1], [1, 0], [1, 1], [1, -1], [-1, 0], [-1, 1], [-1, -1]]:
            x2 = x + dir[0]
            y2 = y + dir[1]
            if x2 < 0 or x2 >= W or y2 < 0 or y2 >= H:
                continue
            n += 1 if Ss[y2][x2] == "#" else 0
        ans[y] = ans[y][:x] + str(n) + ans[y][x+1:]

print("\n".join(ans))


Measured memory_bytes: 3064
n=int(input())
XYH=[]
for i in range(n):
  x,y,h=map(int,input().split())
  XYH.append([x,y,h])
XYH.sort(key=lambda x:x[2])
for i in range(101):
  for j in range(101):
    peak=abs(i-XYH[-1][0])+abs(j-XYH[-1][1])+XYH[-1][2]
    flag=1
    for k in range(n-1):
      if max(0,peak-abs(i-XYH[k][0])-abs(j-XYH[k][1]))!=XYH[k][2]:
        flag=0
    if flag==1:
      Ans=[i,j,peak]
print(*Ans)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

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

    final int M = 1_000_000_007;
    int N = scanner.nextInt();
    int[] c = new int[N];
    for (int i = 0; i < N; i++) c[i] = scanner.nextInt();
    Arrays.sort(c);

    long res = 0;
    for (int i = 0; i < N; i++) {
      res += (long) (N - i + 1) * c[i] % M;
      if (res >= M) res -= M;
    }
    res *= modpow(2, 2 * N - 2, M);
    res %= M;
    System.out.println(res);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}


Measured memory_bytes: 86584
n=int(input())
li=[input() for i in range(n)]
li2=[li[0]]

for i in range(1,len(li)):
    if li[i][0] == li[i-1][-1] and li[i] not in li2:
        li2.append(li[i])
    else:
        print("No")
        break
if li==li2:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define min(a,b) (((a)>(b))?(b):(a))
#define max(a,b) (((a)>(b))?(a):(b))
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
	int n;
	cin>>n;
	int a[100000]={};
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		a[t]++;
	}
	int res=a[0]+a[1]+a[2];
	int s=a[0]+a[1]+a[2];
	for(int i=0;i<99997;i++){
		s=s-a[i]+a[i+3];
		res=max(res,s);
	}
	cout<<res;
	return 0;
}

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

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

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

const int MAX = 1e5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> P(N);
    rep(i, N) {
        cin >> P[i];
    }

    vector<int> index(N);
    rep(i, N) {
        index[ P[i] - 1 ] = i;
    }

    ll ans = 0;
    set<int> s;
    for (int i = N - 1; i >= 0; --i) {
        int num = index[i];
        s.insert(num);

        // l[0] <= l[1]
        int l[2];
        l[0] = l[1] = -1;

        auto itr = s.lower_bound(num);
        if (itr != s.begin()) {
            itr--;
            l[1] = *itr;
        }
        if (itr != s.begin()) {
            itr--;
            l[0] = *itr;
        }

        // r[0] <= r[1]
        int r[2];
        r[0] = r[1] = N;

        itr = s.upper_bound(num);
        if (itr != s.end()) {
            r[0] = *itr;
            itr++;
        }
        if (itr != s.end()) {
            r[1] = *itr;
        }

        ll res = (ll)(l[1] - l[0]) * (r[0] - num) + (ll)(num - l[1]) * (r[1] - r[0]);
        res *= i + 1;
        ans += res;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
_  = gets.to_s.split.map(&:to_i)
a  = gets.to_s.split.map(&:to_i).sort
bcs = $<.read.split.map(&:to_i).each_slice(2).sort{|a,b|a[1] <=>b[1]}

ans = 0

b, c = bcs.pop
a.each do |k|
  
  if b && k < c
    ans += c
    b -= 1
    b,c = bcs.pop if b == 0
  else
    ans += k
  end
end

puts ans

Measured memory_bytes: 28896
#include <iostream>
#include <string.h>

using namespace std;

int main () {
  int N;
  cin >> N;
  int p[9];
  p[0] = 111;
  p[1] = 222;
  p[2] = 333;
  p[3] = 444;
  p[4] = 555;
  p[5] = 666;
  p[6] = 777;
  p[7] = 888;
  p[8] = 999;
  for (int i = 0; i < 9; i++) {
    if (N <= p[i]) {
      cout << p[i] << endl;
      break;  
    }  
  }
  
   
}

Measured memory_bytes: 256
// 5/10 リアルタイム参加
#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>;
using Graph = vector<vector<int>>;

int main() {
    string S, T;
    cin >> S >> T;

    if (S.size() + 1 == T.size()) {
        bool ans = true;

        for (int i; i < S.size(); i++) {
            if (S[i] != T[i]) {
                ans = false;
            }
        }

        if (ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        cout << "No" << endl;
    }    
}

Measured memory_bytes: 3620
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 X = sc.nextInt();
		int Y = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[M];
		int z1 = X;
		int z2 = Y;
		for(int i=0; i<N; i++) {
			x[i] = sc.nextInt();
			z1 = Math.max(z1, x[i]);
		}
		for(int i=0; i<M; i++) {
			y[i] = sc.nextInt();
			z2 = Math.min(z2, y[i]);
		}
		sc.close();
		System.out.println(z1 < z2 ? "No War":"War");
	}

}

Measured memory_bytes: 36004
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 998244353LL
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long powering(long long now,long long now_go){
	long long ans = 1;
	while (now_go != 0) {
		if (now_go % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		now_go /= 2;
	}
	return ans;
}
vector<long long> calc(vector<long long> a, vector<long long> b) {
	long long k = sqrt(a.size());
	vector<long long> ans;
	for (int i = 0; i < k; ++i) {
		for (int q = 0; q < k; ++q) {
			//ans[i][q]を計算する
			long long geko = 0;
			for (int t = 0; t < k; ++t) {
				geko += a[i * k + t] * b[t * k + q];
				geko %= MAX_MOD;
 			}
			ans.push_back(geko);
		}
	}
	return ans;
}
vector<long long> powered(vector<long long> a, long long n) {
	vector<long long> ans = a;
	n--;
	while (n != 0) {
		if (n % 2 == 1) {
			ans = calc(ans, a);
		}
		a = calc(a, a);
		n /= 2;
	}
	return ans;
}
long long inv(long long now) {
	return powering(now, MAX_MOD - 2LL);
}
int main(){
#define int long long
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		map<int, int> gogo;
		int itr = 1;
		int calc[12] = {};
		int bad[12] = {};
		REP(i, n-1) {
			string a;
			cin >> a;
			long long neko = 1;
			for (int q = a.length()-1; q >= 0; --q) {
				if (gogo[a[q]] == 0) {
					gogo[a[q]] = itr;
					itr++;
				}
				if (q == 0&&a.length() != 1) {
					bad[gogo[a[q]]-1] = 1;
				}
				calc[gogo[a[q]] - 1] -= neko;
				neko *= 10;
			}
		}
		{
			string a;
			cin >> a;
			long long neko = 1;
			for (int q = a.length() - 1; q >= 0; --q) {
				if (gogo[a[q]] == 0) {
					gogo[a[q]] = itr;
					itr++;
				}
				if (q == 0&&a.length() != 1) {
					bad[gogo[a[q]] - 1] = 1;
				}
				calc[gogo[a[q]] - 1] += neko;
				neko *= 10;
			}
		}
		vector<pair<long long, long long>> input;
		REP(i, itr-1) {
			input.push_back(make_pair(calc[i], bad[i]));
		}
		sort(input.begin(), input.end());
		vector<long long> geko;
		REP(i, 10) {
			geko.push_back(i);
		}
		sort(geko.begin(), geko.end());
		set<long long> ans;
		do {
			long long now = 0;
			long long ga = 0;
			long long tmp = 1;
			for (int q = 0; q < input.size(); ++q) {
				now += geko[q] * input[q].first;
				ga += geko[q] * tmp;
				tmp *= 10LL;
				if (geko[q] == 0 && input[q].second == 1) {
					now = -1;
					break;
				}
			}
			if (now == 0) {
				ans.insert(ga);
			}
		} while (next_permutation(geko.begin(), geko.end()));
		cout << ans.size() << endl;
	}
}



Measured memory_bytes: 4768
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main()
{
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    for(int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        g.add_edge(u, v);
    }
    vector<vector<int>> ans = g.scc();
    cout << ans.size() << endl;
    for(auto v : ans)
    {
        cout << v.size() << " ";
        for(int i : v) cout << i << " ";
        cout << endl;
    }
}


Measured memory_bytes: 40596
S = input()
if S[0] == S[1] and S[2] == S[3] and S[1] != S[2]:
  print("Yes")
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
  print("Yes")
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
long long cnt;


void merge(int A[], int n, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = SENTINEL;

	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i] < R[j]) A[k] = L[i++];
		else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
}

void mergeSort(int A[], int n, int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main()
{
	static int A[MAX], n, i;
	cnt = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &A[i]);;

	mergeSort(A, n, 0, n);

	printf("%lld\n", cnt);

	return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    int dp[100000][3];

    int solve(int a[][3],int n,int i,int j){
        if(i==n) return 0;
        if(j!=-1 && dp[i][j]!=-1) return dp[i][j];
        int mx=-1;
        rep(k,0,3){
            if(k!=j)
                mx=max(mx,a[i][k]+solve(a,n,i+1,k));
        }
        return dp[i][j]=mx;
    }

    int main(){
                        
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif 
 
        fast;   
        int t=1;
        // cin>>t; 
        while(t--){
            int n;
            cin>>n;
            int a[n][3];
            memset(dp,-1,sizeof(dp));
            rep(i,0,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
            cout<<solve(a,n,0,-1)<<endl;
        } 
        return 0;   
    }       


    // First, solve the problem. Then, write the code. 


Measured memory_bytes: 10368
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 1000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int fac[maxn],inv[maxn];
int n;
inline ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
inline ll C(int n,int m){return m<0||m>n?0:(ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	n=read();
	fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=(ll)fac[i-1]*i%mod;
		inv[i]=power(fac[i],mod-2);
	}
	int ans=0,last=0;
	for(int i=1;i<n;i++){
		int now=C(i-1,n-i-1)*fac[n-i-1]%mod*fac[i]%mod;
//		printf("%d %d\n",i,now-last);
		ans=(ans+(ll)(now-last+mod)*i)%mod;
		last=now;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll n, x, y;
ll dx[N], dy[N];
vector<ll> G[N];
void dfsx(ll v , ll par = 0) {
	for (auto u : G[v])
		if (u != par)
			dx[u] = dx[v] + 1, dfsx(u , v);
}
void dfsy(ll v , ll par = 0) {
	for (auto u : G[v])
		if (u != par)
			dy[u] = dy[v] + 1, dfsy(u, v);
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n >> x >> y;
    for (int i = 0 ; i <n - 1; i ++) {
    	ll v, u;
    	cin >> v >> u;
    	G[v].pb(u);
    	G[u].pb(v);
	}
	dfsx(x);
	dfsy(y);
	ll ans = 0 ;
	for (int i = 1; i <= n ; i ++) {
		ll res = 0;
		if (dx[i] >= dy[i]) continue;
		res = dy[i] - 1;
		ans = max(ans, res);
	}
	cout << ans<< endl;
    
    return (0) ;
}


Measured memory_bytes: 14336
N = int(input())
X = []
U = []
for _ in range(N):
    x, u = input().split()
    X.append(float(x))
    U.append(u)

ans = 0
for x, u in zip(X, U):
    if u == 'JPY':
        ans += x
    else:
        ans += x*380000.
print(ans)


Measured memory_bytes: 9160
N = int(input())
dif = []
a = list(map(int,input().split()))
bef = a[0]
for i,j in enumerate(a):
    if i==0:
        bef = j
        sum = 1
    elif j==bef:
        sum += 1
    else:
        dif.append(sum)
        sum = 1
        bef = j
dif.append(sum)

res = 0
for i in dif:
    res += i//2
print(res)


Measured memory_bytes: 3060
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
S = input().rstrip()
S = S[::-1]

words = ["dream","dreamer","erase","eraser"]
for i in range(4):
    words[i] = words[i][::-1]

i = 0
while i < len(S):
    for w in words:
        l = len(w)
        if w == S[i:i+l]:
            i += l
            break
    else:
        print("NO")
        sys.exit()

print("YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
int c[30],n;
vector<int> v[30];
char s[N];
bool pd[N];
int f[N];
inline int sum(int x){
	int ret = 0;
	while(x){
		ret += f[x];
		x -= x&-x;
	}
	return ret;
}
inline void add(int x,int d){
	while(x<N){
		f[x]+=d;
		x+= x&-x;
	}
}
int main(){
	scanf("%s",s+1);
	n = strlen(s+1);
	for(int i =1;i<=n;i++) c[s[i]-'a']++;
	int cnt = 0;
	for(int i=0;i<26;i++) if(c[i]&1) cnt++;
	if(cnt>1){
		puts("-1");
		return 0;
	}
	ll ans = 0;
	for(int i = 1;i<=n;i++) v[s[i]-'a'].push_back(i);
	int ban = -1;
	for(int i = 0;i<26;i++) if(c[i]&1){
		ban = v[i][v[i].size()/2];
	}
	//cout<<ban<<endl;
	if(ban!=-1){
		for(int i = ban;i<n;i++) s[i] = s[i+1];
		n--;
	}
	for(int i=0;i<26;i++) v[i].clear();
	for(int i = 1;i<=n;i++) v[s[i]-'a'].push_back(i);
	int delta = 0;
	//cout<<ban<<endl; cout<<s+1<<endl;
	for(int i =1;i<=n;i++){
		if(pd[i]){
			delta++;
			continue;
		}
		int t = v[s[i]-'a'].back();
	//	cout<<i<<' '<<t<<endl;
		v[s[i]-'a'].pop_back();
		int now = i-delta;
		int des = n-now+1;
		ans += des-(t-sum(t));
		if(ban!=-1 && !(i<ban && t>=ban)) ans++;
		add(t,1);
		pd[t] = true;
	//	cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2040
import sys

def makeprime():
  num = 2
  while num <= 55555:
    m = num - 1
    while m > 1 and num % m != 0:
      m -= 1
    if m == 1:
      yield num
      num += 1
    else:
      num += 1 


def main():
  input = sys.stdin.readline
  N = int(input())
  A = []
  for p in makeprime():
    if p % 5 == 1:
      A.append(str(p))
    if len(A) == N:
      break

  print(" ".join(A))


if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>

char buff;
ll ans = 0;

int main(){
    for(int i =0; i < 4; i++) {
        cin >> buff;
        if(buff == '+') ans++;
        else ans--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int L; cin >> L;
    int R; cin >> R;
    int d; cin >> d;
    int ans = 0;

    for(int i = L; i < R+1; i++){
        int tmp = i % d;
        if(tmp == 0){
            ans ++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, k, a[100008], b[100008];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> k;
	rep(i, 1, n){
		cin >> a[i] >> b[i];
	}
	
	ll ans = 0;
	if(k == 0){
		rep(i, 1, n){
			if(a[i] == 0){
				ans += b[i];
			}
		}
	}
	else{
		rep(bit, 0, 30){
			ll buf = 0;
			if(k >= (1 << bit)){
				ll kk = (bit == 0)? k : (k - (1 << bit)) | ((1 << bit)-1);
				rep(i, 1, n){
					if((kk | a[i]) == kk){
						buf += b[i];
					}
				}
				ans = max(buf, ans);
			}
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 1792
# ABC_129 C

def stairs(n, a):
    num_list = set(i for i in range(n+1) if i not in a)
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, n+1):
        if i in a:
            continue
        dp[i] = dp[i-1] + dp[i-2]
            
    result = dp[n] % 1000000007

    print(result)

    
n, m = list(map(int, input().split()))
a = set(int(input()) for _ in range(m))


if __name__ == '__main__':
    stairs(n, a)

Measured memory_bytes: 467304