akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

template <typename T>
ll lcm(T a, T b){
  return (ll)a * (ll)b / (ll)__gcd(a, b);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll X;
  cin >> X;
  cout<< lcm(X, 360LL) / X << endl; 
}

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

using namespace std;

int main(){
  string str, ret("NO");

  cin >> str;

  int win=0;
  for(int i=0; i<(int)str.length(); i++){
    if(str[i] == 'o'){
      win++;
    }
  }

  if(7 >= (int)(str.length())){
    ret="YES";
  }else if(win >= (int)(str.length()-7)){
    ret="YES";
  }

  cout << ret <<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>

#define DIM (long long)1007
#define INF (long long)100000007

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pairll;

ll n,m,i,j,k,sum,f1,f2,v1,v2,res;
ll a[DIM][DIM];
ll dp[DIM][DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    char x;
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            cin >> x;
            if(x=='#') a[i][j]=1;
        }
    }
    dp[1][1]=1;
    a[1][1]=1;
    ll mod=1e9+7;
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            if(a[i][j]==0){
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            if(dp[i][j]>=mod) dp[i][j]%=mod;
            }

        }
    }

    cout << dp[n][m] << endl;




    return 0;
}


Measured memory_bytes: 16000
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    int n = Integer.parseInt(br.readLine());
    int[] arr = new int[n-1];
    String[] s = br.readLine().split(" ");
    int prev = 987654321;
    long sum = 0;
    for (int i=0; i<n-1; i++) {
      int curr = Integer.parseInt(s[i]);
      sum += (long)Math.min(prev, curr);
      prev = curr;
    }
    sum += prev; 
    System.out.println(sum);
  }
}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long R, G, B, N, count = 0;
	cin >> R >> G >> B >> N;
	for (int i = 0; i <= N / R; i++) {
		int n = N - R * i;
		for (int j = 0; j <= n / G; j++) {
			if (n - j * G >= 0 && (n - j * G) % B == 0) count++;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

bool isKawaisou(std::vector<int>& v)
{
  std::sort(v.begin(), v.end());
  auto r = std::unique(v.begin(), v.end());
  v.erase(r, v.end());

  return (v.size() == 2);
}

int main(int argc, char* pArgv[])
{
  std::vector<int> v(3, 0);

  std::cin >> v[0] >> v[1] >> v[2];
  bool result = isKawaisou(v);

  std::cout << (result ? "Yes" : "No") << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main() {

    int r, d, x;
    std::cin >> r >> d >> x;
    int res = 0;
    for (int i = 0; i < 10; ++i) {
        x = r * x - d;
        std::cout << x << std::endl;
    }
    return 0;
}   

Measured memory_bytes: 3600
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(iim())

    if N == 0:
        print(1 if A[0] == 1 else -1)
        return

    if A[0] > 0:
        print(-1)
        return

    B = [0]*(N+1)
    x = 1
    B[0] = 1
    for i in range(1, N+1):
        B[i] = B[i-1]*2 - A[i]
        if B[i] < 0:
            print(-1)
            return

    A.reverse()
    B.reverse()
    ans = node = 0
    for d, lim in zip(A, B):
        node = min(node, lim)
        node += d
        ans += node

    print(ans)

if __name__ == "__main__":
    resolve()


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

#define MOD 1000000007

long long plus_mod(long long x, long long y, long long mod)
{
    return (x + y) % mod;
}

long long inv_mod(long long x, long long mod)
{
    long long y = mod;
    long long u = 1;
    long long v = 0;
    while (y)
    {
        long long t = x / y;
        x -= t * y;
        swap(x, y);
        u -= t * v;
        swap(u, v);
    }
    u %= mod;
    if (u < 0)
        u += mod;
    return u;
}

long long mul_mod(long long x, long long y, long long mod)
{
    return (x * y) % mod;
}

long long div_mod(long long x, long long y, long long mod)
{
    return mul_mod(x, inv_mod(y, mod), mod);
}

long long calcCombination(long long x, long long y, vector<long long> &func_memo, vector<long long> &func_inv_memo, long long mod)
{
    if (x < y)
    {
        return 0;
    }

    if ((x - y) < y)
    {
        y = x - y;
    }

    long long ans = 1;
    ans *= func_memo[x];
    ans %= mod;
    ans *= func_inv_memo[y];
    ans %= mod;
    ans *= func_inv_memo[x - y];
    ans %= mod;
    return ans;
}

int main()
{
    long long H, W, A, B;
    cin >> H >> W >> A >> B;

    vector<long long> func_memo(200000, 1);
    for (int i = 1; i < 200000; i++)
    {
        func_memo[i] = mul_mod(func_memo[i - 1], i, MOD);
    }

    vector<long long> func_inv_memo(200000, inv_mod(func_memo.back(), MOD));
    for (int i = 200000 - 2; i >= 0; i--)
    {
        func_inv_memo[i] = mul_mod(func_inv_memo[i + 1], i + 1, MOD);
    }

    long long ans = 0;
    for (int i = B; i < W; i++)
    {
        ans = plus_mod(
            ans,
            mul_mod(
                calcCombination((H - A - 1) + i, H - A - 1, func_memo, func_inv_memo, MOD),
                calcCombination((A - 1) + (W - i - 1), A - 1, func_memo, func_inv_memo, MOD), MOD),
            MOD);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
ll n,sm;
vector<pa>o;
int main(){
	read(n);
	rep(i,1,n){
		char opt[5];if(i!=1)scanf("%s",opt);else opt[0]='+';
		int x=read();sm+=x;
		if(opt[0]=='-')o.pb(pa(x,0));else if(o.size())o.back().w2+=x;
	}
	ll ans;if(o.size()==0)ans=sm;else ans=-linf;
	re(i,0,o.size()){
		gmax(ans,sm-2*(o[i].w1+o[i].w2));
		sm-=o[i].w1*2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a,b,c,d;  cin>>a>>b>>c>>d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes";
            return 0;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No";
            return 0;
        }
    }
    return 0;
}


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

long N, K;
vector<long> A;

bool f(long mid) {
  if (mid == 0) return false;
  long cut = 0;
  for (long i = 0; i < N; i++) {
    cut += (A.at(i) + mid - 1) / mid - 1;
  }
  if (cut <= K) return true;
  return false;
}

int main() {
  cin >> N >> K;
  A.resize(N);
  for (long i = 0; i < N; i++) cin >> A.at(i);
  long mx = *max_element(A.begin(), A.end());
  long ng = 0, ok = mx;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      (f(mid)) ? ok = mid : ng = mid;
    }
  cout << ok << "\n";
}

Measured memory_bytes: 4812
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, m = 0, k = 0, sum = 0;
ll A[500000] = {}, B[500000] = {}, X[1500][13], rui[500000] = {}, dp[200000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;

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() {
	//Code Line
	for (int i = 1; i < 200000; i++)dp[i] = INF;
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> A[i];

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(A[i] - A[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 5888
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll _v):v(normS(_v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ModInt& operator++(int){ return *this=*this+1;}
	ModInt& operator--(int){ return *this=*this-1;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll p[]={a,1,0},q[]={b,0,1};
		while(*q){
			ll t=*p/ *q;
			rep(i,3) swap(p[i]-=t*q[i],q[i]);
		}
		if(p[0]<0) rep(i,3) p[i]=-p[i];
		x=p[1],y=p[2];
		return p[0];
	}
	ModInt inv() const {
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	ModInt pow(ll p) const {
		if(p<0) return inv().pow(-p);
		ModInt a = 1;
		ModInt x = *this;
		while(p){
			if(p&1) a *= x;
			x *= x;
			p >>= 1;
		}
		return a;
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;
int main(){
	int N,A[100001];
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	mint ans=1;
	int now[3]={};
	rep(i,N){
		int cnt=0,sore=-1;
		brep(j,3){
			if(now[j]==A[i]){
				cnt++;
				sore=j;
			}
		}
		ans*=cnt;
		if(cnt==0) break;
		now[sore]++;
	}
	prin(ans);
	return 0;
}


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

using namespace std;

int gcd(int a, int b)
{
    if (!b) return a;
    return gcd(b, a%b);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    while (n--) {
        int x;
        cin >> x;
        ans = gcd(ans, x);
    }
    cout << ans << endl;
    return 0;
}


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

A=list(map(int,input().split()))
B=list(map(int,input().split()))

ans=min(A)+min(B)

for i in range(m):
    x,y,c=map(int,input().split())
    if A[x-1]+B[y-1]-c <ans:
        ans=A[x-1]+B[y-1]-c 
print(ans)

Measured memory_bytes: 18736
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    //ここだけ見てね！
    public void calc()
    {
        int N, M;
        N = cin.nextInt();
        M = cin.nextInt();
        int[] a, b, c;
        a = new int[M];
        b = new int[M];
        c = new int[M];
        for (int i = 0; i < M; i++)
        {
            a[i] = cin.nextInt() - 1;
            b[i] = cin.nextInt() - 1;
            c[i] = cin.nextInt();
        }

        //Warshall Floyd;
        const int MAX = 99999999;

        //dist[from, to]がfromからtoの最短距離
        int[,] dist = new int[N, N];
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                dist[i, j] = MAX;
            }
            dist[i, i] = 0;
        }

        for (int i = 0; i < M; i++)
        {
            dist[a[i], b[i]] = Math.Min(dist[a[i], b[i]], c[i]);
            dist[b[i], a[i]] = Math.Min(dist[b[i], a[i]], c[i]);
        }

        for (int k = 0; k < N; k++) //中継点
        {
            for (int i = 0; i < N; i++) //始点
            {
                for (int j = 0; j < N; j++) //終点
                {
                    dist[i, j] = Math.Min(dist[i, j], dist[i, k] + dist[k, j]);
                }
            }
        }

        int ans = 0;
        for (int t = 0; t < M; t++)
        {
            if (dist[a[t], b[t]] < c[t]) ans++; 
        }

        Console.WriteLine(ans);
    }
    
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end() 
using namespace std;
typedef long long ll;

const int N = 15;

int d, g;
int p[N], c[N];
int res;

int ceil(int a, int b) {
    return (a+b-1)/b;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   res = 1e9;
   cin >> d >> g;
   for(int i=0; i<d; ++i) {
       cin >> p[i] >> c[i];
   }
   for(int b=0; b<(1<<d); ++b) {
       int tot = 0;
       vector<int> lst;
       for(int i=0; i<d; ++i) {
           if(b & (1<<i)) {
               tot += p[i]*100*(i+1) + c[i];
               lst.push_back(i);
           }
       }
       if(tot < g) continue;
       vector<int> id(lst.size());
       iota(all(id), 0);
       do {
           tot = 0;
           int pr = 0;
           for(int x: id) {
               if(tot >= g) break;
               if(tot + p[lst[x]]*100*(lst[x]+1) <= g) 
                   tot += p[lst[x]] * 100 * (lst[x]+1) + c[lst[x]], pr += p[lst[x]];
               else if(tot < g) {
                   pr += ceil((g-tot), ((100)*(lst[x]+1)));
                   break;
               }
           }
           res = min(res, pr);
       } while(next_permutation(all(id)));
   }
   cout << res << "\n";
   return 0;
} 


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

struct AB{
    int a;
    int b;
};
bool operator<(const AB& left, const AB& right) {
    return left.a < right.a;
}


int main(){
    int N;
    long K;
    cin >> N >> K;
    AB ab[N];
    for (int i = 0; i < N; i++) {
        cin >> ab[i].a >> ab[i].b;
    }
    sort(ab, ab + N);

    long sum = 0;
    for (int i = 0; i < N; i++) {
        sum += ab[i].b;
        if (sum >= K) {
            cout << ab[i].a << endl;
            return 0;
        }
    }

    return 0;
}


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

int main(void){
  int n, m, x, y, i;
  cin >> n >> m >> x >> y;

  vector<int> xs(n);
  vector<int> ys(m);

  for(i = 0; i < n; i++){
    cin >> xs[i];
  }
  for(i = 0; i < m; i++){
    cin >> ys[i];
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());

  for(int z = -100; z <= 100; z++){
    if(x < z && z <= y && xs[n-1] < z && ys[0] >= z){
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int ret=0;
	for(int i=0;i<a;i++)if(i%2==0&&p[i]%2)ret++;
	printf("%d\n",ret);
}

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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int n;
  std::cin >> n;
  if (n % 10 == 9 || n / 10 == 9) {
    cout(yes);
  } else {
    cout(no);
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int r, g, b, n, i=0, k=0, j=0, cnt=0;
    scanf("%d%d%d%d", &r, &g, &b, &n);
    
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            k=(n-(i*r)-(j*g))/b;
            if(i*r+j*g+k*b==n && (n-(i*r)-(j*g))%b==0 && k>=0) cnt++;
        }
    }

    printf("%d\n", cnt);
    return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, K;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K;
    int res = 0;
    if(K == 0) cout << N * N  << endl;
    else {
        FOR(i, K + 1, N + 1) {
            res += N / i * (i - K) + max(0LL, N % i - K + 1);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
  
int main(){
  ll x,y;
  cin >> x >> y;
  
  ll ans = 0;
  ll now = x;
  for(ll i = x; i <= y ;){
    if(now <= y) ans++;
    else break;
    now*=2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
// वाह मोदी जी वाह!

#include<iostream>
#include<algorithm>
#include<bitset>

#include<cmath>
#include<cstring>
#include<climits>

#include<deque>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#include<fstream>
#include<chrono>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{
    // DANGER;
    ofstream out("output.txt");

    auto start = chrono::high_resolution_clock::now();
    
    LL n;
    cin>>n;
    n--;
    cout<< (n*(n+1)) / 2 <<endl;

    // LL s = 0, m = 2;
    // rep(i,1,n)
    // {
    //     s += (i%m);
    //     m++;
    //     if( m>n ) m = 1;
    // }
    // cout<<s<<endl;
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    rep(i,n-1)a[i+1]+=a[i];
    int ans=inf;
    rep(i,n-1){
        int d=abs(a[n-1]-2*a[i]);
        ans=min(ans,d);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		if (b == 2)
			cout << 3 << endl;
		else
			cout << 2 << endl;
	}
	else if (a == 2) {
		if (b == 1)
			cout << 3 << endl;
		else
			cout << 1 << endl;
	}
	else {
		if (b == 1)
			cout << 2 << endl;
		else
			cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  string s,t;

  cin >> n >>s >> t;

  string ans;
  REP(i,n){
    ans += s[i];
    ans += t[i];
  }

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

Measured memory_bytes: 256
//	-*- mode: C++ -*-
//	Circle in a Rectangle
//		Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate (W,H) of the rectangle and the central coordinate (x,y) and radius r of the circle are given.
//
//	Input
//		Five integers W, H, x, y and r separated by a single space are given in a line.
//
//	Output
//		Print "Yes" if the circle is placed inside the rectangle, otherwise "No" in a line.
//
//	Constraints
//		−100≤x,y≤100
//		0<W,H,r≤100
//	Sample Input 1
//		5 4 2 2 1
//	Sample Output 1
//		Yes
//	Sample Input 2
//		5 4 2 4 1
//	Sample Output 2
//	No

#include <iostream>

int	main(int	argc,
		 char*	argv[])
{
  int	w	= 0;
  int	h	= 0;
  int	x	= 0;
  int	y	= 0;
  int	r	= 0;

  std::cin >>  w >> h >> x >> y >> r;

  if(((x + r) > w) ||
	 ((y + r) > h) ||
	 ((x - r) < 0) ||
	 ((y - r) < 0)){
	  std::cout << "No\n";
  }
  else{
	  std::cout << "Yes\n";
  }
}



Measured memory_bytes: 3100
N = int(input())
T, A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

# 小数の扱いをせずに済ますため、1000 倍する
candidate = [(abs(1000 * A - 1000 * T + 6 * h), k) for k, h in enumerate(H, 1)]
print(sorted(candidate)[0][1])

Measured memory_bytes: 3188
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!(
    n: usize,
    a: usize,
    b: usize,
    );
    let mut sum = 0;
    for i in 1..n + 1 {
        let mut num = i;
        let mut total = 0;
        while num != 0 {
            let dig = num % 10;
            total += dig;
            num /= 10;
        }
        if total >= a && total <= b {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<bool> accepted(N + 1, false);
  map<int64_t, int64_t> was;
  int64_t cnt_ac = 0;
  int64_t cnt_wa = 0;
  for (size_t m = 0; m < M; ++m) {
    int64_t q;
    string res;
    cin >> q >> res;
    if (accepted[q]) {
      continue;
    }
    if (res == "WA") {
      ++was[q];
    } else {
      accepted[q] = true;
      ++cnt_ac;
      cnt_wa += was[q];
    }
  }
  cout << cnt_ac << " " << cnt_wa << endl;
  
  return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define N 100100
#define Q 1000000007
using namespace std;
long long s[N];
long long a,b;
int nb[N],ca[N];
bool chk[N][2];
int dp[N][2];
int solve(int k,int st,int n){
	if(k>=n) return 1;
	if(chk[k][st]) return dp[k][st];
	chk[k][st]=true;
	if(st==0){
		if(s[k+1]-s[k]>=a) dp[k][st]=(dp[k][st]+solve(k+1,0,n))%Q;
		else dp[k][st]=(dp[k][st]+solve(k+2,1,n))%Q;
		dp[k][st]=(dp[k][st]+solve(k+1,1,n))%Q;
		return dp[k][st];
	}
	else{
		if(s[k]-s[k-1]>=b) return dp[k][st]=solve(k,0,n);
		if(k>=2&&s[k]-s[k-2]<a) return 0;
		if(ca[k]<nb[k-1]) return 0;
		else if(ca[k]==nb[k-1]) return dp[k][st]=solve(nb[k-1]+1,1,n);
		else return dp[k][st]=solve(nb[k-1],0,n);
	}
}
int main(){
	int n;
	scanf("%d%lld%lld",&n,&a,&b);
	if(a>b) swap(a,b);
	for(int i=0;i<n;i++) scanf("%lld",&s[i]);
	s[n]=1LL<<62;
	ca[n]=n+2,nb[n]=n;
	for(int i=n-1;i>=0;i--){
		if(s[i]+a<=s[i+1]) ca[i]=ca[i+1];
		else ca[i]=i+1;
		nb[i]=nb[i+1];
		while(s[nb[i]-1]-s[i]>=b) nb[i]--;
	}
	printf("%d\n",solve(0,0,n));
	return 0;
}

Measured memory_bytes: 7424
use std::io::{self, BufRead, Write, BufWriter};

fn read<R: BufRead, T: std::str::FromStr>(input: &mut R) -> T {
    let mut s = String::new();
    input.read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let mut a = Vec::with_capacity(200_000);
    {
        let input = io::stdin();
        let mut input = input.lock();
        let n = read::<_, usize>(&mut input);
        for _ in 0..n {
            let ai = read::<_, usize>(&mut input);
            a.push(ai);
        }    
    }

    let mut max1 = 0;
    let mut max2 = 0;
    for &ai in a.iter() {
        if max1 <= ai {
            max2 = max1;
            max1 = ai;
        } else if max2 <= ai {
            max2 = ai;
        }
    }

    let stdout = io::stdout();
    let mut buf = BufWriter::new(stdout.lock());

    for ai in a.into_iter() {
        let res = if ai == max1 {
            max2
        } else {
            max1
        };
        writeln!(buf, "{}", res).unwrap();
    }
}

Measured memory_bytes: 7676
def sqmake(n):
    if sq[n-1:n]:pass
    else:sqmake(n-1)
    sq_n=[]
    for j in sq[n-1]:
        for k in range(len(j)):
            sq_n_i=j[:]
            sq_n_i[k]+=1
            sq_n_i.sort(reverse=True)
            if sq_n_i in sq_n:pass
            else:sq_n.append(sq_n_i)
    sq_n_i=j[:]
    sq_n_i.append(1)
    sq_n.append(sq_n_i)
    sq_n.sort(reverse=True)
    sq.append(sq_n)
sq=[[[0]],[[1]]]
while 1:
    n=int(input())
    if n==0:break
    sqmake(n)
    for i in sq[n]:print(' '.join(map(str,i)))


Measured memory_bytes: 8936
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	long long a[n];
	int check[n-1];
	rep(i,n){
		cin>>a[i];
		if(i!=0){
			if(a[i]-a[i-1]>0)check[i-1]=1;
			else if(a[i]-a[i-1]<0)check[i-1]=-1;
			else check[i-1]=0;
		}
	}
	int num=0,cnt=0;
	rep(i,n-1){
		if(check[i]==0)continue;
		if(cnt==0){
			cnt=check[i];
			continue;
		}
		if(cnt*check[i]<0){
			num++;
			cnt=0;
		}
	}
	cout<<num+1<<endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	int k;
  	string s,ans;
  	cin >> k >> s;
  	if(s.length()>k){
      ans = s.substr(0,k);
      ans = ans + "...";
    }
    else
      ans = s;
  	cout << ans;
    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
m_cnt = 0
a_cnt = 0
r_cnt = 0
c_cnt = 0
h_cnt = 0
for _ in range(n):
    s = input()
    if s[0] == 'M':
        m_cnt += 1
    elif s[0] == 'A':
        a_cnt += 1
    elif s[0] == 'R':
        r_cnt += 1
    elif s[0] == 'C':
        c_cnt += 1
    elif s[0] == 'H':
        h_cnt += 1

lst = [m_cnt, a_cnt, r_cnt, c_cnt, h_cnt]
ans = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += lst[i] * lst[j] * lst[k]
print(ans)

Measured memory_bytes: 75828
from collections import Counter

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

counter = Counter(A)
counter = list(counter.items())
counter = sorted(counter, key=lambda x: x[1])

ans = 0
for i in range(len(counter)-K):
    ans += counter[i][1]

print(ans)



Measured memory_bytes: 37760
#include<stdio.h>
int main(){
	int n,m,l,x,y,z,a[100][100],b[100][100];
	long long int c[100][100]={0};
	scanf("%d %d %d",&n,&m,&l);
	for(y=0;y<n;y++){
		for(x=0;x<m;x++){
			scanf("%d",&a[y][x]);
		}
	}
	for(y=0;y<m;y++){
		for(x=0;x<l;x++){
			scanf("%d",&b[y][x]);
		}
	}
	for(y=0;y<n;y++){
		for(x=0;x<l;x++){
			for(z=0;z<m;z++){
				c[y][x]=c[y][x]+(a[y][z]*b[z][x]);
			}
		}
	}
	for(y=0;y<n;y++){
		for(x=0;x<l;x++){
			if(x!=(l-1)){
				printf("%lld ",c[y][x]);
			}
			else{
				printf("%lld",c[y][x]);
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 2824
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll p(ll x) {
	if (x == 0) { return 1; }
	return p(x - 1) * 2;
}


int main() {

	ll N, M;
	cin >> N >> M;

	cout << (100 * (N - M) + 1900 * M)*p(M);

	system("PAUSE");

	

}


Measured memory_bytes: 504
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
	vb line(201, false);
	ll x, n;
	cin >> x >> n;
	rep(i, n) {
		ll p;
		cin >> p;
		line[p] = true;
	}
	ll ans = 10000000;
	ll ansi = 0;
	mrep(i, 200) {
		if (line[i] == false) {
			if (ans >= abs(x - i)) {
				ans = abs(x - i);
				ansi = i;
			}
		}
	}
	cout << ansi << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin>>n>>m;
  
  int left = 0;
  int right = 100001;
  
  rep(i,m) {
    int l,m;
    cin>>l>>m;
    
    if(l>left) {
      left=l;
    }
    
    if(m<right) {
      right=m;
    }
  }
  
  if(left>right) {
    cout<<0;
  } else if (left==right) {
    cout<<1;
  } else {
    cout<<right-left+1;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set<string> s;
	string i;
	for(int j=0;j<n;j++)
	{
		cin>>i;
		s.insert(i);
	}
	cout<<s.size();
	
}

Measured memory_bytes: 19228
n = int(input())
a, b, c = input(), input(), input()
ans = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main(){
	cin>>s>>t;
	if(s==t){
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=1;i<=s.size()-1;i++){
		string str1=s.substr(0,i);
		string str2=s.substr(i,s.size()-i);
		str2+=str1;
		if(str2==t){
			cout<<"Yes"<<endl;
			return 0;
		} 
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = s.length();
    string key = "keyence";
    bool ans = false;
    if(s==key||s.substr(0,7)==key||s.substr(l-7,7)==key){
        ans = true;
    }else{
        for(int i=1;i<=6;++i){
            if(s.substr(0,i)==key.substr(0,i)&&s.substr(l-7+i,7-i)==key.substr(i,7-i)){
                ans = true;
            }
        }
    }
    if(ans){
        cout << "YES\n";
    }else{
        cout <<"NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main()
{
	int n, m, l;
	std::cin >> n >> m >> l;
	int **A = new int*[n], **B = new int*[m];
	for(int i = 0; i < n; i++)
	{
		A[i] = new int[m];
	}
	for(int i = 0; i < m; i++)
	{
		B[i] = new int[l];
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			std::cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++)
	{
		for(int j = 0; j < l; j++)
		{
			std::cin >> B[i][j];
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < l; j++)
		{
			long long C = 0;
			for(int k = 0; k < m; k++)
			{
				C += A[i][k] * B[k][j];
			}
			std::cout << C;
			if(j != l - 1)
			{
				std::cout << ' ';
			}
		}
		std::cout << std::endl;
	}
	return 0;
}


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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

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

int main(){
  int n;long long k;cin >> n >> k;
  vector<int> a(n),b(n);
  vector<long long> c(100001,0);
  long long sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    c[a[i]-1] += b[i];
  }
  for(int i=0;i<100001;i++){
    sum += c[i];
    if(sum >= k){
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 1792
program main
    implicit none
    integer:: n, rate(2), i,j,k, dj,dk,dc, jj,kk
    integer:: inf = 10000, lowest, mul
    integer, allocatable:: med(:,:), cost(:), dp(:,:), ndp(:,:)

    read*, n, rate(1:2)
    allocate(med(2,n), cost(n), dp(0:n*10,0:n*10), ndp(0:n*10,0:n*10))
    
    do i = 1,n
        read*, med(1:2,i), cost(i)
    end do

    ndp(:,:) = inf
    dp(:,:) = inf

    ndp(0,0) = 0
    dp(0,0) = 0

    do i = 1, n
        dj = med(1,i)
        dk = med(2,i)
        dc = cost(i)
        do j = 0, n*10    
            do k = 0, n*10
                if (j+dj > n*10 .or. k+dk > n*10) cycle
                ndp(j+dj, k+dk) = min(ndp(j+dj,k+dk), dp(j,k)+dc)
            end do
        end do
        dp = ndp       
    end do
    lowest = inf
    mul = 1

    do while(maxval(rate)*mul <= 10*n)
        jj = rate(1)*mul
        kk = rate(2)*mul
        if (dp(jj,kk) < lowest)then
        endif
        lowest = min(lowest, dp(jj, kk))
        mul = mul + 1
    end do

    if(lowest < inf)then
        print'(i0)', lowest
    else
        print'(i0)', -1
    end if
    
end program

Measured memory_bytes: 1536
s = input()

math_s_list = []

def plus_or_nothing(math_s, pos_s, s):
    if pos_s == len(s):
        math_s_list.append(eval(math_s))
        return
    
    plus_or_nothing(math_s+s[pos_s], pos_s+1, s)
    plus_or_nothing(math_s+'+'+s[pos_s], pos_s+1, s)
    return

plus_or_nothing(s[0], 1, s)

ans = 0
for i in math_s_list:
    ans += i

print(ans)

Measured memory_bytes: 38384
n, a, b = map(int, input().split())

if a == 0:
    print("0")
elif b == 0:
    print(n)
else:
    ans = n // (a+b)
    remainder = n % (a+b)

    if remainder > a:
        print("{}".format(ans*a + a))
    else:
        print("{}".format(ans*a + remainder))


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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

char c[100];

int main(){
	cin>>c;
	int n=0;
	for(int i=0;i<4;i++){
		if(c[i]=='+') n++;
		else n--;
	}
	cout<<n;
	return 0;
}


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

int main()
{
   long long int n,i,c,t;
   char a[100000];

   scanf("%lld",&n);
   scanf("%s",a);

   if(n%2==1)
   {

       printf("No\n");
   }

   else{
        t=n/2;
        c=0;
   for(i=0;i<=n/2-1;i++)
   {

    if(a[i]==a[t]){
        c++;
   t++;
    }
    else{
        break;
    }





   }

    if(c==n/2)
   {

       printf("Yes\n");
   }

else{
    printf("No\n");
}
   }



    return 0;
}


Measured memory_bytes: 128