akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        System.out.println(Math.max(0, -scanner.nextInt() + scanner.nextInt() + scanner.nextInt()));
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21204
#include <stdio.h>
int main(void)
{
    long int n, m, ans=0;
    scanf("%ld%ld", &n, &m);
    m=m/2;
    if(n>m){
        ans=m;
        printf("%ld\n", m);
        return 0;
    }
    ans=n;
    m=m*2-n*2;
    ans=ans+m/4;
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i*500+j*100+k*50 == X:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = (max(a, b) - min(a, b)) / 2 + min(a, b);
    cout << (abs(a - ans) == abs(b - ans) ? to_string(ans) : "IMPOSSIBLE") << '\n';
}


Measured memory_bytes: 888
#include <iostream>
#define US unsigned short
#define UI unsigned int
using namespace std;

int main(int argc, char const *argv[])
{
    US N;
    UI out = 0;
    cin >> N;
    US d[N];
    for (size_t i = 0; i < N; i++)
        cin >> d[i];

    for (size_t i = 0; i < N; i++)
        for (size_t j = i + 1; j < N; j++)
            out += d[i] * d[j];
    cout << out << endl;
}


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

#define MAX 26
int  c(int x,int y ,int z);
int check(int x,int y ,int z);

int cell[5][5][5];
int before[5][5][5];
int N,m1,m2;
int a[MAX],b[MAX];

int main(){
  int i,j,k,step;
  int count=1;
  string str;
  cin >> N;
  while(N!=0){
    for(k=0;k<5;k++){
      for(j=0;j<5;j++){
        cin >> str;
        for(i=0;i<5;i++){
          before[i][j][k]=str[i]-'0';
          if(before[i][j][k]>1)
            cout <<i<<j<<k<< endl;
        }
      }
    }
    
    cin >> m1;
    for(i=0;i<m1;i++) cin >> a[i];
    cin >> m2;
    for(i=0;i<m2;i++) cin >> b[i];
    

    for(step=0;step<N;step++){
      for(i=0;i<5;i++){
        for(j=0;j<5;j++){
          for(k=0;k<5;k++){
            cell[i][j][k]=c(i,j,k);
          }
          
        }
      }
      for(i=0;i<5;i++){
        for(j=0;j<5;j++){
          for(k=0;k<5;k++){
            before[i][j][k]=cell[i][j][k];
          }
          
        }
      }
    }
    cout << "Case " << count << ":" << endl;
    for(k=0;k<5;k++){
      for(j=0;j<5;j++){
        for(i=0;i<5;i++){
          cout << cell[i][j][k];
        }
        cout << endl;
      }
      if(k!=4 )cout << endl;
    }
    count++;
    cin >> N;
    if(N!=0) cout << endl;
  }
  
  return 0;

}

int c(int x,int y ,int z){
  int r=0,i,j,k;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      for(k=0;k<3;k++){
        if(!(i==1&&j==1&&k==1)&&check(x-1+i,y-1+j,z-1+k)==1){
          r+=before[x-1+i][y-1+j][z-1+k];
        }
      }
    }
  }
  //  cout << r << endl;
  if(before[x][y][z]==0){
    for(i=0;i<m1;i++){
      if(a[i]==r) return 1;
    }
    return 0;
  }else{
    for(i=0;i<m2;i++){
      if(b[i]==r) return 1;
    }
    return 0;
  }
}

int check(int x,int y ,int z){
  if(x<0||x>4||y<0||y>4||z<0||z>4)  return 0;
  else return 1;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include<string>
#include <iostream>
#include <cmath>
using ll = long long;
using namespace std;
  
  
int main() { 
  int k; cin >> k; string s; cin >> s;
  if(s.size() <= k){
    cout << s << endl;
    return 0;
  }
  else{
    for(int i=0; i<k;i++)
      cout << s.at(i);
    cout << "..." <<endl;
    return 0;
  }
}

Measured memory_bytes: 3628
N=int(input())
S=list(input())

def rgb(now,sec):
    if now=='R' and sec=='G':
        return 'B'
    if now == 'R' and sec == 'B':
        return 'G'
    if now == 'G' and sec == 'R':
        return 'B'
    if now == 'G' and sec == 'B':
        return 'R'
    if now == 'B' and sec == 'G':
        return 'R'
    if now == 'B' and sec == 'R':
        return 'G'

r=[0]*N+[0]
g=[0]*N+[0]
b=[0]*N+[0]

for i in reversed(range(N)):
    if S[i]=='R':
        r[i]=r[i+1]+1
        g[i]=g[i+1]
        b[i]=b[i+1]
    if S[i]=='G':
        r[i]=r[i+1]
        g[i]=g[i+1]+1
        b[i]=b[i+1]
    if S[i]=='B':
        r[i]=r[i+1]
        g[i]=g[i+1]
        b[i]=b[i+1]+1 
    
ans=0
for i in range(N-2):
    now = S[i]
    for j in range(i+1,N-1):
        if S[j] == now:
            continue
        else:
            sec = S[j]
            thi = rgb(now,sec)
            if thi=='R':
                ans += r[j+1]
            if thi=='G':
                ans += g[j+1]
            if thi=='B':
                ans += b[j+1]
            if j+(j-i) < N and S[j+(j-i)]==thi:
                ans-=1
print(ans)

Measured memory_bytes: 81040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a!=c && d==1) {
        cout << 1 << endl;
    }else {
        cout << 0 << endl;
    }

    return 0;
}

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

int main(){
	char str[3];
	scanf("%3s", &str);
	int price = 700;
	for(int i = 0; i < 3; i++){
		if(str[i] == 'o')
			price += 100;
	}
	printf("%i", price);
}

Measured memory_bytes: 128
import java.util.Scanner;

/*
問題文
問題文
時針と分針の長さがそれぞれ A センチメートル、
B センチメートルであるアナログ時計を考えます。

時針と分針それぞれの片方の端点は同じ定点に固定されており、
この点を中心としてそれぞれの針は一定の角速度で時計回りに回転します。時針は
12 時間で、分針は 1 時間で 1 周します。

0 時ちょうどに時針と分針は重なっていました。
ちょうど H 時 M 分になったとき、2 本の針の固定されていない方の
端点は何センチメートル離れているでしょうか。

制約
入力はすべて整数
1≤A,B≤1000
0≤H≤11
0≤M≤59

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double hour = 0.5 * (60 * h + m);
        double min = 6 * m;

        double angle = hour-min;

        if (hour < min) {
        	angle = 360 - min + hour;
        }

        double ans = a*a + b*b - 2*a*b * Math.cos(angle / 180 * Math.PI);
        System.out.println(String.format("%.20f", Math.sqrt(ans)));
    }
}

Measured memory_bytes: 35992
import sys
sys.setrecursionlimit(20000)
h= 0
w = 0
list1 = []

def dfs(x, y, f):
    list1[y] = list1[y][:x] + '1' + list1[y][x+1:]

    if y - 1 >= 0:
        if list1[y - 1][x] == f:
            dfs(x, y - 1, f)
    if y + 1 < h:
        if list1[y + 1][x] == f:
            dfs(x, y + 1, f)
    if x - 1 >= 0:
        if list1[y][x - 1] == f:
            dfs(x - 1, y, f)
    if x + 1 < w:
        if list1[y][x + 1] == f:
            dfs(x + 1, y, f)
    return

while True:
    h, w = list(map(lambda x: int(x),input().split(" ")))
    if 0 in (h, w):
        break
    n = 0
    for i in range(0, h):
        list1.append(input())
    for i in range(0, h):
        for j in range(0, w):
            if list1[i][j] != '1':
                dfs(j, i, list1[i][j])
                n+=1
    print(n)
    list1=[]

Measured memory_bytes: 15552
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 400000;
map < int, int > cnt;
vector < int > v;
int a[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    int ans = 1;
    int p = 0;
    int mod = 1e9 + 7;
    for (int i = 0; i < n; i++){
        if (s1[i] != s2[i]){
            i++;
            if (p == 1){
                ans = ans * 3 % mod;
            } else
            if (p == 0){
                ans = ans * 6 % mod;
            } else
                ans = ans * 2 % mod;
            p = 1;
        } else{
            if (p == 0){
                ans = ans * 3 % mod;
            } else
            if (p == 2){
                ans = ans * 2 % mod;
            }
            p = 2;
        }
    }
    cout << ans;
}


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

import collections
dic=dict(collections.Counter(A))
li=list(dic.values())

ans='No'

if len(li)==3:
    if N%3 == 0:
        x,y,z = dic.keys()
        if li[0]== N//3 and li[1]==N//3 and x^y== z:
            ans='Yes'           
elif len(li)==2:
    if N%3 == 0:
        if li[0]== 2*N//3 or li[1]==2*N//3:
            ans='Yes'
elif len(li)==1:
        if list(dic.keys())[0]==0:
            ans='Yes'

print(ans)

Measured memory_bytes: 16548
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
set<string> S;

LL ans = 0;

void solve(){
	ans = S.size();
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++){
    	string s;cin >> s;
    	S.insert(s);
    }
 
    solve();

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

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  Solver(LL n) : n(n){};

  void solve() {
  }
};
class Solver2 {
 public:
  LL n, m;
  string s, t;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
    cin >> s >> t;
    LL g = gcd(n, m);
    LL nn = n / g;
    LL mm = m / g;
    for (LL i = 0; i < g; ++i) {
      if (s[i * nn] != t[i * mm]) {
        cout << -1 << endl;
        return;
      }
    }
    cout << lcm(n, m) << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


Measured memory_bytes: 640
S = input()
T = input()

len_s = len(S)
len_t = len(T)

result = len_t
i = 0

while (i <= len_s - len_t):
    diff = 0
    for j, c in enumerate(T):
        if (c != S[i + j]):
            diff += 1
    # result = min(result, diff)
    if (diff < result):
        result = diff

    i += 1

print(result)



Measured memory_bytes: 73232
#include <iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;

int main() {
	int N;
	int A;
	int B;

	cin >> N >> A >> B;

	if (N*A >= B) {
		cout << B << endl;
	}
	else {
		cout << N * A << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, k = [int(v) for v in input().split(' ')]

    if k <= a:
        ans = k
    elif k <= a + b:  # a < k <= a + b
        ans = a
    else:  # a + b < k < a + b + c
        ans = a - (k - a - b)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Q = 1000000007;

int main(){
  int N; cin >> N;
  vector<ll> A(N,0);
  vector<ll> B(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i] >> B[i];
  }
  ll ans = 0;
  for(int i=N-1;i>=0;i--){
    A[i] += ans;
    A[i] %= B[i];
    if(A[i]>0){
      ans += (B[i]-A[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

struct Node{
    int key;
    Node *right,*left,*parent;
};


Node *root,*NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z= (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while( x != NIL){
        y=x;
        if (z->key < x->key) x=x->left;
        else x = x->right;
    }

    z->parent = y;
    if(y == NIL) root = z;
    else
        if(z->key < y->key)
            y->left = z;
        else y->right = z;
}


void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}


void preorder(Node *u){
    if( u == NIL ) return;
    printf (" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}



int main(){
    int n,i,x;
    string com;

    scanf(" %d",&n);

    for( i=0; i<n; i++){
        cin >> com;
        if( com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if( com== "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26720
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,x;
  cin>>n>>x;
  if(x==1||x==2*n-1)return cout<<"No",0;
  cout<<"Yes\n";
  if(n==2)return cout<<"1\n2\n3",0;
  
  vector<int> r(2*n-1,0);
  map<int,bool> m;
  bool f=x==2*n-2;
  m[r[n-2]=x+1-2*f]=true;
  m[r[n-1]=x]=true;
  m[r[n]=x-1+2*f]=true;
  m[r[n+1]=x+2-4*f]=true;
  for(int i=0,c=1;i<2*n-1;++i)if(!r[i]){
    while(m[c])c++;
    m[r[i]=c++]=true;
  }
  for(auto i:r)cout<<i<<"\n";
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

 // 20^5以下階乗とその逆元(mod mod[素数])を求める
vector<ll> fact, inv;
void fact_inv(int n, ll mod = MOD) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

// nCr % modを求める(modは素数)
ll ncr(ll n, ll r, ll mod = MOD) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}


ll div(ll a, ll b, ll mod) {
	a %= mod;
	b %= mod;
	return a * mod_pow(b, mod - 2, mod) % mod;
}

int main() {
	fact_inv(212345);
	
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	
	ll p = div(A, A + B, MOD);
	ll q = div(B, A + B, MOD);
	
	ll ans = 0;
	REP(i, N) {
		ll t1 = mod_pow(p, N) * mod_pow(q, i) % MOD * ncr(N - 1 + i, i) % MOD;
		ll t2 = mod_pow(p, i) * mod_pow(q, N) % MOD * ncr(N - 1 + i, i) % MOD;
		ans += (t1 + t2) % MOD * (N + i) % MOD;
		ans %= MOD;
	}
	
	ans = div(ans, div(A + B, 100, MOD), MOD);
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }

signed main(void){
    int n; cin>>n;
    vector <int> a(n), b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    int ue=0,shita=0;
    rep(i,n){
        if(a[i] > b[i]){
            shita += a[i] - b[i];
        }else if(a[i] < b[i]){
            if((b[i] - a[i])%2 == 1) b[i]++, shita++;
            ue += (b[i] - a[i])/2;
        }
    }
    if(ue - shita >= 0){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }
const int maxn = 2e5;
int p[maxn];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i];
  int res = 0;
  int mini = maxn + 1;
  for (int i = 0; i < n; i++) {
    mini = min(mini, p[i]);
    if (mini >= p[i]) res++;
  }
    Out(res); return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define pb push_back
#define mk make_pair
#define flp(i, k, n) for(int i=k; i<n; i++)
#define F first
#define S second
#define SIZE 2000


int32_t main(void)
{
	int n, x, y;
	cin>>n>>x>>y;
	int dp[n+1]={0};
	for(int i=1; i<=n; i++)
	{
		for(int j=i+1; j<=n; j++)
		{	
			int dis = min((abs(x-i)+abs(y-j)+1), abs(j-i));
			dp[dis]++;
		}
	}	

	flp(i, 1, n) cout<<dp[i]<<"\n";
	return 0;
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	ll n, t;
  cin >> n >> t;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = t;
  for(int i = 0; i < n-1; ++i){
    ans += min(t, a[i+1] - a[i]);
  }
  cout << ans << endl;
	return 0;
}



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

using namespace std;
#define N 2005
int c[N];

int main()
{
    ios::sync_with_stdio(0);
    int n,a,b,ans=0;
    cin>>n>>a>>b;
    for(int i=0;i<n;++i){
        cin>>c[i];
    }
    if(n==1){
        ans=fabs(c[0]-b);
    }
    else{
        ans=max(fabs(c[n-2]-c[n-1]),fabs(c[n-1]-b));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	n--;
	k--;
	if(n%k!=0) cout<<n/k+1;
	else cout<<n/k;
	return 0;
}


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

#define d(i, k) (i % (1 << (k))) / (1 << (k - 1))

int main(){
    int n, m, r = 0;
    cin >> n >> m;
    vector<pair<vector<int>, bool>> V(m);
    for(auto &i: V){
        int k;
        cin >> k;
        i.first.resize(k);
        for(int j = 0; j < k; j++) cin >> i.first[j];
    }
    for(auto &i: V) {
        int x;
        cin >> x;
        i.second = x;
    }
    for(int i = 0; i < (1 << n); i++){
        bool B = true;
        for(auto j : V){
            int c = 0;
            for(auto k: j.first) if(d(i, k)) c++;
            if((c % 2) != j.second) B = false;
        }
        if(B) r++;
    }
    cout << r;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
int main(){
	int A,B,C;
	cin>>A>>B;
	if((A>=0&&A<=23 )&& (B>=0&&B<=23) )
	C=A+B;
	if(C>=24)
	cout<< C-24;
	else
	cout<<C;
	
		return 0;
		
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int N; cin >> N;
  int x,y,z,i;
  int ans[10001]; for(i=1;i<=10000;i++){ans[i]=0;}

  for(x=1;x<=100;x++){
      for(y=1;y<=100;y++){
          for(z=1;z<=100;z++){
              int f = x*x + y*y + z*z + x*y + y*z + z*x;
              if(f<=10000){ans[f]++;}
          }
      }
  }
  for(i=1;i<=N;i++){
      cout << ans[i] << endl;
  }

  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 1e9+7;

long long binpow(long long b, long long e) {
  if (!e) return 1;
  if (e&1) return b*binpow(b, e-1)%mod;
  return binpow(b*b%mod, e/2);
}

void solve() {
  long long n; scanf("%lld", &n);
  if (n == 1) printf("0");
  else printf("%lld", (binpow(10, n)-binpow(9, n)*2%mod+binpow(8, n) + mod) % mod);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll a;
  cin >> a;
  cout << a + a*a + a*a*a<< endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (int i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": ";
    printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  ll N;
  cin >> N;
  vector<ll> P(N);
  rep(i, N) {
    cin >> P[i];
  }
  // printvec(P);

  map<ll, ll> mp; // number => count
  rep(i, N) {
    ll x = P[i];

    if (mp.count(x) > 0) {
      ll cnt = mp[P[i]];
      mp.erase(x);
      mp[x+1] = cnt+1;
    } else {
      mp[x+1] = 1;
    }
  }

  // cout << "mp: " << endl;
  // printmap(mp);

  ll ma = 0;
  for (auto x : mp) {
    if (ma < x.second) {
      ma = x.second;
    }
  }

  cout << N - ma << endl;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    int res = 1e9 + 7;
    for(int i = 0; i <= N; ++i) {
        int a = 1;
        for(int j = 0; j < i; ++j) a *= 2;
        for(int j = 0; j < N - i; ++j) a += K;
        res = min(res, a);
    }
    cout << res << endl;
    return 0;
}

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

int gcd(int a,int b){
  if(a < b)swap(a,b);
  if(a % b == 0)return b;
  else return gcd(b, a % b);
}

int main(){
  int n,ans,a;
  cin >> n;
  cin >> ans;
  for(int i = 1;i < n;i++){
    cin >> a;
    ans = gcd(ans,a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


d,t,s = list(map(int, input().split()))
if s*t>=d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61704
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

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

  vector<double> V(N);
  for (auto &v : V) {
    cin >> v;
  }

  sort(V.begin(), V.end());
  double ans = V[0];
  for (int i = 1; i < V.size(); i++) {
    ans = (ans + V[i])/2;
  }
  printf("%lf\n", ans);
}

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


Measured memory_bytes: 256
// card-eater.rs ---
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
      n: usize,
      xs: [usize; n]
    }

    let mut memo = [0; 100001];
    for x in xs.into_iter() {
        memo[x] += 1;
    }

    let k = memo
        .into_iter()
        .map(|&t| if 1 < t { t - 1 } else { 0 })
        .sum::<usize>();
    let ans = if k % 2 == 0 { n - k } else { n - k - 1 };
    println!("{}", ans);
}


Measured memory_bytes: 7164
#include<bits/stdc++.h>
typedef long long int ll;
#define M 1000000007
#define all(a) a.begin(), a.end()
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define stringupper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define stringlower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define nl cout<<endl
#define pb push_back
#define mp make_pair
#define vll vector<ll>
using namespace std;
int main()
{
	
	ll k;
	cin>>k;
	string s;
	cin>>s;
	ll l=s.size();
	if(l<=k)
		cout<<s;
	else{
		for(ll i=0;i<k;i++)
		{
			cout<<s[i];
		}
		cout<<"...";
	}
return 0;
}


Measured memory_bytes: 3596
#include <iostream>

int main(int argc, char const* argv[])
{
	int S, h, m, s;
	std::cin >> S;
	h = S/3600;
	m = (S%3600)/60;
	s = S%60;
	std::cout << h << ":" << m << ":" << s << std::endl;
	return 0;
}



Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

vector<int> t_parent;
vector<int> t_ord;

void tree_getorder(const vector<vi> &g, int root) {
	int n = g.size();
	t_parent.assign(n, -1);
	t_ord.clear();

	vector<int> stk; stk.push_back(root);
	while (!stk.empty()) {
		int i = stk.back(); stk.pop_back();
		t_ord.push_back(i);
		for (int j = (int)g[i].size() - 1; j >= 0; j --) {
			int c = g[i][j];
			if (t_parent[c] == -1 && c != root) {
				t_parent[c] = i;
				stk.push_back(c);
			}
		}
	}
}

int main() {
	int N;
	while (~scanf("%d", &N)) {
		vector<vector<int> > g(N);
		for (int i = 0; i < N - 1; ++ i) {
			int u, v;
			scanf("%d%d", &u, &v), -- u, -- v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		tree_getorder(g, 0);
		vector<bool> matched(N);
		bool ans = true;
		for (int ix = (int)t_ord.size() - 1; ix >= 0; -- ix) {
			int i = t_ord[ix], p = t_parent[i];
			if (!matched[i]) {
				if (p == -1 || matched[p]) {
					ans = false;
					break;
				}
				matched[i] = matched[p] = true;
			}
		}
		puts(ans ? "Second" : "First");
	}
	return 0;
}


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

int main() {
    string s; cin >> s;

    int ans = 0, tmp = 0;
    rep(i, s.size()) {
        if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T')
            tmp++;
        else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }

    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = 0
c = 0
for i in range(N):
  if i + 1 == a[i]:
    res += 1
    if c > 0:
      c -= 2
      res -= 1
    c += 1
  else: c = 0
print(res)

Measured memory_bytes: 54044
#include<stdio.h>

int main(void)
{
	int H, W;
	int i, j;

	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0){
			break;
		}

		for (i = 0; i < H; i++){
			for (j = 0; j < W; j++)
			{
				if (i % 2 == 0){
					if (j % 2 == 0){
						putchar('#');
					}
					else{
						putchar('.');
					}
				}
				else{
					if (j % 2 == 0){
						putchar('.');
					}
					else{
						putchar('#');
					}
				}
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 572
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int H = sc.nextInt(), W = sc.nextInt();
                                if (H == 0 && W == 0) {
                                        break;
                                }
                                for (int i = 0; i < H; i++) {
                                        for (int j = 0; j < W; j++) {
                                                System.out.print("#");
                                        }
                                        System.out.println("");
                                }
                                System.out.println("");
                        }
                }
        }
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<P>> v(n);
  rep(i,m){
    int p,y;
    cin >> p >> y;
    --p;
    v[p].emplace_back(y,i);
  }
  vector<P> ans(m);
  rep(i,n){
    sort(v[i].begin(),v[i].end());
    int x = 0;
    for(P p:v[i]){
      ans[p.second].first = i+1;
      ans[p.second].second = ++x;
    }
  }
  rep(i,m) printf("%06d%06d\n",ans[i].first,ans[i].second);
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int max(int x, int y)
{
	return x>y?x:y;
}

int main()
{
	fastio;
	ll n, k, i, j;
	cin>>n;
	ll h[n][3];
	for(i=0;i<n;i++)
		cin>>h[i][0]>>h[i][1]>>h[i][2];

	for(i=n-2; i>=0; i--)
	{
		h[i][0] += max(h[i+1][1], h[i+1][2]);
		h[i][1] += max(h[i+1][0], h[i+1][2]);
		h[i][2] += max(h[i+1][0], h[i+1][1]);
	}
	cout<<max(h[0][0], max(h[0][1], h[0][2]));
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <stack>
#include <list>

using namespace std;

#define rep(i,j,k) for(int i=j;i<k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define vi vector<int>
#define vc vector<char>
#define INF 1e9
#define MOD 1e9+7



int main(void){
    int n,minn=INF,maxx=0;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n){
        cin>>v[i];
        minn=min(minn,v[i]);
        maxx=max(maxx,v[i]);
    }
    
    int allmin=INF;
    rep(k,minn,maxx+1){
        int sum=0;
        rep(i,0,n){
            sum+=(v[i]-k)*(v[i]-k);
        }
        allmin=min(allmin,sum);
    }
    
    cout<<allmin<<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] B = new int[n];

            int k = A.Max();

            CountingSort(A, B, k);

            StringBuilder sb = new StringBuilder();
            foreach (var b in B)
                sb.Append(" " + b);
            Console.WriteLine(sb.ToString().TrimStart());
        }

        static void CountingSort(int[] a,int[] b,int k)
        {
            int[] c = new int[k + 1];
            int i, n = a.Length;

            for (i = 0; i < n; i++)
                c[a[i]]++;

            for (i = 1; i <= k; i++)
                c[i] += c[i - 1];

            for (i = n - 1; i >= 0; i--)
            {
                b[c[a[i]] - 1] = a[i];
                c[a[i]]--;
            }
        }
    }
}

Measured memory_bytes: 328596
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>

#include <cassert>
using namespace std;

bool IsGood(const int n, const vector<int>& a) {
    int lfDist = -1;
    int lfValue;
    for (int i = n - 1; i > 0; --i) {
        if (a[i] == a[i - 1]) {
            lfValue = a[i];
            lfDist = (n - 1) - i;
            break;
        }
    }
    int rgDist = -1;
    int rgValue;
    for (int i = n - 1; i + 1 < (int) a.size(); ++i) {
        if (a[i] == a[i + 1]) {
            rgValue = a[i];
            rgDist = i - (n - 1);
            break;
        }
    }

    if (lfDist == -1 && rgDist == -1) {
        if (n & 1) {
            return a[n - 1];
        } else {
            return 1 - a[n - 1];
        }
    } else if (lfDist != -1 && rgDist != -1) {
        if (lfDist <= rgDist) {
            return lfValue;
        } else {
            return rgValue;
        }
    } else if (lfDist != -1) {
        return lfValue;
    } else if (rgDist != -1) {
        return rgValue;
    }
    assert(false);
}

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

    int n;
    cin >> n;
    vector<int> a(2 * n - 1);
    for (int i = 0; i + 1 < 2 * n; ++i) {
        cin >> a[i];
    }

    vector<int> b(2 * n - 1);

    int ba = 2 * n - 1;
    int br = 2 * n - 1;
    int bl = 1;
    while (bl <= br) {
        int bm = (bl + br) >> 1;

        for (int i = 0; i + 1 < 2 * n; ++i) {
            b[i] = (a[i] <= bm);
        }

        if (IsGood(n, b)) {
            ba = bm;
            br = bm - 1;
        } else {
            bl = bm + 1;
        }
    }

    cout << ba << endl;

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
bool v[500010];
int nedge,too[500010],hed[500010],x[500010],y[500010],nxt[500010],n,m,d[500010],d4,A,B;
void ae(int x,int y){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
}
void dfs(int x){
	v[x]=1;
	for (int i=hed[x];i;i=nxt[i]){
		int y=too[i];
		if (y==B || v[y]) continue;
		dfs(y);
	}
}
int main(){
	cin>>n>>m;
	if (n==1) return puts("No"),0;
	FOR(i,1,m){
		getint(x[i]),getint(y[i]);
		++d[x[i]],++d[y[i]];
		ae(x[i],y[i]),ae(y[i],x[i]);
	}
	FOR(i,1,n) if (d[i]&1) return puts("No"),0;
	FOR(i,1,n) if (d[i]>=6) return puts("Yes"),0;
	FOR(i,1,n) if (d[i]>=4) ++d4;
	if (d4>=3) return puts("Yes"),0;
	if (d4<=1) return puts("No"),0;
	FOR(i,1,n) if (d[i]==4) A=i;
	FOR(i,1,n) if (d[i]==4 && i!=A) B=i;
	dfs(A);
	for (int i=hed[B];i;i=nxt[i]){
		int y=too[i];
		if (!v[y]) return puts("Yes"),0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 9728
/**
 * Created by hiramekun at 09:16 on 2019-10-18.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;

    auto mima = minmax_element(all(a));
    ll mi = *mima.F, ma = *mima.S;
    if (mi >= 0) {
        cout << n - 1 << '\n';
        rep(i, n - 1) {
            cout << i + 1 << ' ' << i + 2 << '\n';
        }
    } else if (ma <= 0) {
        cout << n - 1 << '\n';
        repr(i, n - 1) {
            cout << i + 2 << ' ' << i + 1 << '\n';
        }
    } else {
        cout << 2 * n - 1 << '\n';
        if (abs(mi) > abs(ma)) {
            ll i_mi = mima.F - a.begin();
            rep(i, n) {
                cout << i_mi + 1 << ' ' << i + 1 << '\n';
            }
            repr(i, n - 1) {
                cout << i + 2 << ' ' << i + 1 << '\n';
            }
        } else {
            ll i_ma = mima.S - a.begin();
            rep(i, n) {
                cout << i_ma + 1 << ' ' << i + 1 << '\n';
            }
            rep(i, n - 1) {
                cout << i + 1 << ' ' << i + 2 << '\n';
            }
        }
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
	string S;
  	cin>>S;
  
  sort (S.begin(),S.end());
  if(S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2]){
  	cout<<"Yes"<<endl;
  }
  else{
  	cout<<"No"<<endl;
  }
    
    
  
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;
ll n;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n; n++; vector<ll>a(n); for (ll i = 0; i < n; i++) cin >> a[i];
	vector<ll>b(n - 1);
	for (ll i = 0; i < n - 1; i++) cin >> b[i];
	ll mx = 0;
	for (ll i = 0; i < n - 1; i++) {
		ll kek = min(a[i], b[i]);
		b[i] -= kek;
		a[i] -= kek;
		mx += kek;
		kek = min(a[i + 1], b[i]);
		mx += kek;
		b[i] -= kek;
		a[i + 1] -= kek;
	}
	cout << mx << endl;
	return 0;
}
/*

*/

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#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>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    vector<int> cnt(3, 0);

    ll ans = 1;
    for(int i=0; i<n; i++){
        int sum = 0;
        for(int j=0; j<3; j++){
            sum += (a[i] == cnt[j]);
        }

        ans *= sum;
        ans %= MOD;

        for(int j=0; j<3; j++){
            if(a[i] == cnt[j]){
                cnt[j]++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
  int u, minv;
  int d[MAX], p[MAX], color[MAX]; // d:??±??? ,p:??????v?????? ,color:????????????

  for(int i = 0; i < n; i++){ //??????????????????????????????
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;
  
  while(1){

    minv = INFTY;
    u = -1;

    for(int i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }

    if(u == -1)break;

    color[u] = BLACK;

    for(int v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }      
    }
  }

  int sum = 0;
  for(int i = 0; i < n; i++){
    if(p[i] != -1)sum += M[i][p[i]];
  }
  
  return sum;
  
}

int main(){
  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      int e;
      cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
  
  cout << prim() << endl;

  return 0;  
}

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

vector<int> input(int N){
    int i;
    vector<int> output(N);
    for(i=0;i<N;i++)cin>>output[i];
    return output;
}

int main(){
    int N,K,i;
    int result=0;
    vector<int> H;

    cin>>N>>K;
    H=input(N);

    for(i=0;i<N;i++){
        if(H[i]>=K)result+=1;
    }

    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 640