akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 long long int i,j,c,b,g,r,bg,gb,br,rb,gr,rg,n,ans;
 b=g=r=bg=gb=rb=br=gr=rg=ans=0;
 c=1;
 string s;
 cin >> n >> s;
 s.append(1,'#');
 for(i=0;i<n;i++)
 {
  if(s[i]==s[i+1])
  c++;
  else
  {
   if(s[i]=='R')
   {
    ans+=bg*c;
    ans+=gb*c;
    r+=c;
    gr+=g*c;
    br+=b*c;
   }
   else if(s[i]=='G')
   {
    ans+=br*c;
    ans+=rb*c;
    g+=c;
    rg+=r*c;
    bg+=b*c;
   }
   else if(s[i]=='B')
   {
    ans+=gr*c;
    ans+=rg*c;
    b+=c;
    gb+=g*c;
    rb+=r*c;
   }
   c=1;
  }
 }
 for(i=0;i<n;i++)
 {
  for(j=(i+1);j<n;j++)
  {
   if(s[i]!=s[j] && (j+j-i)<n && s[j+j-i]!=s[i] && s[j+j-i]!=s[j])
   ans--;
  }
 }
 cout << ans;
 return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans(0);
  string s;
  cin >> n >> s;
  for(int i = 0;i<n-2;i++){
    if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C'){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

int main()
{
	int n=read(),now=0;
	for (int i=1;i<=n;i++)
	{
		int a=read();
		if (a==now+1) now++;
	}
	if (now==0) print(-1);
		   else print(n-now);

	return 0;
}

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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

int main() {
  int n;
  cin >> n;
  ll result = 1;
  ll m = 1000000007;
  rep(i, n) {
    result = (i + 1) * result % m;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#define pi 3.14159265358979323846
using namespace std;

int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double arg1, arg2, count;
  arg1 = (h * 60 + m) / 2;
  arg2 = m * 6;
  if(arg1 >= arg2)
    count = arg1 - arg2;
  else
    count = arg2 - arg1;
  if(count >= 180)
    count = 360 - count;
  count = (count / 360) * 2 * pi;
  cout << fixed << setprecision(20);
  //cout << pi << "\n" << count << "\n" << cos(count);
  cout << sqrt((a * a) + (b * b) - 2 * a * b * cos(count)) << endl;
  return 0;
}
  

Measured memory_bytes: 4160
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=300050;
//↑templete
#define int long long
//↓区間和を求めるSegmentTree
struct SegmentTreeSum {
private:
    int n;
    vector<int> node;

public:
    // 元配列 v をセグメント木で表現する
    SegmentTreeSum(vector<int> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = (node[2*i+1] + node[2*i+2]);
    }
	void update(int x, int val) {
		// 最下段のノードにアクセスする
		x += (n - 1);

		// 最下段のノードを更新したら、あとは親に上って更新していく
		node[x] = val;
		while(x > 0) {
			x = (x - 1) / 2;
			node[x] = (node[2*x+1] + node[2*x+2]);
		}
	}
	int getsum(int a, int b, int k=0, int l=0, int r=-1) {
		// 最初に呼び出されたときの対象区間は [0, n)
		if(r < 0) r = n;

		// 要求区間と対象区間が交わらない -> 適当に返す
		if(r <= a || b <= l) return 0;

		// 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
		if(a <= l && r <= b) return node[k];

		// 要求区間が対象区間の一部を被覆 -> 子について探索を行う
		// 左側の子を vl ・ 右側の子を vr としている
		// 新しい対象区間は、現在の対象区間を半分に割ったもの
		int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
		int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
		return (vl + vr);
	}
};
vll A;
//↑区間和を求めるSegmentTree
signed main(){
	ll N;
	cin>>N;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	SegmentTreeSum T(A);
	ll ans=INFLL;
	for(int i=1;i<N;i++){
		ans=min(ans, llabs(T.getsum(0, i)-T.getsum(i, N)));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  int n, check=1, now=0;;
  cin >> n;
  vector<PiP>a(n+1);
  a[0].first=0;a[0].second.first=0;a[0].second.second=0;
  REP(i, n)cin >> a.at(i).first >> a.at(i).second.first >> a.at(i).second.second;
  REP(i, n){
    int num = (a[i].first - a[i-1].first - ( abs(a[i].second.first - a[i-1].second.first) + abs(a[i].second.second - a[i-1].second.second)));
    if(num % 2 != 0 || num < 0)check=0;
  }
  if(check)cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
int h,w;
cin>>h>>w;
int dx[8] = {-1,-1,-1,0,0,1,1,1};
int dy[8] = {-1,1,0,1,-1,-1,0,1};
char buf[55][55] = {};
for(int i = 0; i<h; i++){
    for(int j = 0; j<w; j++){
        cin>>buf[i][j];
    }
}
int count = 0;
for(int i = 0; i<h; i++){
    for(int j = 0; j<w; j++){
        if(buf[i][j]=='.'){
            for(int k = 0; k<8; k++){
                int x = j + dx[k];
                int y = i + dy[k];
                if(x>=0&&x<=w&&y>=0&&y<=h&&buf[y][x]=='#'){
                    count++;
                }
            }
            buf[i][j] =  '0' + count;
        }
        count = 0;
    }
}
for(int i = 0; i<h; i++){
    for(int j = 0; j<w; j++){
        if(j%w==0){
            cout<<endl;
        }
        cout<<buf[i][j];
    }
}
return 0;
}



Measured memory_bytes: 256
n, m = [int(i) for i in input().strip().split()]
a = []
for _ in range(m):
    a.append([int(i) for i in input().strip().split()])
a.sort(key=lambda s: s[1])
result = a[0]
for i in range(1, len(a)):
    if result[1] >= a[i][0]:
        result = [max(result[0], a[i][0]), min(result[1], a[i][1])]
    else:
        result = []
        break
print(result[1] - result[0] + 1 if len(result) else 0)


Measured memory_bytes: 22768
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
typedef struct Node {
    struct Node *next;
    struct Node *prev;
    long key;
} NODE;
 
NODE *front = NULL;
NODE *rear = NULL;
 
void insert(long key)
{
    NODE *node = (NODE *)malloc(sizeof(NODE));
    node->prev = NULL;
    node->next = NULL;
    node->key = key;
    if (front == NULL) {
        front = rear = node;
    }
    else {
       front->prev = node;
       node->next = front;
       front = node;
    }
}
 
void delete_first()
{
    NODE *tmp = front;
    if (tmp != NULL) {
        if (front == rear) {
	    front = NULL;
	    rear = NULL;
	}
	else {
	    front = tmp->next;
	    front->prev = NULL;
	}
	free(tmp);
    }
}
 
void delete_last()
{
    NODE *tmp = rear;
    if (tmp != NULL) {
        if (front == rear) {
	    front = NULL;
	    rear = NULL;
        }
        else {
	    rear = tmp->prev;
	    rear->next = NULL;
        }
	free(tmp);
    }
}
 
void delete(long key)
{
    NODE *node = front;
    while (node != NULL) {
        if (node->key == key) {
            if (node == front) {
                delete_first();
            }
            else if (node == rear) {
                delete_last();
            }
            else {
                node->next->prev = node->prev;
                node->prev->next = node->next;
                free(node);
		node = NULL;
            }
            break;
        }
	node = node->next;
    }
}
 
int main(int argc, int *argv[])
{
    int i, num;
    char cmd[16];
    long key;
     
    scanf("%d", &num);
 
    for(i = 0; i < num; i++) {
        scanf("%s", cmd);
 
        if (strcmp(cmd, "insert") == 0) {
            scanf("%ld", &key);
            insert(key);
        }
        else if (strcmp(cmd, "delete") == 0) {
            scanf("%ld", &key);
            delete(key);
        }
        else if (strcmp(cmd, "deleteFirst") == 0) {
            delete_first();
        }
        else if (strcmp(cmd, "deleteLast") == 0) {
            delete_last();
        }
    }
 
    NODE *node = front;
    while (node != NULL) { 
	if (node == rear) {
            printf("%ld\n", node->key);
        }
        else {
            printf("%ld ", node->key);
        }

        NODE *tmp = node->next;
	free(node);
	node = tmp;
    }
    return 0;
}

Measured memory_bytes: 31788
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s;
    bool ans = false;
    rep(i,s.size()){
        if(s[i]=='7')ans = true;
    }
    Yes(ans);
    return 0;
}

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

int n;
int64_t k;
int adj[200020], d[200020], clr[200020], p[200020];
deque < pair < int, int > > cyc;

void dfs (int u) {
    clr[u] = 1;
    if (clr[adj[u]] == 1) {
        cyc.push_front(make_pair(u, d[u]));
        while (cyc.front().first != adj[u]) 
            cyc.push_front(make_pair(p[cyc.front().first], d[p[cyc.front().first]]));
    }
    else {
        d[adj[u]] = d[u] + 1;
        p[adj[u]] = u;
        dfs(adj[u]);
    }
    clr[u] = 2;
}

signed main () {
    cin >> n >> k;
    for (int u = 1; u <= n; ++u) 
        cin >> adj[u];
    dfs(1);
    if (k < int64_t(cyc.front().second)) {
        for (int ans = 1; ans <= n; ++ans) {
            if (d[ans] == k) {
                cout << ans << '\n';
                return 0;
            }
        }
    }
    else {
        k -= int64_t(cyc.front().second);
        k %= int64_t(cyc.size());
        cout << cyc[k].first << '\n';
    }
}


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

    

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);
  vector<vector<ll>> dp(N, vector<ll>(3));
  dp.at(0).at(0)=0;
  dp.at(0).at(1)=0;
  dp.at(0).at(2)=A.at(0);
  dp.at(1).at(0)=0;
  dp.at(1).at(1)=max(A.at(0),A.at(1));
  if(N==2){
    cout << dp.at(1).at(1) << endl;
    return 0;
  }
  for(ll i=2;i<N;i++){
    for(ll j=0;j<=2-(i%2);j++){
      if(i==2&&j==0){
        dp.at(i).at(j)=0;
        continue;
      }
      if(i%2==0){
        if(j==0||j==1){
          dp.at(i).at(j)=max(dp.at(i-2).at(j)+A.at(i),dp.at(i-1).at(j));
        }else{
          dp.at(i).at(j)=dp.at(i-2).at(j)+A.at(i);
        }
      }else{
        dp.at(i).at(j)=max(dp.at(i-2).at(j)+A.at(i),dp.at(i-1).at(j+1));
      }
    }
  }
  cout << dp.at(N-1).at(1) << endl;
}

Measured memory_bytes: 15652
#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;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//
 
int main() {
	int x, t;
	cin >> x >> t;
	cout << max(x - t, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

const ll N = 1e6+100;

void solve(){
	int n;
	cin >> n;
	
	vi a(N, 0), arr(n);
	for(int i=0 ; i<n ; ++i){
		cin >> arr[i];
		++a[arr[i]];
	}
	
	sort(all(arr));
	
	vb prime(N, 1);prime[0] = prime[1] = 0;
	for(ll i=2 ; i<N ; ++i){
		if(prime[i]){
			for(ll j=i*i ; j<N ; j+=i){
				prime[j] = 0;
			}
		}
	}
	
	set<int> s;
	for(ll i=2 ; i<N ; ++i){
		if(prime[i]){
			int cnt=0;
			for(ll j=i ; j<N ; j+=i){
				cnt+=a[j];
			}
//			debug(i);debug(cnt);
			if(cnt)s.insert(cnt);
		}
	}
	
	if((s.size() == 1 && *s.begin() == 1) || (!s.size())){
		cout << "pairwise coprime";
	}
	else{
		int g = arr[0];
		for(int i=1 ; i<n&&g!=1 ; ++i)g = __gcd(g, arr[i]);
		
		if(g == 1)cout << "setwise coprime";
		else cout << "not coprime";
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 11204
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

void dfs(string s,int size){
  if(s.size() == size-1){
    if(size == 1){
      print('a');
      return;
    }
    int last = 0;
    rep(i,size)chmax(last,s[i]-'a');
    rep(i,last+2){
      print(s + (char)('a'+i));
    }
    return;
  }
  int last = 0;
  rep(i,size)chmax(last,s[i]-'a');
  if(s.size() == 0)last--;
  rep(i,last+2){
    // s += (char)('a'+i);
    if(s.size() < size)dfs(s+char('a'+i),size);
  }
}

// TODO: write
int main() {
  int n;cin>>n;
  string s;
  dfs(s,n);
  
  return 0;
}


Measured memory_bytes: 1536
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  const points = [0, 0];
  let [str, opSize, ...codes] = content.trim().split('\n');

  const ops = codes.map(code => {
    const [op, ...args] = code.split(' ');
    if (op === 'print' || op === 'reverse') {
      return {op, args: args.map(n => parseInt(n, 10))};
    } else {
      const [a, b, str] = args;
      return {
        op,
        args: [parseInt(a, 10), parseInt(b, 10), str],
      };
    }
  });

  ops.forEach(({op, args}) => {
    switch (op) {
      case 'print': {
        return console.log(str.slice(args[0], args[1] + 1));
      }
      case 'reverse': {
        str = reverse(str, ...args);
        return;
      }
      case 'replace': {
        str = replace(str, ...args);
        return;
      }
    }
  });
});

const reverse = (str, a, b) =>
  str.substring(0, a) +
  str
    .substring(a, b + 1)
    .split('')
    .reverse()
    .join('') +
  str.substring(b + 1);

const replace = (str, a, b, replacement) =>
  str.substring(0, a) + replacement + str.substring(b + 1);


Measured memory_bytes: 17008
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,h[100],tot,ans,w;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
        tot+=h[i];
    }
    while(tot){
        for(int i=0;i<n;i++){
            if(h[i]){
                h[i]--;
                w=1;
                tot--;
                if(!tot){cout<<ans+1<<endl;return 0;}
            }
            else if(w){
                w=0;
                ans++;
            }
        }
        if(w){
            w=0;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
heights = list(map(int, input().split()))
humidai = []
for i in range(len(heights)):
    if humidai == []:
        humidai.append(0)
    else:
        if heights[i] < heights[i-1]:
            h_height = heights[i-1] - heights[i]
            heights[i] += h_height
            humidai.append(h_height)
        else:
            humidai.append(0)
print(sum(humidai))



Measured memory_bytes: 32216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
#define for0(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define forA(a, b, c) for (int(a) = (b); (a) <= (c); (a)++)
#define forD(a, b, c) for (int(a) = (b); (a) >= (c); (a)--)
#define deb(x) cout<< #x << "=" << x <<endl
#define all(a) a.begin(),a.end()
#define re(x) cin>>x
#define readarr(a,n) for0(i,n) cin>>a[i]
#define mod 1000000007
#define INF 1000000000000000003
#define ff first
#define ss second
#define pb push_back 
#define pob pop_back
#define mp make_pair
#define endl "\n"

typedef long long int            ll;
typedef vector<int>              vi;
typedef pair<int, int>           pi;
typedef unordered_map<int, int>  mii;
typedef unordered_map<char, int> mci;
typedef unordered_set<int>       usi;

int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}

void solve(){
	double n,m;
	re(n),re(m);
	vi arr(n);
	readarr(arr,n);
	sort(all(arr),greater<int>());
	int mm=0;
	int sum=0;
	for0(i,n)
	sum+=arr[i];
	double com = 1/(4*m);
	com = com * sum;
	for0(i,n)
	if(arr[i] >= com)
		mm++;
	if(mm>=m)
		cout<<"Yes";
	else
		cout<<"No";
}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1; 
    // cin>>t;
    while(t--){
      solve();
    }
    return 0;
}

Measured memory_bytes: 3744
#include <stdio.h>

int main()
{
 
  int a, b, r, stmp;
 

  scanf("%d %d",&a,&b);
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    stmp = a;
    a = b;
    b =stmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最大公約数を出力 */
  printf("%d\n", b);
 
  return 0;
}



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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

ll dp[200015][5][2];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	dp[5][0][0] = dp[5][1][0] = dp[5][3][0] = dp[5][0][1] = dp[5][1][1] = dp[5][2][1] = dp[5][3][1] = -1000000000000000000;
	rep1(i, n) {
		int v; gi(v);
		int k = i+5;
		if(i % 2) {
			dp[k][0][0] = max(dp[k-1][0][0], dp[k-1][0][1]);
			dp[k][1][0] = max(dp[k-1][1][0], dp[k-1][1][1]);
			dp[k][2][0] = max(dp[k-1][2][0], dp[k-1][2][1]);
			dp[k][3][0] = max(dp[k-1][3][0], dp[k-1][3][1]);
			dp[k][0][1] = -1000000000000000000;
			dp[k][1][1] = dp[k-1][0][0] + v;
			dp[k][2][1] = dp[k-1][1][0] + v;
			dp[k][3][1] = dp[k-1][2][0] + v;
		} else {
			dp[k][0][0] = max(dp[k-1][1][0], dp[k-1][1][1]);
			dp[k][1][0] = max(dp[k-1][2][0], dp[k-1][2][1]);
			dp[k][2][0] = max(dp[k-1][3][0], dp[k-1][3][1]);
			dp[k][3][0] = -1000000000000000000;
			dp[k][0][1] = dp[k-1][0][0] + v;
			dp[k][1][1] = dp[k-1][1][0] + v;
			dp[k][2][1] = dp[k-1][2][0] + v;
			dp[k][3][1] = dp[k-1][3][0] + v;
		}
	}
	print(max(dp[n+5][2][0], dp[n+5][2][1]));
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, X, M;
    cin >> N >> X >> M;

    vector<lint> A(1000000);
    A[1] = X;

    map<lint, lint> mp;
    mp[A[1]] = 1;

    int start = -1, end = -1;
    int len;
    for (int i = 2; i < 1000000; i++) {
        A[i] = ((A[i - 1] % M) * (A[i - 1] % M)) % M;
        if (mp.count(A[i]) == 0) {
            mp[A[i]] = i;
        } else {
            start = mp[A[i]];
            end   = i;
        }
    }
    len = end - start;

    lint cycle_sum = 0;
    for (int i = start; i < end; i++) {
        cycle_sum += A[i];
    }

    N++;
    lint ans = 0;
    if (N < start) {
        for (int i = 0; i <= N; i++) {
            ans += A[i];
        }
    } else {
        for (int i = 0; i < start; i++) {
            ans += A[i];
        }
        N -= start;

        lint k = N / (end - start);
        lint r = N % (end - start);

        ans += cycle_sum * k;

        for (int i = start; i < start + r; i++) {
            ans += A[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14012
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

a=0#0
b=0#1

for i in range(len(s)):
    if s[i] == '0':
        if i % 2 == 0:
            b += 1
        else:
            a += 1
    if s[i] == '1':
        if i % 2 == 0:
            a += 1
        else:
            b += 1

print(min(a,b))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC147 C - HonestOrUnkind2
// 2020.06.19

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<vector<pair<int, int> > > Axy(N, vector<pair<int, int> >());
  REP(i, N){
    int A; cin >> A;
    REP(j, A){
      int x, y; cin >> x >> y; x--;
      Axy[i].push_back({x, y});
    }
  }
  int ans = 0;
  REP(i, 1<<N){
    vector<int> check(N, 0);
    int res = 0;
    REP(j, N){
      if((i >> j) & 1){
        check[j] = 1;
        res++;
      }
    }
    bool flag = true;
    REP(j, N){
      if(check[j]){
        for(auto k : Axy[j]){
          if(check[k.first] != k.second){
            flag = false;
            break;
          }
        }
      }
      if(!flag) break;
    }
    if(flag){
      ans = max(ans, res);
    }
  }
  cout << ans << endl;
}

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

#define X first
#define Y second
#define N 300010
#define M 400010
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1000000007;

int n,m;
int c[N];
vector<pii> g[N];

inline int Lowbit(int x){return x&(-x);}

void Add(int x,int v)
{
	while (x<=m)
	{
		c[x]+=v;
		x+=Lowbit(x);
	}
}

int Val(int x)
{
	int res=0;
	while (x)
	{
		res+=c[x];
		x-=Lowbit(x);
	}
	return res;
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		int l,r; scanf("%d%d",&l,&r);
		g[r-l+1].push_back(make_pair(l,r));
	}
	int sz=0;
	for (int i=1;i<=m;i++)
	{
		int x=i,res=0;
		do
		{
			res+=Val(x);
			x+=i;
		}while (x<=m);
		
		for (int j=0;j<g[i].size();j++)
		{
			Add(g[i][j].X,1);
			Add(g[i][j].Y+1,-1);
		}
		printf("%d\n",res+n-sz);
		sz+=g[i].size();
	}
	return 0;
}


Measured memory_bytes: 12672
N = int(input())
H = list(map(int, input().split()))

ans = True
h = H[0]
decreaseable = True
for i in range(1, N):
    if H[i] <= H[i - 1] - 2 or not decreaseable and H[i] < h:
        ans = False
        break
    if H[i] == h - 1:
        h = H[i]
        decreaseable = False
    elif H[i] > h:
        h = H[i]
        decreaseable = True
print('Yes' if ans else 'No')


Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);

int H, W;
int mp[1400][1400];
int dp[1400][1400];

int main() {
	cin >> H >> W;
	rep(y, H) rep(x, W) cin >> mp[y][x];

	rep(y, H) rep(x, W){
			if(y == 0 || x == 0) {
				dp[y][x] = (mp[y][x] == 0 ? 1 :0);
			}
			else{
				dp[y][x] = (mp[y][x] == 0 ? 1 + min(min(dp[y-1][x], dp[y][x-1]), dp[y-1][x-1]) : 0) ;
			}
		}

	int ret = 0;
	rep(y, H) rep(x, W) ret = max(ret, dp[y][x]);

    /*
	rep(y, H){
		rep(x, W) cerr << mp[y][x] << " ";
		cerr << endl;
	}
	cerr << "------" << endl;
	rep(y, H){
		rep(x, W) cerr << dp[y][x] << " ";
		cerr << endl;
	}
     */

	cout << ret * ret << endl;
}

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

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


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

    ll i,j,k,l,m,n,w,z=0,p,q,tmp,sum=0;
    string str;
    cin>>n>>m;
    vector<ll> cnt(n+1);
    vector<ll> x(m+1);
    vector<ll> y(m+1);
    rep(i,m){
        cin>>x[i]>>y[i];
    }
    reverse(x.begin(),x.end());
    reverse(y.begin(),y.end());
    for(ll i=1;i<n;i++){
        z+=i;
    }
    l=z;
    UnionFind t(n+1);
    t.init(n);
    vector<ll> d(m+1000000);
    d[m-1]=z;
    for(i=0;i<m;i++){
        //cout<<z<<endl;
        ll lastx,lasty,nowx,nowy;
        lastx=t.size(x[i]);
        lasty=t.size(y[i]);

        t.merge(x[i],y[i]);
        nowx=t.size(x[i]);
        nowy=t.size(y[i]);
        z=z-(nowx-lastx)*(nowy-lasty);
        d[m-i-1]=z;
    }
    rep(i,m) cout<<d[i]<<endl;

    //cout<<l<<endl;
    //cout<<sum<<endl;

    return 0;
}





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

using namespace std;

struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	UnionFind tree(n);

	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) tree.unite(x, y);
		if (com == 1) {
			if (tree.same(x, y)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}


	return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long long n,m;
    cin>>n>>m;
    int sum=0;
    if(2*n>=m)
        printf("%lld\n",m/2);
    else
        printf("%lld\n",n+(m-n*2)/4);
}
//aaa

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n;

struct node{
	int x;
	int y;
}a[maxn];

bool cmp(node a,node b){
	return a.x<b.x;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].x;
		a[i].y=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
	cout<<a[i].y<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1536
import itertools
import math
n=int(input())
lst=[None]*n
for i in range(n):
    lst[i]=tuple(map(int, input().split()))
total=0
for v in itertools.permutations(lst):
    for i in range(n-1):
        dis=math.sqrt( (v[i][0]-v[i+1][0])**2 + (v[i][1]-v[i+1][1])**2 )
        total+=dis
print(total/math.factorial(n))



Measured memory_bytes: 3064
N = int(input())
S = list(input())
dp = [[0]*(N) for _ in range(N)]
for i in range(N):
  if S[-1] == S[i]:
    dp[-1][i] = 1
    dp[i][-1] = 1
  

for i in range(N-2, -1, -1):
  for j in range(N-2, -1, -1):
    if S[i] == S[j]:
      dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
  for j in range(N):
    if i + dp[i][j] <= j:
      ans = max(ans, dp[i][j])
print(ans)

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

int main() {
  long long N;
  cin >> N;
  long long ans = 4;
  vector<long long> time(5);
  for (int i = 0; i < 5; i++) cin >> time.at(i);
  sort(time.begin(), time.end());
  if (N <= time.at(0)) cout << 5 << endl;
  else {
    if (N % time.at(0) == 0) ans--;
    ans += (N - N % time.at(0)) / time.at(0) + 1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	double v;

	while(scanf("%lf", &v)!=EOF){
		double t=v/9.8;
		double y=4.9*t*t;
		double n=(y+5.0)/5.0;
		n+=1.0;
		printf("%d\n", (int)n);
	}

	return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ld, ld> pii;
#define x first
#define y second
#define mp make_pair

int n;
pii a[15];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0 ; i < n ; ++i){
	cin >> a[i].x >> a[i].y;
}
vector <int> v;
ld k = 1;
for(int i = 0 ; i < n ; ++i){
	v.push_back(i);
	k *= (i + 1);
}
ld sve = 0;
do{
	for(int i = 0 ; i < n - 1 ; ++i){
		int sad = v[i];
		int nxt = v[i + 1];
		//cout << a[sad].x << ' ' << a[sad].y << ":" << a[nxt].x << ' ' << a[nxt].y << endl;
		ld dist = sqrt((a[sad].x - a[nxt].x) * (a[sad].x - a[nxt].x) + (a[sad].y - a[nxt].y) * (a[sad].y - a[nxt].y));
		sve += dist;
	}
}while(next_permutation(v.begin(), v.end()));
sve /= k;
cout << fixed << setprecision(12) << sve << endl;

return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

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

		long a =  sc.nextLong();
		long b =  sc.nextLong();
		long x =  sc.nextLong();
		

		long min = a / x;
		long max = b / x;

		if( a % x == 0 && b % x == 0)
		{
			System.out.println((max - min + 1));
		}else if(a % x == 0)
		{
			System.out.println((max - min + 1));
		}else if(b % x == 0)
		{
			System.out.println((max - min));
		}
		else
		{
			System.out.println((max - min));
		}
	}



}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
void fuk() { puts("-1"); exit(0); }

char A[100055];

int N, C = 1;

int f(int cnt, int rt) {
	if(1 == cnt) return 1;
	int nt = cnt-1; for(; '0' == A[nt]; nt--);
	C++; printf("%d %d\n", rt, C);
	int lft = cnt - 1 - f(nt, C);
	for(; lft--;) {
		C++;
		printf("%d %d\n", rt, C);
	}
	return cnt;
}

int main() {
	scanf(" %s", A+1);
	N = strlen(A+1);

	if('1' != A[1] || '0' != A[N]) fuk();
	for(int i = 1; i < N; i++)
		if(A[i] != A[N-i]) fuk();

	f(N, 1);

	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    for(int i=1; i<=b; ++i){
        if((a*i)%b==c){
            cout("YES");
            return 0;
        }
    }
    cout("NO");
    return 0;
}








Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
// #include <bit>
// #include <bitset>
// #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main()
{
	ll n;
	cin >> n;
	ll a[n];
	ll b[n];
	ll c[n];

	rep(i, n)
	{
		cin >> a[i];
	}
	rep(i, n)
	{
		cin >> b[i];
	}
	rep(i, n)
	{
		cin >> c[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);

	ll ans = 0;
	rep(i, n)
	{
		ll middle = b[i];
		ll a_index = lower_bound(a, a + n, middle) - a;
		ll b_index = upper_bound(c, c + n, middle) - c;

		ans += a_index * (n - b_index);
	}

	cout << ans << endl;
}

//g++ -std=c++17 -g main.cpp -o mai	n


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

typedef long long ll;

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

    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    int a[110][110] = {0};
    int ok[110] = {0};
    for(int i=0;i<k;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            cin >> a[i][j];
            ok[a[i][j]-1]++;
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(ok[i]==0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,h[100000],dp[100000];
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2; i<n; i++) {
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n / 2] - a[n / 2 - 1] << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b,c; cin>>a>>b>>c;
    if(a<b&&b<c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  
  if(abs(a-b)>=1) co(max(a, b)*2-1);
  else co(max(a, b)*2);
  
  return 0;
}


Measured memory_bytes: 256
// Aizu 0270: Modular Query
// 2017.8.24 bal4u@uu

#include <stdio.h>

char tbl[300005];

int main()
{
	int N, Q, i, k, q, max;

	scanf("%d%d", &N, &Q);
	max = 0; while (N-- > 0) {
		scanf("%d", &k), tbl[k] = 1;
		if (k > max) max = k;
		if (k & 1) tbl[1] = 1;
		else tbl[2] = 1;
	}
	while (Q-- > 0) {
		scanf("%d", &q);
		for (k = q-1; ; k--) {
			for (i = k; i <= max; i += q)
				if (tbl[i]) { printf("%d\n", k), k = 0; goto Done; }
		}
		Done:;
	}
	return 0;
}

Measured memory_bytes: 888
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <sstream>
#include <stack>

int main()
{
	//std::cout << std::fixed << std::setprecision(15);

	int a, b;
	std::cin >> a >> b;

	int min = std::min(a, b);
	int max = std::max(a, b);

	std::ostringstream os;
	for (size_t i = 0; i < max; ++i)
	{
		os << min;
	}

	std::cout << os.str() << std::endl;

	return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
n = int(input())
A = tuple(map(int, input().split()))
B = [0]*n
B[0] = A[0]
for i in range(1, n):
    B[i] = B[i-1] + A[i]
    B[i] %= mod
ans = 0
for i in range(1, n):
    a = A[i]
    a *= B[i-1]
    a %= mod
    ans += a
    ans %= mod
print(ans)

Measured memory_bytes: 32076
row = [False] * 8
col = [False] * 8
dpos = [False] * 15
dneg = [False] * 15


board = [['.', '.', '.', '.', '.', '.', '.', '.'] for i in range(8)]

import sys

file_input = sys.stdin

k = int(file_input.readline())

for line in file_input:
    r, c = map(int, line.split())
    row[r] = True
    col[c] = True
    dpos[r + c] = True
    dneg[r - c + 7] = True
    board[r][c] = 'Q'

def dfs(i = 0):
    if i == 8:
        for line in board:
            print(''.join(line))
    elif row[i]:
        dfs(i + 1)
    else:
        for j in range(8):
            if col[j] or dpos[i + j] or dneg[i - j + 7]:
                continue
            row[i] = True
            col[j] = True
            dpos[i + j] = True
            dneg[i - j + 7] = True
            board[i][j] = 'Q'
            dfs(i + 1)
            row[i] = False
            col[j] = False
            dpos[i + j] = False
            dneg[i - j + 7] = False
            board[i][j] = '.'

dfs()


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

using namespace std;

int main() {
  // input values
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  //1st output
  cout << fixed << setprecision(15);
// defining string 
  string s, t;
  // input 
  cin >> s >> t;
// for loop cond.
  for (int i = 0; i < s.size(); ++i) {
    // if logical
    if (s[i] != t[i]) {
      // print ans
      cout << "No" << '\n';
      // return 
      return 0;
    }
  }
  // final answer 
  cout << "Yes" << '\n';

  return 0;
}

Measured memory_bytes: 3612
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
    es: [(Usize1, Usize1); m],
  }
  let mut adj = vec![vec![]; n];
  for (u, v) in es.into_iter() {
    adj[u].push(v);
    adj[v].push(u);
  }
  use std::collections::VecDeque;
  let mut point = vec![None; n];
  let mut que = VecDeque::new();
  que.push_back(0);
  while let Some(v) = que.pop_front() {
    for &u in &adj[v] {
      if point[u] == None {
        point[u] = Some(v);
        que.push_back(u);
      }
    }
  }

  println!("Yes");
  for p in point.iter().skip(1) {
    println!("{}", p.unwrap() + 1);
  }
}


Measured memory_bytes: 15988
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")
  };
}

fn main() {
  input! {
  	s: String
  }
  
  println!("{}",
  	if s != "AAA" && s != "BBB" { "Yes" }
    else { "No" }
  );
}

Measured memory_bytes: 4352
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(false);
	int n;
	int a[53];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int maxi = -10000000, mini = 10000000;
	int maxindex, minindex;
	for (int i = 0; i < n; i++) {
		if (a[i] > maxi) { maxi = a[i]; maxindex = i; }
		if (a[i] < mini) { mini = a[i]; minindex = i; }
	}
	cout << max(2 * n - 4, 0) + 3 << endl;
	if (abs(maxi)>abs(mini)) {
		cout << maxindex + 1 << " " << n << endl;
		cout << maxindex + 1 << " " << n << endl;
		cout << maxindex + 1 << " " << n << endl;
		for (int i = 1; i < n-1; i++) {
			cout << n << " " << i + 1 << endl;
			cout << i + 1 << " " << n << endl;
		}
	}
	else {
		cout << minindex + 1 << " " << 1 << endl;
		cout << minindex + 1 << " " << 1 << endl;
		cout << minindex + 1 << " " << 1 << endl;
		for (int i = n - 2; i >= 1; i--) {
			cout << 1 << " " << i + 1 << endl;
			cout << i + 1 << " " << 1 << endl;
		}
	}
}

Measured memory_bytes: 256