akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  const int MAX = 100000;
  int b[MAX + 5] = {0};
  rep(i, n) {
    int a; cin >> a;
    b[a]++;
  }

  int ans = 0;
  for (int i = 2; i <= MAX; i++)
    ans = max(ans, b[i]+b[i-1]+b[i-2]);
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 640
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def main():
    x,y,z,k=MI()
    set_=set()
    A=sorted(LI(),reverse=True)
    B=sorted(LI(),reverse=True)
    C=sorted(LI(),reverse=True)
    Q=[[(A[0]+B[0]+C[0])*(-1),0,0,0]]
    heapify(Q)
    set_.add((0,0,0))
    i=0
    ans=[]
    xl,yl,zl=0,0,0
    al=[]
    al=[[0,0,0]]
    while i<k:
        #print(Q)
        a,u,v,w=heappop(Q)
        ans.append([-a,u,v,w])
        print(-a)
        i+=1
        if u+1<x and (u+1,v,w) not in set_:
            heappush(Q,[-A[u+1]-B[v]-C[w],u+1,v,w])
            set_.add((u+1,v,w))
        if v+1<y and (u,v+1,w) not in set_:
            heappush(Q,[-A[u]-B[v+1]-C[w],u,v+1,w])
            set_.add((u,v+1,w))
        if w+1<z and (u,v,w+1) not in set_:
            heappush(Q,[-A[u]-B[v]-C[w+1],u,v,w+1])
            set_.add((u,v,w+1))
if __name__=="__main__":
    main()
    

    
    

    

    
    



    

    
    


Measured memory_bytes: 79324
fn main() {
  fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
  }
  let num = read::<i32>();
  let mut ans = 1;
  loop {
    if (ans+1)*(ans+1) > num {
      break;
    } else {
      ans += 1;
    }
  }
  println!("{}", ans*ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main() {
    int n, r[MAX];
    cin >> n;

    for (int i = 0; i < n; i++) cin >> r[i];

    int maxv = MAX * -10000;
    int minv = r[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, r[i] - minv);
        minv = min(minv, r[i]);
    }

    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3860
from collections import Counter
n, m, k = map(int, input().split())

class UnionFind:
    def __init__(self, val):
        self.parent = self
        self.val = val
        self.rank = 0
        self.size = 1

    def get_root(self):
        n = self
        while n.parent is not n:
            n = n.parent
        return n

    def find_set(self):
        return self.get_root().val


friends = []
for i in range(n + 1):
    friends.append(UnionFind(i))

graph = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
    x, y = friends[a], friends[b]
    x_root, y_root = x.get_root(), y.get_root()
    if x_root.rank == y_root.rank:
        y_root.parent = x_root
        x_root.rank += 1
    elif x_root.rank > y_root.rank:
        y_root.parent = x_root
    else:
        x_root.parent = y_root

block = [[] for _ in range(n + 1)]
for _ in range(k):
    c, d = map(int, input().split())
    block[c].append(d)
    block[d].append(c)


labels = [None] * (n + 1)
parents = [0] * (n + 1)
for i in range(1, n + 1):
    u = friends[i]
    parents[i] = u.get_root().val
CounterDict = Counter(parents)

for i in range(len(parents)):
    p = parents[i]
    labels[i] = [p, CounterDict.get(p)]

ans = []
for i in range(1, n + 1):
    num = labels[i][1] - 1
    for j in graph[i]:
        if labels[i][0] == labels[j][0]:
            num -= 1
    for k in block[i]:
        if labels[i][0] == labels[k][0]:
            num -= 1
    ans.append(num)
print(*ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;

ll lpow(int p, int q) {
	ll ans = 1;
	ll pp = p;
	while (q) {
		if (q % 2) {
			ans *= pp;
			ans %= MOD;
		}
		q /= 2;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}

ll com(int n, int r) {
	if (n < r || n < 0 || r < 0)	return 0;
	ll ans = 1;
	int k = n - r;

	rep1(i, n) {
		ans *= i;
		ans %= MOD;
	}

	rep1(i, r) {
		ans *= lpow(i, MOD - 2);
		ans %= MOD;
	}

	rep1(i, k) {
		ans *= lpow(i, MOD - 2);
		ans %= MOD;
	}

	return ans;
}

int main() {
	int n, p;
	cin >> n >> p;
	int od = 0, ev = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 0)ev++;
		else od++;
	}

	ll k = 0;
	for (int i = 0;od >= 2 * i + p;i++) {
		k += com(od, 2 * i + p);
	}

	cout << (ll)pow(2,ev) * k << endl;
}

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

int main()

{
   int N,t,sum;
   cin>>N;
    t=N;
   while(N>0)
   {
          
       sum+=N%10;
       N/=10;
        
        
    }
    
    if(t%sum==0)
    {
    cout<<"Yes"<<endl;
    }
    else
    {
    cout<<"No"<<endl;
   
}
    }


Measured memory_bytes: 256
n,x = map(int,input().split())
if x> 0:
    p = list(map(int,input().split()))
else:
    print(n)
    exit()

i = n
c = 0
while c <= 100:
    i = n - c
    if not i in p:
        break

    i = n + c
    if not i in p:
        break

    c += 1
    
print(i)

Measured memory_bytes: 9180
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    string A,B;
    cin>>A>>B;
    FORI(i,0,N)
    {
        cout<<A[i]<<B[i];
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    string ans;
    if (s == "ABC") ans = "ARC";
    else ans = "ABC";
    cout << ans;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;


//ここから編集する
char board[2][52];
ll mod = 1000000007l;
bool nowTate(int num){
    return board[0][num] == board[1][num];
}

ll calc(int start,int end,bool isTate){
    if(start == 0){
        if(nowTate(start)){
            return 3 * calc(start+1,end,true) % mod;
        }else{
            return 6 * calc(start + 2,end,false) % mod;
        }
    }
    if(start == end) return 1;
    if(isTate){
        if(nowTate(start)){
            return 2 * calc(start+1,end,true) % mod;
        }else{
            return 2 * calc(start + 2,end,false) % mod;
        }
    }else{
        if(nowTate(start)){
            return calc(start+1,end,true) % mod;
        }else{
            return 3 * calc(start+2,end,false) % mod;
        }
    }

}

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

    ll res = calc(0,n,true);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<priority_queue<int>> lines(n);
  int q = in();
  rep(i,q){
    int kind = in();
    if(kind==0){
      int t = in();
      int x = in();
      lines[t].emplace(x);
    }else if(kind==1){
      int t = in();
      if(lines[t].size()){
        cout << lines[t].top() << endl;
      }
    }else{
      int t = in();
      if(lines[t].size()){
        lines[t].pop();
      }
    }
  }
}



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

int main(void){
  int w,a,b;
  cin >> w >> a >> b;

  if((b <= a && a <= b+w) ||
     ((a <= b && b <= a+w))){
      cout << 0 << endl;
  }
  else{
    cout << max(b-(a+w),a-(b+w)) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, k = map(int, readline().split())


graph = [[] for _ in range(n + 1)]
cnt = [0] * (n + 1)
for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
    cnt[a] += 1
    cnt[b] += 1
ans = 1

mod = 10 ** 9 + 7
kaidan = [1] * (10 ** 5 + 1)
gyaku = [1] * (10 ** 5 + 1)

for i in range(1, 10 ** 5 + 1):
    kaidan[i] = i * kaidan[i - 1] % mod
    gyaku[i] = pow(kaidan[i], mod - 2, mod)


def perm(k, i):
    if i > k:
        return 0
    return kaidan[k] * gyaku[k - i]


# dfs

stack = [1]
used = [False] * (n + 1)
while stack:
    v = stack.pop()
    used[v] = True
    if v == 1:
        ans *= k * perm(k - 1, cnt[v])
        ans %= mod
    else:
        ans *= perm(k - 2, cnt[v] - 1)
        ans %= mod
    for u in graph[v]:
        if used[u] == True:
            continue
        stack.append(u)

print(ans)


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

#define inf 100000000000

using namespace std;

int N, M, L, Q;
long long dist[305][305];
int a, b, c;

int main() {
    scanf("%d %d %d", &N, &M, &L);
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = inf;
        }
    }

    for (int i=0; i<M; i++) {
        scanf("%d %d %d", &a, &b, &c);
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = (dist[i][j] <= L) ? 1:inf;
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    cin >> Q;
    for (int i=0; i<Q; i++) {
        scanf("%d %d", &a, &b);
        if (dist[a-1][b-1] == inf) {
            printf("-1\n");
        } else {
            printf("%lld\n", dist[a-1][b-1]-1);
        }
    }

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
   int n;cin>>n;
   double x[n];
   string u[n];
   for(int i=0;i<n;i++){
      cin>>x[i]>>u[i];
   }
   double ans=0;
   for(int i=0;i<n;i++){
      if(u[i]=="BTC"){
         ans +=x[i] * 380000.0;
      }else{
         ans += x[i];
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
stay_a=N
stay_b=0
stay_c=0
stay_d=0
stay_e=0
stay_f=0
f = -(-N//min(A,B,C,D,E))
print(4+f)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
    int X, Y;

    scanf("%d %d", &X, &Y);

    for (int i = 0; i <= X; i++) {
        if (Y == 4 * X - 2 * i) {
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 2084
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;cin>>N;
    if(N<1200) cout << "ABC";
    else cout << "ARC";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    B = [int(a) for a in input().split()]
    A = [0]*N
    A[0] = B[0]
    A[1] = B[0]
    for i in range(1, N-1):
        if A[i] < B[i]:
            A[i+1] = B[i]
        else:
            A[i] = B[i]
            A[i+1] = B[i]
    print(sum(A))
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int b[n], c[n];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    int ans = 0;
    rep(i, n){
        ans += b[a[i] - 1];
        //cout << b[a[i] - 1] << endl;
        if(i + 1 < n)if(a[i + 1] - a[i] == 1 ){
            ans += c[a[i] - 1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
int main(){
    int x;
    cin >> x;
    for(int i=1;i<1e9;i++){
        if((i+1)*i/2>=x){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
a, b, x = map(int, input().split())

import math
if x < a * a * b / 2:
    y = 2 * x / (a * b)
    print(math.degrees(math.atan(b / y)))
else:
    z = 2 * b - 2 * x / (a * a)
    print(math.degrees(math.atan(z  /a)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int x,y;
  cin >> x >> y;
  int group[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  if (group[x] == group[y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>

int abs(int a)
{
  if(a < 0)
  {
    return a * (-1); 
  }
  else
  {
    return a;
  }
}

int main()
{  
  int N, M, a[50], b[50], c[50], d[50], goal_num[50], goal_dist[50];
  std::cin >> N >> M;
  
  for(int i = 0; i < N; i++)
  {
    std::cin >> a[i] >> b[i];
    goal_dist[i] = 1000000000;
  }

  for(int i = 0; i < M; i++)
  {
    std::cin >> c[i] >> d[i];  
  }
  
  for(int i = 0; i < N; i++)
  {
    for(int k = 0; k < M; k++)
    {
      int dist = (abs(a[i] - c[k]) + abs(b[i] - d[k]));
      if(dist < goal_dist[i])
      {
        goal_dist[i] = dist;
        goal_num[i] = k;
      }
    }
  }
  
  for(int i = 0; i < N; i++)
  {
    std::cout << (goal_num[i] + 1) << "\n";  
  }

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int l1[n], r1[n], l2[n], r2[n];
    for(int i = 0; i < n; i++){
        cin >> l1[i] >> r1[i];
        l2[i] = l1[i];
        r2[i] = r1[i];
    }
    sort(r1, r1+n);
    sort(l1, l1+n);
    int houkou;
    int left = 0;
    int right = 0;
    long long int sum1 = 0;
    long long int sum2 = 0;
    houkou = 0;
    int x = 0;
    /*0はleft*/
    if(n == 1 && l1[0] <= 0 && r1[0] >= 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        if(houkou == 0){
            if(l1[n-1-left]-x >= 0) {
                sum1 += l1[n-1-left]-x;
                x = l1[n-1-left];
            }
            left++;
        }
        else{
            if(x-r1[right] >= 0){
                sum1 += x-r1[right];
                x = r1[right];
            }
            right++;
        }
        if(houkou == 0)houkou = 1;
        else houkou = 0;
        if(i == n-1) sum1 += abs(x);
    }
    houkou = 1;
    x = 0;
    right = 0;
    left = 0;
    for(int i = 0; i < n; i++){
        if(houkou == 0){
            if(l1[n-1-left]-x >= 0){
            sum2 += l1[n-1-left]-x;
            x = l1[n-1-left];
            }
            left++;
        }
        else{
            if(x-r1[right] >= 0){
            sum2 += x-r1[right];
            x = r1[right];
            }
            right++;
        }
        if(houkou == 0)houkou = 1;
        else houkou = 0;
        if(i == n-1) sum2 += abs(x);
    }
    long long int sum;
    if(sum1 > sum2) sum = sum1;
    else sum = sum2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void){
string s ; cin>>s ;
if(s.length()==6){
char x[7];
strcpy(x,s.c_str());
bool b = 0;
for(int i=0 ; i<2 ; i++){
    if(int(x[i])<97||int(x[i])>122)
        {b = 1;break;}
}
if(b==0&&x[2]==x[3]&&x[4]==x[5])
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

}

return 0;}


Measured memory_bytes: 3664
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            int h = int.Parse(input[0]);
            int n = int.Parse(input[1]);

            int sum = 0;

            string[] input2 = Console.ReadLine().Split(' ');
            //値を代入する
            for(int i = 0;i < n;i++)
            {
                sum += int.Parse(input2[i]);
            }
            
            //答は取り除いたロボットを引く
            if(sum >= h)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
    
        }
    }

Measured memory_bytes: 18380
n = int(input())
res = 0
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))
ab = sorted(ab)
for l,m in zip(ab,ab[1:]):
    res += min(m[0] - l[0], l[1] - m[1]) - 1
res += n
res += ab[0][0] - 1
res += ab[-1][1]
print(res)


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int tap = 1;
		int ret = 0;
		for (int i = 0; i < 100; i++) {
			if (tap >= b) {
				ret = i;
				break;
			}
			tap -= 1;
			tap += a;
		}

		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

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

template<class T>
void printIter(const T &a, string delimiter) {
    if (a.size() == 0) return;
    auto it = a.begin();
    cout << *it;
    it++;
    while (it != a.end()) {
        cout << delimiter << *it;
        it++;
    }
    cout << endl;
}

int main() {
    int H, N;
    cin >> H >> N;
    vector<pair<int, int>> spell(N);
    int mm = 0;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        mm = max(mm, a);
        spell[i] = make_pair(a, b);
    }
    vector<int> dp(H + mm + 1);
    for (int i = 0; i < H + mm + 1; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i + spell[j].first <= mm || H + mm + 1 <= i + spell[j].first) continue;
            else if (dp[i + spell[j].first] == 0) dp[i + spell[j].first] = dp[i] + spell[j].second;
            else dp[i + spell[j].first] = min(dp[i + spell[j].first], dp[i] + spell[j].second);
        }
    }
//    printIter(dp, " ");
    int m = 0;
    cout << dp[H+mm] << endl;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int n, m, d;
    cin >> n >> m >> d;
    if (d == 0)
    {
        cout << setprecision(12) << static_cast<double>(m - 1) / static_cast<double>(n) << endl;
    }
    else
    {
        cout << setprecision(12) << static_cast<double>(m - 1) * 2.0 * static_cast<double>(n - d)
            / static_cast<double>(n) / static_cast<double>(n) << endl;
    }
}


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

int main(){
  int64_t N, K;
  cin >> N >> K;
  int64_t m = (N/K) * (N/K) * (N/K);
  int64_t t = (N/K);
  if(K % 2 == 1){
    cout << m << endl;
  }
  else {
    if(K*t + K/2 <= N){
      t++;
    }
    cout << m + t*t*t << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string L;
    cin>>L;
    long long n,i,a,b,mod;
    n=L.length();
    mod=1e9+7;
    a=2;b=1;
    for(i=1;i<n;i++){
        if(L[i]=='1'){
            b=(a+b*3)%mod;
            a=(a*2)%mod;
        }else{
            b=(b*3)%mod;
        }
    }
    b=(a+b)%mod;
    cout<<b<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  
 string S;
  cin>>S;
  ll K;
  cin>>K;
  vector<string>date;
  
for(ll i=1;i<=min(K,S.size());i++){
  for(ll j=0;j<=S.size()-i;j++){
    if(j+i-1<=S.size()-1){
    date.push_back(S.substr(j,i));
    

  }
  }
}

 sort(all(date));
  unique(all(date));
 

  
  cout<<date[K-1]<<endl;

}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)1e2+5
#define M (int)1e7+5
#define f1 first
#define s2 second
#define INF 9999999
#define pb push_back
#define ll long long
#define mod (int)1e9+7
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

int n,m,dizi[M];
bool dp[M];

bool dpf(){
	for(int i=1;i<=m;i++){
		for(int j=0;j<n;j++){
			if(!dp[i+dizi[j]] && dp[i]==0){
				dp[i+dizi[j]]=1;
			}
		}
		//cout<<dp[i]<<endl;
	}
	return dp[m];
}

int main(){
	//fri("in.txt");
	//fro("out.txt");

	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>dizi[i];
		dp[dizi[i]]=1;
	}
	if(dpf())cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

Measured memory_bytes: 2432
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void scd(int &a){scanf("%d",&a);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

void swap(int *a,int *b)
{
	int tmp=*a;
	*a=*b;
	*b=tmp;
}

int main()
{
	int a,b,c;
	sctd(a,b,c);
	if(a>b)
	swap(a,b);
	if(b>c)
	swap(b,c);
	if(a>b)
	swap(a,b);
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	string s;
	int n;
	int a, b, c, d;
	int flag = -1;
	int ans[8];
	cin >> n;
	s = to_string(n);
	a = n / 1000;
	b = n / 100 - a * 10;
	c = n / 10 - a * 100 - b * 10;
	d = n - a * 1000 - b * 100 - c * 10;
	ans[0] = a + b + c + d;
	ans[1] = a + b + c - d;
	ans[2] = a + b - c + d;
	ans[3] = a + b - c - d;
	ans[4] = a - b + c + d;
	ans[5] = a - b + c - d;
	ans[6] = a - b - c + d;
	ans[7] = a - b - c - d;
	for (int i = 0; i < 8; i++){
		if (ans[i] == 7){
			flag = i;
			break;
		}
	}
	if (flag>-1){
		if (flag == 0){
			cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
		}if (flag == 1){
			cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
		}if (flag == 2){
			cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
		}if (flag == 3){
			cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
		}if (flag == 4){
			cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
		}if (flag == 5){
			cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
		}if (flag == 6){
			cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
		}if (flag == 7){
			cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
		}
	}
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n;
    	vi v(n+10,0);
    	for(i=0;i<n-1;i++)
    	{
    		cin>>l;
    		v[l]++;
    	}
    	for(i=1;i<=n;i++)
    	{
    		cout<<v[i]<<endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 4748
#!/usr/bin/env php
<?php
// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

function genInputs() {
    while(($input = rtrim(fgets(STDIN))) !== false) {
        foreach (explode(' ', $input) as $v) {
            yield $v;
        }
    }
}
function getNext($gen) {
    $value = $gen->current();
    $gen->next();
    return $value;
}
$gen = genInputs();

$N = (int)getNext($gen);
$M = (int)getNext($gen);
$hints = [];
$hint_counts = array_fill(0, $N, 0);
for ($i = 0; $i < $M; $i++) {
    $X = (int)getNext($gen);
    $Y = (int)getNext($gen);
    $Z = (int)getNext($gen);

    $hints[$X][$Y] = true;
    $hints[$Y][$X] = true;
}
$clear = array_fill(0, $N, false);
arsort($hint_counts);
$magic = 0;
$chain = function($k) use($hints, &$clear, &$chain) {
    if ($clear[$k]) {
        return;
    }
    $clear[$k] = true;
    if (!isset($hints[$k])) {
        return;
    }
    foreach ($hints[$k] as $v => $tr) {
        $chain($v);
    }
};
for ($i = 1; $i <= $N; $i++) {
    if ($clear[$i]) {
        continue;
    }
    $magic++;
    if (!isset($hints[$i])) {
        continue;
    }
    $chain($i);
}
echo $magic.PHP_EOL;


Measured memory_bytes: 96760
#include<stdio.h>

void trace(int A[],int N)
{
  for(int i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}


void insertionSort(int A[],int N)
{
  int i,j;
  int v;
  trace(A,N);
  for(int i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&v<A[j]){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}

int main(void)
{
  int N;
  int A[1000];
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  insertionSort(A,N);

  return 0;
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
  ll l,r,d,cnt=0;
  cin>>l>>r>>d;
  
  if(l%d==0 || r%d==0) cnt++;
  cnt+=((r-l)/d);
  
  cout<<cnt<<endl;
  
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum ^= a[i];
	}
	for (int i = 0; i < n; i++) {
		int ans = sum ^ a[i];
		cout << ans;
		if (i != n-1) cout << ' ';
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3984
import math
from collections import Counter

from scipy.misc import comb


def get_factors(n):
    """
    素因数分解
    :param int n:
    :type: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


n, m = map(int, input().split())
MOD = 10 ** 9 + 7

factors = get_factors(m)
counts = Counter(factors)
# k**v を全部かけあわせたやつが m に一致する
# print(functools.reduce(operator.mul, [k ** v for k, v in counts.items()]))

# v 個の k を n 個の数に配分する組み合わせの数
# → v + (n-1) 個のスペースへの v の置き方の組み合わせの数
ans = 1
for k, v in counts.items():
    ans *= comb(v + (n - 1), v, exact=True)
    ans %= MOD
print(ans)


Measured memory_bytes: 20732
#include <iostream>
#define ll long long
using namespace std;
int main() {
    ll n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int dp[n+1];
    for(int i=0;i<=n;i++){
        dp[i]=0;
    }
    for(int i=2;i<=n;i++){
        dp[i]=(dp[i-1]+abs(arr[i-1]-arr[i-2]));
        if(i>=3){
            dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]));
        }
    }
    cout<<dp[n];
}


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

int main()
{
int A,B,C;
cin >>A;
cin >>B;
cin >>C;

if ((B+C-A)<0) {
cout << 0 <<endl;
}
else if (A>=B){    
cout << (B+C-A) << endl;
}
}    

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long prev = -1;
        String result = "Yes";
        for(int i = 0; i < N; i++){
            long now = sc.nextLong();
            if(now - prev <= -1){
                result = "No";
                break;
            }
            if(now - prev == 0){
                prev = now;
            }else{
                prev = now - 1;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 48632
def resolve():
    h,w,K = map(int, input().split())
    mas = [list(input()) for i in range(h)]
    wk = []
    hk = []
    for i in range(h):
        plus = 0
        for j in range(w):
            if mas[i][j] == "#":
                plus += 1
        hk.append(plus)
    for i in range(w):
        plus = 0
        for j in range(h):
            if mas[j][i] == "#":
                plus += 1
        wk.append(plus)
    total = sum(wk)

    ans = 0
    for i in range(2**h):
        vert = []
        for k in range(h):
            vert.append((i>>k)&1)
        for j in range(2**w):
            hor = []
            for m in range(w):
                hor.append((j>>m)&1)
            subt = 0

            for n in range(len(vert)):
                subt += vert[n] * hk[n]
            for n in range(len(hor)):
                subt += hor[n] * wk[n]
            for n in range(len(vert)):
                for o in range(len(hor)):
                    if (vert[n] == 1) and (hor[o] == 1) and (mas[n][o] == "#"):
                        subt -= 1

            if total-subt == K:
                ans += 1


    print(ans)
resolve()

Measured memory_bytes: 9296
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  int a[100005];

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

  int max = a[n - 1];
  for(int i = 0; i < n; i++){
    if(i == (n-1)){
      cout << max << " " << a[i - 1] << endl;
      break;
    }
    if(a[i] > (max/2)){
      if((a[i] - (max/2)) > ((max/2) - a[i-1]))
        cout << max << " " << a[i - 1] << endl;
      else
        cout << max << " " << a[i] << endl;
      break;
    }else if(max == a[i]){
      cout << max << " " << a[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 640
#!/user/bin/python

if __name__ == "__main__":
	while True:
		N = int(raw_input())
		if N == 0:
			break;
		
		name = [""] * N
		member = []
		for i in range(0,N):
			name[i], S = raw_input().strip('.').split(':')
			member.append(S.split(','))
		
		used = [False] * N
		for REP in range(0,N):
			for i in range(0,N):
				if used[i]:
					continue
				if name[i] in member[0]:
					for S in member[i]:
						member[0].append(S)
					member[0] = list(set(member[0]))
					used[i] = True
		
		cnt = 0
		for i in range(0,N):
			if used[i]:
				cnt = cnt + 1
		
		print len(member[0]) - cnt

Measured memory_bytes: 6400
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int S = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    int[] A = new int[M];
    int[] B = new int[M];
    int[] E = new int[M];
    for (int i = 0; i < M; i++) {
      int u = scanner.nextInt() - 1;
      int v = scanner.nextInt() - 1;
      A[i] = scanner.nextInt();
      B[i] = scanner.nextInt();
      nodes[u].edges.add(i);
      nodes[v].edges.add(i);
      E[i] = u ^ v;
    }
    int[] C = new int[N];
    int[] D = new int[N];
    for (int i = 0; i < N; i++) {
      C[i] = scanner.nextInt();
      D[i] = scanner.nextInt();
    }

    long INF = 10_000_000_000_000L;
    int G = 2500;
    long[][] dp = new long[N][G + 1];
    for (int i = 0; i < N; i++) Arrays.fill(dp[i], INF);
    for (int i = 0; i <= S && i <= G; i++) dp[0][i] = 0;
    for (int k = 0; k < N + 1; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j <= G; j++) {
          if (j >= C[i]) dp[i][j] = Math.min(dp[i][j], dp[i][j - C[i]] + D[i]);
          for (int e : nodes[i].edges)
            if (j + A[e] <= G) dp[i][j] = Math.min(dp[i][j], dp[E[e] ^ i][j + A[e]] + B[e]);
        }
      }
    }
    for (int i = 1; i < N; i++) {
      long min = INF;
      for (int j = 0; j <= 2500; j++) {
        min = Math.min(min, dp[i][j]);
      }
      System.out.println(min);
    }
  }

  private static class Node {
    private final List<Integer> edges = new ArrayList<>();
  }
}


Measured memory_bytes: 47912
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#define PB push_back
#define MP make_pair
using namespace std;
typedef pair<int,int> P;

vector<pair<int,int> > edge[3000];
int dist[3000];
int main(){
    int N,M,K;
    scanf("%d%d%d",&N,&M,&K);
    int a,b,l;
    for(int i=0;i<M;i++){
        scanf("%d%d%d",&a,&b,&l);
        a--;b--;
        edge[a].PB(MP(b,l));
        edge[b].PB(MP(a,l));
    }
    for(int i=0;i<N;i++){
        dist[i]=INT_MAX;
    }
    int s;
    priority_queue<P,vector<P>,greater<P> > pq;
    for(int i=0;i<K;i++){
        scanf("%d",&s);
        s--;
        dist[s]=0;
        pq.push(MP(0,s));
    }
    while(!pq.empty()){
        int d=pq.top().first,at=pq.top().second;
        pq.pop();
        if(d>dist[at]) continue;
        for(int i=0;i<edge[at].size();i++){
            int ne=edge[at][i].first,co=edge[at][i].second;
            if(co+d<dist[ne]){
                dist[ne]=co+d;
                pq.push(MP(co+d,ne));
            }
        }
    }
    double ma=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<edge[i].size();j++){
            int ad=dist[i],bd=dist[edge[i][j].first],len=edge[i][j].second;
            if(ad>bd) swap(ad,bd);
            ma=max(ma,(ad+bd+len)/2.0);
        }
    }
    printf("%d\n",(int)(ma+0.5+1e-6));
}

Measured memory_bytes: 3304
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x = sc.nextInt();
		for(int i=0;i<x; i++){
			int [] a = {sc.nextInt(),sc.nextInt(),sc.nextInt()};
			Arrays.sort(a);
			if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2]) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
	}
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int main()
{
    int n;
    cin >> n;
    int odd = 0, even = 0;
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        if(t % 2 == 0) even++;
        else odd++;
    }

    if(odd % 2 == 0) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 384