akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int h, w;
vector<string> field(1005);

int dy[] = {1, 0, 0, -1};
int dx[] = {0, -1, 1, 0};


int main() {
    cin >> h >> w;
    rep(i, h){
        cin >> field[i];
    }

    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<P> q;
    rep(i, h) {
        rep(j, w) {
            if (field[i][j] == '#') {
                dist[i][j] = 0;
                q.push(make_pair(i, j));
            }
        }
    }

    while(!q.empty()) {
        auto cur = q.front();
        q.pop();
        rep(i, 4) {
            int ny = cur.first + dy[i], nx = cur.second + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (dist[ny][nx] == -1) {
                dist[ny][nx] = dist[cur.first][cur.second] + 1;
                q.push(make_pair(ny, nx));
            }
        } 
    }

    int ans = 0;
    rep(i, h) {
        rep(j ,w) {
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13456
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

bool chk (ll mid, ll a[], ll n, ll k) {
    ll ret = 0;
    for (ll i = 0; i < n; i++) {
        ret += (a[i] / mid);
        if ((a[i] % mid) == 0){
            --ret;
        }
    }
    return (ret <= k);
}

void Flash(){
    ll n, k;
    cin>>n>>k;
    ll a[n];
    ll mx = -1;
    for (ll i = 0; i < n; i++) {
        cin>>a[i];
        mx = max(mx, a[i]);
    }
    ll high = mx, low = 1, mid;
    ll ans = mx;
    while (high >= low) {
        mid = (high + low) >> 1;
        if (chk(mid, a, n, k)) {
            ans = mid;
            high = mid - 1; 
        } else {
            low = mid + 1;
        }
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  // cout<<fixed<<setprecision(10);


  ll n,m; cin>>n>>m;

  ll ans = n*(n-1)/2 + m*(m-1)/2;

  cout<<ans<<endl;

}






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

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var len = int.Parse(Console.ReadLine());
            var vec = Console.ReadLine().Split(' ').Select(n=>int.Parse(n)).ToList();
            var res = vec.ToList();
            res.Sort();

            int count = 0;

            for (int i = 0; i < len; i++)
            {
                if (vec[i] != res[i])
                {
                    count++;
                    if (count >= 3)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
            }

            Console.WriteLine("YES");
        }
    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String args[]) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	for(int tc = 0; tc < N; ++tc) {
	    int[] e = new int[3];
	    for(int i = 0; i < 3; ++i) {
		e[i] = s.nextInt();
	    }
	    Arrays.sort(e);
	    if(e[0]*e[0] + e[1]*e[1] == e[2]*e[2])
		System.out.println("YES");
	    else
		System.out.println("NO");
	}
    }
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007


#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll dp[110][110];

int main(){
  ll h,w;
  cin>>h>>w;
  vector<string> vs;
  rep(i,0,h){
    string s;
    cin>>s;
    vs.pb(s);
  }
  rep(i,0,110)rep(j,0,110)dp[i][j] = 100000;
  dp[0][0] = 0;
  rep(y,0,h){
    rep(x,0,w){
      if(y!=0){
        if(vs[y][x]==vs[y-1][x]){
          dp[y][x] = min(dp[y][x],dp[y-1][x]);
        }
        else{
          dp[y][x] = min(dp[y][x],dp[y-1][x]+1);
        }
      }
      if(x!=0){
        if(vs[y][x]==vs[y][x-1]){
          dp[y][x] = min(dp[y][x],dp[y][x-1]);
        }
        else{
          dp[y][x] = min(dp[y][x],dp[y][x-1]+1);
        }        
      }
    }
  }
  ll d = dp[h-1][w-1];
  if(vs[0][0]=='.'&&vs[h-1][w-1]=='.'){
    cout << d/2 << endl;
  }
  else if(vs[0][0]=='#'&&vs[h-1][w-1]=='#'){
    cout << d/2+1 << endl;
  }
  else{
    cout << (d-1)/2+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    char str[4];
    int n = 0;
    
    std::cin >> str;
    
    for(int i = 0; i < 4; i++){
        if(str[i] == '+') n++;
        else n--;
    }
    
    std::cout << n << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>


int main(){
  long int N, max;
  long int ans, tmp, tmp2, tmp3;
  ans = 0;
  std::cin >> N;
  std::cin >> max;
  long int a[N];
  for(int i = 0; i < N; i++){
    std::cin >> a[i];
    if (i > 0){
      tmp2 = a[i-1] + a[i];
        if (max < tmp2){
          tmp = tmp2 - max;
          ans = ans + tmp;
          tmp3 = tmp - a[i];
          if (tmp3 > 0){
            a[i] = 0;
            a[i-1] = a[i-1] - tmp3;
          }else{
            a[i] = a[i] - tmp;
          }
        }
    }
  }


  std::cout << ans <<std::endl;
  return (0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
//#define endl '\n'

using namespace std ;

#define MAXN 100010
//lli spf[MAXN];  
//void sieve();
//set<lli> factors(lli x);
lli power(lli x,lli y,lli p);
//void getZarr(string str, lli Z[]);
//vll prefix_function(vll s); 

int main()
{


    lli H,W,h,w;
    cin>>H>>W>>h>>w;

    cout<<H*W - h*W - H*w + h*w<<endl;


}


/*vll prefix_function(vll s) 
{
    lli n = (lli)s.size();
    vll pi(n);
    
    for (lli i = 1; i < n; i++)
    {
        lli j = pi[i-1];
        
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        
        if (s[i] == s[j])
            j++;
        
        pi[i] = j;
    }
    return pi;
}
*/
/*void sieve() 
{ 
    spf[1] = 1; 
    loopl(i,2,MAXN) 
        spf[i] = i; 
    for (lli i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (lli i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (lli j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    }

} 

multiset<lli> factors(lli x) 
{ 
    multiset<lli> pr; 
    while (x != 1) 
    { 
        pr.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return pr; 
}

*/

/*
void dfs(lli q,lli root) 
{
    vis[q]=1;
    
    ans[q]=1;

    for(auto x: v[q])
    {
        if(!vis[x])
        {
            if(a[x]==a[root] && x<root) continue;
            if(a[x]<a[root] || a[x]>a[root]+d) continue;
            dfs(x,root);
            ans[q]=(ans[q]*((ans[x]+1)%mod))%mod ;
        }
    }
        
}
*/



/*void getZarr(string str, lli Z[])
{
    lli n = str.length();
    lli L, R, k;
    L = R = 0;
    for (lli i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}


*/

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


Measured memory_bytes: 256
def main():
	raw_input()
	a = map(int, raw_input().split())
	n = len(a)
	s = sum(a)
	ans = float("inf")
	cur_sum = 0
	for i in range(n - 1):
		cur_sum += a[i]
		ans = min(ans, abs(cur_sum * 2 - s))
	print ans

if __name__ == "__main__":
	main()

Measured memory_bytes: 18416
def main():
  n = int(input())
  A = list(map(int, input().split()))

  sum = 0
  for i in range(n):
    if A[i] % 2 == 1 and (i + 1) % 2 == 1:
      sum += 1

  print(sum)

if __name__ == '__main__':
  main()


Measured memory_bytes: 9160
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 10005,maxm = 100005,INF = 0x3f3f3f3f;
inline int read(){
	int out = 0,flag = 1; char c = getchar();
	while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
	while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
	return flag ? out : -out;
}
int f[maxn],n;
int cal(int x,int y,int z){
	return x * x + y * y + z * z + x * y + y * z + x * z;
}
int main(){
	n = read();
	for (int i = 1; i * i <= n; i++){
		for (int j = 1; cal(i,j,1) <= n; j++){
			for (int k = 1; cal(i,j,k) <= n; k++)
				f[cal(i,j,k)]++;
		}
	}
	for (int i = 1; i <= n; i++) printf("%d\n",f[i]);
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define el cout<<endl;
#define flog(n) 31-__builtin_clz((n))
#define clog(n) 32-__builtin_clz((n)-1)
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define forib(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(n) fori(asdasdasd_RaNdOm_VaRiAbLe_NaMe_asdasdasd,1,(n))

using ui=unsigned int;
using ll=long long; using pi=pair<int,int>;
#define vec vector
using vb=vec<bool>; using vc=vec<char>; using vs=vec<string>; using vi=vec<int>; using vl=vec<ll>; using vpi=vec<pi>;
using sb=set<bool>; using sc=set<char>; using ss=set<string>; using si=set<int>; using sl=set<ll>; using spi=set<pi>;

void solve() {
    double a,b,h,m; cin>>a>>b>>h>>m;
    double pi=3.14159265358979323846;
    double am=pi*2*m/60,ah=pi*2*h/12+am/12, da=min(min(abs(am-ah),abs(am-ah-pi*2)),abs(am-ah+pi*2));
    double c=a*a+b*b-2*a*b*cos(da);
    c=sqrt(c);
    cout<<setprecision(20)<<c<<" ";
}

int main() {
    if(false){
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    }
    int t=1;
    //cin>>t;
    rep(t) solve();
    return 0;
}


Measured memory_bytes: 4168
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
const lli logN = 60L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

lli gt(lli n)
{
    lli i;
    repD(i,logN,0)
    {
        if(n&(1LL<<i))
        {
            dbg(n,(1LL<<(i+1)));
            return (1LL<<(i+1));
        }
    }
    return 1;
}

lli solve(lli l,lli r)
{
    if(l==r)
        return 1;
    lli i;
    repD(i,logN,0)
    {
        if((l&(1LL<<i))&&(r&(1LL<<i)))
        {
            l^=(1LL<<i);
            r^=(1LL<<i);
        }

        if((l&(1LL<<i))!=(r&(1LL<<i)))
            break;
    }

    lli cnt=0;
    cnt+=solve(l,(1LL<<i)-1);
    cnt+=min( 1LL<<i ,(1LL<<i)-l+gt(r^(1LL<<i)));
    dbg(l,r,cnt);
    return cnt;
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    lli l,r;
    cin>>l>>r;

    cout<<solve(l,r)<<endl;

}   aryanc403();
    return 0;
}


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

int main() {

	string a, b;

	cin >> a >> b;

	if (a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]) {
		puts("YES");
	}

	else {
		puts("NO");
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

vector<ll> odd(100000,0);
vector<ll> even(100000,0);

int main(){
	ll N,l;
	cin >> N;
	for (int i = 0;i < N;i++){
		if (i % 2 == 0){
			cin >> l;
			odd[l - 1]++;
		}
		else{
			cin >> l;
			even[l - 1]++;
		}
	}
	auto max_odd = max_element(ALL(odd));
	ll odd_index = distance(odd.begin(),max_odd);
	auto max_even = max_element(ALL(even));
	ll even_index = distance(even.begin(),max_even);
	if (odd_index == even_index){
		if (odd[odd_index] > even[even_index]){
			even[even_index] = 0;
			max_even = max_element(ALL(even));//二番目に大きいやつ
			even_index = distance(even.begin(),max_even);
		}
		else if (odd[odd_index] == even[even_index]){
			ll tmp_odd = odd_index;
			ll t_odd = odd[odd_index];
			ll tmp_even = even_index;
			ll t_even = even[even_index];
			even[even_index] = 0;
			max_even = max_element(ALL(even));//二番目に大きいやつ
			even_index = distance(even.begin(),max_even);


			odd[odd_index]	 = 0;	
			max_odd = max_element(ALL(odd));//二番目に大きいやつ
			odd_index = distance(odd.begin(),max_odd);

			if (odd[odd_index] > even[even_index]){
				even_index = tmp_even;	
				even[even_index] = t_even;
			}
			else{
				odd_index = tmp_odd;
				odd[odd_index] = t_odd;
			}
		}
		else{
			odd[odd_index]	 = 0;	
			max_odd = max_element(ALL(odd));//二番目に大きいやつ
			odd_index = distance(odd.begin(),max_odd);
		}

	}
	ll ans = N/2 - odd[odd_index] + N / 2 - even[even_index];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
dp = [[0]*(m+1) for i in range(n+1)]
for i in range(1,n+1):
  w,v=map(int,input().split())
  for j in range(m+1):
    if j < w:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = max(dp[i-1][j-w]+v,dp[i-1][j])
print(dp[n][m])

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

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

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

  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  rep(i, n-1) {
    if(a[i] > x) {
      ans += a[i]-x;
      a[i] = x;
    }
    if(a[i]+a[i+1] > x) {
      ans += a[i]+a[i+1]-x;
      a[i+1] = x-a[i];
    }
  }

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[20];
map<int,vector<pair<int,int> > > mp;
bool flag[20];
int mx=0;
int n;
void dfs(int x,int y){
	flag[x]=y;
	if(x==n){
		bool ok=true;
		int cnt=0;
		for(int i=1;i<=n;i++){
			if(flag[i]){
				cnt++;
				for(int j=0;j<mp[i].size();j++){
					if((mp[i][j].second==1&&!flag[mp[i][j].first])||(mp[i][j].second==0&&flag[mp[i][j].first]))ok=false;
				}
			}
		}
		if(ok)mx=max(mx,cnt);
		return ;
	}
	dfs(x+1,0);
	dfs(x+1,1);
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int tmp;
		cin>>tmp;
		for(int j=0;j<tmp;j++){
			int a,b;
			cin>>a>>b;
			mp[i].push_back(make_pair(a,b));
		}
	}
	dfs(1,0);
	dfs(1,1);
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 384
s = input()
a = int(s[:2])
b = int(s[2:])

if (1 <= a <= 12) and (1 <= b <= 12):
  print("AMBIGUOUS")
elif (1 <= a <= 12):
  print("MMYY")
elif (1 <= b <= 12):
    print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
N = int(input())

def divisors(n):
    ret1 = []
    ret2 = []
    i = 1
    while i**2 <= N:
        if n%i == 0:
            ret1 += [i]
            ret2 += [n//i]
        i += 1
    return ret1 + ret2

ans1 = len(set(divisors(N-1))) - 1
ans2_cand = set(divisors(N))
ans2 = 0
for k in ans2_cand:
    if k == 1: continue
    n = N
    while n%k == 0:
        n = n//k
    if n%k == 1:
        ans2 += 1


print(ans1 + ans2)

Measured memory_bytes: 67760
#include<stdio.h>
#define min(rhs,lhs) ((rhs)<(lhs)?(rhs):(lhs))
#define iabs(num) ((num) < 0 ? (-(num)):(num))
#include<limits.h>

int main(void){
    register int i;
    int n,k;
    scanf("%d %d",&n,&k);
    long x[n];
    for(i = 0;i < n;i++)scanf("%ld",&x[i]);
    long dist[n-k+1];
    for(i = 0;i < n-k+1;i++)dist[i] = iabs(x[i+k-1] - x[i]) + min(iabs(x[i+k-1]),iabs(x[i]));
    long ans = LONG_MAX;
    for(i = 0;i < n-k+1;i++)ans = min(ans,dist[i]);
    printf("%ld",ans);
}

Measured memory_bytes: 1280
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
bool cmp(pair<ll,ll> a,pair<ll,ll> b){
    if(a.F!=b.F)
        return a.F<b.F;
    else
        return a.S>b.S;
}
ll mod=1000000007;
const ll N=200005;
int main()
{
fast;
    ll n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t;
    }
    else
    {
        cout<<((n/x)+1)*t;
    }
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define no {cout<<"NO"<<endl;return;}
#define yes {cout<<"YES"<<endl;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1000000;


void solve(){

    string s;
    cin>>s;
    int cnt=0;
    for(auto c:s){
        cnt+=(c-'0');
        cnt=(cnt)%9;
    }
    if(cnt%9==0) cout<<"Yes";
    else cout<<"No";
}

int main(){
    IO

    //TEST
    solve();

    return(0);
}



Measured memory_bytes: 3752
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
dp = [0]*(N*3+1)
dp[1] = 1
dp[2] = -1
mod = 998244353
LR = [list(mapint()) for _ in range(K)]
for i in range(1, N+1):
    dp[i] = (dp[i]+dp[i-1])%mod
    for l, r in LR:
        dp[i+l] = (dp[i+l]+dp[i])%mod
        dp[i+r+1] = (dp[i+r+1]-dp[i])%mod

print(dp[N])

Measured memory_bytes: 77988
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    int a;
    string s;
    cin >> a >> s;
    if(a < 3200){
        cout << "red" << endl;
    }else{
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    string s;
    cin >> s;
    int a;
    if(s=="SUN"){
        a = 7;
    }else if(s=="MON"){
        a = 6;
    }else if(s=="TUE"){
        a = 5;
    }else if(s=="WED"){
        a = 4;
    }else if(s=="THU"){
        a = 3;
    }else if(s=="FRI"){
        a = 2;
    }else if(s=="SAT"){
        a = 1;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 760
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	p := a[0]
	for i := 1; i < n; i++ {
		p = p ^ a[i]
	}

	if p == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    k = int(input())
    a, b = map(int,input().split())
    for i in range(0, b + 1, k):
        if i >= a:
            print("OK")
            return
    print("NG")
resolve()

Measured memory_bytes: 61680
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
if n == 1 or m == 1:
    if n == 1 and m == 1:
        print(1)
    else:
        print(n * m - 2)
else:
    print(n * m - (n + m - 2) * 2)


Measured memory_bytes: 2940
import heapq
import collections

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

heap = []
heapq.heapify(heap)
heapq.heappush(heap,(-(A[0]+B[0]+C[0]),0,0,0))

dictionary = collections.defaultdict(bool)
dictionary[(0,0,0)] = True

i = 0

while i<k:
    M = heapq.heappop(heap)
    print(-M[0])
    i += 1
    if not dictionary[(M[1]+1,M[2],M[3])] and M[1]+1<x:
        heapq.heappush(heap,(-(A[M[1]+1]+B[M[2]]+C[M[3]]),M[1]+1,M[2],M[3]))
        dictionary[(M[1]+1,M[2],M[3])] = True
    if not dictionary[(M[1],M[2]+1,M[3])] and M[2]+1<y:
        heapq.heappush(heap,(-(A[M[1]]+B[M[2]+1]+C[M[3]]),M[1],M[2]+1,M[3]))
        dictionary[(M[1],M[2]+1,M[3])] = True
    if not dictionary[(M[1],M[2],M[3]+1)] and M[3]+1<z:
        heapq.heappush(heap,(-(A[M[1]]+B[M[2]]+C[M[3]+1]),M[1],M[2],M[3]+1))
        dictionary[(M[1],M[2],M[3]+1)] = True

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

ll xorotn(ll n){
    ll ans=0,c;
    if(n%2==0) ans=n,c=n/2;
    else c=(n+1)/2;
    if(c%2) ans^=1;
    return ans;
}

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    ll A,B;
    cin >>A>>B;
    cout << (xorotn(A-1)^xorotn(B)) <<endl;
    return (0);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
for i in range(n):
    b[i] = a[i] - i
b.sort()
x = b[n//2]
ans = 0
for i in range(n):
    ans += abs(x - b[i])
print(ans)


Measured memory_bytes: 88148
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 6e5+20;

int n, este, fil, col;
int puntos [N][3];
int mejor [N][3];

void f(int fil, int col)
{
    if(fil == 0) 
    {
        mejor[0][0] = puntos[0][0];
        mejor[0][1] = puntos[0][1];
        mejor[0][2] = puntos[0][2];
    }
    else
    {
        if(col == 0)
        {
            mejor[fil][col] = max( mejor[fil-1][1], mejor[fil-1][2] ) + puntos[fil][col];
        }
        else if(col == 1)
        {
            mejor[fil][col] = max(mejor[fil-1][0], mejor[fil-1][2]) + puntos[fil][col];
        }
        else
        {
            mejor[fil][col] = max(mejor[fil-1][0], mejor[fil-1][1]) + puntos[fil][col];
        }   
    }
}
int main()
{
    cin>>n;
    for(int i = 0; i < n; i++){cin>>este; puntos[i][0] = este; cin>>este; puntos[i][1] = este; cin>>este; puntos[i][2] = este;}
    for(int i = 0; i < n; i++){f(i, 0); f(i, 1); f(i, 2);}
    cout<<max(mejor[n-1][0], max(mejor[n-1][1], mejor[n-1][2]) )<<endl;
    //cout<<mejor[n-1][0]<<" - "<<mejor[n-1][1]<<" - "<<mejor[n-1][2]<<endl;
}

Measured memory_bytes: 5476
using System;

namespace ConsoleApp37
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if (s.Contains("RRR"))
            {
                Console.WriteLine(3);
            }else if (s.Contains("RR"))
            {
                Console.WriteLine(2);
            }
            else if (s.Contains("R"))
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

bool possible(ll x,ll n,ll k,ll a[])
{
	for(ll i=0;i<n;i++)
		k-=((a[i]+x-1)/x)-1;
	return (k>=0);
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
    	cin>>a[i];

   	ll mn=1,mx=1e9;
   	while(mn < mx)
   	{
   		ll mid=mn+((mx-mn)>>1LL);
   		if(possible(mid,n,k,a))
   			mx=mid;
   		else
   			mn=mid+1;
   	}

   	cout<<mn<<endl;
    
    return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {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;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

/// tree con LCA procesamiento O(N log N) consultas O(log N)
struct tree {
    int N, timer, l,root;
    vector<vii> G;
//   vii children[NMAX];
    vvi up;
    vi tin,tout,level;
    tree(int n,int _root) : N(n),root(_root) {
        tin.resize(n),tout.resize(n),level.resize(n);
        up.resize(n),G.resize(n);
    };

    void add_edge(int a, int b, int w = 0) {
        G[a].push_back(MP(b, w));
        G[b].push_back(MP(a, w));
    }

    void build() {
        l = log2(N)+1;
        for(int i = 0; i < N; ++i) up[i].resize(l + 1);
        dfs(root,root);
    }

    void dfs(int node, int p,int lev=0) {
        tin[node] = ++timer;
        level[node]=lev++;
        up[node][0] = p;
        for(int i = 1; i <= l; ++i)
            up[node][i] = up[up[node][i - 1]][i - 1];
        for(auto c : G[node])
            if(c.first != p) dfs(c.first, node,lev);
        tout[node] = ++timer;
    }

    bool upper(int a, int b) {return tin[a] <= tin[b] && tout[a] >= tout[b];}

    int lca(int a, int b) {
        if(upper(a, b)) return a;
        if(upper(b, a)) return b;
        for(int i = l; i >= 0; --i)
            if(!upper(up[a][i], b))
                a = up[a][i];
        return up[a][0];
    }

    int dist(int u,int v){
        return abs(level[u]-level[v]);
    }
};


int main() {
    READ(1);
    int n,u,v;cin>>n>>u>>v;
    --u,--v;
    tree t(n,v);
    FOR(i,n-1){
        int x,y;cin>>x>>y;
        t.add_edge(x-1,y-1);
    }
    t.build();
    int ret=0;
    for(int i=0;i<n;++i) {
        if (t.tin[i]+1==t.tout[i] && t.level[i]>ret){
            int l=t.lca(i,u);
            int d1=t.dist(u,l);
            if (d1<t.level[l]){
                ret=t.level[i];
            }
        }
    }
    cout << ret -1;
}



Measured memory_bytes: 20224
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int array[3];
    for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
    for(int i = 2; i > 0; i--){
        for(int j = 0; j < i; j++){
            if(array[j] > array[j+1])swap(array[j],array[j+1]);
        }
    }
    printf("%d %d %d\n",array[0],array[1],array[2]);
}


Measured memory_bytes: 2744
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
S= input()


if S=='SUN':
    print(7)
elif S=='MON':
    print(6)
elif S=='TUE':
    print(5)
elif S=='WED':
    print(4)
elif S=='THU':
    print(3)
elif S=='FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

//素因数分解　
//pair<ll,ll>型
//auto pf=prime_factorize(ll N);で呼ぶ
//for(auto p:pf){}で探す
ll k(1);

vector<pair<ll, ll>>prime_factorize(ll n) {
	vector<pair<ll, ll>>res;
	for (ll p = 2; p * p <= n; ++p) {
		if (n % p != 0)continue;
		int num = 0;
		while (n % p == 0) {
			++num;
			n /= p;
		}
		k *= (num + 1);
		res.push_back(make_pair(p, num));
	}
	if (n != 1) {
		res.push_back(make_pair(n, 1));
		k *= 2;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	ll ans(0);
	for (int i = 1; i < n; ++i) {
		k = 1;
		prime_factorize(n - i);
		ans += k;
	}
	cout << ans;
	return 0;
}

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

class Main {

	static String anther="Yes";
	//比較をするためサイコロを2つ用意する
	static Dice dice=new Dice();
	static Dice dice2=new Dice();


	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);



	


		int n=scanner.nextInt();
		int alldice[][]=new int[n][6];//全てのサイコロの目を記録する

		for(int i=0;i<n;i++){
			for(int k=0;k<6;k++){
				alldice[i][k]=scanner.nextInt();
			}
		}


		//サイコロの全比較、
		for(int i=0;i<n;i++){
			for(int k=i+1;k<n;k++){
				for(int p=0;p<6;p++){
					dice.num[p]=alldice[i][p];
					dice2.num[p]=alldice[k][p];
				}
				co();
				}
		}
	

		System.out.println(anther);
		scanner.close();
						}

	
	//サイコロ比較メソッド
	public static void co(){



		for(int i =0; i<4;i++){
			dice.Roll("S");  //水平軸に一回転
			for(int k =0;k<4;k++){
				dice.Roll("W");  //垂直軸に一回転
				for(int p=0;p<4;p++){
					dice.Roll("R"); //縦軸に一回転
					if(Arrays.equals(dice.num,dice2.num)){
						anther="No";
					}
				}
			}
		}
	}
}





class Dice {

	int num [];
	Dice(){
		num= new int[6];
	}

	int box=0;



	public void Roll(String order) {


		switch(order){//配列の各数字をサイコロの展開図に見立て動きを再現

		case "S" :

			box=num[0];
			num[0]=num[4];
			num[4]=num[5];
			num[5]=num[1];
			num[1]=box;


			break;

		case "N" :

			box=num[0];
			num[0]=num[1];
			num[1]=num[5];
			num[5]=num[4];
			num[4]=box;


			break;

		case "W" :

			box=num[0];
			num[0]=num[2];
			num[2]=num[5];
			num[5]=num[3];
			num[3]=box;


			break;

		case "E":


			box=num[0];
			num[0]=num[3];
			num[3]=num[5];
			num[5]=num[2];
			num[2]=box;


			break;

		case "R"://サイコロを縦軸で回転させる
			box=num[1];
			num[1]=num[2];
			num[2]=num[4];
			num[4]=num[3];
			num[3]=box;



		}


	}




}







Measured memory_bytes: 30164
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N;
    cin >> N;
    int l = -1,r = N;
    cout << 0 << endl;
    string S;
    cin >> S;
    if(S == "Vacant") {
        return 0;
    }
    while(l+1 < r) {
        int mid = (l+r)/2;
        cout << mid << endl;
        string T;
        cin >> T;
        if(T == "Vacant") {
            return 0;
        }
        if(mid%2 == 0) {
            if(S == T) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
        else {
            if(S != T) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
    }
    cout << l << endl;
}


Measured memory_bytes: 3768
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var s = o.m(m);
  var p = o.l();
  var ans = 0;
  for(var i = 0; i < 1<<n; i++){
    var x = xArray(0,m);
    for(var j = 0; j < n; j++){
      if(i&(1<<j)){
        for(var v = 0; v < m; v++)
        for(var k = 1; k <= s[v][0]; k++){
          if(s[v][k] === j+1){
            x[v] ^= 1;
            break;
          }
        }
      }
    }
    var f = 1;
    for(var j = 0; j < m && f; j++){
      if(x[j] !== p[j])f = 0;
    }
    if(f)ans++;
  }
  return ans;
}

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

#define int long long
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; }

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

	int a[100010];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}

	multiset<int> st;

	for(int i = 0;i < n;i++){
		auto idx = st.lower_bound(a[i]);
		if(idx != st.begin()){
			idx--;
			st.erase(idx);
		}
		st.insert(a[i]);
	}

	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int gcd(int a, int b) {
  if (a < b) {
	  return gcd(b, a);
	}
  if (b == 0) {
	  return a;
	}
  return gcd(b, a % b);
}

int main() {
  int N, X;
  cin >> N >> X;
  int ans = 0;
  for (int i = 0; i < N; i++) {
	  int x;
	  cin >> x;
	  ans = gcd(ans, abs(x - X));
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        String[] params = in.nextLine().split(" ");
        int[] hs = new int[n];
        for( int i = 0 ; i < n ; i++ ){
            hs[i] = Integer.parseInt( params[i]);
        }

        boolean flag = true;
        for( int i = 0 ; i < n - 1 ; i++ ){
            int prev = i == 0 ? 0 : hs[i-1];
            if( prev < hs[i]){
                hs[i] -= 1;
            }
            if( hs[i] > hs[i + 1 ]){
                flag = false;
                break;
            }
        }

        System.out.println( flag ? "Yes" : "No" );

    }

}


Measured memory_bytes: 47776
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;


#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define each(it,c) for(__typeof(c.begin()) it=c.begin(); it!=c.end(); it++)
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;
typedef map<int,int> mpii;
typedef priority_queue<int, vi, greater<int> > pqi;

typedef long long ll;


int main(){
	ll n,x;cin>>n>>x;
	ll a = n;
	n = n - x;
	while(x!=0){
		ll t = (n/x)*2*x;
		a += t;
		//cout<<n<<" "<<x<<" "<<t<<endl;
		ll y = x;
		x = n % x;
		n = y;
	}
	cout<<a-n<<endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

MOD = 10 ** 9 + 7


def f(l, r):
    return (l + r) * (r - l + 1) // 2


ans = 0
for i in range(K, N + 2):
    left = f(0, i - 1) % MOD
    right = f(N - i + 1, N) % MOD
    ans += (right - left + 1) % MOD
print(ans % MOD)


Measured memory_bytes: 9156
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())

	A := make([]int, N)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
		a[i] = A[i]
	}
	sort.Ints(a)
	max_a := a[len(a)-1]
	max_b := a[len(a)-2]

	for i := 0; i < N; i++ {
		if A[i] == max_a {
			fmt.Println(max_b)
		} else {
			fmt.Println(max_a)
		}
	}

}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 8192