akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    map<int, int> p,q;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(i%2==1)p[a]++;
        else q[a]++;
    }
    int nump=0,nump2=0,numq=0,numq2=0;
    int p1=0,q1=0;//,p2=0,q2=0;
    for(auto x:p){
        if(x.second>nump){
            nump2=nump;
            nump=x.second;
            //p2=p1;
            p1=x.first;
        }
        else if(x.second>nump2){
            nump2=x.second;
            //p2=x.first;
        }
    }
    for(auto x:q){
        if(x.second>numq){
            numq2=numq;
            numq=x.second;
            //q2=q1;
            q1=x.first;
        }
        else if(x.second>numq2){
            numq2=x.second;
            //q2=x.first;
        }
    }
    if(p1!=q1)cout<<n-nump-numq<<endl;
    else cout<<n-max(numq2+nump,nump2+numq)<<endl;
    //cout<<nump<<numq<<n<<nump2<<numq2<<endl;
    //cout<<p1<<p2<<q1<<q2<<endl;
}


Measured memory_bytes: 4992
#include<stdio.h>
char str[10000];
int main() {
  int i;
  fgets(str, 1000, stdin);
  for (i = 0; i < 1000; i ++) {
    if ('a' <= str[i] && str[i] <= 'z') str[i] -= 32;
  }
  printf("%s", str);
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
using namespace std;
int a[100];
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, p;
	while (cin >> n)
	{
		for (int i = 0;i < n;i++)
			cin >> a[i];
		int count = 0;
		for (int i = 1;i < n - 1;i++)
		{
			if (a[i - 1] < a[i] && a[i] < a[i + 1])
				count++;
			if (a[i - 1] > a[i] && a[i] > a[i + 1])
				count++;
		}
		cout << count << '\n';

	}

	return 0;
}

Measured memory_bytes: 888
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [Int] -> Int
solve bN as = cost
  where
  vA = VU.fromListN bN as
  acc = VU.scanl' (+) 0 vA

  enc (len,i) = len * bN + i
  size = bN*(bN+1)
  cost = buildVec VU.! (enc (bN,0))

  buildVec = VU.create $ do
    vec <- VUM.replicate size (-1)
    calc vec (bN,0)
    return vec
    where
      calc vec (1,_) = return 0
      calc vec (len,i) = do
        val <- VUM.read vec (enc (len,i))
        if val >= 0 then return val
          else do
          newVal <- top <$> minimumM (map f [1 .. len-1])
          VUM.write vec (enc (len,i)) newVal
          return newVal
        where
          top v = v + (acc VU.! (i+len)) - (acc VU.! i)
          f k = (+) <$> calc vec (k, i) <*> calc vec (len-k, i+k)

minimumM :: (Monad m, Ord a) => [m a] -> m a
minimumM [] = error "list is empty for minimumM"
minimumM (x:xs) = x >>= sub xs
  where sub []     !p = return p
        sub (x:xs) !p = do
          q <- x
          sub xs (min p q) 


readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents

-------------------------------------------------------------------------------

inp1 = "4\n10 20 30 40\n"
inp2 = "5\n10 10 10 10 10\n"
inp3 = "3\n1000000000 1000000000 1000000000\n"
inp4 = "6\n7 6 8 6 1 1\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
test1 = tv1 == 190
test2 = tv2 == 120
test3 = tv3 == 5000000000
test4 = tv4 == 68
alltest = test1 && test2 && test3 && test4



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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (n * (n + 1) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int mini1=min(a,b);
    int mini2=min(c,d);
    cout<<mini1+mini2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
//C - Candies
int main(void){
    int n,a1[100],a2[100],ans=0;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a1[i];
        if(i>0)a1[i]+=a1[i-1];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> a2[i];
    }
    for (int i = n-2; i >= 0; i--) {
        a2[i]+=a2[i+1];
    }
    for (int i = 0; i < n; i++) {
        if(a1[i]+a2[i]>ans)ans=a1[i]+a2[i];
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void Yes(){
	cout<<"Yes\n";
	exit(0);
}
void No(){
	cout<<"No\n";
	exit(0);
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin>>n;
	if(n<4||(n>4&&n<7))No();
	if(n%4==0||n%7==0)Yes();
	for(int i=1;i<=n/4+1;i++){
		int j=n-i*4;
		if(j%7)continue;
		else Yes();
	}
	No();
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string a;
  int o=1;
  cin>>a;
  if(a[6]=='1'&&a[5]=='0'){ cout<<"Heisei";o=0;}
  if(a[6]=='2'&&a[5]=='0') {cout<<"Heisei";o=0;}
  if(a[6]=='3'){ cout<<"Heisei";o=0;}
  if(a[6]=='4'){ cout<<"Heisei";o=0;}
  if(a[6]!='1'&&a[5]=='0'&&o!=0||a[6]!='2'&&o!=0&&a[5]=='0'||o!=0&&a[6]!='3'||a[6]!='4'&&o!=0) cout<<"TBD";
  cout<<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const ll INF=1e18;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    ll dp[n+1][2];
    for(int i=0;i<n;i++){
        dp[i][0]=-INF;
        dp[i][1]=-INF;
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        dp[i+1][0]=max(dp[i][0]+a[i],dp[i][1]-a[i]);
        dp[i+1][1]=max(dp[i][0]-a[i],dp[i][1]+a[i]);
    }
    cout << dp[n][0] << endl;
}

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

// conj(x) : complex conjugate,(0,1)->(0,-1)
// abs(x) : dist between(0,0) and x
// norm(x) : abs(x) * abs(x)
// arg(x) : argment,[-PI,PI]
using CP = complex<long double>;
#define X real()
#define Y imag()
const long double PI = acos(-1.0L);
const long double EPS = 1e-10;
// cos a
long double costh(long double a, long double b,
                  long double c) {
  return (b * b + c * c - a * a) / (2.0L * b * c);
}

// dot(a,b) = |a||b|cos x
long double dot(CP a, CP b) { return (conj(a) * b).X; }
// cross(a,b) : area of parallelogram
// sign : a-> b ,counter clockwise? + : -
long double cross(CP a, CP b) { return (conj(a) * b).Y; }
long double corner(CP a, CP b) {
  //[0,PI]
  return acos(dot(a, b) / (abs(a) * abs(b)));
}

CP intersectionLL(CP a, CP b, CP c, CP d) {
  return a + (b - a) * (cross(d - c, c - a) /
                        cross(d - c, b - a));
}

bool on_seg(CP s, CP t, CP p) {
  // if not use end point, dot(s - p, t - p) < 0
  return abs(cross(s - p, t - p)) <= 1e-10 &&
         dot(s - p, t - p) <= 0;
}

// crossing lines? (a,b) and (c,d)
bool iscross(CP a, CP b, CP c, CP d) {
  // parallel
  if(abs(cross(a - b, c - d)) <= 1e-10) {
    return on_seg(a, b, c) || on_seg(a, b, d) ||
           on_seg(c, d, a) || on_seg(c, d, b);
  }
  CP isp = intersectionLL(a, b, c, d);
  return on_seg(a, b, isp) && on_seg(c, d, isp);
}

long long a, b;
vector<CP> va, vb;

long double solve();
long double calc(const vector<CP> &v, const CP s,
                 const CP t);

int main() {
  cout << fixed << setprecision(10);
  cin >> a >> b;
  va.resize(a);
  vb.resize(b);
  for(int i = 0; i < a; ++i) {
    long long x, y;
    cin >> x >> y;
    va[i] = CP(x, y);
  }
  for(int i = 0; i < b; ++i) {
    long long x, y;
    cin >> x >> y;
    vb[i] = CP(x, y);
  }
  long double res = solve();
  if(res >= inf)
    cout << "-1" << endl;
  else
    cout << res << endl;
  return 0;
}

long double solve() {
  return min({(long double)inf, calc(va, vb[0], vb[1]),
              calc(vb, va[0], va[1])});
}

long double calc(const vector<CP> &v, CP s, CP t) {
  long long n = v.size();
  vector<long double> dist(n, inf);
  dist[0] = 0.0L;
  struct data {
    int n;
    long double d;
    bool operator<(const data &r) const { return d > r.d; }
  };
  priority_queue<data> pq;
  pq.push({0, 0.0L});
  while(pq.size()) {
    data now = pq.top();
    pq.pop();
    if(dist[now.n] < now.d) continue;
    for(int i = 0; i < n; ++i)
      if(i != now.n && !iscross(s, t, v[now.n], v[i])) {
        data nextp = now;
        nextp.n = i;
        nextp.d += abs(v[now.n] - v[i]);
        if(dist[nextp.n] > nextp.d) {
          dist[nextp.n] = nextp.d;
          pq.push(nextp);
        }
      }
  }

  return min((long double)inf, dist[1] + abs(s - t));
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
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;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i*j==n){
				if(i<=9&&j<=9){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <list>

class Edge{
public:
    int from, to;
    long long cost;
    Edge(): from(0), to(0), cost(0){};
    Edge(int u, int v, long long w): from(u), to(v), cost(w){};
    ~Edge(){};
};

// Dijkstra's Algorithm
void Dijkstra(std::vector<Edge> &edge, int N, int start, std::vector<long long> &distance)
{
    typedef std::pair<long long, int> P;
    const long long infty = 1e+18;

    // initialize
    distance.clear();
    for(int i=0; i<N; i++) distance.push_back(infty);
    distance[start] = 0;
    std::priority_queue<P, std::vector<P>, std::greater<P> > q;
    q.push(P(0, start));

    std::vector<std::list<P> > edge_list(N);
    for(auto &&itr = edge.begin(); itr != edge.end(); itr++){
        edge_list[itr->from].push_back(P(itr->cost, itr->to));
    }

    // update
    while(!q.empty()){
        int d = q.top().first;
        int u = q.top().second;
        q.pop();
        if(distance[u] < d) continue; // not updated

        for(auto &&itr = edge_list[u].begin(); itr != edge_list[u].end(); itr++){
            int v = itr->second;
            long long w = itr->first;
            if(distance[u] + w < distance[v]){
                distance[v] = distance[u] + w;
                q.push(P(distance[v], v));
            }
        }
    }
}

// directed graph -> undirected graph
void to_undirected(std::vector<Edge> &edge)
{
    int M = edge.size();
    for(int i=0; i<M; i++){
        edge.push_back(Edge(edge[i].to, edge[i].from, edge[i].cost));
    }
}

int main()
{
    int N;
    scanf(" %d", &N);
    std::vector<Edge> edge(N);
    for(int i=0; i<N-1; i++){
        scanf(" %d %d %lld", &(edge[i].from), &(edge[i].to), (&edge[i].cost));
        edge[i].from--; edge[i].to--;
    }

    to_undirected(edge);
    std::vector<long long> distance;
    Dijkstra(edge, N, 0, distance);
    for(int i=0; i<N; i++) printf("%lld\n", distance[i] % 2);
}

Measured memory_bytes: 17252
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.endaa(),0),pop_back()
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

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

    int n,k;
    cin>>n>>k;
    set<int>s;
    for(int i=0;i<k;i++)
    {
        int d;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            int a;
            cin>>a;
            s.insert(a);
        }
    }
    int r = n - s.size();
    cout<<r;
    return 0;
}	

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

using namespace std;

#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;

const int N = 123456;
const int M = 1234567;

int main(int argc, char const *argv[])
{
	
	#ifdef Cyborg1o1
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	

	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, a, b;
	cin >> n >> a >> b;

	int cnt = b - a + 1;

	if(a > b || (n == 1 && a != b)){
		cout << 0 << endl;
	}
	else if(n == 1 && a == b){
		cout << 1 << endl;
	}
	else{
		ll upper = a + (n - 1) * 1ll * b;
		ll lower = b + (n - 1) * 1ll * a;
		cout << upper - lower + 1 << endl;
	}

	return 0;					
}

Measured memory_bytes: 256
i = input().split()
W = int(i[0])
H = int(i[1])
x = int(i[2])
y = int(i[3])
r = int(i[4])
if W < x + r or x - r < 0 or H < y + r or y - r < 0:
    print("No")
else:
    print("Yes")


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

int main(){
  ll K, N, i, ans = 0;
  vector<ll> A(200000);
  cin >> K >> N;
  rep(i, N){
    cin >> A[i];
  }
  A[N] = K + A[0];
  rep(i, N){
    A[i] = A[i+1] - A[i];
  }
  rep(i, N){
    if(A[i] > ans){
      ans = A[i];
    }
  }
  

  cout << K - ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys

def main():
    argv = input().split()
    A = int(argv[0])
    B = int(argv[1])
    C = int(argv[2])
    print(judge(A, B, C))

def judge(A, B, C):
    if (A < C and C < B) or (C < A and B < C):
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int a,b;
    cin>>a>>b;
    int k=max(a*b,max(a+b,a-b));
    cout<<k<<endl;


}
//Alhamdulillah







Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 1e5+9;
const ll MOD = 1e9+7;

struct graph {
    vector<int> next;
    ll dp[2] = {-1, -1}; // 0: white, 1: black
};

int n;
graph g[N];

ll mod(ll n) {
    n %= MOD;
    if(n < 0)  n += MOD;
    return n;
}

ll mulmod(ll &a, ll b) {
    return a = mod( mod(a) * mod(b) );
}

ll rec(int node, int color, int from) {
    if(g[node].dp[color] != -1)  return g[node].dp[color];

    ll ans = 1;
    for(auto nn : g[node].next) {
        if(nn == from)  continue;
        if(color == 0)  mulmod(ans, rec(nn, 0, node) + rec(nn, 1, node));
        if(color == 1)  mulmod(ans, rec(nn, 0, node));
    }
    return g[node].dp[color] = ans;
}

int main() {
    cin >> n;
    for(int i = 0; i < n-1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].next.push_back(y);
        g[y].next.push_back(x);
    }

    cout << mod(rec(0, 0, -1) + rec(0, 1, -1)) << endl;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    int n,k,ans=1;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        ans = min(2*ans,ans+k);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int a[60];
signed main() {
    int N; cin >> N;
    
    vector<pii> ops;
    int ma = -INF, mi = INF;
    int cnt_a = 0, cnt_b = 0;
    rep(i,0,N) {
        cin >> a[i];
        chmax(ma, a[i]);
        chmin(mi, a[i]);
        if(a[i] < 0) cnt_a++;
        else if(a[i] > 0) cnt_b++;
    }

    // 全て正でない
    if(ma <= 0) {
        repr(i,N-2,0) {
            ops.push_back(make_pair(i+2, i+1));
            a[i] += a[i+1];
        }
    }
    // 全て負でない
    else if(mi >= 0) {
        rep(i,0,N-1) {
            ops.push_back(make_pair(i+1, i+2));
            a[i+1] += a[i];
        }
    }
    // 正負どちらもある
    else {
        // mode = 1 ... 全て正に, 0 ... 全て負にする
        int mode = (abs(ma) > abs(mi));

        int idx = 0;
        while(a[idx] != (mode ? ma : mi)) idx++;

        while(abs(a[idx]) < abs( (mode ? mi : ma) )) {
            ops.push_back(make_pair(idx+1, idx+1));
            a[idx] += a[idx];
        }

        rep(i,0,N) {
            if(mode && a[i] < 0) {
                // first を second に足す
                ops.push_back(make_pair(idx+1, i+1));
                a[i] += a[idx];
            }
            else if(!mode && a[i] > 0) {
                ops.push_back(make_pair(idx+1, i+1));
                a[i] += a[idx];
            }
        }

        if(mode == 1) {
            rep(i,0,N-1) {
                ops.push_back(make_pair(i+1, i+2));
                a[i+1] += a[i];
            }
        }
        else {
            repr(i,N-2,0) {
                ops.push_back(make_pair(i+2, i+1));
                a[i] += a[i+1];
            }
        }
    }

    cout << ops.size() << endl;
    for(auto e : ops) {
        printf("%lld %lld\n", e.first, e.second);
    }
    
    /*
    // debug
    rep(i,0,N) cout << (i != 0 ? " " : "") << a[i];
    cout << endl;
    */
    return 0;
}

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

int main() {
    int64_t L,R;
    cin >> L >> R;
    
    int64_t ans = 1e+8;
    if ( R - L >= 2019 ){
        ans = 0;
    } else {
        for ( int64_t i = L; i < R; ++i){
            for ( int64_t j = i + 1; j <=R; ++j){
                ans = min(ans,i*j%2019);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = ''
while n != 0:
    if n % (-2) == 0:
        n //= (-2)
        ans +='0'
    else:
        n = (n - 1) // (-2)
        ans +='1'
if ans=='':
  print(0)
else:
  print(ans[::-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAXN 200005
#define LL long long
#define P int(1e4+7)
using namespace std;

int N;

vector<int> adj[MAXN];

int deg[MAXN], c[MAXN];
int dp[MAXN];
bool vis[MAXN];
int ans1, ans2;
void dfs(int u){
	//cout<<"dfs: "<<u<<endl;
	
	vis[u] = 1;
	dp[u] = (c[u]==1) - (c[u]==0);
	
	int v, m1 = -1e9;
	for(int k=0;k<adj[u].size();k++){
		v = adj[u][k];
		if(vis[v]) continue;
		
		
		dfs(v);
		ans2 = max(ans2, m1 + dp[u] + 1 + dp[v]);
		m1 = max(m1, 1 + dp[v]);
	}
	
	if(m1 != -1e9) dp[u] += m1;
	
	ans2 = max(ans2, dp[u]);//cout<<"dp[u]: "<<u<<" "<<dp[u]<<" "<<ans2<<endl;
	return;
}

string s;



int main(){
	ios::sync_with_stdio(0);
	
	cin>>N;
	
	int u,v;
	for(int i=1;i<N;i++){
		cin>>u>>v;
		
		adj[u].push_back(v);
		adj[v].push_back(u);
		++deg[u]; ++deg[v];
	}
	
	cin>>s;
	s = "$" + s;
	
	int N1 = N;
	queue<int> q;
	for(int i=1;i<=N;i++){
		if(s[i]=='B' && deg[i]==1){
			q.push(i);
		}
	}
	
	//
	while(!q.empty()){
		u = q.front(); q.pop();
		--deg[u]; 
		vis[u] = 1;
		--N1;
		
		for(int k=0;k<adj[u].size();k++){
			v = adj[u][k];
			if(vis[v]) continue;
			--deg[v];
			if(deg[v]==1 && s[v]=='B'){
				q.push(v);
			}
		}
	}
	
	ans1 = 2*(N1-1);
	for(int i=1;i<=N;i++){
		if(vis[i]) continue;
		
		c[i] = (deg[i] + (s[i]=='B') + 1) % 2;
		//cout<<"c[i]: "<<i<<" "<<c[i]<<" "<<deg[i]<<endl;
		ans1 += c[i];
	}
	
	if(N1==1){
		cout<<ans1<<endl;
		return 0;
	}
	
	//ans2
	for(int i=1;i<=N;i++){
		if(!vis[i]){
			dfs(i);
			break;
		}
	} 
	
	
	if(ans2 > 0) ans2 = ans1 - ans2 - 1;
	else ans2 = ans1;
	//cout<<ans1<<" "<<ans2<<endl;
	cout<<max(0, min(ans1, ans2))<<endl;
	
	return 0;
}

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

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	LL N, C;
	cin >> N >> C;
	vector<LL> X(N), V(N), sum1(N, 0), sum2(N, 0), max1(N, 0), max2(N, 0);
	REP(i, N) cin >> X[i] >> V[i];

	sum1[0] = V[0];
	sum2[0] = V[N - 1];
	cerr << sum1[0] << " " << sum2[0] << endl;
	FOR(i, 1, N){
		 sum1[i] = sum1[i - 1] + V[i];
		 sum2[i] = sum2[i - 1] + V[N - 1 - i];
		 cerr << sum1[i] << " " << sum2[i] << endl;
 	}
	cerr << endl;

	max1[0] = sum1[0] - X[0];
	max2[0] = sum2[0] - (C - X[N - 1]);
	cerr << max1[0] << " " << max2[0] << endl;
	FOR(i, 1, N){
		 max1[i] = max(max1[i - 1], sum1[i] - X[i]);
		 max2[i] = max(max2[i - 1], sum2[i] - (C - X[N - 1 - i]));
		 cerr << max1[i] << " " << max2[i] << endl;
	}
	
	LL ret = 0;
	REP(i, N){
		ret = max(ret, max1[i]);
		ret = max(ret, max2[i]);
		if(1 < N && i < N - 1) ret = max(ret, max1[i] - X[i] + max2[N - 2 - i]);
		if(1 < N && i < N - 1) ret = max(ret, max2[i] - (C - X[N - 1 - i]) + max1[N - 2 - i]);
	}

	cout << max(0LL, ret) << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int d[n];
	REP(i, n) cin >> d[i];
	sort(d, d+n);
	cout << d[n/2]-d[n/2-1] << endl;
}


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

int n;
long long p,q,t,ans=0;

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

    if(n==1){
    cout<<t<<endl;return 0;}

    for(int i=2;i<=n;i++)
    {
    cin>>q;
    ans+=min(t,q-p);
    p=q;
    }
    cout<<ans+t<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split(" ")))
# 割り切れる
if sum(A)%len(A) == 0:
  avrA = sum(A)/len(A)
# 割り切れない
else:
  if (sum(A) / len(A)) < (sum(A) // len(A) + 0.5):
    avrA = sum(A) // len(A)
  else:
    avrA = sum(A) // len(A) +1

dst = 0
for i in A:
  dst += (i-avrA)**2
print(int(dst)) 

#print(int(avrA))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
using namespace std;

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	int b[1000];
	
	int ans = 0;
	for (int i = 0; i <m ; i++)
	{
		cin >> b[i];
	}
	for (int j = 0; j < n; j++)
	{
		int g = 0;

		for (int i = 0; i < m; i++)
		{
			int aa;
			cin >> aa;
			g += aa * b[i];

		}
		g += c;
		if (g > 0)
		{
			ans++;
		}

	}
	cout << ans << endl;

}

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

int main() {
  long n,m,ans=0;
  cin >> n >> m;
  vector<long> a(n),x(m),y(m),aa;
  vector<vector<long>> moridata(n,vector<long>(0));
  vector<vector<long>> group;
  vector<bool> check(n);
  for(long i=0;i<n;i++) cin >> a[i];
  for(long i=0;i<m;i++) {
    cin >> x[i] >> y[i];
    moridata[x[i]].push_back(y[i]);
    moridata[y[i]].push_back(x[i]);
  }

  for(long i=0;i<n;i++) {
    if(check[i]) continue;
    group.push_back({});
    queue<long> q;
    q.push(i);
    while(q.size()!=0) {
      group.back().push_back(a[q.front()]);
      check[q.front()]=true;
      for(long j=0;j<moridata[q.front()].size();j++) {
        if(check[moridata[q.front()][j]]) continue;
        q.push(moridata[q.front()][j]);
      }
      q.pop();
    }
  }
  if(group.size()==1) {
    cout << 0 << endl;
    return 0;
  }
  if(n<group.size()*2-2) {
    cout << "Impossible" << endl;
    return 0;
  }
  for(long i=0;i<group.size();i++) {
    sort(group[i].begin(),group[i].end());
    ans+=group[i][0];
    for(long j=1;j<group[i].size();j++) aa.push_back(group[i][j]);
  }
  sort(aa.begin(),aa.end());
  for(long i=0;i<group.size()-2;i++) ans+=aa[i];

  cout << ans << endl;
}

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

typedef long long ll;

int main() {
    int n,q,right;
    ll sum,ans;
    cin >> n >> q;
    vector<ll> a(n),x(q);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < q; ++i) {
        cin >> x[i];
    }
    
    for(int i = 0; i < q; ++i) {
        right = sum = ans = 0;

        for (int left = 0;left < n;++left) {
            while (right < n && sum + a[right] <= x[i]) {
                sum += a[right];
                ++right;
            }
            ans += (right - left);
            if (right == left){
                ++right;
            }else{
              sum -= a[left];
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3560
#include <cstdio>
#include <iostream>
#define debug(...) fpritnf(stderr,__VA_ARGS__)
using namespace std;
inline char nc()
{
	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++; 
}
template<class T> void read(T &x)
{
	x=0; int f=1,ch=nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x*=f;
}
typedef long long ll;
const int maxk=300+5;
const int maxn=300+5;
int mod;
int n,k;
int C[maxn][maxn];
int f[maxk][maxn],g[maxk][maxn][2];
inline int add(int x) {return x>=mod?x-mod:x;} 
int main()
{
	read(n),read(k),read(mod);
	for(int j=1;j<=n;++j) f[k][j]=1;
	for(int i=0;i<=n;++i)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;++j) C[i][j]=add(C[i-1][j]+C[i-1][j-1]);
	}
	for(int i=k;i>1;--i) 
	{
		g[i-1][0][0]=1;
		for(int j=1;j<=n;++j)
		{
			g[i-1][j][0]=add(g[i-1][j-1][0]+g[i-1][j-1][1]);
			for(int k=1;k<=j;++k)
			{
				g[i-1][j][1]=(g[i-1][j][1]+(ll)g[i-1][j-k][0]*C[j][k]%mod*f[i][k])%mod;
			}
		}
		for(int j=1;j<=n;++j) f[i-1][j]=add(g[i-1][j][0]+g[i-1][j][1]);
	}
	printf("%d\n",f[1][n]);
	return 0;
}

Measured memory_bytes: 1664
/**
 *  author: mahfuzz
 *  created: 10.04.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << #x << ':' << x << "\n"
typedef long long ll;


int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string s; cin >> s;
    
    for(int i = 0; s[i]; i++){
        if(s[i] == '7'){
            cout << "Yes\n";
            return 0;
        }
    }
        
    cout << "No\n";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 1) {
    cout << "Odd";
  } else {
    cout << "Even";
  }
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char
import qualified Data.Map.Strict as M

fun :: M.Map Int Int -> Int
fun m = sum [ k*l | (k,l) <- M.toList m ]

push :: M.Map Int Int -> Int -> M.Map Int Int
push m k = M.insertWith (+) k 1 m

popMin :: M.Map Int Int -> (Int,M.Map Int Int)
popMin m = let (k,i) = M.findMin m in if i == 1 then (k,M.delete k m) else (k,M.update (\x -> Just $ x-1) k m)

popMax :: M.Map Int Int -> (Int,M.Map Int Int)
popMax m = let (k,i) = M.findMax m in if i == 1 then (k,M.delete k m) else (k,M.update (\x -> Just $ x-1) k m)

main :: IO ()
main = do
    n <- readLn
    xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let (as,oo) = splitAt n xs
        (bs,cs) = splitAt n oo
        bb = V.fromList bs
    let u :: V.Vector Int
        u = V.create $ do
            u <- VM.new (n+1)
            u' <- VM.new (n+1)
            VM.write u 0 $ sum as
            VM.write u' 0 $ M.fromListWith (+) [(a,1) | a <- as]
            forM_ [1..n] $ \i-> do
                s <- VM.read u (i-1)
                m <- VM.read u' (i-1)
                let (k,m') = popMin $ push m (bb V.! (i-1))
                VM.write u i $ s-k+(bb V.! (i-1))
                VM.write u' i m'
            return u
        v :: V.Vector Int
        v = V.create $ do
            v <- VM.new (n+1)
            v' <- VM.new (n+1)
            VM.write v n $ sum cs
            VM.write v' n $ M.fromListWith (+) [(c,1) | c <- cs]
            forM_ [n-1,n-2..0] $ \i -> do
                s <- VM.read v (i+1)
                m <- VM.read v' (i+1)
                let (k,m') = popMax $ push m (bb V.! i)
                VM.write v i $ s-k+(bb V.! i)
                VM.write v' i m'
            return v
    print $ maximum [ u V.! i - v V.! i | i <- [0..n] ]

Measured memory_bytes: 117116
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B,C;
	bool check[105];
	for(int i = 0; i < 105; i++){

		check[i] = false;
	}

	scanf("%d %d %d",&A,&B,&C);

	for(int i = 1; ; i++){

		int tmp = (i*A)%B;

		if(tmp == C){

			printf("YES\n");
			return 0;
		}

		if(check[tmp]){

			printf("NO\n");
			return 0;
		}
		check[tmp] = true;
	}

	return 0;
}


Measured memory_bytes: 3760
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    LL n, m;
    cin >> n >> m;
    if(abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }
    LL ans = 1;
    REP(i, n) {
        ans *= i+1;
        ans %= MOD;
    }
    REP(i, m) {
        ans *= i+1;
        ans %= MOD;
    }
    if(n == m) {
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  string s;
  cin >> s;
  int ans = 700;
  rep(i, 3){
    if(s[i] == 'o') ans+=100;
  }
  cout << (ans) << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
k = int(input())

cand = []
for i in range(len(s)):
    temp = ''
    for j in range(k):
        if i + j >= len(s):continue
        temp += s[i + j]
        cand.append(temp)

cand.sort()
#print(cand)
ans = cand.pop(0)
k -= 1
while k != 0:
    temp = cand.pop(0)
    if temp == ans:continue 
    ans = temp
    k -= 1

print(ans)

Measured memory_bytes: 10484
#include <iostream>
#define llint long long

using namespace std;

llint N, A, B;

int main(void)
{
	cin >> N >> A >> B;
	
	if(B < A){
		cout << 0 << endl;
		return 0;
	}
	if(N == 1){
		cout << (A == B) << endl;
		return 0;
	}
	cout << (B*(N-1)+A) - (A*(N-1)+B) + 1 << endl;
	return 0;
}

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

typedef long long ll;
ll MOD = 1e9+7;

int number[10]={-1,2,5,5,4,5,6,3,7,6};
string dp[10100];//i本のマッチ棒で作ることのできる最大の数の組

int main()
{
	int n,m;
	char a[9];
	cin>>n>>m;
	for(int i=0;i<m;i++)
		cin>>a[i];
	sort(a,a+m, greater<>());
	fill(dp,dp+10100,"0");
	//初期値は1ケタの整数
	for(int i=0;i<m;i++)
		dp[number[a[i]-'0']]=max(dp[number[a[i]-'0']], string(1, a[i]));
	//ここからdp
    for(int j=0;j<m;j++)
	{
        for(int i=1;i<10001;i++)
		{
			if(dp[i]!="0")
			{
				int targetindex=i+number[a[j]-'0'];
				string temp=dp[i]+a[j];
				if(temp.size()>dp[targetindex].size())
					dp[targetindex]=temp;
				else if(temp.size()==dp[targetindex].size() && temp>dp[targetindex])
					dp[targetindex]=temp;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 43520
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int m, f, r;
	while (true) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		if ((m == -1 || f == -1) || (m + f < 30)) {
			cout << "F" << endl;
		}
		else if (m + f >= 80) {
			cout << "A" << endl;
		}
		else if (m + f < 80 && m + f >= 65) {
			cout << "B" << endl;
		}
		else if (m + f < 65 && m + f >= 50 || (m + f < 50 && m + f >= 30 && r >= 50)) {
			cout << "C" << endl;
		}
		else if (m + f < 50 && m + f >= 30) {
			cout << "D" << endl;
		}
	}
}


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

int main()
{
  string a, b;
  cin >> a >> b;
  string S = a + b;
  int c = stoi(S);
  if (ceil(sqrt(c)) == floor(sqrt(c)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;


int main(){
	
	int n;cin >> n;
	
	REP(i,n){
		int a;cin >> a;
		if(a % 2){
			cout << "first" << endl;
			return 0;
		}
	}
	
	cout << "second" << endl;
	
	return 0;
}


Measured memory_bytes: 256
/* Author rumoisen */
/* created 2018/10/13 */

#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include<iostream>
#include <algorithm>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==0||b==0) cout<<"Zero"<<endl;
    if(0>=a&&b>=0) cout<<"Zero"<<endl;
    if(a>0&&b>0) cout<<"Positive"<<endl;
    if(0>a&&b<0){
        if((b-a)%2==1) cout<<"Positive"<<endl;
        if((b-a)%2==0) cout<<"Negative"<<endl;
    }
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	ll cou = 0;
	while (*max_element(all(a)) > 0) {
		//DISP(a);
		for (ll i = 0; i < n; i++) {
			if((i == 0 || a[i-1]==0) && a[i]) {
				cou++;
			}
		}
		for(ll i=0;i<n;i++) {
			if(a[i]) a[i]--;
		}
		//cout<<cou<<" ";
	}
	cout<<cou;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main(void){
    
    string s;
    cin >> s;
    int len = s.size();
    map<char,int>mp{};
    
    for(int i=0;i<len;i++){
        mp[s[i]] = 1;
    }
    
    if(len == mp.size()) cout << "yes" << endl;
    else cout << "no" <<endl;
}

Measured memory_bytes: 3640
def resolve():
    s = int(input())
    dp = [0] * (s + 1)
    dp[0] = 1
    for i in range(1, s + 1):
        for j in range(0, (i - 3 + 1)):
            dp[i] += dp[j]
            dp[i] %= 10**9 + 7

    print(dp[s])

resolve()

Measured memory_bytes: 9180
n = int(input())
tran = [list(map(int, input().split())) for i in range(n)]
house_list = [[[0] * 10 for i in range(3)] for j in range(4)]

for x in range(n):
    b = tran[x][0] - 1
    f = tran[x][1] - 1
    r = tran[x][2] - 1
    house_list[b][f][r] += tran[x][3]

for i in range(4):
    for j in range(3):
        [print(f" {house_list[i][j][k]}", end="") for k in range(10)]
        print()
    if i != 3:
        [print("#", end="") for i in range(20)]
        print()



Measured memory_bytes: 5636
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n;
    cin>>n;
    if(n%2==0) cout<<n<<endl;
    else cout<<2*n<<endl;
    return 0;
}

Measured memory_bytes: 256
def input_int():
    return map(int, input().split())
def one_int():
    return int(input())
def one_str():
    return input()
def many_int():
    return list(map(int, input().split()))

# N すぬけ君人数
# K お菓子種類
N, K = input_int()

output = []
for i in range(K):
    # [2]
    a = many_int()
    # [1, 2]
    b = many_int()
    output += b
    
print(N - len(set(output)))

Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int d;
	cin >> d;
	if(d == 25) cout << "Christmas" <<endl;
	if(d == 24) cout << "Christmas Eve" <<endl;
	if(d == 23) cout << "Christmas Eve Eve" <<endl;
	if(d == 22) cout << "Christmas Eve Eve Eve" <<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
N = len(S)
num_swap = 0
for i in range(N):
    if num_swap > 24:
        print('No')
        break
    if S[i] != T[i]:
        s, t = S[i], T[i]
        S = S.replace(s, '0').replace(t, s).replace('0', t)
        num_swap += 1
else:
    if S == T:
        print('Yes')
    else:
        print('No')

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

using namespace std;

int main(){
cin.sync_with_stdio(0); cin.tie(0);
int a, b, c, d;
cin >> a >> b >> c >> d;
int maxbeg = max(a, c);
int mined = min(b, d);
	int ans = max(0, mined - maxbeg);
	cout << ans;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxN = 2e5 + 10;
int a[maxN] = {0};
int main() {
	int k, n, max = -1;
	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i + 1] - a[i] > max) {
			max = a[i + 1] - a[i];
		}
	}
	if (a[0] + k - a[n - 1] > max) {
		max = a[0] + k - a[n - 1];
	}
	cout << k - max << endl;
	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B = sr().split()
A = int(A)
B = int(float(B)*100 + 0.5)
answer = A*B // 100
print(answer)


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

string S, T;

int main(){
  cin >> S >> T;
  if(T.substr(0, S.size()) == S && T.size() == S.size() + 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3636
/*空港 A, B, C があり、それぞれの空港の間では、双方向に飛行機が運航しています。

空港 A, B 間の飛行時間は片道 
P時間、
空港 B, C 間の飛行時間は片道 
Q時間、
空港 C, A 間の飛行時間は片道 
R時間です。

いずれかの空港からスタートして他の空港に飛行機で移動し、さらにそのどちらでもない空港に飛行機で移動するような経路を考えます。

飛行時間の和は最短で何時間になるでしょうか。*/

#include<iostream>
#include<stdio.h>
#include <algorithm>

using namespace std;

int main(){

	int n;
	cin>>n;
	int sum1=0,sum2=0;
	int difference;
	int ans;
	int w[n];

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

	for (int t = 0; t < n; ++t)
	{
		for (int i = 0; i < n; ++i)
		{
			if(i<t){
				sum1+=w[i];
			}else{
				sum2+=w[i];
			}

		}
		ans=abs(sum1-sum2);
		if(difference>ans){	
			difference=ans;
		}
		sum1=0;
		sum2=0;
	}

	printf("%d\n",difference);
	return 0;
}




Measured memory_bytes: 256