akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, k;
    cin >> n >> k;
    auto a = make_vec<int>({n, n});
    rep(i, n) rep(j, n) cin >> a[i][j];

    int v = n + n + 2;
    int s = n + n, t = s + 1;
    mcf_graph<int, ll> g(v);
    int cost_max = 1000000000;
    rep(i, n) rep(j, n) {
        g.add_edge(i, n + j, 1, cost_max - a[i][j]);
    }
    rep(i, n) g.add_edge(s, i, k, 0);
    rep(j, n) g.add_edge(n + j, t, k, 0);
    g.add_edge(s, t, n * k, cost_max);
    auto [flow, cost] = g.flow(s, t, n*k);
    ll sum = 1LL * cost_max * n * k - cost;
    vector<string> ans(n, string(n, '.'));
    auto es = g.edges();
    for (auto e : es) {
        if (e.from != s && e.to != t && e.flow > 0) {
            ans[e.from][e.to - n] = 'X';
        }
    }
    cout << sum << '\n';
    rep(i, n) cout << ans[i] << '\n';
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >> s;
REP(i,s.size()){
if(i%2==0)cout << s[i];
}
}


Measured memory_bytes: 3708
#define _CRT_SECURE_NO_WARNINGS
 #define _USE_MATH_DEFINES
 #include <iostream>
 #include <list>
 #include <cstdio>
 #include <cmath>
 #include <cstring>
 #include <string>
 #include <vector>
 #include <algorithm>
 #include <utility>
 #include <queue>
 #include <iomanip>
 #define INF 2147483647
  
 using namespace std;

 int gcd(int a, int b)
{
	int tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	while (1) {
		r = a % b;
		if (r == 0) break;
		a = b;
		b = r;
	}

	return (b);
}

 int main(void)
 {
	 int a, b;

	 cin >> a >> b;

	 cout << gcd(a, b) << endl;


	 return (0);
 }

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

int main() {
  int n,m; cin>>n>>m;
  set<int> s;
  s.insert(0);
  int sum=0;
  rep(i,m){
    int a; cin>>a;    
    sum+=a;
    set<int> t;  t=s;
    for(int j: t){
      s.insert(j+a);
    }
  }
  int x=0;
  for(int i:s){
    if(i<=sum/2){x=max(x,i);}
  }
  cout<<max(0,sum-x-x-1)<<endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin>>H>>W;
    set<pi> Set;
    rep(i,W) Set.ins({i,i});
    multiset<int> freq;
    rep(i,W) freq.ins(0);
    rep(i,H){
        int l,r; cin>>l>>r; l--;
        auto itr = Set.lower_bound(pi(l,0));
        int t=-1;
        while(itr!=Set.end() && itr->fi<=r){
            chmax(t,itr->se);
            freq.erase(freq.find(itr->fi - itr->se));
            Set.erase(itr++);
        }
        if (t!=-1 && r<W){
            Set.ins({r,t});
            freq.ins(r-t);
        }
        cout<<(freq.empty()?-1:*freq.begin()+i+1)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 22412
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var a = int.Parse(_[1]);
            var b = int.Parse(_[2]);

            Console.WriteLine(n * a > b ? b : n * a);
        }
    }
}


Measured memory_bytes: 13140
from collections import deque

N = int(input())
A = input().split()

offset = 0 if N % 2 == 0 else 1
ans = deque([A[0]])
for i in range(1, N):
    if (i+offset) % 2 == 0:
        ans.append(A[i])
    else:
        ans.appendleft(A[i])

print(" ".join(ans))


Measured memory_bytes: 26564
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int A[300][300];
int main() {
	int N, M;
	cin >> N >> M;
	rep(i, N) {
		rep(j, M) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	int l = 0, r = N;
	while (r - l > 1) {
		int m = (l + r) / 2;
		bool OK = 1;
		int Rank[300] = { 0 };
		bool NG[300] = { 0 };
		while (1) {
			bool update = 0;
			int Cnt[300] = { 0 };
			rep(i, N) {
				if (Rank[i] >= M) {
					OK = 0;
					break;
				}
			}
			if (!OK) break;
			rep(i, N) {
				Cnt[A[i][Rank[i]]]++;
			}
			rep(i, M) {
				if (Cnt[i] > m) {
					update = 1;
					NG[i] = 1;
				}
			}
			rep(i, N) {
				while (Rank[i] < M&&NG[A[i][Rank[i]]]) Rank[i]++;
			}
			if (!update) break;
		}
		if (OK) {
			r = m;
		}
		else {
			l = m;
		}
	}
	cout << r << endl;
}

Measured memory_bytes: 640
_,*s=*$<
eval"_,*A="+_.split*?,
f=->i{s[i]&.chop&.bytes{|x|A[y=s[i].sum-x-75]+=1;$*[i]=""<<y+65;f[i+1]if~0<A[x-=65]-=1;A[x]+=1;A[y]-=1}||puts(:Yes,$*)+exit}
f[0]
puts:No

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

class Dice{
public:
    int f[6];
    Dice(){}
    void roll_x(){ roll(1, 2, 4, 3);}
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_z(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
        int t= f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
    
    void move(char c){
        if ( c == 'E') for(int i=0; i<3; i++) roll_y();
        if ( c == 'N') roll_z();
        if ( c == 'S') for(int i=0; i<3; i++) roll_z();
        if ( c == 'W') roll_y();
    }
};


int main(){
    
    Dice d;
    string order;
    
    for(int i=0; i<6; i++) cin >> d.f[i];
    
    
    cin >> order;
    
    
    for(int j=0; j<order.size(); j++){
       d.move(order[j]);
    }
    
    cout << d.f[0] << endl;
    
    return 0;
    
}




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

int main() {
    int H, W, m;
    cin >> H >> W >> m;
    map<int, int> tate, yoko;
    set<pair<int, int>> st;
    rep(i, m) {
        int h, w;
        cin >> h >> w;
        yoko[w]++;
        tate[h]++;
        st.insert({h, w});
    }

    int mah = 0, maw = 0;
    for (auto p : tate)
        mah = max(mah, p.second);

    for (auto p : yoko)
        maw = max(maw, p.second);

    set<int> sth;
    for (auto p : tate) {
        if (mah == p.second)
            sth.insert(p.first);
    }

    set<int> stw;
    for (auto p : yoko) {
        if (maw == p.second)
            stw.insert(p.first);
    }

    int ans = mah + maw - 1;
    for (auto h : sth) {
        for (auto w : stw) {
            if (st.find({h, w}) == st.end()) {
                ans = mah + maw;
                cout << ans << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 73832
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
using namespace std;
int n,m,w[55],f[55][55][105][105],sum,ans;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
int dp(int l,int r,int k,int p){//l-r取k次得到的最大值 
	if(k==0) return 0;
	if(f[l][r][k][p]!=-1) return f[l][r][k][p];
	int t1,t2;
	t1=dp(l+1,r,k-1,p)+w[l];
	if(p) t1=max(t1,dp(l+1,r,k-1,p-1));
	t2=dp(l,r-1,k-1,p)+w[r];
	if(p) t2=max(t2,dp(l,r-1,k-1,p-1));
	f[l][r][k][p]=max(t1,t2);
	return f[l][r][k][p];
}
signed main(){
	memset(f,-1,sizeof(f));
	n=read(),m=read();
	for(int i=1;i<=n;i++) w[i]=read(),sum+=w[i];
	for(int i=0;i<=m;i++){//i枚举刚好取i次 
		int t;
		if(i>=n){
			t=sum;
			for(int j=1;j<=n;j++) if(w[i]<0) t-=w[i];
		}
		else t=dp(1,n,i,m-i);
		ans=max(ans,t);
	}
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 260864
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int main(){

    int N, M;
    cin >> N >> M;
    ll p = 1;
    for(int i = 0; i < M; i++)
        p *= 2;
    
    cout << (1800 * M + 100 * N) * (p) << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	ll a[n+1];rep(i,1,n+1)cin>>a[i];
	ll b[n+1];rep(i,1,n+1)b[i]=0;
	vll v;
	for(int i=n;i>0;--i){
		ll x=a[i],cnt=0;
		for(int j=i;j<=n;j+=i)cnt+=b[j];
		if(x%2!=cnt%2)b[i]=1,v.pb(i);
	}
	sort(all(v));
	cout<<sz(v)<<"\n";
	rep(i,0,sz(v))cout<<v[i]<<" ";
	
	
	
	return 0;
}



Measured memory_bytes: 5108
def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=(N//I):
                R.append(N//I)
        I += 1
    return L+R[::-1]

N = int(input())
Count = 0
for T in range(1,N+1,2):
    if len(Div(T))==8:
        Count += 1
print(Count)

Measured memory_bytes: 9192
n=int(input())
a=list(map(int,input().split()))
a.append(0)
b=[]
for i in range(n):
  if a[i]!=a[i+1]:
    b.append(a[i])
n=len(b)
s=n
for i in range(n-1):
  if b[i]!=b[i+1]:
    s=i
    if b[s]<b[s+1]:
      f=0
    else:
      f=1
    break
p=1
for i in range(s+1,n-1):
  if f==0:
    if b[i]>b[i+1]:
      p+=1
      if i==n-2 or b[i+1]>b[i+2]:
        f=1
      else:
        f=0
  else:
    if b[i]<b[i+1]:
      p+=1
      if i==n-2 or b[i+1]>b[i+2]:
        f=1
      else:
        f=0
print(p)

Measured memory_bytes: 14484
#include<bits/stdc++.h>
using namespace std;
#define Int long long
#define N 100100

int a[N];
Int dp[102][N];
int w[N],v[N];

int main(){
    int n,W;
    cin>>n>>W;
    for(int i = 1;i<=n;i++)cin>>w[i]>>v[i];
    for(int i = 1;i<=n;i++)
    {
        for(int j = 0;j<=W;j++){if((!i)||(!j)){dp[i][j]=0;continue;}if(w[i]<=j){dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);}else dp[i][j]=dp[i-1][j];}
    }
    cout<<dp[n][W]<<endl;
}


Measured memory_bytes: 78592
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N, K;
int64_t a[100001];
int64_t sum[100001];
int64_t score[100001];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);
	

	in >> N >> K;
	for (size_t i = 1; i <= N; i++)
	{
		in >> a[i];
		sum[i] = sum[i - 1] + a[i];
		score[i] = score[i - 1] + std::max<int64_t>(0, a[i]);
	}

	int64_t res = sum[N];
	for (size_t i = 1; i+K - 1 <= N; i++)
	{
		res = std::max(res, score[N] - (score[i + K-1] - score[i - 1]) + std::max<int64_t>(0, sum[i + K - 1] - sum[i - 1]));
	}

	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

using tf = tuple<ll, ll, ll, ll, ll>;

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll h, w, k;
    cin>>h>>w>>k;
    ll x1, y1, x2, y2;
    cin>>x1>>y1>>x2>>y2;
    x1--; y1--; x2--; y2--;
    vector<string> grid(h); cin>>grid;

    if (grid[x1][y1] == '@') {
        cout<<-1<<endl;
        return 0;
    }

    vector<LP> dir{
        LP(1, 0),
        LP(0, 1),
        LP(-1, 0),
        LP(0, -1),
    };

    priority_queue<tf, vector<tf>, greater<tf>> q;
    rep(i, 4) q.emplace(0, 0, x1, y1, i);
    vector<vvl> dist(h, vvl(w, vl(4, LINF)));
    while (!q.empty()) {
        tf p = q.top(); q.pop();
        ll dn = get<0>(p);
        ll dd = get<1>(p);
        ll x = get<2>(p);
        ll y = get<3>(p);
        ll di = get<4>(p);
        if (dist[x][y][di] != LINF) continue;

        dist[x][y][di] = dn + (dd > 0);
        rep(i, 4) {
            LP nd = dir[i];
            ll nx = x + nd.fi;
            ll ny = y + nd.se;
            if (nx < 0 || nx >= h || ny < 0 || ny >= w || grid[nx][ny] == '@') continue;
            ll ndn = di == i ? dn + (dd + 1) / k : dn + (dd > 0);
            ll ndd = di == i ? (dd + 1) % k : 1;
            q.emplace(ndn, ndd, nx, ny, i);
        }
    }

    ll ans = LINF;
    rep(i, 4) chmin(ans, dist[x2][y2][i]);
    if (ans == LINF) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 144948
#include<bits/stdc++.h>
#define M 200005
#define LL long long
using namespace std;
const int mod=1e9+7;
int n,A[M],B[M],m=0;
LL pre[M],dp[M];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	for(int i=1;i<=n;i++)
		if(A[i]!=A[i-1])B[++m]=A[i];
	n=m;
	dp[0]=1;
	for(int i=1;i<=n;i++){
		dp[i]=(dp[i-1]+pre[B[i]])%mod;
		pre[B[i]]=(pre[B[i]]+dp[i-1])%mod;
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {
	ll n, a, b, c, d;
	ll mini, maxi;
	ll mid;
	bool flag = false;

	cin >> n >> a >> b >> c >> d;

	mid = b - a;

	FOR(i, 0, n - 1) {
		mini = c*(n - 1 - i) - d*i;
		maxi = -c*i + (n - 1 - i)*d;
		if (mini <= mid&&mid <= maxi) {
			flag = true;
		}
	}

	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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


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

    int n,m;
    cin >> n >> m;
    priority_queue<int> q;
    rep (i, n) {
        int a;
        cin >> a;
        q.push(a);
    }
    rep (i, m) {
        int a = q.top();
        q.pop();
        q.push(a/2);
    }
    ll ans=0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3860
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String ans = helper(s,t);
        System.out.println(ans);
    }
    static String helper(String s, String t){
        ArrayList<Integer>[] S = new ArrayList[26];
        ArrayList<Integer>[] T = new ArrayList[26];
        for(int i=0;i<26;i++){
            S[i]=new ArrayList<>();
            T[i]=new ArrayList<>();
        }
        for(int i=0;i<s.length();i++){
            S[s.charAt(i)-'a'].add(i);
            T[t.charAt(i)-'a'].add(i);
        }
        boolean[] used = new boolean[26];
        HashSet<Integer> check = new HashSet<>();
        for(int i=0;i<26;i++){
            for(int j=0;j<26;j++){
                if(used[j]) continue;
                if(solve(S[i],T[j])){
                    check.add(i);
                    used[j] = true;
                    break;
                }
            }
        }
        if(check.size()==26) return "Yes";
        else return "No";
    }
    static boolean solve(ArrayList<Integer> a, ArrayList<Integer> b){
        if(a.size()!=b.size()) return false;
        for(int i=0;i<a.size();i++){
            if((int)a.get(i)!=(int)b.get(i)) return false;
        }
        return true;
    }
}


Measured memory_bytes: 50232
from sys import stdin
n = int(stdin.readline().rstrip())
arg = list(map(int, stdin.readline().rstrip().split()))

flag = 0

for i in arg:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            flag = 1
            break

if flag == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 2940
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

amini = [ai-(i+1) for i,ai in enumerate(a)]
amini.sort()
b = amini[n//2]

print(sum([abs(ai-(b+i+1)) for i, ai in enumerate(a)]))

Measured memory_bytes: 27280
Module _20190422

    Sub Main()

        Dim sNumber() As Char = Console.ReadLine().ToCharArray

        Dim iMin As Integer = 9999999
        Dim iCalc As Integer

        For i As Integer = 0 To sNumber.Length - 3

            iCalc = 753 - CInt(sNumber(i).ToString & sNumber(i + 1).ToString & sNumber(i + 2).ToString)

            If iCalc < 0 Then

                iCalc = iCalc * -1

            End If

            If iMin > iCalc Then

                iMin = iCalc

            End If

        Next

        Console.WriteLine(iMin)

    End Sub

End Module

Measured memory_bytes: 11220
n,k = map(int,input().split())
score = list(map(int,input().split()))
t = list(map(int,input().replace('r','2').replace('s','0').replace('p','1')))
lt = [t[i::k] for i in range(k)]
ans = 0
for it in range(k):
    string = lt[it]
    dp = [[0 for _ in range(3)]for j in range(len(string)+1)]
    for i in range(len(string)):
        for j in range(3):
            for l in range(3):
                if l==j:
                    continue
                elif l==string[i] and dp[i+1][l]<dp[i][j]+score[l]:
                    dp[i+1][l] = dp[i][j]+score[l]
                elif dp[i+1][l]<dp[i][j]:
                    dp[i+1][l] = dp[i][j]
    ans += max((dp[len(string)][0], dp[len(string)][1], dp[len(string)][2]))
print(ans)


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

int main(){
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for(int x = 0 ; x <= k ; ++x){
        for(int y = 0 ; y <= k ; ++y){
            int z = s - x - y;
            if(0 <= z && z <= k){
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    int N;cin>>N;
    bool used[N];
    fill_n(used,N,false);
    int a[N];REP(i,N)cin>>a[i];
    REP(i,N)a[i]--;
    int cnt=0;
    int i=0;
    while(true){
        if(i==1){
            cout<<cnt<<endl;
            return 0;
        }
        if(used[i]){
            cout<<-1<<endl;
            return 0;
        }
        used[i]=true;
        i = a[i];
        cnt++;
    }
}

Measured memory_bytes: 896
input()
x=1
l=sorted(map(int,input().split()))
for i in l:
  if i==0:
    print(0)
    break
  x*=i
  if x>10**18:
    print(-1)
    break
else:
  if x>10**18:
    print(-1)
  else:
    print(x)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

const double PI = std::acos(-1.0);

double A, B, X;

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

  std::cin >> A >> B >> X;

  double t;

  if(X >= 0.5 * A * A * B){
      t = std::atan(2.0 * (A * A * B - X) / A / A / A) * 180.0 / PI;
  }else{
      t = std::atan(A * B * B / 2.0 / X) * 180.0 / PI;
  }

  printf("%.10f\n", t);
}


Measured memory_bytes: 256
L = gets.split.map(&:to_i)
B = L[0].times.map { gets.to_i }
n = L[0]
T = [0, 1, 2, 3]
S = Array.new(n - 1){ T }

m = T.product(*S).map do |types|
  h = n.times.group_by{|i| types[i] }
  unless (1 .. 3).all?{|g| h[g] }
    100_000_000
  else
    (1 .. 3).map do |g|
      t = h[g].map{|i| B[i]}
      (t.inject(0,&:+) - L[g]).abs + 10 * (t.size - 1)
    end.inject(0, &:+)
  end
end.min
puts m


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

using namespace std;

int main()
{
	int a[31] = {0};

	int v;
	for (int i = 0; i < 28; i++) {
		cin >> v;
		a[v] = 1;
	}
	for (int i = 1; i <= 30; i++) {
		if (a[i] == 0)
			cout << i << endl;
	}
	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b;
    cin >> a >> b;
    if(a>b){
        rep(i,a) cout << b;
    }
    else{
        rep(i,b) cout << a;
    }
    cout << endl;
}

Measured memory_bytes: 256
from fractions import math

N = int(input())

def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

Factor = {}
for n in range(2, N+1):
    ns = prime(n)
    for k, v in ns.items():
        if not k in Factor.keys():
            Factor[k] = v
        else:
            Factor[k] += v

c74 = 0
c24 = 0
c14 = 0
c4 = 0
c2 = 0
for num, co in Factor.items():
    if co >= 74:
        c74 += 1
    if co >= 24:
        c24 += 1
    if co >= 14:
        c14 += 1
    if co >= 4:
        c4 += 1
    if co >= 2:
        c2 += 1

ans = c74 + c24*(c2-1) + c14*(c4-1) + c4*(c4-1)*(c2-2)//2
print(ans)



Measured memory_bytes: 5052
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge>>G;

int a;
int main() {
	string h, ans = "First";
	cin >> h;
	if (h.length() % 2 == 0) { ++a; }
	if (h[0] == h[h.length() - 1]) { ++a; }
	if (a == 1) { ans = "Second"; }
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
  int n,x,y;
  cin>>n;
  x=n%10;
  n=n/10;
  y=n%10;
  n=n/10;
  if(x==7)
    cout<<"Yes";
  else if(y==7)
    cout<<"Yes";
  else if(n==7)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

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

int main()
         {
           string s;
           cin>>s;
           
           if((s[2] == s[3]) && (s[4] == s[5]))
           {
            cout<<"Yes"<<endl;
           }
           else
             cout<<"No"<<endl;
           
           
         }

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
	int N;
	long long int K;
	static int A[200000];
	scanf("%d%lld", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		A[i]--;
	}

	// next[k][i]: 2^k
	const int LOG = 62;
	static int next[LOG][200000];
	for (int i = 0; i < N; i++) {
		next[0][i] = A[i];
	}
	for (int k = 1; k < LOG; k++) {
		for (int i = 0; i < N; i++) {
			next[k][i] = next[k - 1][next[k - 1][i]];
		}
	}

	int ans = 0;
	for (int k = LOG - 1; k >= 0; k--) {
		int use = (K & (1LL << k)) != 0;
		if (use) {
			ans = next[k][ans];
		}
	}
	printf("%d\n", ans + 1);

	return 0;
}


Measured memory_bytes: 50948
require 'matrix'

N, M, C = gets.split.map(&:to_i)
cs = Vector[*Array.new(N, C)]
bs = Vector[*gets.split.map(&:to_i)]
as_list = []
N.times do
  as_list.push gets.split.map(&:to_i)
end

A = Matrix[*as_list]
evals = A * bs + cs
ans = evals.to_a.select{|e| e > 0}.length

print("#{ans}\n")


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

int main(){
  string a,b;
  cin >>a>>b;
  int c=a.size(),d=b.size();
  string ans="";
  for(int i=0;i<d;i++){
    ans = ans+a.at(i)+b.at(i);
  }
  if(c-d == 1) ans += a.at(c-1);
  cout << ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    if(N == 1){
        cout << abs(a[0] - W) << endl;
        return 0; 
    } else {
        cout << max(abs(a[N-1]-W), abs(a[N-1]-a[N-2])) << endl;;
        return 0;
    }


}

Measured memory_bytes: 3592
#include<stdio.h>

int main()
{
int h,w,i,t,r=1,j=1;
while(1){
scanf("%d %d",&h,&w);
if(h==0&&w==0)break;
j=1;
r=1;
for(i=0;i<h;i++){
j=r;
for(t=0;t<w;t++){
if((j%2)==1)printf("#");
if((j%2)==0)printf(".");
j++;
}
printf("\n");
r++;
}
printf("\n");
}
return 0;
}

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

int main(void){
  int N;
  cin >> N;
  int X;
  cin >> X;
  vector<int> pow(N);
  int sum = 0;
  for(int i = 0;i < N; i++){
  cin >> pow.at(i);
  sum += pow.at(i);  
}
  sort(pow.begin(),pow.end());
  int ans;
  ans = (X-sum)/pow.at(0);
  cout << N + ans << endl;
}

Measured memory_bytes: 256
p = 10**9+7; M=10**5;
F = [1]; FI=[0]*(M+1)
for i in xrange(1,M*2+1):F+=[i*F[i-1]%p]
FI[M]=pow(F[M],p-2,p)
for i in xrange(M,0,-1):FI[i-1]=i*FI[i]%p
H,W,A,B = map(int,raw_input().split())
hx,hy = B+1,H-A
ans = 0
while hx <= W and hy > 0:
	tmp = F[hx+hy-2]*FI[hx-1]*FI[hy-1]%p * F[W-hx+H-hy]*FI[W-hx]*FI[H-hy]%p
	ans = (ans + tmp) % p
	hx += 1; hy -= 1
print ans

Measured memory_bytes: 12668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , ans = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l , r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());//int型
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());

        sc.close();
        int ans = 1000;

        ans = Math.min(a+b,ans);
        ans = Math.min(b+c,ans);
        ans = Math.min(c+a,ans);

        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#pragma GCC target ("sse4")
    #include <bits/stdc++.h>
    #include <algorithm>
    #define brijesh ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    #define pb push_back
    #define popb pop_back
    #define l1 long long
    #define vi vector<int>
    #define vl vector<l1>
    #define vs vector<string>
using namespace std;
    int main() {
        brijesh;
        l1 i = 0, count = 0, max = 0;
        string s;
        cin >> s;
        if(s=="SRR"||s=="RRS")
            cout<<2;
      else if(s=="SSR"||s=="RSS"||s=="SRS"||s=="RSR")
        	cout<<1;
              else if(s=="RRR")
              cout<<3;
              else
              cout<<0;
    }

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define INF INT_MAX/2

int main(){
	int r, g, b;
	cin >> r >> g >> b;
	int a = r * 100 + g * 10 + b;
	if (a % 4 == 0) { out("YES"); }
	else { out("NO"); }
}



Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = input()

    cnt = [0 for _ in range(2019)]
    cnt[0] += 1
    dec = 1
    num = 0
    for i in reversed(s):
        num += int(i) * dec
        num %= 2019
        dec *= 10
        dec %= 2019
        cnt[num] += 1

    ans = 0
    for c in cnt:
        ans += c * (c - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10876
S = input()
n, m = 0, 1
s = []
patern = 0
for i in range(len(S)):
    s.append(S[i])
while n + m < len(s):
    if s[n] is 'x':
        if s[-m] is not 'x':
            m -= 1
            patern += 1
    else:
        if s[-m] is 'x':
            n -= 1
            patern += 1
        elif s[-m] is not s[n]:
            patern = -1
            break
    n += 1
    m += 1
if patern != -1:
    print(patern)
else:
    print(patern)


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  string ans;
  if(s=="Sunny") 
    ans = "Cloudy";
  if(s=="Cloudy") 
    ans = "Rainy";
  if(s=="Rainy") 
    ans = "Sunny";
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

int a[100000];

int main(void) {
    int i, n;
    scanf("%d",&n);
    REP (i,n) scanf("%d",&a[i]);
    ll ans = 0;
    int p = 1;
    REP (i,n) {
        int x = (a[i] - 1) / p;
        if (x > 0) {
            ans += x;
            a[i] = 1;
        }
        p = max(p,a[i] + 1);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 768
import collections

Card = collections.namedtuple('Card', ['suit', 'value'])


def bubble_sort(array):
    a = array[::]
    for i in range(len(a)):
        for j in reversed(range(i + 1, len(a))):
            if a[j].value < a[j - 1].value:
                a[j], a[j - 1] = a[j - 1], a[j]
    return a


def selection_sort(array):
    a = array[::]
    for i in range(len(a)):
        min_j = i
        for j in range(i, len(a)):
            if a[j].value < a[min_j].value:
                min_j = j
        a[i], a[min_j] = a[min_j], a[i]
    return a


if __name__ == '__main__':
    n = int(input())
    cards = [Card(suit, int(value)) for suit, value in input().split()]
    stable = sorted(cards, key=lambda a: a.value)

    bubble = bubble_sort(cards)
    print(' '.join(''.join(map(str, card)) for card in bubble))
    print('Stable' if bubble == stable else 'Not stable')

    selection = selection_sort(cards)
    print(' '.join(''.join(map(str, card)) for card in selection))
    print('Stable' if selection == stable else 'Not stable')

Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  int p,q,r;
  p=max(a,b);
  q=min(a,b);
  r=p%q;
  while(r>0){
    p=q;
    q=r;
    r=p%q;
  }
  return q;
}
int main() {
  int k,a,b,c;
  int64_t s;
  cin>>k;
  s=0;
  for(a=1;a<=k;a++){
    for(b=1;b<=k;b++){
      for(c=1;c<=k;c++){
        s+=gcd(gcd(a,b),c);
      }
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

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

int var;

string ss,rh,lh;

bool solve(string s)
{
    //cout << s << endl;
    if(s.size() == 1)//1 letter
    {
        if(s == "T") return true;
        if(s == "F") return false;
        return ( (var>> (s[0]-'a') )&1) ;
    }

    //2 letter
    if(s.size() == 2 && s[0] == '-') return !solve(s.substr(1,1));

    int bra = 0;
    if(s[0] == '-' && s[1] == '(')
    {
        bra = 1;
        for(int i=2;i<s.size() - 1;i++)
        {
            if(s[i] == '(') bra++;
            if(s[i] == ')') bra--;
        
            if(bra == 0) break;
        }
        if(bra == 1) return !solve(s.substr(1,s.size() -1));
    }
    
    bra = 0;
    bool inside = true;
    //2 operand
    REP(s.size() -1)
    {
        if(s[i] == '(') bra++;
        if(s[i] == ')') bra--;
        if(bra == 0) inside == false;

        if(s[i] == '+' && bra==0) return solve(s.substr(0,i)) || solve(s.substr(i+1, s.size() - 1 - i));

        if(s[i] == '*' && bra==0) return solve(s.substr(0,i)) && solve(s.substr(i+1, s.size() - 1 - i));
 
        if(s[i] == '>' && bra==0)
        {
            if( (solve(s.substr(0,i-1)) ==true) && (solve(s.substr(i+1,s.size()-i-1)) == false) ) return false;
            else return true;
        }
    }

    if(inside) return solve(s.substr(1, s.size()-2) );
 
    cout << "no match" << endl;
    return 0;
}

int main()
{
    while(cin >> ss  && ss!="#")
    {
        int m2 = 0;
        while(1)
        {
            m2 = ss.find("--");
            if(m2 == -1) break;
            ss.replace(m2, 2, "");
        }
        //cout << ss << endl;
        
        REP(ss.size())if(ss[i] == '=')
        {
            lh = ss.substr(0,i);
            rh = ss.substr(i+1,ss.size()-i-1);
            break;
        }
        int ans = true;

        for(var = 0;var<( 1 << 11);var++)if(solve(lh) != solve(rh)) ans = false;
        //if(solve(lh) != solve(rh)) ans = false;
        if(ans ) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 904
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n;cin>>n;
  vector<Pll> LR,RL;
  rep(i,n){
    ll l,r;cin>>l>>r;
    LR.push_back({l,-r});
  }
  //Lが最も大きいものが最初
  sort(all(LR));
  ll l1 = LR[n-1].first;
  ll r1 = -LR[n-1].second;
  LR.pop_back();

  rep(i,n-1){
    RL.push_back({-LR[i].second, LR[i].first});
  }

  sort(all(RL));
  ll max_range = 0;
  rep(i,n-1){
    chmax(max_range, RL[i].first - RL[i].second);
  }

  ll ans = 0;
  chmax(ans, max(-1ll, min(r1, RL[0].first) - l1) + max_range);

  ll l2 = -LINF, r2 = LINF;
  rep(i,n-1){
    if(i!=0) chmax(ans, max(-1ll, min(r1, RL[i].first) - l1) + max(-1ll, r2 - l2));
    chmax(l2, RL[i].second);
    chmin(r2, RL[i].first);
  }
  chmax(ans, max(-1ll, r1 - l1) + max(-1ll, r2 - l2));
  cout<<ans+2<<endl;
  return 0;
}

Measured memory_bytes: 4848
from collections import deque

K = int(input())

G = [None]*K
for i in range(K):
    G[i] = ((10*i % K, 0), ((i+1) % K, 1))
s = 1

dist = [10**9] * K
S = deque([s])
T = deque()
dist[s] = 0

d = 0
while S:
    while S:
        v = S.popleft()
        for w, c in G[v]:
            if d+c < dist[w]:
                dist[w] = d+c
                if c:
                    T.append(w)
                else:
                    S.append(w)
    S, T = T, S
    d += 1

print(dist[0]+1)


Measured memory_bytes: 30580
// use proconio::input;
use std::io;

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

fn main() {
    loop {
        let vec = read_vec::<String>();
        let a: i32 = vec[0].parse().unwrap();
        let b: i32 = vec[2].parse().unwrap();

        match &*vec[1] {
            "+" => println!("{}", a + b),
            "-" => println!("{}", a - b),
            "*" => println!("{}", a * b),
            "/" => println!("{}", a / b),
            _ => break,
        }
    }
}



Measured memory_bytes: 5032
#include<stdio.h>

int binary_search(int *a, int n, int key)
{
    int left = 0, right = n, mid;
    while(left < right){
        mid = (left + right) / 2;
        if(a[mid] == key) return 1;
        else if(key < a[mid]) right = mid;
        else left = mid + 1;
    }
    return 0;
}

int main()
{
    int i, n, q, key, a[100000], cnt;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &key);
        if(binary_search(a, n, key)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 2120
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
a=input()
b=input()
c=input()
def f(a,b,c):
  re=2
  if a==b:
    re-=1
  if c==b:
    re-=1
  if a==c:
    re-=1
  return max(0,re)
for i in range(n):
  count += f(a[i],b[i],c[i])
print(count)

Measured memory_bytes: 38384
/*

This is a good question to learn DP with bitmasking.

Here when i was unaware of how to use DP with bitmasking what i was doing is
just maintaining a set which will store that what column-index of previous rows 
has been visited and then comparing it with set everytime.

With help of bitmasking we can easily store this thing in a variable with the 
help of bits, and just check if it is visited or not by checking if bit is
set or not.

Space and Time complexity:- O(N * 2^N) because 2^N masks are possible

created by sanyam singhal
*/

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

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)
const ll inf = 1e18;

int n;  
int mat[22][22];

ll visited_all;
ll dp[22][1LL<<22];

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

ll recursive_solve(int i, int n, ll mask){
  if(visited_all==mask)
    return 1;
  // else if(i==n)
  //   return 0;
  else if(dp[i][mask]!=-1)
    return dp[i][mask];
  else{
    ll ans=0;
    for(int j=0; j<n; j++){
      ll curr_mask = (1<<j);
      if(mat[i][j]==1 &&  ((mask&curr_mask) == 0)){
          ans = (ans + recursive_solve(i+1, n, (mask|curr_mask)))%mod;
      }
    }
    return dp[i][mask]=ans;
  }
}

void solve(){ 
  cin>>n;
  visited_all = (1<<n)-1;
  // cout<<visited_all<<endl;
  loop(i, 0, n)
    loop(j, 0, n)
      cin>>mat[i][j];
  memset(dp, -1, sizeof(dp));
  cout<<recursive_solve(0, n, 0LL)<<endl;
}

int main(){

  fastIO;
  // take_fileIO();
  solve();
  return 0;
}

Measured memory_bytes: 721152
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define re register
#define LL long long
#define MOD 998244353
#define MAXN 100005
using namespace std;
LL n,ans,bs[3*MAXN];
LL rd(){
	LL x=0,tp=1;char c;c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
struct Graph{
	LL m,sqr,sg[MAXN],f[MAXN];
	vector<int>e[MAXN];
	void work(){
		int x,y;
		m=rd();sqr=sqrt(2*m);
		for(int i=1;i<=m;i++){
			x=rd(),y=rd();
			if(x>y)swap(x,y);
			e[x].push_back(y);
		}
		for(int i=n;i>=1;i--){
			set<int>s;
			int sz=e[i].size();
			for(int j=0;j<sz;j++)s.insert(sg[e[i][j]]);
			while(s.count(sg[i]))sg[i]++;
			(f[sg[i]]+=bs[i])%=MOD;
			// printf("sg[%d]=%d\n",i,sg[i]);
		}
	}
}g[3];
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("shit.out","w",stdout);
	n=rd();
	bs[0]=1;LL fuck=1000000000000000000ll%MOD;
	for(int i=1;i<=3*n;i++)bs[i]=bs[i-1]*fuck%MOD;
	for(int i=0;i<3;i++)g[i].work();
	for(int i=0;i<=g[0].sqr;i++)
		for(int j=0;j<=g[1].sqr;j++)
			(ans+=g[0].f[i]*g[1].f[j]%MOD*g[2].f[i^j]%MOD)%=MOD;
	printf("%lld\n",ans);
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 18944