akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;



long long int N,M,K,A[200200],sum=0,res=0;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    for(long long int i = 0; i < N; i++){
        cin>>A[i];
        sum+=A[i];
    }
    sort(A,A+N,greater<long long int>() );
    if(A[M-1]*4*M<sum){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


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

string s;

int main(){
    cin>>s;
    bool okn = (count(s.begin(),s.end(),'N')!=0)?true:false;
    bool oks = (count(s.begin(),s.end(),'S')!=0)?true:false;
    bool okw = (count(s.begin(),s.end(),'W')!=0)?true:false;
    bool oke = (count(s.begin(),s.end(),'E')!=0)?true:false;
    
    cout<<((okn==oks)&&(okw==oke)?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
//om namah shivaay
//faith over fear
//no one wants to die,yet death is the destination we all share 

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    char ch;
    cin>>ch;
    if((ch>='A')&&(ch<='Z')) cout<<"A";
    else cout<<"a";
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
	int n,y,i,j;
	scanf("%d%d",&n,&y);
	y/=1000;
	for(i=n;i>=0;i--)
		for(j=n-i;j>=0;j--){
			int k=n-i-j;
			int sum=10*i + 5*j + k;
			if(sum==y) {
				printf("%d %d %d",i,j,k);
				return 0;
			}
		}
	printf("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    L = [chr(i) for i in range(97, 97 + 26)]

    res = ""
    while n:
        r = n % 26
        res += L[r - 1]
        n = max(0, (n - 1)) // 26
    print(res[::-1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9076
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

a=I()
b=I()
if a>b:
    print("GREATER")
elif a==b:
    print("EQUAL")
else:
    print("LESS")

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main(){
string tenki;
int x=0;
cin>>tenki;
if(tenki=="SSS")
cout<<0;
else if(tenki=="RSS"||tenki=="SRS"||tenki=="SSR"||tenki=="RSR")
  cout<<1;
else if(tenki=="RRS"||tenki=="SRR")
  cout<<2;
else
  cout<<3;
return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define eb emplace_back

typedef long long ll;
using namespace std;

ll ans = 0;
multiset<int> sr;//right
multiset<int,greater<int>> sl;//left

void add(int a,int b){
    ans += b;
    if(sr.empty()){
        sr.insert(a);
        sl.insert(a);
        return;
    }
    int r = *sr.begin();
    int l = *sl.begin();
    if(r < a){
        ans += a - r;
        sl.insert(r);
        sr.erase(sr.begin());
        sr.insert(a);
        sr.insert(a);
    }
    else if(a < l){
        ans += l - a;
        sr.insert(l);
        sl.erase(sl.begin());
        sl.insert(a);
        sl.insert(a);
    }
    else{
        sr.insert(a);
        sl.insert(a);
    }
}
void answer(){
   cout << *sl.begin() << " " << ans << '\n';
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int query;cin >> query;
    REP(_,query){
        int q;cin >> q;
        if(q == 1){
           int a,b;cin >> a >> b;
           add(a,b);
        }else{
            answer();
        }
    }
    return 0;
}


Measured memory_bytes: 19072
#include <stdio.h>

int main()
{
	int a, b; scanf ("%d %d", &a, &b);
	for (int k = 0; k <= 10000; k++){
		if (k * 8 / 100 == a && k / 10 == b){
			printf ("%d\n", k);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

vector<int>tree[1010];
ll x[1010], dp[1010][5010], mn[1010] = { 0 };

void dfs(int n) {
	ll t[5010], l, r;
	for (int i = 0;i <= x[n];i++)dp[n][i] = INF;
	dp[n][0] = 0;
	for (auto u : tree[n]) {
		dfs(u);
		l = mn[u];
		r = x[u];
		for (int j = 0;j <= x[n];j++) {
			t[j] = INF;
		}
		for (int j = 0;j <= x[n] - l;j++) {
			t[j + l] = min(t[j + l], dp[n][j] + r);
		}
		for (int j = 0;j <= x[n] - r;j++) {
			t[j + r] = min(t[j + r], dp[n][j] + l);
		}
		for (int j = 0;j <= x[n];j++) {
			dp[n][j] = t[j];
		}
	}
		ll mm = INF;
		for (int j = 0;j <= x[n];j++) {
			mm = min(mm, dp[n][j]);
		}
		if (mm == INF) {
			cout << "IMPOSSIBLE" << endl;
			exit(0);
		}
		mn[n] = mm;
}

int main() {
	int n;
	cin >> n;
	for (int i = 2;i <= n;i++) {
		int a;
		cin >> a;
		tree[a].pb(i);
	}
	for (int i = 1;i <= n;i++)cin >> x[i];
	dfs(1);
	cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 45568
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    val (H, W, M) = readIs()
    val hc = IntArray(H + 1)
    val wc = IntArray(W + 1)
    val map = mutableMapOf<Int, MutableList<Int>>()
    repeat(M) {
        val (h, w) = readIs()
        hc[h]++
        wc[w]++
        map.computeIfAbsent(h) {
            mutableListOf()
        } += w
    }

    val maxh = hc.max()!!
    val maxhh = mutableSetOf<Int>()
    hc.forEachIndexed { h, cnt ->
        if (cnt == maxh) maxhh += h
    }

    val maxw = wc.max()!!
    val maxww = mutableSetOf<Int>()
    wc.forEachIndexed { w, cnt ->
        if (cnt == maxw) maxww += w
    }

    val x = maxh + maxw
    var y = 0
    for ((h, ww) in map) {
        for (w in ww) {
            if (h in maxhh && w in maxww) y++
        }
    }
    println(if (y == maxhh.size * maxww.size) x - 1 else x)
}


Measured memory_bytes: 169072
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000007
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<long long,int> P;

int n, M;
int hp[100];
P x[2][100];
long long dp[2][100001];

void solve(){
	rep(i,n) cin >> hp[i];
	rep(i,2) for(int j = 0; j <= 100000; j++) dp[i][j] = INF;
	dp[0][0] = 0; dp[1][0] = 0;
	cin >> M;
	int m[2] = {0,0};
	rep(i,M){
		string na, tar;
		int mp, dam, u = 0;
		cin >> na >> mp >> tar >> dam;
		if(tar[0] == 'A') u = 1;
		x[u][m[u]] = P(mp,dam);
		m[u]++;
	}
	rep(u,2){
		rep(i,m[u]){
			P p = x[u][i];
			for(int j = 0; j <= 100000; j++){
				if(j < p.second) dp[u][j] = min(dp[u][j],p.first);
				else dp[u][j] = min(dp[u][j],dp[u][j-p.second]+p.first);
			}
		}
	}
	long long ans = INF;
	for(int i = 0; i <= 100000; i++){
		long long cnt = dp[1][i];
		rep(j,n){
			if(hp[j]-i <= 0) continue;
			int h = hp[j]-i;
			cnt += dp[0][h];
		}
		ans = min(ans,cnt);
	}
	cout << ans << endl;
}

int main(){
	while(true){
		cin >> n;
		if(n == 0) break;
		solve();
	}
}

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

int main() {
  // 入力を受け取る
  int r, g, b;
  cin >> r >> g >> b;

  // 計算
  int num = r * 100 + g * 10 + b;
  
  // 出力
  if ((num % 4) == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3544
#include<stdio.h>

void Cnt(int *,int);

int n,A[2000000],B[2000000],C[2000000];

int main()
{
  int i;

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

  Cnt(A,n);

  printf("%d",B[0]);
  for(i=1;i<n;i++){
    printf(" %d",B[i]);
  }
  printf("\n");

  return 0;
  
}

void Cnt(int *A,int k){
  int i;

  for(i=0;i<2000000;i++){
    C[i]=0;
  }

  for(i=0;i<n;i++){
    C[A[i]]++;
  }

  for(i=1;i<2000000;i++){
    C[i]=C[i]+C[i-1];
  }

  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
}



Measured memory_bytes: 25292
using System;
using System.Linq;
class Program{
static void Main(string[] args){
  var N = int.Parse(Console.ReadLine());
  //Linq使って先に並び替え
  var a = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderByDescending(x=>x).ToArray();
  int alice=0;
  int bob=0;
  //素直にaliceとbobを計算
  for(int i=0;i<N;i++){
    if(i%2==0) alice+=a[i];
    else bob+=a[i];
  }
  Console.WriteLine(alice-bob);
}
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string n;cin>>n;
  string s=n;
  reverse(n.begin(),n.end());
  if(n==s)out("Yes")
  else out("No")


  return 0;
}


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

namespace abc046_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long a = x[1];
            for (int i = 1; i < x[0]; i++)
            {
                a *= (x[1] - 1);
            }
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 2776
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

  ll a,b;
  std::cin>>a>>b;
  std::cout<<std::max(0ll,a-2*b);
 
  return 0;
}

Measured memory_bytes: 256
def deco_fibo(func):
    answer_list = [1, 1] + [None] * 43
    def main_fibo(i):
        ans = answer_list[i]
        if ans:
            return ans
        ans = func(i)
        answer_list[i] = ans
        return ans
    return main_fibo

@deco_fibo
def fibo(num):
    return fibo(num - 1) + fibo(num - 2)


n = int(input())

print(fibo(n))

Measured memory_bytes: 7764
import numpy as np

n, m = map(int, input().split())
from_1 = np.zeros(n+1, dtype=np.int)
to_n = np.zeros(n+1, dtype=np.int)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        from_1[b] = 1
    elif b == n:
        to_n[a] = 1

print('IMPOSSIBLE') if np.sum(from_1*to_n) == 0 else print('POSSIBLE')


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

int main(){
    
    int t,k;
    cin>>t>>k;
    string s;
    cin>>s;
    
   //putchar(tolower(s[k]));
   for(int i=0;i<t;i++){
       if(i!=k-1){
           putchar(s[i]);
       }
       else{
           putchar(tolower(s[i]));
       }
   }
   
   //cout<<s<<endl;
   
   return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n, m; cin >> n >> m;
    int ans[30] = {0};
    for (int i = 0; i < n; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int a; cin >> a;
            ans[a - 1]++;
        }
    }
    /*
    for (int i = 0; i < m; ++i) {
        cout << ans[i] << " ";
        
    }
    cout << endl;*/
    int cnt = 0;
    for (int i = 0; i < m; ++i) {
        if (ans[i] == n) cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n,k;
  cin >> n >> k;
  
  int count = 0;
  for(int i=0; i<n; i++){
    int tall;
    cin >> tall;
    if(tall >= k){
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>

#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)

using namespace std;

const ll sz=100005;
const ll szz=1000006;

ll kitne=0;
vl ar[sz];
ll n,m,par[sz],ht[sz];
bool vis[sz];
set<pll> s;
void bfs(ll node)
{
    queue<ll> q;
    q.push(node);
    vis[node]=true;
    //par[node]=-1;
    while(!q.empty())
    {
        ll curr=q.front();
        // cout<<curr<<" ";
        int flag=true;
        q.pop();
        // if(ar[curr].size()==0)
        //     kitne++;//,cout<<curr<<"<-\n";
        // cout<<curr<<" ";
        for(ll child:ar[curr])
        {
            if(ht[child]>=ht[curr])
            {
                flag=false;
            }
            if(!vis[child])
            {
                vis[child]=true;
                q.push(child);
                // if(ht[child]<ht[curr])
                //     kitne++;//,cout<<curr<<" "<<child<<endl;
               // par[child]=curr;
            }
        }
        if(flag)
            kitne++;//,cout<<curr<<"<-\n";
    }
}

int main()
{
    Ryuga;
    
    
    cin>>n>>m;
    rep(i,1,n+1)
    {
        cin>>ht[i];
    }

    rep(i,0,m)
    {
        ll a,b;
        cin>>a>>b;
        // if(find(all(ar[a],b)))
        // {

        // }
        // else
        // {
            ar[a].pb(b);
            ar[b].pb(a);
        // }
    }

    rep(i,1,n+1)
    {
        if(!vis[i])
        {
            bfs(i);
        }
    }

    cout<<kitne;

}//Goodbye...

Measured memory_bytes: 10472
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  ll N,K;
  cin>>N>>K;
  cout<<min(N%K,abs(K-N%K))<<endl;
}

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();
		int y = scan.nextInt();
		int z = scan.nextInt();

		int a = 0,b = 0,c = 0;

		a = y;
		b = x;

		c = a;
		a = z;


		System.out.println(a);
		System.out.println(b);
		System.out.println(c);

		scan.close();

	}

}


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

using namespace std;
int n,h,tic = 0,p[1<<20];
const int mod = 1000000007;
long long ans,tick[1<<20],val[1<<20];
inline void AddTag(int now,long long bas) {
	bas *= now;
	bas %= mod;
	if (now >= (1<<h)) {
		now = p[now-(1<<h)+1]+(1<<h)-1;
		while (now > 1) {
			if (tick[now>>1] < tic)
				val[now>>1] = 0,tick[now>>1] = tic;
			bas *= now;
			bas %= mod;
			(val[now>>1] += bas) %= mod;
			now >>= 1;
		//	cout << now << " " << val[now] << endl;
		}
		return ;
	}
	AddTag(now<<1,bas);
	AddTag((now<<1)+1,bas);
}
inline void calcAns(int now,long long bas) {
	bas *= now;
	bas %= mod;
	if (now >= (1<<h)) {
		now = p[now-(1<<h)+1]+(1<<h)-1;
		long long tmp = bas*now%mod,caled = 0;
		while (now > 1) {
			//caled *= now;
			//caled %= mod;
			caled *= now;
			caled %= mod;
			now >>= 1;
			tmp *= now;
			tmp %= mod;
			if (tick[now] == tic) {
				//cout << now << " " << tmp << " " << val[now] << " " <<caled << endl;
				(ans += tmp*(val[now]-caled)) %= mod;
				caled = val[now];
			}
		}
		return ;
	}
	calcAns((now<<1),bas);
	calcAns((now<<1)+1,bas);
}
inline void dfs(int now) {
	if (now >= (1<<h))
		return ;
	tic++;
	AddTag(now<<1,now);
	calcAns((now<<1)+1,1);
	//cout << ans << endl;
	dfs(now<<1);
	dfs((now<<1)+1);
}
int main() {
	int  D,T,S;
	cin >> D >> T >> S;
	if (S*T >= D) {
		cout << "Yes" << endl;
	} 
	else
		cout << "No" << endl;
	return 0;
}
/*
5
6 14 15 7 12 16 5 4 11 9 3 10 8 2 13 1
4
1 2 3 4 5 6 7 8
*/

Measured memory_bytes: 3628
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)

ll inf = 1000000000000000;
vector<vector<ll>> d;
vector<vector<unordered_set<ll>>> nxt;
vector<vector<bool>> f;

void ff(ll x, ll y) {
    for (ll z : nxt[x][y]) {
        f[min(z, x)][max(z, x)] = false;
        ff(z, y);
    }
}

int main() {
    ll N, M;
    cin >> N >> M;
    d.resize(N);
    nxt.resize(N);
    f.resize(N);
    rep(i, N) {
        d[i].resize(N);
        nxt[i].resize(N);
        f[i].resize(N);
        rep(j, N) {
            d[i][j] = (i == j ? 0 : inf);
            f[i][j] = false;
        }
    }
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        f[min(a, b)][max(a, b)] = true;
        nxt[a][b].insert(b);
        nxt[b][a].insert(a);
    }
    rep(k, N)rep(i, N)rep(j, N) {
        if (d[i][j] < d[i][k] + d[k][j] || k == j) continue;
        else if (d[i][j] > d[i][k] + d[k][j]) {
            d[i][j] = d[i][k] + d[k][j];
            nxt[i][j].clear();
        }
        nxt[i][j].insert(nxt[i][k].begin(), nxt[i][k].end());
    }
    rep(i, N - 1)repi(j, i + 1, N) {
        if (d[i][j] == inf) continue;
        ff(i, j);
    }
    ll res = 0;
    rep(i, N - 1)repi(j, i + 1, N)if (f[i][j])res++;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll value[200100];
ll ans[200100];
int n,q; 
Graph G(200100);

void dfs(int now, int prev, ll val){
    ll newval = val + value[now];
    ans[now] = newval;
    rep(i,0,SZ(G[now])){
        if(G[now][i] == prev) continue;
        dfs(G[now][i], now, newval);
    }
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n >> q;
    rep(i,0,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,0,q){
        int p,x; cin >> p >> x;
        p--;
        value[p] += (ll)x;
    }

    dfs(0, -1, 0LL);

    rep(i,0,n){
        if(i > 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 29780
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
  int n;
  cin>>n;
  for(;n--;)
    {
      int map[9][9];
      bool tf[9][9];
      for(int i=0;i<9;i++)
	for(int j=0;j<9;j++)
	  cin>>map[i][j];

      memset(tf,false,sizeof(tf));
      //check
      for(int i=0;i<9;i++)
	for(int j=0;j<9;j++)
	  {
	    if(!tf[i][j])
	      {	      
		//たてよこ
		for(int x=0;x<9;x++)
		  {
		    if(map[i][j]==map[i][x] && j!=x)
		      {
			//			cout<<i<<" "<<j <<"-> "<<map[i][j]<<endl;
			tf[i][j]=true;
			//			cout<<i<<" "<<x <<"-> "<<map[i][x]<<endl;
			tf[i][x]=true;
		      }
		    if(map[i][j]==map[x][j] && i!=x)
		      {
			//			cout<<i<<" "<<j <<"-> "<<map[i][j]<<endl;
				tf[i][j]=true;
				//	cout<<x<<" "<<j <<"-> "<<map[x][j]<<endl;
				tf[x][j]=true;
		      }
		  }
		//ブロック単位
		int start_x=3*(i/3);
		int start_y=3*(j/3);
		for(int x=start_x;x<start_x+3;x++)
		  for(int y=start_y;y<start_y+3;y++)
		    {
		      if(map[i][j]==map[x][y] && i!=x && j!=y)
			{
			  //  cout<<i<<" "<<j <<"-> "<<map[i][j]<<endl;
			    tf[i][j]=true;
			    //  cout<<x<<" "<<y <<"-> "<<map[x][y]<<endl;
			  tf[x][y]=true;
			}		      
		    }		
	      }
	  }
      for(int i=0;i<9;i++,cout<<endl)
	for(int j=0;j<9;j++)
	  {
	    if(tf[i][j])
	      cout<<"*";
	    else
	      cout<<" ";
	    cout<<map[i][j];
	  }

      if(n!=0)
	cout<<endl;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, a, b;
    int ans;
    
    scanf("%d%d%d", &n, &a, &b);
    
    ans=fmin(n*a, b);
    
    printf("%d", ans);
    
    return 0;
}



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

int main() {
    int n, count = 0;
    cin >> n;
    int p[n], ps[n];
    for(int i = 0; i < n; ++i) {
        cin >> p[i];
        ps[i] = p[i];
    }
    sort(ps, ps+n);
    for(int i = 0; i < n; ++i) {
        if(p[i] != ps[i])
            count++;
    }
    if(count == 2 || count == 0) {
        cout << "YES" << '\n';
    } else {
        cout << "NO" << '\n';
    }
}


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

using ll=long long;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=k;i<(ll)(n);i++)
template<class T> void out(T a){cout<<a<<'\n';}

int main(){
  int t; cin>>t;
  rep(i,t){
    ll n,m,a,b;
    cin>>n>>m>>a>>b;
    out(floor_sum(n,m,a,b));
  }
}


Measured memory_bytes: 3596
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
   if m == 0:
     return True
   if i >= n or m > sum(A):
     return False
   res = solve(i + 1, m) or solve(i + 1, m - A[i])
   return res

for m in M:
  if solve(0,m):
     print "yes"
  else:
     print "no"

Measured memory_bytes: 6448
#include<bits/stdc++.h>
using namespace std;
char p[]={'+','-'};
int d[]={1,-1};

int main(){
  string s;
  int a[9];
  cin>>s;
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
	if(a[0]+a[1]*d[i]+a[2]*d[j]+a[3]*d[k]==7){
	  cout<<a[0]<<p[i]<<a[1]<<p[j]<<a[2]<<p[k]<<a[3]<<"=7"<<endl;
	  return(0);
	}
      }
    }
  }

  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;

}
//################################################################
ll n,W;
ll w[109];
ll v[109];
ll mem[100][100009];
ll solve(ll ind,ll c){
    if(c<=0) return 0;
    if(ind==0){
        if(w[ind]<=c) return v[ind];
        else
            return 0;
    }

    if(mem[ind][c]!=-1)return mem[ind][c];
    ll ret=0;
    if(w[ind]>c){
        ret=solve(ind-1,c);
    }else{
        ret=max( solve(ind-1,c),(v[ind]+solve(ind-1,c-w[ind])) );
    }
    return mem[ind][c]=ret;

}
int main(){
    n=LLD(),W=LLD();
    for(int i=0;i<n;i++){
        w[i]=LLD();
        v[i]=LLD();
    }
    memset(mem,-1, sizeof(mem));
    printf("%lld",solve(n-1,W));
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
void solve(){
	int n; 
	cin>>n; 
	int sq = sqrt(n);
	cout<<sq*sq<<endl;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cout<<fixed<<setprecision(12);
	int t=1; 
//	cin>>t;
	while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int d,t,s;

	scanf("%d", &d);
	scanf("%d", &t);
	scanf("%d", &s);

	if(d <= t*s) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 1732
public class Main {

    private static void solve() {
        long n = nl();

        long ret = 0;
        for (int p = 1; p <= (int) 1e6 + 10; p++) {
            if (n % p == 0) {
                long m = n / p - 1;
                if (m <= p)
                    continue;
                ret += m;
            }
        }
        System.out.println(ret);
    }

    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                long start = System.currentTimeMillis();
                String debug = args.length > 0 ? args[0] : null;
                if (debug != null) {
                    try {
                        is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
                reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
                solve();
                out.flush();
                tr((System.currentTimeMillis() - start) + "ms");
            }
        }, "", 64000000).start();
    }

    private static java.io.InputStream is = System.in;
    private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
    private static java.util.StringTokenizer tokenizer = null;
    private static java.io.BufferedReader reader;

    public static String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new java.util.StringTokenizer(reader.readLine());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    private static double nd() {
        return Double.parseDouble(next());
    }

    private static long nl() {
        return Long.parseLong(next());
    }

    private static int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = ni();
        return a;
    }

    private static char[] ns() {
        return next().toCharArray();
    }

    private static long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nl();
        return a;
    }

    private static int[][] ntable(int n, int m) {
        int[][] table = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                table[i][j] = ni();
            }
        }
        return table;
    }

    private static int[][] nlist(int n, int m) {
        int[][] table = new int[m][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                table[j][i] = ni();
            }
        }
        return table;
    }

    private static int ni() {
        return Integer.parseInt(next());
    }

    private static void tr(Object... o) {
        if (is != System.in)
            System.out.println(java.util.Arrays.deepToString(o));
    }
}


Measured memory_bytes: 22868
///BE NAME KHODA
#include <bits/stdc++.h>

using namespace std;

#define S second
#define F first
#define int long long

typedef long long ll;
typedef long double ld;

const int maxn = 1e6+10;
const int mod = 998244353;
const ll inf = 1e9+10;

int n, m, k;
int a[maxn], fac[maxn];

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

    fac[0] = 0;
    for(int i = 1; i < maxn; i++)
    {
        int cnt = 0, j = i;
        while(!(j&1)){j >>= 1; cnt++;}
        fac[i] = fac[i-1] + cnt;
    }

    cin>> n;
    string s; cin>> s;
    int X = 0, z = 0;
    for(int i = 0; i < n; i++)
    {
        if(i < n-1)
        if(abs(s[i]-s[i+1]) == 1)
            X = 1;
        if(((s[i]-'0') & 1) && !(fac[n-1] - fac[i] - fac[n-1-i]))
            z ^= 1;
    }
    if(z)
        cout<< 1;
    else
        if(X)
            cout<< 0;
        else
        {
            int ans = 0;
            for(int i = 0; i < n-1; i++)
                if((abs(s[i]-s[i+1]) == 2) && !(fac[n-2] - fac[i] - fac[n-i-2]))
                {
                    ans ^= 2;
                }
            cout<< ans;
        }
}




Measured memory_bytes: 9604
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	bool odd = k % 2;
	ll ans = -1;
	if (k <=1000) {
		rep(i, 0, k) {
			ll na, nb, nc;
			na = b + c;
			nb = a + c;
			nc = a + b;
			a = na;
			b = nb;
			c = nc;
		}
		ans = a - b;
	}
	else {
		if (odd) {
			ans = -a + b;

		}
		else { ans = a - b; }

	}

	abs(ans) >= 1000000000000000000L ? cout << "Unfair": cout << ans;

	return 0;
}





Measured memory_bytes: 256
n = int(input())

s = n*(n+1)//2

n3 = n//3
s3 = n3*(n3*3+3)//2
n5 = n//5
s5 = n5*(n5*5+5)//2
n15 = n//15
s15 = n15*(n15*15+15)//2

print(s-s3-s5+s15)


Measured memory_bytes: 9176
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back
 
using namespace std;

int main(){

    int k,a,b;
    int ans = 0;
    cin >> k >> a >> b;

    for(int i = a;i <= b;i++){

        if(i % k == 0){
            ans++;
        }
    }

    if(ans > 0){
        puts("OK");
    }else{
        puts("NG");
    }
}

Measured memory_bytes: 3624
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	
	char a[10];
	scanf("%s", a);
	string s = a;
	printyn(s.find("AC") != string::npos);

	return 0;
}


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

int main() {
    size_t h, w;
    cin >> h >> w;
    vector<string> v( h );
    for ( size_t i = 0; i < h; ++i ) {
        cin >> v.at( i );
    }
    for ( size_t i = 0, c; i < h; ++i ) {
        c = 0;
        for ( size_t j = 0; j < w; ++j ) {
            if ( v.at( i ).at( j ) == '.' || v.at( i ).at( j ) == '@' )
                ++c;
        }
        if ( c == w ) {
            for ( size_t j = 0; j < w; ++j ) {
                v.at( i ).at( j ) = '@';
            }
        }
    }
    for ( size_t i = 0, c; i < w; ++i ) {
        c = 0;
        for ( size_t j = 0; j < h; ++j ) {
            if ( v.at( j ).at( i ) == '.' || v.at( j ).at( i ) == '@' )
                ++c;
        }
        if ( c == h ) {
            for ( size_t j = 0; j < h; ++j ) {
                v.at( j ).at( i ) = '@';
            }
        }
    }
    bool f;
    for ( size_t i = 0; i < h; ++i ) {
        f = false;
        for ( size_t j = 0; j < w; ++j ) {
            if ( v.at( i ).at( j ) != '@' ) {
                cout << v.at( i ).at( j );
                f = true;
            }
        }
        if ( f == true )
            cout << "\n"s;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
S = sum(A)
for i in range(N):
  if A[i]>=B[i]:
    A[i]-=B[i]
  else:
    A[i+1]= max(0, A[i+1]-(B[i]-A[i]))
    A[i]=0
print(S-sum(A))

Measured memory_bytes: 24212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int f(ll k) {
	if (k == 0) return 0;
	int a = 1;
	while (k >>= 1) a++;
	return a;
}
int main(void)
{
	ll n, k, num[64] = {};
	cin >> n >> k;
	rep (i, n) {
		ll a;
		cin >> a;
		rep (j, 64) num[j] += (int)((a & (1LL << j)) != 0);
	}
	ll ans = 0, tmp = 0;
	for (int i = f(k) - 1; i >= 0; i--) {
		tmp = 0;
		if ((k & (1LL << i)) == 0) continue;
		// cout << i << " ";
		for (int j = 63; j >= 0; j--) {
			if (i < j) {
				if ((k & (1LL << j)) != 0) tmp += (n - num[j]) << j;
				else tmp += num[j] << j;
			} else if (i == j) {
				tmp += num[j] << j;
			} else {
				tmp += max(num[j], n - num[j]) << j;
			}
/* 			if (i < j) {
				if ((k & (1LL << j)) != 0) cout << (n - num[j]);
				else cout << num[j];
			} else if (i == j) {
				cout << num[j];
			} else {
				cout << max(num[j], n - num[j]);
			} */
		}
		// cout << endl;
		// cout << tmp << endl;
		chmax(ans, tmp);
		// cout << endl << i << " " << tmp << endl;
		// cout << endl;
	}
	tmp = 0;
	for(int j = 63; j >= 0; j--) {
		if ((k & (1LL << j)) != 0) tmp += (n - num[j]) << j;
		else tmp += num[j] << j;
		// if ((k & (1LL << j)) != 0) cout << n - num[j];
		// else cout << num[j];
	}
	// cout << endl;
	// cout << tmp << endl;
	chmax(ans, tmp);
	cout << ans << endl;
	// rep(j,64)cout<<num[63-j];cout<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int D = scanner.nextInt();
		int N = scanner.nextInt();
		int x = N + 1;

		//Nが100のときとそれ以外で場合分け
		if (N != 100) {
			System.out.println(N * determine(D));
		} else {
			System.out.println(x * determine(D));
		}
	}

	//Dの値によって場合分け
	public static int determine(int d) {
		int result;
		if (d == 0) {
			result = 1;
		} else if (d == 1) {
			result = 100;
		} else {
			result = 100 * 100;
		}
		return result;
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  string S, T;
  for (int i = 0; i < b; i++) {
    S += char('0' + a);
  }
  for (int i = 0; i < a; i++) {
    T += char('0' + b);
  }
  if (S > T) swap(S, T);
  cout << S << "\n";
}

Measured memory_bytes: 3628
#include <stdio.h>
//#define scanf scanf_s
typedef long long int lli;

// ITP1_4_D
// n個の整数を入力し、それらの最小値、最大値、合計値を出力
int main()
{
	int iInputN;
	int iInputA;
	int iMin = 1000000;
	int iMax = -1000000;
	lli iSum = 0;

	scanf("%d", &iInputN);

	for (; iInputN > 0; iInputN--)
	{
		scanf("%d", &iInputA);
		iSum += iInputA;
		if (iMin > iInputA)
		{
			iMin = iInputA;
		}
		if (iMax < iInputA)
		{
			iMax = iInputA;
		}
	}

	printf("%d %d %lld\n", iMin, iMax, iSum);

	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include <vector>
#include<algorithm>
#include<functional>

using namespace std;

long long int N;

vector<long long int> V;


long long int D[100005];

int main(void) {
	cin >> N;

	V.push_back(1);
	long long int a;
	a = 1;
	for (int i = 1;; i++) {
		a *= 6; V.push_back(a);
		if (a > 100000) { break; }
	}

	a = 1;
	for (int i = 1;; i++) {
		a *= 9; V.push_back(a);
		if (a > 100000) { break; }
	}

	sort(V.rbegin(), V.rend());

	int count = 0;

/*	for (int i = 0; i < V.size(); i++) {

		cout << i <<" " <<V[i] << endl;
	}*/

/*	while (N > 0) {
		//cout << N << endl;
		for (int i = 0; i < V.size(); i++) {
			if (V[i] <= N) { N -= V[i]; count++; break; }
		}
	}*/
	D[0] = 0;
	D[1] = 1;
	for (int i = 2; i <= N; i++) { D[i] = 99999999; }
	for (int i = 2; i <= N; i++) {
		for (int j = 0; j < V.size(); j++) {
			if (i - V[j] >= 0) { D[i] = min(D[i], D[i - V[j]] + 1); }
		}
	}

	cout << D[N] << endl;
	//system("pause");
	return 0;
};

Measured memory_bytes: 1024
N = int(input())
T, A = map(int, input().split())
Hs = list(map(int, input().split()))


def get_temp(height):
    return T - (0.006 * height)


ans = -1
cht = abs(get_temp(100000) - (-60))


for i in range(N):
    t = abs(get_temp(Hs[i]) - A)
    if t < cht:
        ans = i + 1
        cht = t

print(ans)


Measured memory_bytes: 3060