akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

struct Point{int x, y;};

template <typename V>
void argument_sort(vector<V>& A, bool reverse=false){
    vector<V> tmp[2];
    if(reverse){
        for(const auto& v : A){
            if(v.y<0 or (v.y==0 and v.x>0)) tmp[0].push_back(v);
            else tmp[1].push_back(v);
        }
    }else{
        for(const auto& v : A){
            if(v.y<0 or (v.y==0 and v.x<0)) tmp[1].push_back(v);
            else tmp[0].push_back(v);
        }
    }
    for(auto& vec : tmp) sort(vec.begin(), vec.end(), [](const auto& v1, const auto& v2){return 1ll*v1.x*v2.y>1ll*v2.x*v1.y;});
    int n = tmp[0].size(), m = tmp[1].size();
    for(int i=0;i<n;++i) A[i] = tmp[0][i];
    for(int i=0;i<m;++i) A[n+i] = tmp[1][i];
}

class FEngines {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<Point> V;
        REP(i, N){
            int x, y;
            in>>x>>y;
            if(x or y) V.pb({x, y});
        }
        N = LEN(V);
        argument_sort(V);
        lint ans = 0;
        REP(i, N){
            lint sumx = 0, sumy = 0;
            REP(j, N){
                sumx += V[(i+j)%N].x;
                sumy += V[(i+j)%N].y;
                chmax(ans, sumx*sumx+sumy*sumy);
            }
        }
        out<<setprecision(12)<<fixed<<sqrtl(ans)<<'\n';
    }
};


int main() {
	FEngines solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INA(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n;
pair<int, int> p[MAXN];

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n;
	FOR(i, 1, n) {
		cin >> p[i].second >> p[i].first;
	}
	
}


void preprocess() {
	
	sort(p+1, p+n+1);
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	ll timee = 0;
	
	FOR(i, 1, n) {
		timee += p[i].SE;
		if (timee > p[i].FI) {
			cout << "No\n";
			return;
		}
	}
	
	cout << "Yes\n";
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int h = h2 - h1;
    int m = m2 - m1;

    if(m < 0) {
        h--;
        m += 60;
    }

    int ans = h * 60 + m - k;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	
	const int MOD = 1e9 + 7;
	auto dp = make_v<i64>(s.size() + 1, 13); dp[0][0] = 1;
	for(int i = 0; i < s.size(); i++) {
		for(int j = 0; j < 13; j++) {
			for(int D = 0; D < 10; D++) {
				if(s[i] != '?' and (s[i] - '0') != D) continue;
			
				(dp[i + 1][(j * 10 + D) % 13] += dp[i][j]) %= MOD;
			}
		}
	}
	printf("%d\n", dp[s.size()][5]);
	return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int a;
    while (cin >> a) {
        int t = a % 39;
        if (t == 0) t = 39;
        cout << "3C";
        if (t < 10) cout << 0;
        cout << t << endl;
    }
}


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

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	ll ans=0;
	ans+=min(k,a);
	k-=min(k,a);
	k-=min(k,b);
	ans-=min(k,c);
	cout << ans;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define INF 1e7
#define mod 1000000007

using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> tii;
typedef tuple<long long int,long long int,long long int> tll;
typedef tuple<double,double,double> tdd;


int main()
{
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll ans = a*c;
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << endl;
}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,x,h,w,n,z=0,min=100000000000,k,ans=0;
    string s1,s2,s3;
    cin >> a >> b >> x;
    if(a==0) ans = b/x + 1;  //  0/x は 0 で 割り切れる 
    else ans = b/x - (a-1)/x;
    cout << ans <<endl; 
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()//面積
{
	int W, H, N, i, k;

	int x[100], y[100], a[100];

	scanf("%d", &W);
	scanf("%d", &H);
	scanf("%d", &N);
	
	for (i = 0; i <N; ++i) {
		scanf("%d", &x[i]);
		scanf("%d", &y[i]);
		scanf("%d", &a[i]);
	}
	int xmax = 0;
	int xmin = W;
	int ymax = 0;
	int ymin = H;
	

	for (k = 0; k < N; k++) {

		
		if (a[k]==1 && xmax < x[k]) {
			xmax = x[k];
		}
		if (a[k]==2 && xmin > x[k]) {
			xmin = x[k];
		}
		if (a[k]==3 && ymax < y[k]) {
			ymax = y[k];
		}
		if (a[k]==4 && ymin > y[k]) {
			ymin = y[k];
		}

	}

	int White = (xmin - xmax) * (ymin - ymax);

	if (White < 0) {
		White = 0;
	}
	if ((xmin - xmax) < 0 && (ymin - ymax) < 0) {
		White = 0;
	}

	printf("%d\n",White);

	return 0;
}



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

using namespace std;

int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin >> a[i];
    if(a[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3620
X,Y=map(int, input().split())
if X/Y>2 or Y/X>2 or (X+Y)%3!=0:
    print(0)
    exit()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
n = (10 ** 6 ) # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p) 階乗のmod
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, n + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)
base=(X+Y)//3
print(cmb(base, (X-base),p))


Measured memory_bytes: 122048
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int ans=1;
		int c=0;
		for(int i=0; i<n; i++){
			int l=sc.nextInt();
			if(c+l<=x){
				ans++;
				c+=l;
			}else{
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
LL X,D,K;
int main(){
    scanf("%lld%lld%lld",&X,&K,&D);
    if(X < 0)X = -X;
    LL tmp = X / D;
    if(tmp >= K){
        printf("%lld\n",(X - K * D));
    }
    else{
        X = X - tmp * D;
        LL Y = D - X;
        K -= tmp;
        if(K & 1){
            printf("%lld\n",Y);
        }
        else {
            printf("%lld\n",X);
        }
    }
    return 0;
}
/*
1000000000000000
1
1000000000000000
*/

Measured memory_bytes: 1732
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll d[3];
int main()
{
	int num;
	scanf("%d", &num);
	string s;
	cin >> s;
	ll ans = 1;
	for (int i = 0; i < s.size(); i++)
	{
		int x;
		if (s[i] == 'R')x = 0;
		if (s[i] == 'G')x = 1;
		if (s[i] == 'B')x = 2;
		int y = (x + 1) % 3, z = (x + 2) % 3;
		if (d[y] > 0 && d[z] > 0)
		{
			ans *= min(d[y], d[z]);
			d[y]--, d[z]--;
		}
		else
		{
			if (d[z] > 0)swap(y, z);
			d[x]++;
			if (d[x] <= d[y])ans *= (d[y] - d[x] + 1);
		}
		ans %= mod;
	}
	for (int i = 1; i <= num; i++)ans = ans*i%mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 1336
#include <iostream>
#include <string>

using namespace std;

int main(void){
    
    int count[4][3][10] = {};
    int b, f, r, v;
    int n;
    
    cin >> n;
 
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        count[b - 1][f - 1][r - 1] += v;
    }
 
    for (int b = 0; b < 4; b++) {
        for (int f = 0; f < 3; f++) {
            for (int r = 0; r < 10; r++) {
                cout << " " << count[b][f][r];
            }
            cout << endl;
        }
        if(b != 3) {
            for(int j = 0; j < 20; j++) {
                cout << "#";
            }
            cout << endl;    
        }
    }
    
    return 0;
    
}

Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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(){
  int a,b;
  cin >> a >> b;
  if(a > b){
    cout << "a > b" << endl;
  }else if(a < b){
    cout << "a < b" << endl;
  }else{
    cout << "a == b" << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
using System;

namespace AtC154
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ST = Console.ReadLine().Split(' ');
            string[] AB = Console.ReadLine().Split(' ');
            int A = int.Parse(AB[0]);
            int B = int.Parse(AB[1]);
            string U = Console.ReadLine();

            if (ST[0] == U) A--;
            if (ST[1] == U) B--;

            Console.WriteLine($"{A} {B}");

        }
    }
}


Measured memory_bytes: 13140
using System;

namespace VisualStudioCode
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if( (a*b) %2 == 0)
            {
            Console.WriteLine("Even");
            }else{
            Console.WriteLine("Odd");
                }
            }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct node{
  int key;
  struct node* next;
  struct node* prev;
}Node;
 
Node *NIL;
void init(void);
void printList(void);
Node* listSearch(int);
void insert(int);
void deleteNode(Node *);
void deleteLast(void);
void deleteKey(int);
void deleteFirst(void);

 int main(){
  int key,n,i,size=0,p=0,d=0;
  char com[20];
 
  scanf("%d",&n);
  init();
  for(i = 0;i < n;i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      p++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
    if(com[6] == 'F') deleteFirst();
    else if(com[6] == 'L') deleteLast();
      }
      else{
    deleteKey(key);
    d++;
      }
      size--;
    }
  }
  printList();
 
  return 0;
}

void init(){
  NIL = (Node*)malloc(sizeof(Node));
  NIL->next = NIL;
 NIL->prev = NIL;
}
 
void printList(){
  Node *cur = NIL->next;
  int isf = 0;
  while(1){
    if(cur == NIL) break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}
 
Node* listSearch(int key){
  Node *cur = NIL->next;
  while(cur != NIL && cur->key != key) cur = cur->next;
  return cur;
}
 
void insert(int key){
  Node *x = (Node*)malloc(sizeof(Node));
  x->key = key;
  x->next = NIL->next;
  NIL->next->prev = x;
  NIL->next = x;
  x->prev = NIL;
}
 
void deleteNode(Node *t){
  if(t == NIL) return ;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}
 
void deleteFirst(){
  deleteNode(NIL->next);
}
 
void deleteLast(){
  deleteNode(NIL->prev);
}
 
void deleteKey(int key){
  deleteNode(listSearch(key));
}
 

Measured memory_bytes: 31788
#include<stdio.h>
int main()
{
  int a,b,c,i,r=0;
  scanf("%d%d%d",&a,&b,&c);
  for(i=a; i<=b; i++)
    {
      if(c%i==0) r+=1;
    }
  printf("%d\n",r);
  return 0;
}

		   

Measured memory_bytes: 596
N = int(input())
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

table = num_divisors_table(N)

ans = 0
for C in range(1, N):
    ans += table[N-C]
print(ans)

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

int main(){
	ll n,m; cin >> n >> m;
	vector<P> q(m); 
	rep(i,m){
		cin >> q[i].second >> q[i].first;
		--q[i].second; --q[i].first;
	}
	sort(q.begin(), q.end());
	ll ans = 0; ll b = 0;
	rep(i,m){
		if(q[i].second >= b){
			ans++;
			b = q[i].first;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];
  vector<int> y;
  vector<string> ans;
  rep(i,h) {
    int cnt = 0;
    rep(j,w) if(a[i][j] == '.') cnt++;
    if(cnt != w) ans.push_back(a[i]);
  }
  rep(j,w) {
    int cnt = 0;
    rep(i,h) if(a[i][j] == '.') cnt++;
    if(cnt == h) y.push_back(j);
  }
  if ((int) y.size() > 0) {
    rep(i,(int)ans.size()) {
      int k = 0;
      rep(j,w) {
      if (y[k] == j) {
          if (k < ((int)y.size()-1)) k++;
          continue;
        } else cout << ans[i][j];
      }
      cout << endl;
    }
  } else {
    rep(i,(int)ans.size()) cout << ans[i] << endl;
  }
  
  return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    int a, b, t;
    cin >> a >> b >> t;
    int ans = 0;
    int i = 1;
    while (a * i <= t) {
        ans += b;
        ++i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> Zahyo;
typedef pair<Zahyo,int> Kirehasi;
int picture[120][120];
int ki[4][60][60];
int firstx[4];
int firsty[4];
main(){
  int n,m;
  while(1){
    int kirehasipos=0;
    memset(picture,-1,sizeof(picture));
    memset(ki,-1,sizeof(ki));
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>picture[i][j];
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
	cin>>ki[0][i][j];
	ki[1][m-1-j][i]=ki[0][i][j];
	ki[2][m-1-i][m-1-j]=ki[0][i][j];
	ki[3][j][m-1-i]=ki[0][i][j];
      }
    }	 
    
    for(int i=0;i<4;i++){
      bool a=true;
      for(int j=0;j<m;j++){
	for(int k=0;k<m;k++){
	  if(a==true&&ki[i][j][k]!=-1){
	    firstx[i]=k;
	    firsty[i]=j;
	    a=false;
	  }
	  //printf("%2d",ki[i][j][k]);
	}
	//cout<<endl;
      }
      //cout<<firsty[i]<<" "<<firstx[i]<<endl;
    }
    
    int ansx=200,ansy=200;
    for(int i=0;i<4;i++){
      for(int j=0;j<=n-m;j++){
	for(int k=0;k<=n-m;k++){
	  bool check=true;
	  for(int l=0;l<m;l++){
	    for(int o=0;o<m;o++){
	      if(ki[i][l][o]!=-1&&picture[j+l][k+o]!=ki[i][l][o]){
		//cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<o<<endl;
		check=false;
	      }
	    }
	  }
	  if(check&&(ansy>j+firsty[i]+1||(ansy==j+firsty[i]+1&&ansx>k+firstx[i]+1))){
	    //cout<<i<<" "<<j<<" "<<k<<endl;
	    ansy=j+firsty[i]+1;
	    ansx=k+firstx[i]+1;
	  }
	}
      }
    }
    if(ansx!=200||ansy!=200){
      cout<<ansx<<" "<<ansy<<endl;
    }
    else{
      cout<<"NA"<<endl;
    }
  }
}

Measured memory_bytes: 1284
#include <bits/stdc++.h> /*4D*/
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){

int h,w;
h=0,w=0;

while(true){
    cin >> h >> w; 
        rep(i,h){
            rep(j,w){
                cout << '#';
            }
            cout << endl;
        }
  if (h == 0 && w == 0) break;
    cout << endl;
}
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
 
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
 
 
int main() {
  ll N;

  cin >> N;

  vector<ll> L(N);
  ll ans = 0;

  for (ll i = 0; i < N; i++) {
    cin >> L.at(i);
  }


  for (ll i = 0; i < N; i++) {
    for (ll j = i+1; j < N; j++) {
      for (ll k = j+1; k < N; k++) {

        if ((L.at(i) + L.at(j) > L.at(k) )&&
        (L.at(j) + L.at(k) > L.at(i)) &&
        (L.at(k) + L.at(i) > L.at(j)) && (
          L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i)
        )) {
          ans++;
        }   
      }
    }
  }
  


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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
int main(){int n,d,x,r,a[d];std::cin>>n>>d>>x;for(int i=0;i<n;i++)std::cin>>a[i];for(int i=0;i<n;i++){int t=0,l=1;while(t<=d){t=a[i]*(l)+1;l++;r++;}}std::cout<<r+x<<std::endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
const int MOD = 1e9+7,mxN = 50,INF = 1e9;
int n=2,q;


void solve()
{
    cin>>n;
    char a[n],b[n],s[n*2];
    cin >> a >> b;
    int i = 0,j=0;
    for(int k=0;k<n*2;k++)
    {
        if(k&1)
            s[k]=b[j],j++;
        else s[k] = a[i],i++;
    }
    s[n*2]=0;
    cout << s;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    
}


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

bool is_eight(int n) {
	int cnt = 0;
	
	for (int i = 1; i <= n; i++) {
		if (n % i == 0) {
			cnt++;
		}
	}
	
	if (cnt == 8) {
		return true;
	}
	else {
		return false;
	}
}

signed main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i += 2) {
		if (is_eight(i)) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
ll n;
ll dp[100001];
int solve(int k,vector<ll>&a){
    if(dp[k]!=-1){
        return dp[k];
    }
    if(k==0){
        return dp[k]==0;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]<=k && solve(k-a[i],a)==0){
            ans=1;
            break;
        }
    }
    return dp[k]=ans;
}
int main() {
    FIO;
    //test
    {
        ll k;
        cin>>n>>k;
        vector<ll>a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        memset(dp,-1,sizeof(dp));
        solve(k,a)?cout<<"First":cout<<"Second";
        cout<<"\n";
    }
	return 0;
}


Measured memory_bytes: 9024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int l,r,d;
	std::cin >> l >> r >> d;
	--l;
	std::cout << (r/d-l/d) << std::endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, C;
  cin >> N >> C;
  vector<vector<bool>> S(1e5 + 10, vector<bool>(C + 10, false));
  vector<vector<bool>> T(1e5 + 10, vector<bool>(C + 10, false));
  for (ll i = 0; i < N; i++)
  {
    ll s, t, c;
    cin >> s >> t >> c;
    S.at(s).at(c) = true, T.at(t).at(c) = true;
  }

  for (ll time = 1; time < 1e5 + 10; time++)
  {
    for (ll i = 1; i <= C; i++)
    {
      if (S.at(time).at(i) && T.at(time).at(i))
        S.at(time).at(i) = false, T.at(time).at(i) = false;
    }
  }
  

  ll ans = 0, used = 0;
  for (ll time = 1; time < 1e5 + 10; time++)
  {
    for (ll i = 1; i <= C; i++)
    {
      if (T.at(time - 1).at(i))
        used--;
      if (S.at(time).at(i))
        used++;
    }

    chmax(ans, used);
    //cerr << used << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 14336
#import numpy as np

i=[input().split() for l in range(4)]

n=int(i[3][0])

j = [input() for i in range(n)]

#i=np.array(i)
#print(i)


k = [['0' for o in range(3)] for p in range(3)]

for b in range(3):
    #print('b:',b)
    for c in range(3):
        #print('c:',c)
        for d in range(n):
            #print('d:',d)
            if i[b][c]==j[d]:
                k[b][c]='1'
                #print('書き換えたよ',k)
                
                
#print(i)
#print(j)
#print(k)


if  k[0][0]=='1' and k[0][1]=='1' and k[0][2]=='1'\
or k[1][0]=='1' and k[1][1]=='1' and k[1][2]=='1'\
or k[2][0]=='1' and k[2][1]=='1' and k[2][2]=='1'\
or k[0][0]=='1' and k[1][0]=='1' and k[2][0]=='1'\
or k[0][1]=='1' and k[1][1]=='1' and k[2][1]=='1'\
or k[0][2]=='1' and k[1][2]=='1' and k[2][2]=='1'\
or k[0][0]=='1' and k[1][1]=='1' and k[2][2]=='1'\
or k[2][0]=='1' and k[1][1]=='1' and k[0][2]=='1':
	print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
s = list(input())
# v = list(map(int,s))

for a in ['+','-']:
    for b in ['+','-']:
        for c in ['+','-']:
            cal = s[0]+a+s[1]+b+s[2]+c+s[3]
            v = eval(cal)
            if v == 7:
                print(cal+'=7')
                exit()

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

int N,L;
int A[100010];

int main(){
	cin >> N >> L;
	for(int i=1;i<=N;i++) cin >> A[i];
	bool judge = false;
	int a;
	for(int i=1;i<N;i++){
		if(A[i]+A[i+1]>=L){
			judge = true;
			a = i;
			break;
		}
	}
	if(!judge) cout << "Impossible" << endl;
	else{
		cout << "Possible" << endl;
		for(int i=1;i<a;i++){
			cout << i << endl;
		}
		for(int i=1;i<N-a;i++){
			cout << N-i << endl;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1152
from collections import deque
def main():
  N, M, *L = map(int, open(0).read().split())
  dic = [[] for i in range(N+1)]
  par =  [None]*N
  cnt = [0]*(N+1)
  cnt[0] = 1
  for a,b in zip(*[iter(L)]*2):
    dic[a].append(b)
    cnt[b] += 1

  for i, m in enumerate(cnt):
    if m==0:
      q = deque([i])
      par[i-1] = 0
      break
  
  while q:
    m = q.popleft()
    for c in dic[m]:
      cnt[c] -= 1
      if cnt[c]==0:
        par[c-1] = m
        q.append(c)

  ans = '\n'.join(map(str,par))
  print(ans)
  
if __name__== '__main__':
  main()


Measured memory_bytes: 31476
#pragma GCC optimize("O3")
#include <stdio.h>
#define INF 2300000000000000000LL
long long dist[1000][1000];
int main(){
	int V,E,i,j;long long k;
	scanf("%d%d",&V,&E);
	for(i=0;i<V;i++){
		for(j=0;j<i;j++)dist[i][j]=INF;
		dist[i][j++]=0;
		for(;j<V;j++)dist[i][j]=INF;
	}
	for(;E--;)scanf("%d%d%lld",&i,&j,&k),dist[i-1][j-1]=-k;
	for(k=0;k<V;k++)for(i=0;i<V;i++)for(j=0;j<V;j++)
		if(dist[i][k]!=INF && dist[k][j]!=INF && dist[i][j]>dist[i][k]+dist[k][j])
			dist[i][j]=dist[i][k]+dist[k][j];
	for(i=0;i<V;i++)if(dist[0][i]!=INF&&dist[i][V-1]!=INF&&dist[i][i]<0){puts("inf");return 0;}
	printf("%lld\n",-dist[0][V-1]);
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;


int main(void) 
{
    ll n,d;
    cin >> n >> d;
    ll x,y,cnt=0;
    d = d*d;

    rep(i,n) {
        cin >> x >> y;
        if (x*x + y*y <= d) cnt++;

    }

    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
using namespace std;

const int maxn = 1e5;

int n, a[maxn + 1];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n, greater<int>());
  a[n] = 0;

  for (int i = 0; i < n; ++i) {
    bool ans = false, got = false;
    if (a[i] == i + 1 || a[i + 1] == i + 1) {
      got = true;
      int j = i;
      while (a[j + 1] == i + 1) {
        ++j;
      }
      ans |= j - i & 1;
    }
    if (i < a[i] && i >= a[i + 1] - 1) {
      got = true;
      ans |= a[i] - i - 1 & 1;
    }
    if (got) {
      puts(ans ? "First" : "Second");
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char a[100];
char s[100];

bool dfs(int sum,int deep){
	if(deep == 5){
		if(sum == 7){	
			for(int i = 1;i <= 4;i++){
				printf("%c",a[i]);
				if(i != 4) printf("%c",s[i + 1]);
			}
			printf("=7\n");
			return true;
		}
		else return false;
	}
	s[deep] = '+';
	if(dfs(sum + (a[deep] - '0'),deep + 1)) return true;
	s[deep] = '-';
	if(dfs(sum - (a[deep] - '0'),deep + 1)) return true;
	return false;
}

int main(){
	scanf("%s",a + 1);
	dfs(0,1);
}

Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstring>
using namespace std;
char a[500][500];
int fn(int x[],int y){
  int i;
  for(i=min(x[0],x[1])+1;i<max(x[0],x[1]);++i){
    if(a[y][i]!='.')
      break;
  }
  if(i<max(x[0],x[1]))
    return 0;
  else
    return 1;
}
int fn(int x,int y[]){
  int i;
  for(i=min(y[0],y[1])+1;i<max(y[0],y[1]);++i){
    if(a[i][x]!='.')
      break;
  }
  if(i<max(y[0],y[1]))
    return 0;
  else
    return 1;
}
int main(){
  int i,j;
  int h,w;
  while(cin>>h>>w){
    int x[26][2],y[26][2];
    memset(x,-1,sizeof(x));    
    for(i=0;i<h;++i){
      for(j=0;j<w;++j){
	cin>>a[i][j];
	if(a[i][j]!='.'){
	  if(x[a[i][j]-'A'][0]<0){
	    x[a[i][j]-'A'][0]=j;
	    y[a[i][j]-'A'][0]=i;
	  }else{
	    x[a[i][j]-'A'][1]=j;
	    y[a[i][j]-'A'][1]=i;
	  }
	}
      }
    }
    int b;
    int sm=0;
    do{
      b=0;
      for(i=0;i<26;++i){
	if(x[i][0]>=0){
	  if(0){
	  }else if(abs(x[i][0]-x[i][1])+abs(y[i][0]-y[i][1])==1){
	  }else if(x[i][0]==x[i][1]){
	    if(fn(x[i][0],y[i])){
	      a[y[i][0]][x[i][0]]=a[y[i][1]][x[i][1]]='.';
	      x[i][0]=-1;
	      ++sm;
	      b=1;
	    }
	  }else if(y[i][0]==y[i][1]){
	    if(fn(x[i],y[i][0])){
	      a[y[i][0]][x[i][0]]=a[y[i][1]][x[i][1]]='.';
	      x[i][0]=-1;
	      ++sm;
	      b=1;
	    }
	  }else{
	    if(a[y[i][1]][x[i][0]]=='.'){
	      if(fn(x[i],y[i][1])){
		if(fn(x[i][0],y[i])){
		  a[y[i][0]][x[i][0]]=a[y[i][1]][x[i][1]]='.';
		  x[i][0]=-1;
		  ++sm;
		  b=1;
		  continue;
		}
	      }
	    }
	    if(a[y[i][0]][x[i][1]]=='.'){
	      if(fn(x[i],y[i][0])){
		if(fn(x[i][1],y[i])){
		  a[y[i][0]][x[i][0]]=a[y[i][1]][x[i][1]]='.';
		  x[i][0]=-1;
		  ++sm;
		  b=1;
		  continue;
		}
	      }
	    }
	  }
	}
      }
    }while(b);
    cout<<sm*2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1064
import std.stdio;
import std.algorithm;

int calc(int x, int y, int b, int p) {
    return min( (x * max(b, 5) + y * max(p, 2)) * 4 / 5, x * b + y * p );
}

void main() {
    int N; readf("%d\n", &N);
    foreach (i; 0 .. N) {
        int x, y, b, p; readf("%d %d %d %d\n", &x, &y, &b, &p);
        calc(x, y, b, p).writeln;
    }
}

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

#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rip return
#define fo(i,a,b) for(int i = a ; a < b ? i <= b : i >= b ; i += (a < b ? 1 : -1))
#define pb push_back
#define F first
#define S second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using ld = long double;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

// const int mod = 1e9 + 7;
const int mod = 998244353;
const ll inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-7;

const int N = 1e5 + 5;

void solve () {
	int a, b;
	cin >> a >> b;
	cout << (b - 1 + (a - 1) - 1) / (a - 1);
}


int main () {
	ios;
	// double start_time = clock();
	// cout << fixed << setprecision (10);
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
		cout << "\n";
	}
	// cerr << (clock() - start_time) / CLOCKS_PER_SEC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
int n,w;
ll dp[100][100005];
vector <pair<int,int> > a;
ll solve(int index,int sum)
{
    if(index==n) return 0;
    ll &ret = dp[index][sum];
    if(~ret) return ret;
    ret=max(ret,solve(index+1,sum));
    if(a[index].first<=sum) ret = max(ret,a[index].second+solve(index+1,sum-a[index].first));
    return ret;
}
int main()
{
    zzz;
    cin>>n>>w;
    a.resize(n);
    for(int i=0;i<n;++i) cin>>a[i].first>>a[i].second;
    memset(dp,-1,sizeof dp);
    cout<<solve(0,w);
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,s=0;
    cin>>n;
    long long a[n];
    for(long long i=0;i<n;i++)
    {
       cin>>a[i];

    }
    for(long long i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1]){
            s+=a[i]-a[i+1];
            a[i+1]+=a[i]-a[i+1];}
    }
    cout<<s<<endl;
}


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

using namespace std;

int main() {
	int k;
	cin >> k;
	int cnt = 0;
	for (int i = 1; i <= k; ++i) if (i % 2 == 0)
		for (int j = 1; j <= k; ++j) if (j % 2)
			cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

typedef long long ll;


int main(){
    ll L,R;
    cin>>L>>R;
    
    ll arr[2019];
    
    ll limit=2019<=R-(L-1)?2019:R-(L-1);
    
    limit=limit;

    //cout<<"limit:"<<limit<<endl;

    for(ll i=L;i<limit+L;++i){
        arr[i-L]=i%(ll)2019;
    }

  /*  
     for(ll i=0;i<limit;++i){
     cout<<i<<":"<<arr[i]<<" ";
     }
     cout<<endl;
  */  
    //cout<<"abc"<<endl;
     
    ll ans=2019;
    
    for(ll i=0;i<limit-1;++i){
        for(ll j=i+1;j<limit;++j){
           ll tmp=(arr[i]*arr[j])%2019;
           ans=ans<=tmp?ans:tmp;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cmath>

int main(){
  int a, b;
  std::cin >> a >> b;
  if((b-a)%2 == 0)
    std::cout << std::min(a,b) + std::abs(b-a)/2 << std::endl;
  else
    std::cout << "IMPOSSIBLE" << std::endl;
  return 0;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        ll A, B, C, K;
        cin >>A >>B >>C >>K;
        if (A>=K)
                cout <<K <<endl;
        else if (A+B>=K)
                cout <<A <<endl;
        else
                cout <<A-(K-A-B) <<endl;
        return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
long long gcd(long long a,long long b)
{
	if(a==0)return b;
	return gcd(b%a,a);
}
long long m,n, mn;
long long s[1266],ind,gd;
int main()
{
	while(cin>>n&&n)
	{
		m=(n+1)*n/2;
		long long mn=1;
		mn<<=62;
		ind=0;
		for(int i=0;i<m;i++)
		{
			long long z;
			scanf("%lld",&z);
			if(z%2==0)
				s[ind++]=z;
			else mn=min(mn,z);
		}
		sort(s,s+ind);
		if(ind!=n)while(1);
		long long gd=gcd(s[0],s[1]);
		//mn/=s[0]/gd;
		//mn/=s[1]/gd;
		//long long	da=gd/mn;
		long long da=sqrt(1.0*s[0]*s[1]/mn)+0.5;

		cout<<da<<endl;
		//if(da==0)continue;
		for(int i=0;i<n;i++)
		{
			if(i)cout<<' ';
			cout<<s[i]/da;
		}cout<<endl;
	}
}

Measured memory_bytes: 1264
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n, a, b;
	int p[100];
	cin >> n >> a >> b;
	rep(i, n)cin >> p[i];

	int x, y, z;
	x = y = z = 0;
	rep(i,n) {
		if (p[i] <= a)x++;
		else if (p[i] <= b)y++;
		else z++;
	}

	cout << min({ x,y,z }) << endl;




	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI h(n);
  rep(i,n) cin >> h[i];

  rep(i,n){
    if(i == 0) h[i]--;
    else{
      if(h[i-1] > h[i]){
        cout << "No" << endl;
        return 0;
      }else if(h[i-1] == h[i]){
        continue;
      }else{
        h[i]--;
      }
    }
  }
  cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int INF=1000010000;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i];
  vector<vector<int>> dp(n+1,vector<int>(4,0));
  for(int i=1; i<=n; i++){
    dp[i][1]=max(dp[i-1][2]+a[i-1],dp[i-1][3]+a[i-1]);
    dp[i][2]=max(dp[i-1][1]+b[i-1],dp[i-1][3]+b[i-1]);
    dp[i][3]=max(dp[i-1][1]+c[i-1],dp[i-1][2]+c[i-1]);
  }
  cout << max({dp[n][1],dp[n][2],dp[n][3]}) << endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll n, k; cin >> n >> k;

    ll a = n/k;
    if(k%2 != 0){
        cout << a*a*a << endl;
    }
    else{
        if(n%k >= k/2){
            ll b = a+1;
            cout << a*a*a + b*b*b << endl;
        }
        else{
            ll b = a;
            cout << 2*a*a*a << endl;
        }
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

ull modpow(ull a, ull n, ull mod) {
    ull res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ull modinv(ull a, ull mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ull K;
    string s;
    cin >> K >> s;
    ull ans = 1;
    ull pow_25 = 1;
    ull comb = 1;
    vector<ull> inv(K+s.size());
    for (ull i = 0; i < inv.size(); i++) {
        inv[i] = modinv(i+1, MOD);
    }
    for (ull i = 0; i < K; i++) {
        pow_25 = (pow_25 * 25) % MOD;
        comb = (((comb * (s.size()+i)) % MOD) *inv[i]) % MOD;
        ans = ((ans * 26) % MOD + (pow_25 * comb) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int R; cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    }
    else if (R < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
    return 0;
}

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

const int DIV = 10007;
int dp[1000][8]; //4...J, 2...O, 1...I
int n;
string order;

int ordertoint(char c)
{
  if(c == 'J')
    return 4;
  if(c == 'O')
    return 2;
  if(c == 'I')
    return 1;
}

bool bitjudge(int a, int b)
{
  for(int i = 0; i < 3; i++)
    if((a >> i) % 2 && !((b >> i) % 2))
      return false;
  return true;
}

int main()
{
  cin >> n >> order;
  
  //day == 1;
  int come = 4 | ordertoint(order[0]);
  for(int i = 1; i < 8; i++)
    if(bitjudge(come, i))
      dp[0][i] = 1;


  //day >= 2
  for(int i = 1; i < n; i++){
    for(int j = 1; j < 8; j++){
      if(!dp[i - 1][j])
	continue;

      for(int k = 1; k < 8; k++){
	if(bitjudge(ordertoint(order[i]), k) && (j & k))
	  dp[i][k] = (dp[i][k] + dp[i - 1][j]) % DIV;
	
      }
    }
  }
  int ans = 0;

  for(int i = 1; i < 8; i++)
    ans += dp[n - 1][i];

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

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  if (A >= B) cout << "delicious" << endl;
  else if (B - A <= X) cout << "safe" << endl;
  else cout << "dangerous" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d, t, s, r;
  
  cin >> d >> t >> s;
  
  r = t * s;
  
  if(r >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int rank[9] = {};
    int N; cin >> N;
    rep(i, N){
        int a; cin >> a;
        rank[min(a/400, 8)]++;
    }
    int mn = 0, mx = 0;
    rep(i, 8) if(rank[i] > 0) mn++;
    mx = mn + rank[8];
    if(mn == 0) mn++;
    cout << mn << " " << mx << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
count = 0

for i in range(1, n-1):
    if (p[i] > p[i-1] and p[i] < p[i+1]) or (p[i] < p[i-1] and p[i] > p[i+1]):
        count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
   int i,j;
   char c[3][4],s[3];
 
   for(i=0;i<3;i++){
   scanf("%s", c[i]);
   }
   s[0]=c[0][0];
   s[1]=c[1][1];
   s[2]=c[2][2];
   s[3]='\0';

   printf("%s\n", s);


   return 0;
}


Measured memory_bytes: 128
void main()
{
    long n = rdElem;
    long k = 1L << n;
    long[] a = k.rdCol;

    auto st = SegTree!((x, y) => x == y ? x : abs(x-y), long, 0)(k);
    foreach (i, x; a)
    {
        st.update(i, x);
    }

    st.tree[1].writeln;
}

struct SegTree(alias pred, T, T init)
{
    import core.bitop;
    alias F = binaryFun!pred;

    long n;
    T[] tree;

    this(long n)
    {
        this.n = n == 1 ? 1 : 1L << bsr(n-1) + 2;
        tree.length = this.n << 1;
        tree[] = init;
    }

    ref T opIndex(long idx) pure nothrow
    {
        return tree[idx+this.n];
    }

    void update(long idx, T x)
    {
        idx += this.n;
        this.tree[idx] = x;
        while (idx >>= 1)
        {
            tree[idx] = F(tree[(idx<<1)], tree[(idx<<1)+1]);
        }
    }

    T query(long x, long y)
    {
        T l = init, r = init;
        for (x += this.n, y += this.n; x < y; x >>= 1, y >>= 1)
        {
            if (x & 1) l = F(l, tree[x++]);
            if (y & 1) r = F(tree[--y], r);
        }
        return F(l, r);
    }
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 14972
#include <string>
#include <iostream>
#include <algorithm>
#include <limits>
using namespace std;

int main() {
  string S,T;
  std::cin >> S >> T;

  int minimum = std::numeric_limits<int>::max();

  for(int j=0;j<= S.size() - T.size() ;j++){
      int count = 0;
      for(int i=0;i<T.size();i++){
          if(T[i] != S[j+i]){
              count++;
          }
      }
      minimum = min(minimum, count);
  }

  cout << minimum << endl;
  return 0;
}

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

int main(){
int a,b,c;
cin>>a>>b>>c;
if(a+b+c==17&&(a==5||b==5||c==5)&&(a==7||b==7||c==7))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 256
seven_count = 0
five_count = 0
s = input().split()
for number in s:
    if number == "5":
  	    five_count += 1
    elif number == "7":
        seven_count += 1
if seven_count == 1 and five_count == 2:
  	print("YES")
else:
  	print("NO")

Measured memory_bytes: 2940