akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,k,s=0;
	cin>>n>>k;
	vi a(n);
	REP(i,0,n-1)cin>>a[i];
	std::sort(a.begin(),a.end());
	for(int i=n-1;i>=n-k;i--)
		s+=a[i];
	cout<<s;
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll int 
#define int long long 
#define mp make_pair
using namespace std;
void solve()
{
    ll x;
    cin >> x;
    if(x>=30)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
 
}
signed main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
 
}

Measured memory_bytes: 3628
while true do
  a=gets.split
  break if a[1] == "?"
  case a[1]
    when "+"
      puts a[0].to_i + a[2].to_i
    when "-"
      puts a[0].to_i - a[2].to_i
    when "*"
      puts a[0].to_i * a[2].to_i
    when "/"
      puts a[0].to_i / a[2].to_i
  end
end

Measured memory_bytes: 6100
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = IR(5)
    k = II()
    if max(a) - min(a) > k:
        print(":(")
    else:
        print("Yay!")
    return

#B
def B():
    a = IR(5)
    b = a[0]
    ans = 0
    for a_ in a:
        if a_ % 10 != 0:
            if b % 10> a_ % 10:
                b = a_
    flg = 0
    for a_ in a:
        if a_ != b or flg:
            ans += math.ceil(a_ / 10) * 10
        else:
            ans += b
            flg = 1
    print(ans)
            
    
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 40688
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int res = 0;
  vector<int> Blist;
  for (int i = 0; i < N - 1; i++) {
    int B;
    cin >> B;
    Blist.push_back(B);
  }
  res += Blist[0];
  for (int i = 1; i < N-1; i++) {
    res += min(Blist[i], Blist[i-1]);
  }
  res += Blist[N-2];
  cout << res << endl;
}

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

vector<pair<int, int> > v;

bool comp(const pair<int, int> &a, const pair<int, int> &b){
  if(a.second==b.second)return a.first<b.first;
  return a.second>b.second;
}

int main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    int a, b;
    cin>>a>>b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end(), comp);
  cout<<v[0].first<<' '<<v[0].second<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;
vector<vector<vector<long long>>>dp; // dp(i,j) probablity of coming j heads when i coins
vector<int>v;

long long winner(int l,int r,int player){
    if(l>r){
        return 0;
    }
    if(dp[l][r][player]!=-1){
        return dp[l][r][player];
    }
    long long x;
    if(player==0){
         x = max(v[l]+winner(l+1,r,1-player),v[r]+winner(l,r-1,1-player));
    }else{
        x = min(winner(l+1,r,1-player)-v[l],winner(l,r-1,1-player)-v[r]);
    }
    return dp[l][r][player]=x;
}

void solve(){
    int n;cin>>n;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    dp.resize(n,vector<vector<long long> >(n,vector<long long>(2,-1)));
    int l=0,r=n-1;
    long long x = winner(l,r,0);
    cout<<x<<"\n";
}

int main(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 493952
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename E>
struct SkewHeap{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  typedef function<bool(T,T)> C;
  F f;
  G g;
  C c;
  E e;
  SkewHeap(F f,G g,C c,E e):f(f),g(g),c(c),e(e){}

  struct Node{
    Node *l,*r;
    T val;
    E add;
    Node(T val,E add):val(val),add(add){l=r=NULL;}
  };

  void eval(Node *a){
    if(a->add==e) return;
    if(a->l) a->l->add=g(a->l->add,a->add);
    if(a->r) a->r->add=g(a->r->add,a->add);
    a->val=f(a->val,a->add);
    a->add=e;
  }
  
  T top(Node *a){
    return f(a->val,a->add);
  }
  
  Node* push(T v){
    return new Node(v,e);
  }
  
  Node* meld(Node *a,Node *b){
    if(!a) return b;
    if(!b) return a;
    if(c(top(a),top(b))) swap(a,b);
    eval(a);
    a->r=meld(a->r,b);
    swap(a->l,a->r);
    return a;
  }
  
  Node* pop(Node* a){
    eval(a);
    auto res=meld(a->l,a->r);
    //free(a);
    return res;
  }
  
};
//END CUT HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  using Heap=SkewHeap<int, int>;
  Heap::F f=[](int a,int b){return a+b;};
  Heap::G g=[](int a,int b){return a+b;};
  Heap::C c=[](int a,int b){return a<b;};

  Heap heap(f,g,c,0);
  auto base=heap.push(0);
  
  string s;
  while(cin>>s,s!="end"){
    int x;
    if(s=="insert"){
      cin>>x;
      auto v=heap.push(x);
      base=heap.meld(base,v);
    }
    if(s=="extract"){
      x=heap.top(base);
      base=heap.pop(base);
      cout<<x<<endl;
    }
  }
  return 0;
}
/*
  verified on 2018/01/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_C&lang=jp
*/



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


using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int ans = INF;
	for (int i = 0; i < n; i++) {
		int c, buft; cin >> c >> buft;

		if (buft <= t) {
			ans = min(ans, c);
		}
	}

	if (ans != INF) {
		cout << ans << endl;

	}
	else {
		cout << "TLE" << endl;
	}
	
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	string s;
	cin >> s;

	deque<char> ds(sz(s));
	rep(i, sz(s)) {
		ds[i] = s[i];
	}

	int q;
	cin >> q;

	int rev = 0;
	rep(i, q) {
		int type;
		cin >> type;
		if (type == 2) {
			int f;
			char c;
			cin >> f >> c;
			f--;
			if (rev) {
				f = 1 - f;
			}
			if (f == 0) {
				ds.push_front(c);
			}
			else {
				ds.push_back(c);
			}
		}
		else {
			rev = 1 - rev;
		}
	}

	if (rev) {
		reverse(ds.begin(), ds.end());
	}

	for (auto c : ds) {
		cout << c;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 976
#include<cstdio>
#include<cctype>
const int maxn=100010;
int n,m;
long long k;
int d[maxn],p[maxn];
long long r[maxn];
bool vs[maxn];
int st[maxn],tp;
long long In() {
	register char c;
	for(;c=getchar(),c!='-'&&!isdigit(c););
	register bool f=c=='-';
	register long long s=f?0:c-'0';
	for(;c=getchar(),isdigit(c);)s=s*10+c-'0';
	return f?-s:s;
}
int main() {
	n=In();
	for(register int i=1;i<=n;++i)d[i]=In();
	for(register int i=n;i;--i)d[i]-=d[i-1];
	m=In(),k=In();
	for(register int i=1;i<=n;++i)p[i]=i;
	for(register int i=1,x;i<=m;++i)x=In(),p[x+1]^=p[x],p[x]^=p[x+1],p[x+1]^=p[x];
	for(register int i=1;i<=n;++i)if(!vs[i]) {
		tp=0;
		for(register int x=i;!vs[x];x=p[x])vs[x]=1,st[++tp]=x;
		for(register int j=1;j<=tp;++j)r[st[j]]=d[st[(j+k-1)%tp+1]];
	}
	for(register int i=1;i<=n;++i)printf("%lld.0\n",r[i]+=r[i-1]);
	return 0;
}

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

int K, ret;
string ans;

void dfs(int rem, int pos, string str) {
	if (rem == 0) {
		if (ret == 1) ans = str;
		ret--;
		return;
	}
	if (ret <= 0) return;

	if (pos >= 1 && pos <= 9) {
		string S1 = str; S1 += ((pos - 1) + '0');
		dfs(rem - 1, pos - 1, S1);
	}
	if (pos >= 0 && pos <= 9) {
		string S1 = str; S1 += ((pos + 0) + '0');
		dfs(rem - 1, pos + 0, S1);
	}
	if (pos >= 0 && pos <= 8) {
		string S1 = str; S1 += ((pos + 1) + '0');
		dfs(rem - 1, pos + 1, S1);
	}
}

int main() {
	cin >> K; ret = K;
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 9; j++) {
			string S0 = ""; S0 += ('0' + j);
			dfs(i - 1, j, S0);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)

using namespace std;
typedef long long ll;
const ll mod=1000000007;
const int bufSize=5140;
ll fact[bufSize];

ll modPow(ll x,int p){
	ll ret=1;
	REP(i,30){
		if((p>>i)&1)
			ret=ret*x%mod;
		x=x*x%mod;
	}
	return ret;
}

ll modInv(ll x){
	return modPow(x,mod-2);
}

int n;

ll Solve(int m){
	ll ans=0;
	REP(i,n+1){
		int x=i,y=n-x;
		if(x+m>=y){
			ll t=modPow(2,y);
			ans=(ans+fact[x+y]*modInv(fact[x])%mod*modInv(fact[y])%mod*t)%mod;
			y=x+m+1;
			x=n-y;
			if(x>=0)
				ans=(ans+mod-fact[x+y]*modInv(fact[x])%mod*modInv(fact[y])%mod*t)%mod;
		}
	}
	return ans;
}

int main(){
	fact[0]=1;
	FOR(i,1,bufSize)
		fact[i]=fact[i-1]*i%mod;
	string s;
	cin>>n>>s;
	cout<<(Solve(s.size())-Solve(s.size()-1)+mod)*modInv(modPow(2,s.size()))%mod<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const long double pi = 3.14159265358979323846;



void solve() {
  ll n; cin >> n;

  ll a[n]; f0r(i, n) cin >> a[i];

  ll x = 0;
  f0r(i, n) x ^= a[i];
  f0r(i, n) cout << (x ^ a[i]) << " ";
  cout << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 5112
import java.util.Scanner;

class Main {

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

        for (int i = 0; i < 10; i++) {
            int t = scan.nextInt();
            a += t;

        }
        System.out.println(a);
    }
}



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

int main(){
	string s;
	cin >> s;
	
	bool res = false;
	rep(i, 3) if(s.at(i) == '7') res = true;

	if(res) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(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 fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E17
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int h, w, in;
	cin >> h >> w;
	vi a, b, c, d;
	vvi vv(h, vi(w));
	rep(i, h) {
		rep(j, w) {
			cin >> in;
			vv[i][j] = in;
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (i != h - 1 || j != w - 1) {
				if (vv[i][j] % 2==1) {
					a.push_back(i + 1);
					b.push_back(j + 1);
					if (j == w - 1) {
						vv[i + 1][j]++;
						c.push_back(i + 2);
						d.push_back(j + 1);
					}
					else {
						vv[i][j + 1]++;
						c.push_back(i + 1);
						d.push_back(j + 2);
					}
				}
			}
			/*rep(o,h) {
				rep(p,w) {
					cout << vv[o][p];
				}
				cout << endl;
			}
			cout << endl;
			*/
		}
	}
	cout << a.size()<< endl;
	rep(i, a.size()) {
		cout << a[i] << " " << b[i] << " " << c[i] << " " << d[i] << endl;
	}
}


Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
const ll INF = 1LL<<60;

int main(){
const  ll NUM=41;
  
  ll N,K;
  cin>>N>>K;
ll A[N];
  vector<ll> counter(NUM,0);

  rep(i,N){
     cin>>A[i];
	  bitset<NUM> a(A[i]);  
    rep(j,NUM){
      counter[j]+=a[j];
    }
  }
ll maxbitnum=0;
  bitset<NUM> k(K);
  rep(i,NUM){
    if(k[NUM-1-i]!=0||counter[NUM-1-i]!=0){
      maxbitnum=NUM-1-i;
      break;
    }
  }

  ll ansR=0;
  ll ans=0;
  //ansRの初期化としてX=kを選んだ時
  rep(i,maxbitnum+1){
    ans=ans*2;
    if(k[maxbitnum-i]==0){ans+=counter[maxbitnum-i];}//k=0の時,norで足すのは1の数
    if(k[maxbitnum-i]==1){ans+=N-counter[maxbitnum-i];}//k=1の時,norで足すのは0の数
  }
  //cout<<ans<<endl;
  ansR=ans;
  
  //ansの計算
  rep(i,maxbitnum+1){//上からmaxbitnum-i番目が，k=1なら，x=0にして以下最適解
    ans=0;
    if(k[maxbitnum-i]==0){continue;}//k=0ならスルー
    //ansの計算(maxbitnum-iのみx=0で，それ以下は最適解，それ以上はkに従う
    rep(j,maxbitnum+1){
      ans=ans*2;
		if(maxbitnum-j>maxbitnum-i){//maxbitnum-iより上の桁（kに従う)
  		  if(k[maxbitnum-j]==0){ans+=counter[maxbitnum-j];}//x=0の時,norで足すのは1の数
   		  if(k[maxbitnum-j]==1){ans+=N-counter[maxbitnum-j];}//x=1の時,norで足すのは0の数
        }
		if(maxbitnum-j==maxbitnum-i){//maxbitnum-iの桁（x=0にする)
  		  ans+=counter[maxbitnum-j];//x=0の時,norで足すのは1の数
        }
		if(maxbitnum-j<maxbitnum-i){//maxbitnum-iより小さい桁(最適解)
          ans=ans+max(counter[maxbitnum-j],N-counter[maxbitnum-j]);
        }
    }
    //cout<<ansR<<endl;
    ansR=max(ansR,ans);
  }
  cout<<ansR<<endl;

}


Measured memory_bytes: 4420
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = LLINF;
	ll tmp, sol;
	int d, g; cin >> d >> g;
	int p[d] ={}, c[d] = {};
	REP(i, d) cin >> p[i] >> c[i];
	int comp[d+1] ={};
	REP(i, d){
		comp[i] = (i+1) * 100 * p[i] + c[i];
		//cout << comp[i] << endl;
	}
	REP(bi, 1 << d){
		tmp = 0;
		sol = 0;
		REP(i, d){
			if(bi & (1<<i)){
				tmp += comp[i];
				sol += p[i];
			}
		}
		//cout << bi << " " << sol << " " << tmp << " ";
		if(tmp < g){
			for(int i = d-1; i >= 0; i--){
				if(!(bi & (1<<i))){
					ll rest = (g - tmp + (i+1) * 100 - 1) / ((i+1) * 100);
					sol += rest;
					if(rest >= p[i]) sol = LLINF;
					//cout << i+1 << " " << rest << endl;
					break;
				}
			}
		}
		ans = min(ans, sol);
	}
	cout << ans << endl;
}

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

using namespace std;

int main (){

  int a,b;
  
  cin>>a>>b;
  
  if(max(a,b) == 2 ){
    cout<<"3"<<endl;
  }
  else if(min(a,b)==2){
    cout<<"1"<<endl;
  }
  else{
    cout<<"2"<<endl;
  }
}

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

using namespace std;

int main(void){
  vector<int> hands;
  int tmp;

  while(cin >> tmp){
	hands.push_back(tmp);
	cin.ignore();
	cin >> tmp;
	hands.push_back(tmp);
	cin.ignore();
	cin >> tmp;
	hands.push_back(tmp);
	cin.ignore();
	cin >> tmp;
	hands.push_back(tmp);
	cin.ignore();
	cin >> tmp;
	hands.push_back(tmp);

	sort(hands.begin(), hands.end());
	if(hands[0] == hands[3] || hands[1] == hands[4]){ //four card
	  cout << "four card" << endl;
	}else if((hands[0] == hands[1] && hands[2] == hands[4]) ||
			 (hands[0] == hands[2] && hands[3] == hands[4])){ //full house
	  cout << "full house" << endl;
	}else if((hands[0]+1 == hands[1] && hands[1]+1 == hands[2] && hands[2]+1 == hands[3] && hands[3]+1 == hands[4]) ||
			 (hands[0] == 1 && hands[1] == 10 && hands[2] == 11 && hands[3] == 12 && hands[4] == 13)){
	  cout << "straight" << endl;
	}else if(hands[0] == hands[2] || hands[1] == hands[3] || hands[2] == hands[4]){//three cards
	  cout << "three card" << endl;
	}else if((hands[0] == hands[1] && (hands[2] == hands[3] || hands[3] == hands[4])) || (hands[1] == hands[2] && hands[3] == hands[4])){//two pairs
	  cout << "two pair" << endl;
	}else if(hands[0] == hands[1] || hands[1] == hands[2] || hands[2] == hands[3] || hands[3] == hands[4]){
	  cout << "one pair" << endl;
	}else{
	  cout << "null" << endl;
	}

	hands.clear();
  }


  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(ll, N);
    CIN(ll, K);

    ll ans;

    if ( K % 2 == 1 ) {
        ll k = N / K;
        ans = k * k * k;
    } else {
        ll odd, even, temp;
        temp = N / (K / 2);
        even = temp / 2;
        odd = temp - even;
        ans = even * even * even + odd * odd * odd;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

int a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	cin >> a >> b;
	priority_queue<lli> Q;
	for(int i=0; i<a; i++)
	{
		lli tmp; cin >> tmp;
		Q.push(tmp);
	}
	for(int i=0; i<b; i++)
	{
		lli tmp = Q.top(); Q.pop();
		tmp = tmp / 2;
		Q.push(tmp);
	}
	lli sum = 0;
	while(!Q.empty())
	{
		lli top = Q.top(); Q.pop();
		sum += top;
	}
	cout << sum;
}

Measured memory_bytes: 1400
n = int(input())
tb,xb,yb = 0,0,0
for _ in range(n):
    ta,xa,ya = list(map(int, input().split()))
    tdiff = abs(ta-tb)
    mdiff = abs(xa-xb) + abs(ya-yb)
    if tdiff < mdiff or (tdiff + mdiff) & 1:
        print('No')
        exit()
    
    tb,xb,yb = ta,xa,ya

print('Yes')


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

int N;
int arr[101];
int main() {
	cin.tie(NULL); cout.tie(NULL);
	ios::sync_with_stdio(false);

	cin >> N;
	int change = 0;
	for (int i = 0; i < N; ++i) {
		cin >> arr[i];
		change = max(change, arr[i]);
	}
	
	int res = 0;

	for (int i = 0; i < N; ++i) {
		if (i && arr[i] == arr[i - 1]) {
			res++; arr[i] = ++change;
		}
	}

	cout << res;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    a, b, c, k = map(int, readline().split())
    if (0 <= k) and (k <= a):
        print(k)
    elif (a < k) and (k <= a+b):
        print(a) 
    elif (a+b < k) and (k <= a+b+c):
        print(a-(k-(a+b)))
    else:
        print(a+c)
if __name__ == '__main__':
    main()


Measured memory_bytes: 61716
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

const int MAX_M = 100000;
int N, M;
int X[MAX_M];
int dist_x[MAX_M-1];

void _main() {
  cin >> N >> M;
  rep(i, 0, M) cin >> X[i];
  sort(X, X + M);

  rep(i, 0, M-1) dist_x[i] = X[i+1]-X[i];
  sort(dist_x, dist_x + M - 1);

  ll ans = 0;
  rep(i, 0, M-1-(N-1)) ans += dist_x[i];
  cout << ans << "\n";
}

Measured memory_bytes: 1024
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

V<ll> used;
VV<ll> edges;
V<ll> cnt;
ll N, M;
V<ll> starts;
V<ll> nxt_starts;

void set_used(ll now, ll cnt_k) {
    cnt_k %= 3;
    used[now] |= (1ll << cnt_k);
}

bool check(ll now, ll cnt_k) {
    cnt_k %= 3;
    return used[now] & (1ll << cnt_k);
}

void dfs(ll now, ll cnt_k) {
    set_used(now, cnt_k);
    if(cnt_k == 3) {
        nxt_starts.push_back(now);
        return;
    }
    for(ll nxt : edges[now]) {
        if(check(nxt, cnt_k + 1)) continue;
        dfs(nxt, cnt_k + 1);
    }
}

void start() {
    static ll cnt_call = 0;
    cnt_call++;
    for(ll n : starts) dfs(n, 0);
    starts = move(nxt_starts);
    for(ll n : starts) cnt[n] = cnt_call;
    nxt_starts.clear();
}

const ll inf = 5e15;

int main() {
    cin >> N >> M;
    used.resize(N);
    edges.resize(N);
    cnt = V<ll>(N, inf);
    for(ll i = 0; i < M; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        edges[u].push_back(v);
    }
    ll S, G;
    cin >> S >> G;
    S--; G--;
    used[S] = 1;
    starts.push_back(S);
    while(starts.size() && cnt[G] == inf) {
        DEBUG(starts);
        start();
    }
    ll ans = cnt[G];
    if(ans == inf) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 

#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int n;
    std::cin >> n;
    int a[n];
    rep(i,n){
        std::cin >> a[i];
    }
    int t=1;
    rep(i,n){
        t=a[t-1];
        if(t==2){std::cout << i+1 << std::endl;return 0;}
    }
    std::cout << -1 << std::endl;
}



Measured memory_bytes: 640
/* Volume1 */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      int h1 = 0,h2 = 0,h3 = 0;

      for(int i = 0; i < 10; i++){
        int height = Integer.parseInt(br.readLine());
        if(h1 < height){
          h3 = h2;
          h2 = h1;
          h1 = height;
        }else if(h2 < height){
          h3 = h2;
          h2 = height;
        }else if(h3 < height){
          h3 = height;
        }
      }

      sb.append(h1).append("\n");
      sb.append(h2).append("\n");
      sb.append(h3).append("\n");

      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24312
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
const int INF = 1000000000;
struct Dinic{
    struct Edge{
        int dst, cap, rev;
        Edge(){}
        Edge(int d, int c, int r) :
            dst(d), cap(c), rev(r) {}
    };
    typedef vector<Edge> Node;
    typedef vector<Node> Graph;

    Graph G;
    vector<int> level;
    vector<int> iter;

    void bfs(int s){
        level.assign(G.size(), -1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while(!que.empty()){
            int v = que.front(); que.pop();
            for(const auto& e : G[v]){
                if(e.cap > 0 && level[e.dst] < 0){
                    level[e.dst] = level[v] + 1;
                    que.push(e.dst);
                }
            }
        }
    }

    int dfs(int v, int t, int f){
        if(v == t) return f;
        for(int& i = iter[v]; i < G[v].size(); i++){
            Edge& e = G[v][i];
            if(e.cap > 0 && level[v] < level[e.dst]){
                int d = dfs(e.dst, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.dst][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    Dinic(int N) : G(N), level(N), iter(N) {}

    void add_edge(int src, int dst, int cap){
         // printf("+ %d -> %d : %d\n", src, dst, cap);
        G[src].push_back(Edge(dst, cap, G[dst].size()));
        G[dst].push_back(Edge(src, 0, G[src].size() - 1));
    }
    void erase_edge(int u, int v){
        assert(G[u].back().dst == v);
        assert(G[v].back().dst == u);
         // printf("- %d -> %d\n", u, v);
        G[u].erase(G[u].begin() + G[u].size() - 1);
        G[v].erase(G[v].begin() + G[v].size() - 1);
    }

    int max_flow(int src, int dst){
        Graph tmpG = G;
        int flow = 0;
        // printf("flow %d -> %d : ", src, dst);
        while(true){
            bfs(src);
            if(level[dst] < 0) break;
            iter.assign(G.size(), 0);
            while(true){
                int f = dfs(src, dst, INF);
                if(f <= 0) break;
                flow += f;
            }
        }
        // printf(" %d \n", flow);
        G = tmpG;
        return flow;
    }
};

int main(){
    int N, M;
    while(cin >> N >> M){
        Dinic solver(2 * N + 1);
        const int src = 0;
        const int dst = 2 * N;
        REP(i, N) solver.add_edge(2 * i, 2 * i + 1, (i == 0 ? 2 : 1));
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            solver.add_edge(2 * a + 1, dst, 1);
            solver.add_edge(2 * b + 1, dst, 1);
            int f = (solver.max_flow(src, dst));
            // cout << "f = " << f << endl;
            if(f == 2){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
            solver.erase_edge(2 * b + 1, dst);
            solver.erase_edge(2 * a + 1, dst);
            solver.add_edge(2 * a + 1, 2 * b, 1);
            solver.add_edge(2 * b + 1, 2 * a, 1);
        }
    }
    return 0;
}

Measured memory_bytes: 1664
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

//#define int ll

using namespace std;



signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	static int vec[100010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	
	//データの読み込み


	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);


//	scanf("%s",&s);
//	scanf_s("%s",&s,1000010);




/*	//scanf("%c",&dummy);
	scanf_s("%c",&dummy);
	for(i=0;i<n;i++){
//		scanf("%c",&s[i]);
		scanf_s("%c",&s[i]);
	}*/


/*	for(i=0;i<3;i++){
//		scanf("%s",&s);
		scanf_s("%s",&s[i],100010);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	printf("%d",n*(n-1)/2+m*(m-1)/2);


//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
use std::io;
fn read() -> Vec<f32> {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok().unwrap();
    input.trim().split(' ').map(|x| x.parse().ok().unwrap()).collect()
}
fn main() {
    let inputs = read();
    println!("{}", inputs[0] / inputs[1]);
}


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

/**
 * Created by Ayushi on 22 Mar 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String temp = br.readLine();
        st = new StringTokenizer(temp, " ");
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        br.close();

        int ans = (n*(n-1))/2;
        ans += (m*(m-1))/2;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21076
//https://vjudge.net/contest/365276#problem/C
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 0;

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    ll n; cin >> n;
    ll sum = 0;
    for(ll i = 1; i * i <n; i++){
        if(n % i == 0){
            ll m = n/i - 1;
            if(i < m){
                sum += m;
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main()
{
	int N,A,B,C,D[100],i,x=0;
	scanf("%d%d%d%d",&N,&A,&B,&C);
	for(i=0;i<N;++i)scanf("%d",D+i);
	std::sort(D,D+N);
	double r=C*1./A;
	for(i=0;i<N;)x+=D[N-1-i],r=std::max(r,(C+x)*1./(A+B*++i));
	printf("%d\n",(int)r);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

int main()
{
	fastio
	lld n,x,m;
	cin>>n>>x>>m;
	map<lld,lld> cnt;
	lld nxt = x;
	lld sum=0;
	cnt[x]++;
	sum+=x;
	lld idx=n;
	for(lld i=1;i<min(n,m);i++)
	{
		nxt = (nxt*nxt)%m;

		if(cnt.find(nxt)!=cnt.end())
		{	
			idx=i;
			break;
		}
		else
		{	
			sum+=nxt;
			cnt[nxt]++;
		}
	}

	cnt.clear();
	cnt[nxt]++;
	lld len=1;
	std::vector<lld> cycsum;
	cycsum.pb(nxt);
	lld lensum=nxt;
	for(lld i=idx;i<min(n,m+idx);i++)
	{
		nxt = (nxt*nxt)%m;

		if(cnt.find(nxt)!=cnt.end())
		{
			break;
		}

		else
		{
			len++;
			cycsum.pb(nxt);
			lensum+=nxt;
			cnt[nxt]++;
		}
	}
	lld cycles = (n-(idx))/len;
	sum = sum + ((cycles)*(lensum));

	for(lld i=0;i<(n-idx)-cycles*len;i++)
	{
		sum+=cycsum[i];
	}

	cout<<sum<<endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    cout<<fixed<<setprecision(8);
    int n; cin>>n;
    double ans = 2 * M_PI * n;
    cout<<ans;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3796
#include <stdio.h>

int main(void)
{
	char a, b, c, d;

	scanf("%c%c", &a, &b);
	if(b == '\n') {
		printf("No");
		return 0;
	}

	scanf("%c", &c);
	if(c == '\n') {
		printf("No");
		return 0;
	}

	scanf("%c", &d);
	if(d == '\n') {
		printf("No");
		return 0;
	}

	if( a == 'Y' &&
		b == 'A' &&
		c == 'K' &&
		d == 'I'
	) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))

//遅い方のダイクストラ（早い方の完全下位互換だが一応）
//頂点数、スタート（と隣接行列）を引いて最短距離と経路を返す
//O(V^2)
ll daikusutorap[1<<11];
ll cost[1<<10][1<<10];//辺が無いところはINFにする前処理が必要
void daikusutora(ll n,ll s){
	ll*f=(ll*)malloc(n*sizeof(ll));
	rep(i,0,n){
		daikusutorap[i]=i==s?0:INF;
		f[i]=0;
	}
	rep(nnnnnn,1,n){
		ll m=INF,mv=-1;
		rep(i,0,n){
			if(!f[i]&&m>daikusutorap[i]){
				m=daikusutorap[i];
				mv=i;
			}
		}
		if(mv==-1)break;
		f[mv]=1;
		rep(i,0,n)if(cost[mv][i]&&daikusutorap[i]>daikusutorap[mv]+cost[mv][i]){
			daikusutorap[i]=daikusutorap[mv]+cost[mv][i];
			daikusutorap[n+i]=mv;
		}
	}
	free(f);
}

int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)rep(j,0,n)cost[i][j]=INF;
	rep(i,0,n){
		int s,k;
		scanf("%d%d",&s,&k);
		while(k--){
			int j,c;
			scanf("%d%d",&j,&c);
			cost[i][j]=c;
		}
	}
	daikusutora(n,0);
	rep(i,0,n)printf("%d %d\n",i,daikusutorap[i]);
}


Measured memory_bytes: 2112
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&c^-1;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
ll x[yuzu|10];

int main(){
ll i,n=read(),a=read(),b=read();
for (i=1;i<=n;++i) x[i]=read();
ll ans=0;
for (i=2;i<=n;++i){
  int dis=x[i]-x[i-1];
  ans+=min(a*dis,b);
  }
write(ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define N 305
using namespace std;

struct st{
	int i, l, c;
} tq;

int n, m, l, Q, ans[N][N];
bool v[N];
vector<int> gr[N], ga[N];
priority_queue<st> pq;

bool operator < (st p, st q) {
	if (p.c != q.c) return p.c > q.c;
	return p.l < q.l;
}

void push(int p, int q, int r, int s) {
	if (v[p]) return;
	if (q < 0) q = l - s, r++;
	pq.push({p, q, r});
}

int main()
{
	int i, j, t1, t2, t3;
	cin >> n >> m >> l;
	while (m--) {
		scanf("%d %d %d", &t1, &t2, &t3);
		if (t3 <= l) {
			gr[t1].push_back(t2); ga[t1].push_back(t3);
			gr[t2].push_back(t1); ga[t2].push_back(t3);
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			ans[i][j] = -1;
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) v[j] = 0;
		pq.push({i, l, 0});
		while (!pq.empty()) {
			tq = pq.top(), pq.pop();
			if (v[tq.i]) continue;
			v[tq.i] = 1;
			ans[i][tq.i] = tq.c;
			for (j = 0; j < gr[tq.i].size(); j++) {
				push(gr[tq.i][j], tq.l - ga[tq.i][j], tq.c, ga[tq.i][j]);
			}
		}
	}
	cin >> Q;
	while (Q--) {
		scanf("%d %d", &t1, &t2);
		printf("%d\n", ans[t1][t2]);
	}
    return 0;
}

Measured memory_bytes: 2688
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

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

    if (n <= d * 2 + 1) {
        cout << 1 << endl;
    }
    else {
        cout << (n + d * 2) / (d * 2 + 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-23
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    char c[10];
    int t[5] = {};
    for (int i = 0; i < N; ++i) {
        cin >> c;
        if (c[0] == 'M') t[0]++;
        else if (c[0] == 'A') t[1]++;
        else if (c[0] == 'R') t[2]++;
        else if (c[0] == 'C') t[3]++;
        else if (c[0] == 'H') t[4]++;
    }

    ll ans = 0;
    for (int i = 0; i < 5; ++i) {
        for (int j = i; j < 5; ++j) {
            if (i == j) continue;
            ll tmp = 1;
            for (int k = 0; k < 5; ++k) {
                if (k == i | k == j) continue;
                else if (t[k] == 0) tmp = 0;
                tmp *= t[k];
            }
            ans += tmp;
        }
    }
    cout << ans << "\n";


    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	basicIO "io"
	"os"
	"strconv"
)

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	sum := 0
	min := 10
	for i := 0; i < 5; i++ {
		a, _ := io.nextInt()
		r := a % 10
		if r == 0 {
			sum += a
		} else {
			if r < min {
				min = r
			}
			sum += (a/10 + 1) * 10
		}
	}
	io.PutInt(sum - (10 - min))
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
  int a,b,c;
  int ans;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b)
    if (a>c)
       ans = b*c;
    else
       ans = b*a;
  else
    if(b>c)
       ans = a*c;
    else
       ans = a*b;

  printf("%d\n",ans/2);

  return 0;
}


Measured memory_bytes: 128