akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

long long LIS(vector<long long> a) {
	long long n=(int)a.size();
	vector<long long> dp(n,1e18);
	for (long long i=0;i<n;i++){
		long long tmp =lower_bound(dp.begin(),dp.end(),a[i])-dp.begin();
		dp[tmp] =a[i];
	}
	long long k=0;
	while (k<n && dp[k]!= 1e18) k++;
	return k;
}

int main()
{
	ll n;
	cin >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	cout << LIS(a) << endl;
	return 0;
}


Measured memory_bytes: 5200
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = false;

// --------------------------------------------------------------------------------------

// DECLARATIONS
template <typename T> void read(size_t n, T* a);
template <typename T> void read2(size_t n, size_t m, T** a);


// IMPLEMENTATIONS
template <typename T> void read(size_t n, T* a) {
    for (size_t i = 0; i < n; ++i) { std::cin >> a[i]; }
}

template <typename T> void read2(size_t n, size_t m, T** a) {
    for (size_t i = 0; i < n; ++i) {
        a[i] = new int[m];
        for (size_t j = 0; j < m; ++j) { std::cin >> a[i][j]; }
    }
}


using namespace std;

int main(void)
{
    size_t n;
    cin >> n;
    n *= 3;
    vector<ull> a;
    for (size_t i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }

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

    vector<ull> b;
    for (size_t i = n/3; i < n; ++i) {
        b.push_back(a[i]);
    }

    ull total = 0UL;

    for (size_t i = 0; i < b.size(); ++i) {
        if (i%2 == 0) {
            total += b[i];
        }
    }

    cout << total << '\n';


    return 0;
}


Measured memory_bytes: 7660
#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>;
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; }

char a[11] = {'a','b','c','d','e','f','g','h','i','j','k'};

int n;

int func(int i, string t){
    if(i == n){
        cout << t << endl;
        return 1;
    }
    int res = 0, cnt = 0;
    set<char> s;
    rep(j,t.size()){
        if(s.find(t[j]) != s.end()) continue;
        cnt++;
        s.insert(t[j]);
        res += func(i+1, t+t[j]);
    }
    res += func(i+1, t+a[cnt]);
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int ans = func(1, "a");
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	sort(ALL(v));
	int l = v[0];
	int r = v[n-1];
	int ans = INF;
	for (int i = l; i <= r; i++) {
		int temp = 0;
		rep(j, n) {
			temp += pow((v[j] - i), 2);
		}
		ans = min(ans, temp);
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    const long INF = 1e15;
    vector<long> dp(N, INF);
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i - j < 0) continue;
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ll a[n+10]={0};
 ll xorr=0;
 rep(i,0,n){
  sc(a[i]);
  xorr^=a[i];
 }
 rep(i,0,n){
  ll b=xorr^a[i];
  cout<<b<<" ";
 }
 pnn;  
return 0;}

Measured memory_bytes: 5112
/*
created on 22/4/2020
*/
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
void solve(){
  int N;
  int K;
  cin>>N>>K;
  int a[N];
  for(int& i: a)
    cin>>i;
  bool dp[2][K+5];
  memset(dp, 0, sizeof dp);
  sort(a, a+N);
  for(int k=0;k<=K;k++){
    dp[0][k] = false;
    dp[1][k] = false;
    for(int x: a){
      if(x<=k){
        dp[0][k] |= (!dp[1][k-x]);
        dp[1][k] |= (!dp[0][k-x]);
      }
    }
  }
  if(dp[0][K] == true){
    cout<<"First"<<Endl;
  }else{
    cout<<"Second"<<Endl;
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll a[1 << 18], x[1 << 18]; LP m[1 << 18];
int main() {
	int n; cin >> n;
	rep(i, (1 << n)) {
		cin >> a[i]; m[i] = { a[i],-INF };
	}
	rep(i, n) {
		rep(j, (1 << n)) {
			if ((j&(1 << i))) {
				int t = j ^ (1 << i);
				ll chk[4];
				chk[0] = m[j].first; chk[1] = m[j].second;
				chk[2] = m[t].first; chk[3] = m[t].second;
				sort(chk, chk + 4, greater<ll>());
				m[j].first = chk[0]; m[j].second = chk[1];
			}
		}
	}
	x[0] = -INF;
	Rep(i, 1, (1 << n)) {
		x[i] = max(x[i - 1], m[i].first + m[i].second);
		cout << x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int a,b,c,k,x=0;
	cin >> a >> b >> c >> k;
	while(b <= a)
	{
		b *= 2;
		x++;
	}
	while(c <= b)
	{
		c *= 2;
		x++;
	}
	if(x <= k)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}






	
	return 0;
}

Measured memory_bytes: 3636
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	string s;cin>>s;
	if(s[2]==s[3] and s[4]==s[5]){
		cout<<"Yes";
	}
	else
		cout<<"No";
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int C = in.nextInt();
      int max = Math.max(A, Math.max(B, C));
      int sumOfNotMax = A + B + C - max;

      System.out.println(max * 10 + sumOfNotMax);
    }
  }
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




int main() {
	int h, w, d;
	cin >> h >> w >> d;
	VI v(90010,0);
	VI x(90010, 0), y(90010, 0);
	REP(i, h) {
		REP(j, w) {
			int a;
			cin >> a;
			x[a] = i, y[a] = j;
		}
	}
	REP(i, 90010) {
		if (i - d >= 0) {
			v[i] = abs(x[i] - x[i - d]) + abs(y[i] - y[i - d]) + v[i - d];
		}
	}
	int q;
	cin >> q;
	REP(i, q) {
		int l, r;
		cin >> l >> r;
		cout << v[r] - v[l] << endl;
	}
	return 0;

}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/*************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/*************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
   // file();
    int n;
    cin>>n;
    int ar[n],br[n];
    forn(i,n) cin>>ar[i],br[i] = ar[i];
    sort(br,br+n);
    int cnt = 0;
    forn(i,n){
        if(br[i]!=ar[i]) cnt++;
    }
    if(cnt==0||cnt==2){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }

  return 0;
}

Measured memory_bytes: 256
//AtCoder Beginner Contest 176
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e5 + 5;
const ll INF = 1e9 + 5;
const ll mxN = 1000000007;
const double E = 1e-9;

//------------------------------------------------------------------------------
string n;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	cin >> n;
	ll sum = 0;
	for (auto it : n)
		sum += (it - '0');
	cout << (sum % 9 ? "No" : "Yes") << "\n";
	return 0;
}
//22-08-2020 17:33:33
//------------------------------------------------------------------------------

Measured memory_bytes: 3704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC141C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NKQ = Console.ReadLine().Split(' ');
            int N = int.Parse(NKQ[0]);
            int K = int.Parse(NKQ[1]);
            int Q = int.Parse(NKQ[2]);
            int[] A = new int[Q];
            int[] point = new int[N];
            for (int i = 0; i < Q; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
                point[A[i] - 1] += 1;
            }
            for (int i = 0; i < N; i++)
            {
                if (point[i] + K - Q > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 31436
# 計算量を下げる 整数問題
n, y = gets.split.map(&:to_i)
res = Array.new(3, -1)
catch(:find) do
    0.upto(n) do |a|
        0.upto(n) do |b|
            c = n-a-b
            if c>=0 && a*10000+b*5000+c*1000 == y then
                res[0] = a
                res[1] = b
                res[2] = c
                throw :find
            end
        end
    end
end
puts res.join(' ')

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


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

	int N;
	cin>>N;
	vector<int> arr(N);
	for (int i = 0; i < N; ++i)
	{
		cin>>arr[i];
	}
	unordered_map<int,int> freq;
	for(int i = 0; i < N; i++){
		freq[arr[i]]++;
	}
	int elementsToRemove = 0;
	for(auto i = freq.begin(); i != freq.end(); i++){
		if(i->second < i->first){
			elementsToRemove += i->second;
		}
		else{
			elementsToRemove += i->second - i->first;
		}
	}
	cout<<elementsToRemove<<endl;
}


Measured memory_bytes: 7716
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;
void solve(int* array) {
	int sum = 0;
	rep(i, 1, 10) {
		sum += array[i];
	}
	cout << array[0] - sum << endl;
}
int main() {

	int i, j, k;
	int a[10];
	rep(i, 0, 10) {
		cin >> a[i];
	}
	while (a[0] != 0) {
		solve(a);
		rep(i, 0, 10)
			cin >> a[i];
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  string s;cin>>s;
  int n = s.size();
  int ans;
  repi(i,(n-1)/2) {
    bool valid = true;
    rep(j,i) if (s[j]!=s[j+i]) valid = false;
    if (valid) ans = i * 2;

  }
  cout << ans << endl;
}


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

vector<int> a;

int dp(int b) {
	if (!b) return 0;
	if (a[b] != -1) return a[b];
	vector<int> c;
	c.push_back(dp(b - 1));
	for (int i = 6; i <= b; i *= 6) c.push_back(dp(b - i));
	for (int i = 9; i <= b; i *= 9) c.push_back(dp(b - i));
	a[b] = *min_element(c.begin(), c.end()) + 1;
	return a[b];
}

int main() {
	int N;
	cin >> N;
	a.resize(N + 1, -1);
	cout << dp(N);
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
 
  int main(){
     lint N,K;
     cin>>N>>K;
     double ans=0;
     lint p[N];
     double accum=0;
     rep(i,N)cin>>p[i];
        lint A[1005];
        A[1]=1;
        repp(i,2,1005){
            A[i]=A[i-1];
            A[i]+=i;
        }
        rep(i,K){
            accum+=((double)A[p[i]]/p[i]);
        }
        ans=accum;
        rep(i,N-K){
            accum-=((double)A[p[i]]/p[i]);
            accum+=((double)A[p[i+K]]/p[i+K]);
            ans=max(ans,accum);
        }
        
        printf("%.9f",ans);
            
  }
  

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
	long long n, azul, ver, ciclo=0, resposta=0, sobra=0;
	scanf("%lld %lld %lld", &n, &azul, &ver);
	ciclo= n/(azul+ver);
	resposta= ciclo*azul;
	sobra= n%(azul+ver);
	if(sobra <= azul)
		resposta+= sobra;
	else
		resposta +=azul;
	printf("%lld\n",resposta);

	return 0;
}

Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var min = int.MaxValue;
        var max = int.MinValue;

        for (int i = 0; i < n; i++)
        {
            min = Math.Min(min, a[i]);
            max = Math.Max(max, a[i]);
        }

        var ans = int.MaxValue;
        for (int i = min; i <= max; i++)
        {
            var sum = 0;
            for (int j = 0; j < n; j++)
            {
                var x = i - a[j];
                sum += x * x;
            }
            ans = Math.Min(ans, sum);
        }

        Console.WriteLine(ans);
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
typedef long long lint;
typedef vector<int> vi;

const int mod = 1e9 + 7;

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

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

// ?????????????????????????????????????????????
lint extgcd(lint a, lint b, lint& x, lint& y) {
	lint d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}

bool is_prime(lint n) {
	for (lint i = 2; i * i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return true;
}

// n????´???° ???????????????unsorted
/*
vi divisor(lint n) {
	vi res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.pb(i);
			if (n / i != i) res.pb(n / i);
		}
	}

	return res;
}*/
vector<lint> divisor(lint n) {
	vector<lint> res;
	deque<lint> d;

	lint i = sqrt(n);
	if (i * i == n) {
		d.push_back(i);
		i--;
	}
	for (; i > 0; --i) {
		if (n % i == 0){
			d.push_front(i);
			d.push_back(n / i);
		}
	}

	res.insert(res.begin(), d.begin(), d.end());
	return res;
}


// 2 * 2 * 3 * 5 * 5 * 5 = {2:2, 3:1,5:3} ???????????? map ????????£????????????
map<int, int> prime_factor(lint n) {
	map<int, int> res;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}

	if (n != 1) res[n] = 1;
	return res;
}

const int MAX_N = 2020202;
vi prime;
bool memo[MAX_N + 1];

// ?´???°?????¨?????? n??\???????´???°????????°?????????
int sieve(int n) {
	prime.clear();
	memset(memo, true, sizeof(memo));
	memo[0] = memo[1] = false;

	for (int i = 2; i <= n; ++i) {
		if (memo[i]) {
			prime.pb(i);
			for (int j = i; j <= n; j += i) {
				memo[j] = false;
			}
		}
	}

	return prime.size();
}

const lint MAX_LEN = 1000000;
const lint MAX_SQRT_B = 1000000;
bool memo_all[MAX_LEN];         //i means i + a
bool memo_small[MAX_SQRT_B];

// [a, b)????´???°????????°???????????????
lint count_prime(lint a, lint b) {
	for (int i = 0; (lint)i * i < b; i++) memo_small[i] = true;
	for (int i = 0; i < b - a; i++)     memo_all[i] = true;

	for (int i = 2; (lint)i * i < b; i++) {
		if (memo_small[i]) {
			for (int j = 2; (lint)j * j < b; j += i) memo_small[j] = false;
			for (lint j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) memo_all[j - a] = false;
		}
	}

	lint ret = 0;
	for (lint i = a; i < b; i++) {
		if (memo_all[i]) ret++;
	}
	return ret;
}

// k???????????§????????£??????????????°??????{a_0 : 0, a_1 : 1, a_2 : 1, ... }
lint Fib[101010];
int calcFib(int k) {
	Fib[0] = 0;
	Fib[1] = Fib[2] = 1;
	for (int i = 3; i <= k; ++i) {
		Fib[i] = Fib[i - 1] + Fib[i - 2];
		// Fib[i] %= mod;
	}

	return Fib[k];
}


int main() {
	lint n;
	
	while (cin >> n) {
		cout << sieve(n) << endl;
	}
}

Measured memory_bytes: 5408
#include<bits/stdc++.h>
using namespace std;
bool isprime( int k ) {
    if( k <= 1 ) return false;
    if( k == 2 ) return true;
    for( int i = 2 ; i < sqrt(k)+1 ; ++i )
        if( k % i == 0 ) return false;
    return true;
}
int main() {
	int x;
	scanf("%d", &x );
	for( int i = x ; 1 ; ++i ) {
	    if( isprime(i) ) {
	        printf("%d\n", i );
	        return 0;
	    }
	}
	return 0;
}


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

int main() {
string s ;
cin >> s;
  if(s=="Sunny"){
cout << "Cloudy" <<endl;
  }
  else if(s=="Cloudy"){
cout << "Rainy" <<endl;
  }
else{
  cout << "Sunny" << endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP std::make_pair
#define FI first
#define SE second
#define M 1000005
#define INF 1000000000
int t,n,faA[M],faB[M];
std::vector <int> EdgeA[M],EdgeB[M],tmp[M],G[M];
bool flag[M];
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(int x){
	if (x<0) putchar('-'),x=-x;
	if (x<10) putchar(x+'0');
	else Write(x/10),putchar(x%10+'0');
	return;
}
int min(int x,int y){return x<y?x:y;}
int max(int x,int y){return x>y?x:y;}
void DFS_A(int x,int f){
	faA[x]=f;
	for (auto i:tmp[x])
		if (i!=f) DFS_A(i,x);
	return;
}
void DFS_B(int x,int f){
	faB[x]=f;
	for (auto i:EdgeB[x])
		if (i!=f) DFS_B(i,x);
	return;
}
bool topo_sort(){
	std::queue <int> Q;
	int cnt=0;static int deg[M];
	for (int i=1;i<=n;i++) deg[i]=0,cnt+=flag[i];
	for (int i=1;i<=n;i++)
		for (auto j:G[i]) deg[j]++;
	for (int i=1;i<=n;i++)
		if (flag[i]&&!deg[i]) Q.push(i),--cnt;
	while (!Q.empty()){
		int now=Q.front();Q.pop();
		for (auto j:G[now])
			if (!--deg[j]) Q.push(j),--cnt;
	}
	return !cnt;
}
int check(int x,int y){
	if (EdgeA[x][0]==y) return INF;
	int ans=0;
	for (int i=1;i<=n;i++)
		for (auto j:EdgeA[i])
			if (!(i==x&&j==EdgeA[x][0])&&!(i==EdgeA[x][0]&&j==x)) tmp[i].PB(j),tmp[j].PB(i);
	tmp[x].PB(y),tmp[y].PB(x),DFS_A(x,0),DFS_B(x,0);
	for (int i=1;i<=n;i++) ans+=(flag[i]=(faA[i]!=faB[i]));
	for (int i=1;i<=n;i++)
		if (faA[i]&&flag[faA[i]]&&!flag[i]) return INF;
	for (int i=1;i<=n;i++)
		if (faA[i]&&flag[i]&&flag[faA[i]]) G[i].PB(faA[i]);
	for (int i=1;i<=n;i++)
		if (faB[i]&&flag[i]&&flag[faB[i]]) G[faB[i]].PB(i);
	return topo_sort()?ans:INF;
}
int main(){
	t=read();
	while (t--){
		n=read();int ans=INF;bool flag=1;
		for (int i=1,u,v;i<n;i++) u=read(),v=read(),EdgeA[u].PB(v),EdgeA[v].PB(u);
		for (int i=1,u,v;i<n;i++) u=read(),v=read(),EdgeB[u].PB(v),EdgeB[v].PB(u);
		for (int i=1;i<=n;i++){
			std::sort(EdgeA[i].begin(),EdgeA[i].end());
			std::sort(EdgeB[i].begin(),EdgeB[i].end());
			flag&=(EdgeA[i]==EdgeB[i]);
		}
		if (flag) printf("0\n");
		else {
			for (int i=1;i<=n;i++)
				for (int j=1;j<=n;j++)
					if (EdgeA[i].size()==1){
						ans=min(ans,check(i,j)+1);
						for (int i=1;i<=n;i++) G[i].clear(),tmp[i].clear();
					}
			Write(ans==INF?-1:ans),putchar('\n');
		}
		for (int i=1;i<=n;i++) EdgeA[i].clear(),EdgeB[i].clear();
	}
	return 0;
}


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

int main(){
  int N,M,X,Y;cin>>N>>M>>X>>Y;
  vector<int> x(N),y(M);
  for(int i=0;i<N;i++) cin>>x.at(i);
  for(int i=0;i<M;i++) cin>>y.at(i);
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  int maxx=x.at(N-1);
  int miny=y.at(0);
  bool conflict=true;
  for(int i=X+1;i<=Y;i++){
    if(maxx<i && i<=miny) conflict=false;
  }
  cout<<(conflict?"War":"No War")<<endl;
  
}
  


Measured memory_bytes: 3616
import sys
from math import gcd
from functools import reduce
input = sys.stdin.buffer.readline

class FLT:
    def __init__(self, mod=10**9+7):
        self.mod = mod

    def rep_sqr(self, base, k):
        ans = 1
        while k > 0:
            if k & 1:
                ans = ans * base % self.mod
            base = base * base % self.mod
            k >>= 1
        return ans

    def inv(self, a):
        """ 逆元を取る """
        return self.rep_sqr(a, self.mod-2)


def gcd_list(numbers):
    return reduce(gcd, numbers)

def euler_phi(n):
    phi = n
    for i in set(prime_factorize(n)):
        phi *= (1 - (1 / i))
    return int(phi)

def prime_factorize(n):
    # Return list of prime factorized result
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n, k = map(int, input().split())
MOD = 10**9 + 7
flt = FLT(MOD)
memo = [-1 for _ in range(k+1)]
ans = 0
for i in range(1, k+1):
    d = k // i
    if memo[d] == -1:
        memo[d] = flt.rep_sqr(d, n)
    ans += memo[d] * euler_phi(i)
print(ans % MOD)

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

int main(void){
  int n,mw;
  cin>>n>>mw;
  int w[100],v[100];
  int dp[100][10000];
  for(int i = 0 ; i < n ; i ++)
    cin>>v[i]>>w[i]; // v,w
  for(int j = w[0] ; j < mw + 1 ; j ++)
    dp[0][j] = v[0];
  for(int i = 1 ; i < n ; i ++){
    for(int j = 0 ; j < w[i] ; j ++)
      dp[i][j] = dp[i-1][j];
    for(int j = w[i] ; j < mw + 1 ; j ++)
      dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i]] + v[i]);    
  }
  int res = -1;
  for(int i = 0 ; i < mw+1 ; i ++)
    res = max(res,dp[n-1][i]);
  /*
  for(int i = 0 ; i < n  ; i ++){
    for(int j = 0 ; j < mw + 1; j ++)
      cout<<dp[i][j]<<" ";
    cout<<endl;
  }
  //*/
  cout<<res<<endl;
}

Measured memory_bytes: 5068
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

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

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

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

  rep (i, 200) {
    for (int j = -200; j <= 200; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4104
// ABC170.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

// A ///////////////////

//int main()
//{
//	int x[5] = { 0 };
//
//	for (int i = 1; i <= 5; i++) {
//		cin >> x[i - 1];
//	}
//
//	for (int i = 1; i <= 5; i++) {
//		if (x[i-1] == 0)
//			cout << i;
//	}
//
//	return 0;
//}


// B //////////////////

//int main()
//{
//	//変数の宣言
//	int X, Y; //X匹でY本
//	int cranes, turtles, legs;
//	//int judgeOK = 0;
//
//	//入力値の格納
//	cin >> X;
//	cin >> Y;
//
//	//鶴の数を0羽→X匹まで変化させ、合計足本数がYになる場合が存在するか判定する
//	for (cranes = 0; cranes <= X; cranes++) {
//		turtles = X - cranes;
//		legs = (cranes * 2) + (turtles * 4);
//		if (legs == Y) {
//			cout << "Yes";
//			return 0;
//		}
//	}
//
//	cout << "No";
//	return 0;
//}


// C //////////////////

int main()
{
	//変数の宣言と初期化
	int X, N, p[100] = { 0 }, q[102] = { 0 }, answer = 100000;

	//入力の格納
	cin >> X >> N;
	for (int i = 1; i <= N; i++) {
		cin >> p[i - 1];
	}

	//qの設定

	if (N == 0) {
		cout << X;
		return 0;
	}

	for (int i = 1; i <= 102; i++) {
		for (int j = 1; j <= N; j++) {
			if (p[j - 1] == i - 1) {
				q[i - 1] = 1000;
				break;
			}
			else {
				q[i - 1] = i - 1;
			}
		}
	}

	//出力の決定

	for (int i = 1; i <= 102; i++) {
		if ((q[i - 1] - X) * (q[i - 1] - X) < (answer - X) * (answer - X)) {
			answer = q[i - 1];
		}
	}

	//出力と終了

	cout << answer;

	return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

using pii = pair<i32, i32>;

#define LOOP_TYPE(s,n) decltype((n)-(s))
#define FOR(i,s,n)  for (auto i = LOOP_TYPE(s,n)(s);   i != LOOP_TYPE(s,n)(n);   i++)
#define FORR(i,s,n) for (auto i = LOOP_TYPE(s,n)(n)-1; i != LOOP_TYPE(s,n)(s)-1; i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) FORR(i,0,n)

void backtrace(const string &s, const string &t, const vector<vector<i32>>& dp, i32 i, i32 j, string &traced)
{
	if (i == 0 || j == 0) {
		return;
	}
	if (s[i - 1] == t[j - 1]) {
		traced += s[i - 1];
		backtrace(s, t, dp, i - 1, j - 1, traced);
	} else {
		if (dp[i - 1][j] > dp[i][j - 1]) {
			backtrace(s, t, dp, i - 1, j, traced);
		} else {
			backtrace(s, t, dp, i, j - 1, traced);
		}
	}
}

int main()
{
	string s, t;
	cin >> s >> t;

	// dp[i][j] =  文字列s_1～s_iと文字列t_1～t_jの最長共通部分列の長さ
	vector<vector<i32>> dp(s.length() + 1, vector<i32>(t.length() + 1, 0));

	REP(i, s.length()) {
		REP(j, t.length()) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			} else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}

	string traced;
	backtrace(s, t, dp, s.length(), t.length(), traced);
	reverse(traced.begin(), traced.end());

	cout << traced << endl;

	return 0;
}


Measured memory_bytes: 35584
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 0;
    rep(i,n-k) {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <ctime>
#include <cstdio>
#include <set>
using namespace std;

#define LL unsigned long long int
#define SZ 110

int g[SZ];

int mex(set<int> &grnd)
{
    int i=0;
    for(const int &x:grnd){
        if(x!=i)
            return i;
        i++;
    }
    return i;
}

int grundy(int n)
{
    if(g[n]!=-1) return g[n];
    if(n<2) return g[n]=0;

    set<int> grnd;

    for(int i=1; i<=n; i++)
        if(n%(n-i)==0)
            grnd.insert(grundy(n-i));

    return g[n]=mex(grnd);
}

int result(int n, int m)
{
    int jor=0;

    if(n&1) jor=grundy(m);

    return jor;
}

int towerBreakers(int n, int m)
{
    if(result(n, m)) return 1;
    return 2;
}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    LL n, a, k, i, sum=0, d;

    cin >> n;
    d=log2((double)n);
    if(d-(int)d<1e-9)
        d++;
    else d=(LL)ceil(d);
    d=((LL)pow(2, d))-1;
    cout << d << endl;

    return 0;
}
/**
2
2 2
1 4

*/


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  string T = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < 16; i++)
  {
    if (S[i] != T[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1010101010
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define mp make_pair

using namespace std;





int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

typedef pair<int, int> P;

ll graph[1010][1010];
ll B[2010], A[2010], C[2010];
ll dist[1010];
bool negative[1010];
int main() {
	fill(graph, INF);
	fill(dist, INF);
	m0(negative);
	dist[0] = 0;
	ll N, M; cin >> N >> M;
	REP(i, M) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--; c = c * (-1);
		graph[a][b] = c;
		A[i] = a; B[i] = b; C[i] = c;
	}
	REP(j, N) {
		REP(i, M) {
			dist[B[i]] = min(dist[B[i]], dist[A[i]] + C[i]);
		}
		if (dist[N] < -111100000000000) {
			cout << "inf" << endl;
			return 0;
		}
	}
	REP(j, N) {
		REP(i, M) {
			if (dist[B[i]] > dist[A[i]] + C[i]) {
				dist[B[i]] = min(dist[B[i]], dist[A[i]] + C[i]);
				negative[B[i]] = true;
			}
		}
		if (dist[N] < -111100000000000) {
			cout << "inf" << endl;
			return 0;
		}
	}
	if (negative[N - 1]) {
		cout << "inf" << endl;
	}
	else {
		cout << dist[N - 1] * (-1) << endl;
	}
}


Measured memory_bytes: 8320
import java.util.*;

/*
問題文
東西に N 個の山が連なっており、西の果てには広大な海が広がっています。
各山頂には旅館があり、あなたは海を眺められる旅館を選ぶことにしました。

西から i 番目の山の高さは Hi です。
西から 1 番目の山頂にある旅館からは必ず海を眺めることができます。

西から i (i=2,3,...,N) 番目の山頂にある旅館については、
H1≤Hi,H2≤Hi,..., かつ Hi−1≤Hi のとき、その旅館から海を眺めることができます。

これら N 個の旅館のうち、海を眺められる旅館はいくつあるでしょうか。

制約
入力は全て整数である。
1≤N≤20
1≤Hi≤100
*/

public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int mounts[] = new int[a];

        int max = 0;
        int count = 0;
        for (int i = 0; i < a; i++) {
          mounts[i] = s.nextInt();
          if (mounts[i] >= max) {
            max = mounts[i];
            count++;
          }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

  public static void main(String[] args) throws IOException {
	  Scanner in = new Scanner(System.in);
	  int a = in.nextInt();
	  int b = in.nextInt();
	  int h = in.nextInt();
	  int m = in.nextInt();
	  double hh = (double)h/12*360;
	  //System.out.println(hh);
	  double mm = (double)m/60*360;
	  //System.out.println(mm);
	  hh += (double)m/60*30;
	  //System.out.println(hh);
	  double angle = Math.abs(mm-hh);
	  if(angle > 180.0) {
		  angle = 360.0-angle;
	  }
	  //System.out.println(angle);
	  double ans;
	  if(angle == 0.0) {
		  ans = Math.abs(b-a);
	  }else if(angle == 180.0) {
		  ans = a+b;
	  }else {
		  //System.out.println(Math.cos(90.0));
		  ans = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(Math.toRadians(angle)));
	  }
	  System.out.println(ans);
  }
}

Measured memory_bytes: 36072
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int a[100000];
int c1[100001];
int c2[100001];
int main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i += 2) {
		c1[a[i]]++;
	}
	for (int i = 1; i < n; i += 2) {
		c2[a[i]]++;
	}
	P ma1 = { 0,0 }, ma2 = { 0,0 };
	P na1 = { 0,0 }, na2 = { 0, 0 };
	rep1(i, 100000) {
		if (ma1.first < c1[i]) {
			ma2 = ma1; ma1 = { c1[i],i };
		}
		else if (ma2.first < c1[i]) {
			ma2 = { c1[i],i };
		}
	}
	rep1(i, 100000) {
		if (na1.first < c2[i]) {
			na2 = na1; na1 = { c2[i],i };
		}
		else if (na2.first < c2[i]) {
			na2 = { c2[i],i };
		}
	}
	int rest = 0;
	if (ma1.second != na1.second) {
		rest = ma1.first + na1.first;
	}
	else {
		rest = max(ma2.first + na1.first, ma1.first + na2.first);
	}
	cout << n - rest << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h> 
using namespace std;  
int main () 
{ 
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;++i){
        for(int j: {i+1,i+2} ){
            dp[j]=min(dp[i]+abs(arr[j]-arr[i]),dp[j]);
        }
    }
    cout<<dp[n-1]<<" ";
   /* for(int i=0;i<n;i++)
    {
        cout<< arr[i];
        cout<<dp[i];
    }
    */
    return 0; 
} 

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

int main(){

  string s;
  while(cin >> s){
    
    int joi = 0, ioi = 0;
    
    for(int i=0;i<s.size()-2;i++){
      if(s[i+1] == 'O' && s[i+2] == 'I'){
	if(s[i] == 'J') joi++;
	if(s[i] == 'I') ioi++;
      }
    }
    
    cout << joi << endl << ioi << endl;
  }

}

Measured memory_bytes: 1196
n, t = map(int, input().split())
A = tuple(map(int, input().split()))
count = 0
maxdiff = 0
mina = 10**9+1
for a in A:
    mina = min(mina, a)
    diff = a - mina
    if diff > maxdiff:
        count = 1
        maxdiff = diff
    elif diff == maxdiff:
        count += 1
print(count)

Measured memory_bytes: 20716
import java.util.*;
import java.io.*;



public class Main{
    static int INFTY=Integer.MAX_VALUE;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            
        int n=sc.nextInt();
        int[] arr = new int[n];
        int ans=0;

        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        for(int i=0;i<n-2;i++){
            if((arr[i]<arr[i+1]&&arr[i+1]<arr[i+2])||(arr[i+2]<arr[i+1]&&arr[i+1]<arr[i])){
             ans++;   
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<ctime>
#include<functional>
#include<algorithm>
#define INF (1<<30)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-6
using namespace std;


void fuga(double prob[10],char a[10][10],double b[10],int n){

	double sum=0.0;
	int t;
	rep(i,n){
		prob[i]=0.0;
		rep(j,n){
			if(a[i][j]=='o')t=3;
			else if(a[i][j]=='-')t=1;
			else t=0;
			prob[i] += t*b[j];
		}
		sum += prob[i];
	}
	rep(i,n)prob[i]= prob[i]/sum;
}
void hoge(double a[10],int b[10],int n){
	int sum=0;
	rep(i,n)sum+=b[i];
	a[0] = (double)b[0]/sum;
	for(int i=1;i<n;i++){
		a[i] = (double)b[i]/sum + a[i-1];
	}
}
int main(){
	int n;
	char a[10][10];
	int sum[10];
	double p[10];//期待値

	double opponent[10];

	double prob[10];
	srand(time(NULL));

	cin>>n;
	memset(sum,0,sizeof(sum));
	rep(i,n){
		rep(j,n){
			cin>>a[i][j];
			if(a[i][j]=='o')sum[i]+=3;
			else if(a[i][j]=='-')sum[i]+=1;
		}
	}
	hoge(p,sum,n);
	memset(sum,0,sizeof(sum));
	memcpy(prob,p,sizeof(prob));
	int self,opp;
	double s,r;
	rep(i,1000){
		r = (double)rand()/(RAND_MAX);
		s=0.0;
		rep(i,n){
			s += prob[i];
			if(r<s){
				self = i;
				break;
			}
		}
		cout<<self+1<<endl;
		cin>>opp;
		opp--;
		sum[opp]++;
		hoge(opponent,sum,n);
		fuga(prob,a,opponent,n);
	}
	return 0;
}

Measured memory_bytes: 1328