akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef int64_t ll;

template <class T1, class T2>
using dict = std::unordered_map<T1, T2>;

int main(){
    int c[3][3];
    for (int i=0;i<3;i++){
        for (int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    int a[3];
    int b[3];
    a[0] = c[0][0];
    a[1] = c[0][1];
    a[2] = c[0][2];
    b[0] = 0;
    b[1] = c[1][0] - c[0][0];
    b[2] = c[2][0] - c[0][0];
    bool ans = true;
    for (int i=0;i<3;i++){
        for (int j=0;j<3;j++){
            if(c[i][j]!=b[i] + a[j]) ans=false;
        }
    }
    if(ans) cout << "Yes\n";
    else cout << "No\n";

}

Measured memory_bytes: 256
s=input()
s=s[::-1]

a=0
while a<len(s):
    if s[a:a+5]=="esare" or s[a:a+5]=="maerd":
        a+=5
    elif s[a:a+6]=="resare":
        a+=6
    elif s[a:a+7]=="remaerd":
        a+=7
    else:
        print("NO")
        exit()

print("YES")

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b, x;

int main(void) {
  // Here your code !
  scanf("%d %d %d", &a, &b, &x);
  
  if (a <= x && x <= (a + b)) printf("YES\n");
  else printf("NO\n");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define rep(a,n) for(int i=a;i<n;i++)
#define rep1(a,n) for(int i=a;i<=n;i++)
#define bada 1000000007
ll c[2001][2001];
int main()
{
    for(int i=0;i<=2000;i++)
   {
    c[i][0]=c[i][i]=1;
    for(int j=1;j<i;j++)
    {
       c[i][j]=(c[i-1][j])+(c[i-1][j-1]);
       c[i][j]%=bada;
    }
   }
   int n,k;
   cin>>n>>k;
   for(int i=1;i<=k;i++)
      cout<<(c[n-k+1][i]*c[k-1][i-1])%bada<<"\n";

   return 0;
}


Measured memory_bytes: 30080
#include<bits/stdc++.h>
using namespace std;
long n,a,b,h[1<<17],i,ng=-1,m,ok=1e10,c;
main(){
  for(cin>>n>>a>>b,a-=b;i<n;)cin>>h[i++];
  while(abs(ok-ng)>1){
    m=(ok+ng)/2;
    for(c=i=0;i<n;i++)if(h[i]>m*b)c+=(h[i]-m*b+a-1)/a;
    if(c<=m)ok=m;
    else ng=m;
  }
  cout<<ok;
}


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


int main() {
   int a,b;
   cin >> a >> b;
   string s;
   cin >> s;
   for(int i=0;i<s.size();i++){
       if(i==a){
           if(s[i]!='-'){
               cout << "No" << endl;
               return 0;
           }
       }
       else{
           if(s[i]=='-'){
               cout << "No" << endl;
               return 0;
           }
       }
   }
   cout << "Yes" << endl;
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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; }



int main() {
    int n; cin >> n;
    ll ans = 1;
    rep(i,n) {
        ll a; cin >> a;
        ans = ans * a / __gcd(ans, a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3120
from math import factorial

inputted = list(map(int, input().split()))
N = inputted[0]
M = inputted[1]

nPk = lambda n, k: 0 if n - k < 0 else factorial(n) / (factorial(k) * factorial(n - k))

answer = nPk(N, 2) +  nPk(M, 2)
answer = int(answer)

print(answer)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int x, y; cin >> x >> y;
	if( (4*x-y) >= 0 and (4*x-y) % 2 == 0 and (y-2*x) >= 0 and (y-2*x) % 2 == 0 ){
		cout << "Yes" << endl;
	} else cout << "No" << endl;
}

Measured memory_bytes: 3612
// vim:ts=4:sts=4:sw=4:et
// MOSCOW IPT JINOTEGA
// Table #14
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef long long i64;

const int mod = 998244353;

int add(int x) {  
    return x;
}

template<typename... T>
int add(int x, T... y) {  
    x += add(y...);
    if (x >= mod)
            x -= mod;
    return x;
}

template<typename... T>
int udd(int &x, T... y) { 
    return x = add(x, y...);
}

template<typename... T>
int sub(int x, T... y) { 
    return add(x, mod - add(y...));
}

int mul(int x) { 
    return x;
}

template<typename... T>
int mul(int x, T... y) { 
    return 1ll * x * mul(y...) % mod;
}

int bin(int x, int to) { 
    int y = 1;
    while (to) { 
            if (to & 1)
                        y = mul(x, y);
                x = mul(x, x);
                    to >>= 1;
    }
    return y;
}

int inv(int x) { 
    assert(x != 0);
    return bin(x, mod - 2);
}
 

const int M = 107;

string s;
int n;

string operator|(const string &l, const string &r) {
    assert(l.length() == r.length());
    string ans(l);
    for (int i = 0; i < (int) l.length(); ++i)
        if (ans[i] == '1' && r[i] == '0')
            ans[i] = '0';
    return ans;
}

map<string, int> mem;

int val(char c) {
    if (c == '0')
        return 1;
    else
        return 2;
}

int calc(const string &s) {
    if (mem.count(s))
        return mem[s];
    if (s.empty())
        return 1;

    int n = s.length();
    int ans = 0;
    udd(ans, mul(val(s[0]), calc(s.substr(1, n - 1))));
        for (int len = 1; len < n; ++len) {
            string cur = s.substr(0, len);
            for (int k = 2; k * len <= n; ++k) {
                cur = cur | s.substr((k - 1) * len, len);
                udd(ans, mul(calc(cur), 
                            calc(s.substr(k * len, n - k * len))
                            ));
            }
        }

    return mem[s] = ans;
}

void read() {
    cin >> s;
    n = s.length();
}

void kill() {
    cout << calc(s) << "\n";
}

int main() {
#ifdef LOCAL
    assert(freopen("e.in", "r", stdin));
#endif
    ios_base::sync_with_stdio(false);
    read();
    //s = string(100, '0');
    //for (int i = 0; i < 100; ++i)
        //s[i] += rand() % 2;
    kill();
    return 0;
}



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

int main() {
	int S,h,m,s;
	cin >> S;
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;

	cout << h << ':' << m << ':' << s << endl;

	return 0;

}

Measured memory_bytes: 3100
import sys
from functools import lru_cache
 
sys.setrecursionlimit(4100000)
 
@lru_cache(maxsize=None)
def f(n):
    if n == 0:
        return 0

    return f(n % bin(n).count('1')) + 1

def main():
    N = int(input())
    X = list(input())
    pc = X.count('1')
    now = 0
    for i in range(N):
        if X[i] == '1':
            now += pow(2,N-i-1)

    ac = pc + 1
    dc = pc - 1
    ac_now = now % ac
    if dc:
        dc_now = now % dc
    for i in range(N):
        cnt = 0
        if X[i] == '1' and dc:
            tmp = (dc_now - pow(2, N-i-1, dc)) % dc
            cnt = 1 + f(tmp)
        elif X[i] == '0':
            tmp = (ac_now + pow(2, N-i-1, ac)) % ac
            cnt = 1 + f(tmp)

        print(cnt)



if __name__ == "__main__":
    main()

Measured memory_bytes: 100784
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,n;
  cin >> n >> m;
  string s[105];
  int i,j,k;
  for(i=0;i<m;i++){
    cin >> s[i];
  }
  int d[10005]={};
   
  for(i=0;i<n;i++){
    d[i+1]=d[i];
    for(j=0;j<m;j++){ 
      if(s[j][i]=='W') d[i+1]++;
    }
  }
   
  int mi=1000005;
  int l=0;
  for(i=0;i<=n;i++){
    if(i*m+d[n]-2*d[i]<mi){
      l=i;
      mi=i*m+d[n]-2*d[i];
    }
  }
   
  cout << l << " " << l+1 << endl;
  return 0;
}

Measured memory_bytes: 2744
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K=int(input())
print(l[K-1])


Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const int MAX = 21000;
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
	IsPrime[0] = false; IsPrime[1] = false; 
	for (int i = 2; i < n; ++i) IsPrime[i] = true;
	for (int i = 2; i < n; ++i) {
		if (IsPrime[i]) {
            res.push_back(i);
			for (int j = i*2; j < n; j += i) IsPrime[j] = false;
		}
	}
    return res;

};

bool isprime(int a, int b) {
	a = abs(a); b = abs(b);
	if (a > b) swap(a, b);
	if (a == 0 && IsPrime[b] && b % 4 == 3) return true;
	int tot = a*a + b*b;
	if (IsPrime[tot] && tot % 4 == 1) return true;
	return false;
}

int n;
int a, b;

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    Era();
	while (cin >> n) {
		for (int i = 0; i < n; ++i) {
			cin >> a >> b;
			bool ok = isprime(a, b);
			if (ok) puts("P");
			else puts("C");
		}
	}
    return 0;
}


Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); 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; }


int main(){
    // input 
    int D; cin >> D;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, D){
        rep(j, 26){
            cin >> s[i][j];
        }
    }

    // greedy
    vector<int> last(26, 0);
    vector<int> res(D);

    rep(d, D){
        int max_plus = -10000;
        int use = -1;
        rep(i, 26){
            int tmp = s[d][i] + c[i] * (d - last[i] + 1);
            if(max_plus < tmp){
                max_plus = tmp;
                use = i;
            }
        }
        last[use] = d + 1;
        res[d] = use + 1;
    }

    rep(i, D){
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q7 = sc.nextInt();
		int[][] q=new int[n+1][n+1];
		for(int i = 0; i < m; i++){
			int l = sc.nextInt();
			int r = sc.nextInt();
			q[l][r]++;
		}
		for(int i=n-1; i>=1; i--){
			for(int j=i; j<=n; j++){
				q[i][j]+=q[i+1][j]+q[i][j-1]-q[i+1][j-1];
			}
		}
		int[] p11=new int[q7];
		int[] p22=new int[q7];
		for(int i = 0; i<q7; i++){
			p11[i]=sc.nextInt();
			p22[i]=sc.nextInt();
		}
		for(int i=0; i<q7; i++){
			System.out.println(q[p11[i]][p22[i]]);
		}
	}
}


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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }
  cin >> n;
  int tmp, tmp2, tmp3;
  rep_i(i, n){
    cin >> tmp >> tmp2 >> tmp3;
    say(count(&nums[tmp], &nums[tmp2], tmp3));
  }
}


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

int main() {
  string S[3];
  for (int i=0; i<3; i++)
    cin >> S[i];
  for (int i=0; i<3; i++)
    printf("%c", S[i][0]-'a'+'A');
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int N, Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vector<char>a(Q),b(Q);
	rep(i, Q) {
		cin >> a[i] >> b[i];
	}
	int l = -1; int r = N;
	while (r-l>1) {
		int mid = (l + r) / 2;
		char tmp = s[mid];
		int pos = mid;
		rep(i, Q) {
			if (tmp == a[i]) {
				if (b[i] == 'R') {
					pos++;
				}
				else {
					pos--;
				}
				if (pos == N  || pos == -1) {
					break;
				}
				tmp = s[pos];
			}
		}
		if (pos == -1) {
			l = mid;
			//OKなら右に進める
		}
		else {
			r = mid;
			//OKじゃないなら左に戻る
		}
	}
	int maxr = r;
	l = -1; r = N ;
	while (r - l>1) {
		int mid = (l + r) / 2;
		char tmp = s[mid];
		int pos = mid;
		rep(i, Q) {
			if (tmp == a[i]) {
				if (b[i] == 'R') {
					pos++;
				}
				else {
					pos--;
				}
				if (pos == N || pos==-1){
					break;
				}
				tmp = s[pos];
			}
		}
		if (pos == N) {
			r = mid;
			//OKなら左に進める
		}
		else {
			l = mid;
			//OKじゃないなら右に戻る
		}
	}
	//cout << l <<" "<< r << endl;
	int maxl = r;
	cout << maxl-maxr << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long lint;
typedef vector<lint> vl;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) REP(i,0,b)
#define maxn 100010

int n;

lint f(lint s, vl v){
	lint ans=0LL, x,t=0LL,y;
	if((s==-1LL&&(t+v[0])>=0)||(s==1LL&&(t+v[0])<=0)){
		x=s*(1LL)-t;
		y=abs(x-v[0]);
		v[0]=x;
		ans+=y;
	}
	t=t+v[0];
	REP(i,1,n){
		s*=(-1LL); 				//change sign
		if((s==-1LL&&(t+v[i])>=0)||(s==1LL&&(t+v[i])<=0)){
			x=s*(1LL)-t;
			y=abs(x-v[i]);
			v[i]=x;
			ans+=y;
		}
		t=t+v[i];
	}
	return ans;
}

int main(){
	while(scanf("%d",&n)==1){
		vl arr(maxn);
		lint a;
		rep(i,n){
			scanf("%lld",&arr[i]);
		}
		lint x=f(-1LL,arr);
		lint y=f(1LL,arr);
		lint ans=min(x,y);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<set>
using namespace std;

typedef long long int64;
typedef int int__;
#define rep(i,j) for(int__ i=0;i<j;i++)
#define all(v) v.begin(),v.end()
typedef unsigned long long ull;
const ull HashBase = 100000007;

/*
  s := s1 s2 ... sn
  
  hash[1_to_i] := s1*b^(i-1) + s2*b^(i-2) + ... + si*b^0
  
  hash[1_to_j] := s1*b^(j-1) + s2*b^(j-2) + ... + si*b^(j-i) + ... + sj*b^0
  
  
  hash[(i+1)_to_j] = hash[1_to_j] - hash[1_to_i]*b^(j-i)
  
                   = s(i+1)*b^(j-i-1) + ... + sj*b^0
*/


int main()
{
  int n,m;string s;
  cin>>n>>m>>s;
  
  vector<ull> hash(n+1);
  vector<ull> pow_base(n+1);

  hash[0]=0;pow_base[0]=1;
  rep(i,n){
    hash[i+1] = hash[i]*HashBase + s[i];
    pow_base[i+1]=pow_base[i]*HashBase;
  }
  
  int r=1,l=1;
  vector<ull> subhash;
  rep(i,m){
    string query;
    cin>>query;

    if(query=="L++")l++;
    else if(query=="L--")l--;
    else if(query=="R++")r++;
    else if(query=="R--")r--;

    subhash.push_back(hash[r]-hash[l-1]*pow_base[r-l+1]);
  }
  sort(all(subhash));

  cout<<unique(all(subhash))-subhash.begin()<<endl;
  
  return 0;
}

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

using namespace std;

vector<vector<pair<int, bool>>> edges;
vector<bool> colors;

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

  int N;
  cin >> N;

  edges.resize(N + 1);
  for (int i = 1; i < N; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    edges[u].emplace_back(v, w % 2 == 1);
    edges[v].emplace_back(u, w % 2 == 1);
  }
  colors.resize(N + 1);

  unordered_set<int> tbd;
  for (int i = 2; i <= N; ++i) {
    tbd.emplace(i);
  }
  queue<int> q;
  q.emplace(1);
  for (; !q.empty(); q.pop()) {
    auto cur = q.front();
    auto& nexts = edges[cur];
    for (auto next : nexts) {
      auto it = tbd.find(next.first);
      if (it != tbd.end()) {
        tbd.erase(it);
        colors[next.first] = next.second ? !colors[cur] : colors[cur];
        q.emplace(next.first);
      }
    }
  }

  for (auto it = colors.begin() + 1; it != colors.end(); ++it) {
    cout << (*it ? 1 : 0) << endl;
  }
}


Measured memory_bytes: 10532
#include <stdio.h>
typedef long long LL;

int main(){
    LL N, M;
    scanf("%lld%lld", &N, &M);
    LL buf, shukudai = 0;
    for(LL i=0; i<M; i++){
        scanf("%lld", &buf);
        shukudai += buf;
    }
    LL ans = N-shukudai;
    printf("%lld\n", ans>-1 ? ans: -1);
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int h[200000];
signed main(){
    int n;
    cin>>n;
    rep(i,n)cin>>h[i];
    for(int i=n-2;i>=0;i--){
        if(h[i+1]<h[i]-1){
            puts("No");
            return 0;
        }
        if(h[i+1]==h[i]-1)h[i]--;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 1024
object Main {
  def main (args: Array[String]) {
    val Array(r) = scala.io.StdIn.readLine.split(" ").map(_.toDouble)
    println( f"${scala.math.pow(r,2) * scala.math.Pi}%4f ${r *2 * scala.math.Pi}%4f" )
  }
}

Measured memory_bytes: 44104
a, b, c, x, y = map(int, input().split())
if a + b < 2*c:
    print(a*x + b*y)
elif x<=y and b <= 2 *c:
    print(c*2*x + (y-x)*b)
elif x>=y and a <= 2*c:
    print(c*2*y + (x-y)*a)
elif x <= y and b > 2*c:
    print(c*2*y)
elif x >= y and a > 2*c:
    print(c*2*x)


Measured memory_bytes: 9052
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int b[30][4];

int main(){
	ll q;
	scanf("%lld",&q);
	while(q--){
		rep(i,0,26){
			b[i][0]=100;
			b[i][1]=-1;
			b[i][2]=100;
			b[i][3]=-1;
		}
		ll h,w;
		scanf("%lld%lld",&h,&w);

		int cnt=0;
		char s[60][60]={};
		rep(i,0,h)rep(j,0,w){
			scanf(" %c",&s[i][j]);
			if(s[i][j]!='.'){
				int c=s[i][j]-'A';
				if(b[c][0]==100)cnt++;
				b[c][0]=min(b[c][0],i);
				b[c][1]=max(b[c][1],i);
				b[c][2]=min(b[c][2],j);
				b[c][3]=max(b[c][3],j);
			}
		}
		//cnt種
		int flag=1;
		while(flag){
			flag=0;
			rep(c,0,26)if(b[c][0]!=100){
				int temp=1;
				rep(i,b[c][0],b[c][1]+1)rep(j,b[c][2],b[c][3]+1){
					if(s[i][j]!=' '&&s[i][j]!=c+'A'){
						temp=0;i=j=100;
					}
				}
				if(temp){
					rep(i,b[c][0],b[c][1]+1)rep(j,b[c][2],b[c][3]+1)s[i][j]=' ';
					cnt--;
					flag=1;
					b[c][0]=100;
				}
			}
		}
//		rep(i,0,h)puts(s[i]);
		puts(cnt?"SUSPICIOUS":"SAFE");
	}
}


Measured memory_bytes: 2044
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
struct Stick{
    int p,q,r,b;
};
Stick s[101];
int tsurami(int a,int b){
    if(b==0) return a;
    else return tsurami(b,a%b);
}
int solve(int n){
    if(n==0) return 1;
    int pq_gcd = tsurami(s[n].p,s[n].q);
    s[n].p /= pq_gcd;
    s[n].q /= pq_gcd;
    int a = solve(s[n].r),
        b = solve(s[n].b);
    int ab_gcd = tsurami(a,b);
    for(int i=1;;i++){
        if(s[n].p*ab_gcd*i%b==0 && s[n].q*ab_gcd*i%a==0){
            return (s[n].p+s[n].q)*ab_gcd*i;
        }
    }
}
int main(){
    int N;
    while(cin>>N,N){
        int par;
        bool cnt[101]={};
        for(int i=1;i<=N;i++){
            cin>>s[i].p>>s[i].q>>s[i].r>>s[i].b;
            cnt[s[i].r]=cnt[s[i].b]=true;
        }
        for(int i=1;i<=N;i++){
            if(cnt[i]==false){
                par = i;
                break;
            }
        }
        printf("%d\n",solve(par));
    }
    return 0;
}

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

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

	long long int h = 0;
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		if (h > a[i]) {
			ans+= h - a[i] ;
		}
		else h = a[i];
	}

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


Measured memory_bytes: 4024
from math import *

a,b,h,m=map(int,input().split())

a_k=(h+m/60)*30
b_k=m*6
k=abs(a_k-b_k)

if k==0:
  print(abs(a-b))
else:
  x=a**2+b**2-2*a*b*cos(radians(k))
  print(x**0.5)

Measured memory_bytes: 9524
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> c(h+2,vector<char>(w+2,'#'));
  vector<vector<long>> path(h+2,vector<long>(w+2,0));
  rep(i,h){
    rep(j,w){
      cin >> c.at(i+1).at(j+1);
    }
  }
  queue<pair<int,int>> que;
  pii start(1,1);
  path.at(1).at(1) = 1;
  que.push(start);
  while(que.size()){
    pii p = que.front();
    que.pop();
    int x = p.first;
    int y = p.second;
    //cout << x << " " << y << endl;
    if(c.at(x+1).at(y) == '.' && path.at(x+1).at(y) == 0){
      path.at(x+1).at(y) = (path.at(x).at(y) + path.at(x+1).at(y-1))%MOD;
      pii np(x+1,y);
      que.push(np);
    }
    if(c.at(x).at(y+1) == '.' && path.at(x).at(y+1) == 0){
      path.at(x).at(y+1) = (path.at(x-1).at(y+1) + path.at(x).at(y))%MOD;
      pii np(x,y+1);
      que.push(np);
    }
  }
  cout << path.at(h).at(w) << endl;
}

Measured memory_bytes: 9216
#include<stdio.h>
#include<limits.h>
#define min(a,b) (a)<(b)?(a):(b)
int main(void)
{
  long long n,i=0,ans=LLONG_MAX;
  scanf("%lld",&n);
  while(i*i<=n){
    i++;
    if(n%i==0){
      ans=min(ans,i+(n/i)-2);
      if(ans!=i+(n/i)-2){
        break;
      }
    }
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(void)
{
	string str;
	int count = 0;
	cin >> str;
	int i;
	for (i = 0; i < str.length(); i++)
	{
		if (str[i] == '1')
		{
			count++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,X,Y;
int main(){
  cin >> n >> m >> X >> Y;
  vector<int> x(n+1);
  vector<int> y(m+1);
  for(int i = 0;i < n;i++) cin >> x[i];
  for(int i = 0;i < m;i++) cin >> y[i];
  x[n] = X;
  y[m] = Y;
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if(x[n] < y[0]) cout << "No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc074/tasks/abc074_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    cout << n * n - x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    vector<int> ans;
    int now = n;
    int last = -1;
    int mov;
    while (now>0) {
        //cout << "now: " << now << endl;
        //cout << "last: " << last << endl;
        int prenow = now;
        int next = -1;
        if (now<=m) {
            ans.pb(now);
            break;
        }
        if (last > 0) {
            mov = m - (now - last);
            now = last;
        }
        else mov = m;
        //cout << "mov: " << mov << endl;
        srep(i,1,mov+1) {
            if (now-i<0) continue;
            if (s[now-i] == '0') next = now-i;
            last = now-i;
        }
        if (next==-1) {
            cout << -1 << endl;
            return 0;
        }
        //cout << "next: " << next << endl;
        //cout << "now: " << now << endl;
        ans.pb(prenow-next);
        now = next;
    }
    for(int i = ans.size()-1; i>=0; --i) cout << ans[i] << " ";
    cout << endl;
    return 0;
}











Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef  unsigned long long ULL;
typedef  double db;
typedef  long double ld;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fuck(x) cout<<x<<endl
#define fuck1(x,y) cout<<x<<" "<<y<<endl
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define MP(a,b) make_pair(a,b)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
const int INF = 0x3f3f3f3f3f,mod = 1e9+7;
const double eps  =1e-6,PI = acos(-1);
template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
const int maxn = 2e5+100;
int N,K;
int main(){
    scanf("%d%d",&N,&K);
    int max1 = (N-1)*(N-2)/2;
    if(K>max1){
        printf("-1");
        return 0;
    }
    int M = N-1;
    vector<PII> ans;
    for(int i = 2;i<=N;i++){
        ans.push_back(MP(1,i));
    }
    int temp = 2,lef = N-temp,cnt = 1;
    while(max1>K){
        M++;
        ans.push_back(MP(temp,temp+cnt));
        lef--;
        cnt++;
        if(lef==0){
            temp++;
            lef = N-temp;
            cnt = 1;
        }
        max1--;
    }
    printf("%d\n",M);
    for(auto e:ans){
        printf("%d %d\n",e.first,e.second);
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[4];
  for(int i=0;i<4;++i) cin >> s[i];
  sort(s,s+4);
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < N; ++i) cin >> B[i];
	for (int i = 1; i < N; ++i) A[i] += A[i - 1];
	for (int i = N - 2; i >= 0; --i) B[i] += B[i + 1];
	int ret = 0;
	for (int i = 0; i < N; ++i) ret = max(ret, A[i] + B[i]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
require 'pp'
n, m = gets.split(" ").map{|n| n.to_i }
cakes = []
n.times {
  cakes << gets.split(" ").map{|n| n.to_i }
}
if m == 0
  puts 0
  exit
end

result = []
[-1, 1].each {|a|
  [-1, 1].each {|b|
    [-1, 1].each {|c|
      result << cakes.map {|x, y, z|
        a*x + b*y + c*z
      }.sort[-m..-1].inject(:+)
    }
  }
}
puts result.max


Measured memory_bytes: 2428
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())
number = {}
for i in range(N):
    a = input()
    if a not in number:
        number[a] = 1
    else:
        number[a] += 1

ans = 0
for a in number:
    if number[a] % 2 == 1:
        ans += 1

print(ans)


Measured memory_bytes: 17884
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  map<string, int> mp{};
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
  return 0;
}

Measured memory_bytes: 19172
from collections import Counter
def solve():
    ans = 0
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    D = [[0,0],[0,0]]
    for k,v in C.items():
        if v>=2:
            D.append([k,v])
    D.sort(reverse=True)
    if D[0][1]>=4:
        return D[0][0]**2
    return D[0][0]*D[1][0]
print(solve())

Measured memory_bytes: 18600
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 5e3 + 15;
int dx[8] = { -1, 0, 0, 1, 1, -1, 1, -1 };
int dy[8] = { 0, -1, 1, 0, 1, -1, -1, 1 };

int main()
{
	//fast();
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(b,a)*c + ((a - b) > 0 ? (a - b)*d : 0) << endl;
	return 0;
}

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

int main(){
  int N,X,D=0,cnt = 0;
  cin >> N >> X;
  int l[N];
  for(int i=0;i<N;i++){
    cin >> l[i];
    D = D + l[i];
    if(D<=X)
      cnt++;
  }
  cout << cnt+1 << endl;
}


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

int main(void)
{
  char s[1000], t[1000];
  scanf("%s %s", s, t);

  int ans = 1000;
  int ls, lt;
  ls = strlen(s);
  lt = strlen(t);
  
  for(int i=0;i<ls-lt+1;i++){
    int now=0;
    int n=0;
    for(int j=i;j<i+lt;j++){
      if(s[j] != t[n]) now++;
      n++;
    }
    if(now<ans) ans = now;
  }
  
  printf("%d\n", ans);

  return 0;
}


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

int main(){
  int K,S;
  cin >> K >> S;
  long long count = 0;
  for(int X=0;X<=K;X++){
    for(int Y=0;Y<=K;Y++){
      int Z = S - X - Y;
      if(0<=Z&&Z<=K){
        count ++;
      }
    }
  }
  cout << count << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D){
    cout << "Left" << endl;
  }else if(A + B < C + D){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 384
# Author: cr4zjh0bp
# Created: Thu Mar 12 07:43:04 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

S = ns()
ans = 700
for i in range(3):
    if S[i] == 'o':
        ans += 100

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
 
template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
const int MAX = 100100;
int c[MAX],vis[MAX];
vector<int> d[MAX];
vector<int> rest,ak;
int n,m;
void dfs(int v){
  if(vis[v])return;
  vis[v] = 1;
  ak.PB(c[v]);
  for(int el:d[v])dfs(el);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  R(i,n){
    cin >> c[i];
  }
  R(i,m){
    int a,b;
    cin >> a >> b;
    d[a].PB(b);
    d[b].PB(a);
  }
  int res = 0;
  int il = 0;
  R(i,n){
    if(vis[i] == 0){
      dfs(i);
      sort(ALL(ak));
      res+=ak[0];
      il++;
      for(int j = 1;j < SZ(ak);j++){
        rest.PB(ak[j]);
      }
      ak.clear();
    }
  }
  if(il == 1){
    cout << "0\n";
  }else{
    if(SZ(rest) < il-2){
      cout << "Impossible\n";
      return 0;
    }
    sort(ALL(rest));
    R(i,il-2){
      res += rest[i];
    }
    cout << res << "\n";
  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, m;
  cin >> n >> m;
  vll c(m);
  REP(i,m) cin >> c[i];

  vll dp(n+1,LINF);

  dp[0] = 0;

  for(ll i = 1; i <= n; i++){
    for(ll j = 0; j < m ; j++){
      if(i - c[j] < 0) continue;
      dp[i] = min(dp[i], dp[i - c[j]] + 1);
    }
  }

  cout << dp[n] <<endl;

    
  return 0;
}




Measured memory_bytes: 3376
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e16;

template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

lint A, B, C, D;
ModInt dp[3003][3003];
int main() {
	cin >> A >> B >> C >> D;
	dp[A][B] = 1;
	FOR(i, A, C + 1) {
		FOR(j, B, D + 1) {
			dp[i + 1][j] += dp[i][j] * j;
			if (dp[i][j + 1].a != 0) dp[i][j + 1] += dp[i][j] * i - dp[i - 1][j] * j * (i - 1);
			else dp[i][j + 1] += dp[i][j] * i;
		}
	}
	cout << dp[C][D].a << endl;
}


Measured memory_bytes: 73812
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

long long MX = (long long)(1e18);
int main() {
    FIO;
    int n, m, x;
    long long c[20];
    long long v[20][20];
    cin >> n >> m >> x;
    for(int i=0; i<n; i++)
    {
        cin >> c[i];
        for(int j=0; j<m; j++)
        {
            cin >> v[i][j];
        }
    }
    long long ans = MX;
    for(int i=1; i<(1 << n); i++)
    {
        vector<int> tmp(m+1, 0);
        long long cst = 0;
        for(int j=0; j<n; j++)
        {
            if((i&(1 << j)) == 0) continue;
            cst += c[j];
            for(int k=0; k<m; k++)
            {
                tmp[k] += v[j][k];
            }
        }
        for(int j=0; j<m; j++)
        {
            if(tmp[j] < x)
            {
                goto th;
            }
        }
        ans = min(ans, cst);
        th:
        ;
    }
    if(ans == MX)
    {
        cout << -1 << "\n";
    }
    else
    {
        cout << ans << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3168
n=int(input())
a=list(map(int,input().split()))
x,y,z=0,0,0
for i in range(n):
    x+=a[i]
    if i%2==0:
        if x>0:pass
        else:
            y+=1-x
            x=1
    else:
        if x<0:pass
        else:
            y+=x+1
            x=-1
x=0
for i in range(n):
    x+=a[i]
    if i%2==1:
        if x>0:pass
        else:
            z+=1-x
            x=1
    else:
        if x<0:pass
        else:
            z+=x+1
            x=-1
print(min(y,z))

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

int gcd(int x, int y){
  if(x < y) swap(x,y);
  if(!y) return x;
  return gcd(y,x%y);
}

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


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main()
{
	char S[11] = { NULL };
	int C = 0;
	int U = 0;

	scanf("%s", S);

	if (S[0] == 'A') {
		for (int i = 2; i < strlen(S) - 1; i++) {
			if (S[i] == 'C') {
				C++;
			}
		}

		if (C == 1) {
			for (int i = 0; i < strlen(S); i++) {
				if (isupper( S[i]) ) {
					U++;
				}
			}

			if (U == 2) {
				printf("AC");
				return 0;
			}
			else {
				goto X;
			}

		}else {
			goto X;
		}


	}else {
		goto X;
	}

	X: printf("WA");

	return 0;
}

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

using namespace std;

int tab[1005];
int main()
{
    int n;
    cin  >> n;
    for (int i = 0; i < n;  i++)
    {
        cin >> tab[i];
    }
    sort(tab, tab+n);
    int prev = 100000;
    int res = 0;
    for (int i = n-1; i >= 0; i--)
    {
        if (tab[i] < prev)
        {
            prev = tab[i];
            res++;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  char c;cin>>c;
  if(c == 'A')cout << 'T';
  if(c == 'T')cout << 'A';
  if(c == 'G')cout << 'C';
  if(c == 'C')cout << 'G';
  cout << endl; 
}


Measured memory_bytes: 256
#include <stdio.h>
#define NM 500000
#define SM 1000000000
void merge(int*, int, int, int);
void mergeSort(int*, int, int);
int num;
main()
{
  int i;
  int left;
  int right;
  int n;
  int S[NM];

  scanf("%d",&n);

  for(i = 0;i < n;i++)
    {
      scanf("%d",&S[i]);
    }

  left = 0;
  right = n;
   
  mergeSort(S, left, right);

  for(i = 0;i < n;i++)
    {
      printf("%d",S[i]);
      if(i != n - 1)
	{
	  printf(" ");
	}
    }
  printf("\n");
  printf("%d\n",num);

  return 0;

}

void mergeSort(int *A, int left, int right)
{
  int mid;

  if(left + 1 < right)
    {
      mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }
}

void merge(int *A, int left, int mid, int right)
{
  int n1, n2;
  int i,j,k;

  n1 = mid - left;
  n2 = right - mid;

  int L[n1 + 1];
  int R[n2 + 1];


  for(i = 0;i < n1;i++)
    {
      L[i] = A[left + i];
    }

 
  for(i = 0;i < n2;i++)
    {
      R[i] = A[mid + i];
    }


  L[n1] = SM;
  R[n2] = SM;

  i = 0;
  j = 0;

  for(k = left;k < right;k++)
    {
      if(L[i] <= R[j])
	{
	  A[k] = L[i];
	  i++;
	  num++;
	}

      else
	{
	  A[k] = R[j];
	  j++;
	  num++;
	}
    }
}

Measured memory_bytes: 4508