akhauriyash/Code-Regression huggingface dataset:
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static int ans = 0;
    public static int[] dx, dy;
    public static int h, w;
    public static bool[,] map;
    public static void Main()
    {
        dx = new int[] { 0, 1, 0, -1 };
        dy = new int[] { 1, 0, -1, 0 };
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        map = new bool[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
                if (s[j] == '.') map[i, j] = true;
        }
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (map[i, j]) getAns(i, j);
        Console.WriteLine(ans);
    }
    static void getAns(int sx, int sy)
    {
        var t = new int[h, w];
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++) t[i, j] = 1000; ;
        var q = new Queue<P>();
        q.Enqueue(new P { x = sx, y = sy });
        t[sx, sy] = 0;
        while (q.Count() > 0)
        {
            var a = q.Dequeue();
            var aa = t[a.x, a.y];
            for (int i = 0; i < 4; i++)
            {
                var nx = a.x + dx[i];
                var ny = a.y + dy[i];
                if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] && t[a.x, a.y] +1 < t[nx,ny] )
                {
                    t[nx, ny] = t[a.x, a.y] + 1;
                    ans = Max(ans, t[nx, ny]);
                    q.Enqueue(new P { x = nx, y = ny });
                }
            }
        }
    }
}


Measured memory_bytes: 15440
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
ll a;
ll x[51];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> a;
  REP(i, n) cin >> x[i];

  ll dp[51][51][3000];

  REP(i, n + 1) dp[0][i][0] = 1;
  REP(i, n) {
    REP(j, n) {
      REP(k, 3000) {
        dp[i + 1][j + 1][k] += dp[i + 1][j][k];
        if(k >= x[j]) dp[i + 1][j + 1][k] += dp[i][j][k - x[j]];
      }
    }
  }

  ll ans = 0;
  FOR(i, 1, n + 1) ans += dp[i][n][a * i];

  cout << ans << endl;
}


Measured memory_bytes: 60928
#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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;
// ll dp[100010];

int main(){

  int n,m;cin>>n>>m;
  int a[m+10];rep(i,0,m)cin>>a[i];

  vector<ll>dp(n+10,0);
  int k=0;
  rep(i,0,n){
    if(i==a[k]){
      dp[i]=-1;
      k++;
    }
  }

  dp[0]=1;
  rep(i,0,n){
    if(dp[i]==-1)dp[i]=0;
    if(dp[i+1]!=-1){
      dp[i+1]+=dp[i];
      dp[i+1]%=mod;
    }
    if(dp[i+2]!=-1){
      dp[i+2]+=dp[i];
      dp[i+1]%=mod;
    }
  }

  out(dp[n]);


  return 0;
}


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

const int N = 100100;

int n, k, h[N], dp[N];

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

	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];

		dp[i] = INT_MAX;
		for (int j = 1; j <= min(k, i - 1); j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define bignum 100000000000009
using namespace std;
void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
const int Max=1e5+1;
const int OO=-1e6;
int st[4]= {1,0,0,-1};
int nt[4]= {0,1,-1,0};
ll n,m;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}

ll mem[109][Max];
void init()
{
    memset(mem,-1,sizeof mem);
}
/////////////////////////////////////////////////////////////////////
ll a[106];
ll v[106];

ll solve (ll i,ll rem )
{
    if(!rem)return 0;
    if(i==n||rem<0)return 1e18;
    ll &ret=mem[i][rem];
    if(~ret)return ret;
    ll leave=solve(i+1,rem);
    ll take=solve(i+1,rem-v[i])+a[i];
    return ret=min(leave,take);
}

int main()
{
   init();
    n =D();
    m =D();
   for(int i=0; i<n;i++)
   {
       a[i]=llD();
       v[i]=llD();
   }
   ll ans=0;
   for(int i=0 ;i <Max;i++)
   {
       if(solve(0,i)<=m)
        ans=i;

   }
   printf("%lld",ans);

}



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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

string s;
ll l, r, k, ans;
int main()
{
	cin >> s >> k;

	for(int i = 0; i < s.size(); i++)
		if(s[i] == s[0])
			l = i + 1;
		else
			break;
	
	for(int i = s.size() - 1; i >= 0; i--)
		if(s[i] == s[s.size() - 1])
			r = s.size() - i;
		else
			break;

	if(l == s.size()){
		cout << s.size() * k / 2;
		return 0;
	}
	
	for(int i = l; i < s.size() - r; i++)
		if(s[i] == s[i - 1])
			s[i] = -1, ans++;                
	if(s[0] == s[s.size() - 1])
		cout << ans * k + l / 2 + r / 2 + (l + r) / 2 * (k - 1);
	else
		cout << (ans + l / 2 + r / 2) * k << endl;
	return 0;
}


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

using namespace std;

int main()
{
  int a, b;

  scanf("%d %d", &a, &b);

  if (a + b < 24)
  {
    printf("%d", a + b);
  }
  else
  {
    printf("%d", a + b - 24);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int n, k, s, i;

int main() {
scanf("%d %d %d", &n, &k, &s);
for (i=0;i<k;i++) printf("%d ", s);
if (s == 1000000000) for (i=k;i<n;i++) printf("1 "); else for (i=k;i<n;i++) printf("1000000000 ");
printf("\n");

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, ans=0;
  cin >> n;
  vl a(n), b(n), c(n-1);
  rep(i, n) cin >> a[i];
  rep(i, n) {cin >> b[i]; ans += b[i];}
  rep(i, n-1) cin >> c[i];
  rep(i, n-1) if(a[i+1]-a[i]==1) ans+=c[a[i]-1];
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] input = new String[N];
		for (int i = 0; i < input.length; i++) {
			String[] tmp = sc.next().split("");
			Arrays.sort(tmp);
			input[i] = String.join("", tmp);
		}
		Arrays.sort(input);
		long res = 0;
		int conn = 0;
		String before = "";
		for (String element : input) {
			if (before.equals(element)) {
				conn++;
				res += conn;
			} else {
				conn = 0;
			}
			before = element;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 66252
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int64_t getMinSadness(const std::vector<int64_t> &value) {
  auto removed_value = value;
  for (int i = 0; i < value.size(); ++i) {
    removed_value[i] -= (i + 1);
  }
  std::sort(removed_value.begin(), removed_value.end());
  const int64_t center = removed_value[(removed_value.size() - 1) / 2];
  int64_t total = 0L;
  for (const auto &r : removed_value) {
    total += std::abs(r - center);
  }
  return total;

}

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> values(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> values[i];
  }
  std::cout << getMinSadness(values) << std::endl;
  return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			int n=sc.nextInt();
			if(n==0)
				return;

			int sum=0;

			for(int i=0; i<n/4; i++)
			{
				sum += sc.nextInt();
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
#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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

ll d[310][310];
bool del[310][310];
int n;
ll sum;

bool warshall(){
    rep(k,n){
        rep(i,n){
            rep(j,i){
                if(chmin(d[i][j],d[i][k]+d[k][j]))return false;
                if(d[i][j]==d[i][k]+d[k][j] && i!=k && j!=k && !del[i][j]){
                  	sum-=d[i][j];
                  	del[i][j]=true;
                }
            }
        }
    }
  	return true;
}

int main() {
    cin >> n;
    sum=0;
    rep(i,n){
        rep(j,n){
            cin >> d[i][j];
            sum+=d[i][j];
        }
    }
  	sum/=2;
    rep(i,n){
        rep(j,n){
            if(d[i][j]!=d[j][i]){
                cout << -1;
                return 0;
            }
        }
    }
  	rep(i,n)rep(j,n)del[i][j]=false;
    if(warshall()){
        cout << sum;
    }
    else cout << -1;
    


}

/*



 */



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const int dy[]={0,1, 0,-1};
const int dx[]={1,0,-1, 0};
const string dr="LDRU";

int cvv(int y,int x, int d){
	return (y<<16) + (x<<2) + d;
}
void rvv(int a, int& y,int& x,int& d){
	d = a&3;
	x = (a>>2)&  ((1<<14)-1);
	y = (a>>16)& ((1<<14)-1);
}
int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	int gx,gy;
	cin >>s >>gx >>gy;
	
	
	int n=sz(s);
	
	VI ct(n);
	int cc=0;
	rep(i, n){
		if(s[i]=='T'){ cc++; continue;}
		ct[cc]++;
	}
	
	VI ba(20000);
	ba[ct[0]+10000] = 1;
	rep2(i,1,n){
		if(i%2) continue;
		VI na(20000);
		rep(j,20000){
			if(ba[j]==1) na[j-ct[i]] = na[j+ct[i]] = 1;
		}
		swap(ba, na);
	}
	if(ba[gx+10000]==0){ puts("No"); return 0;}
	
	fill(all(ba), 0);
	ba[10000]=1;
	rep(i,n){
		if(i%2==0) continue;
		VI na(20000);
		rep(j,20000){
			if(ba[j]==1) na[j-ct[i]] = na[j+ct[i]] = 1;
		}
		swap(ba, na);
	}
	if(ba[gy+10000]==0){ puts("No"); return 0;}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 512
#include "cstdio"
#include "algorithm"
using namespace std;
int main()
{
    int arr[210];
    int N;
    while (~scanf("%d", &N) && N)
    {
        for (int i = 2 * N - 1; i >= 0; i--)
            scanf("%d", &arr[i]);
        int sum = 0;
        sort(arr, arr + 2 * N);
        for (int i = 0; i < N; i++)
            sum += arr[2 * i];
        printf("%d\n", sum);
    }
}

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

int main(){
    string s;
    cin>>s;
    if (s == "Sunny"s) {
        cout<<"Cloudy"<<endl;
    }else if(s == "Cloudy"s){
        cout<<"Rainy"<<endl;
    }else if(s == "Rainy"s){
        cout<<"Sunny"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        if (Math.abs(n - m) > 1) {
            System.out.println(0);
            return;
        }

        long ln = 1;
        long mod = 1000000007;

        for (int i = 2; i <= n ; i++) {
            ln *= i % mod;
            ln %= mod;
        }

        for (int i = 2; i <= m ; i++) {
            ln *= i % mod;
            ln %= mod;
        }

        if (Math.abs(n - m) == 0) {
            ln *= 2;
        }

        System.out.println(ln % mod);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
 
using namespace std;
const int MAXN = 2010;
 
void setmax (int &a, int b) {
	if (a < b) {
		a = b;
	}
}
 
int N, K;
int dp[MAXN][MAXN];	//dp[vertex][max_depth]
int par[MAXN];
vector<int> adj[MAXN];
 
void dfs (int x, int p) {
	auto it = find(adj[x].begin(), adj[x].end(), p);
	if (it != adj[x].end()) {
		adj[x].erase(it);
	}
	for (int t : adj[x]) {
		if (t != p) {
			dfs(t, x);
		}
	}
}
 
int getdp (int x, int mxd) {
	int &ref = dp[x][mxd];
	if (ref >= 0) {
		return ref;
	}
	//biggest child depth is < mxd - 1.
	if (mxd == 0) {
		return ref = 1;
	}
	ref = getdp(x, mxd - 1);
	//biggest child depth = mxd - 1
	if (mxd == K) {
		//then just do this 
		for (int t : adj[x]) {
			setmax(ref, 1 + getdp(t, mxd - 1));
		}
		return ref;
	}
	int mxallow = min(mxd - 1, K - 1 - mxd);
	int s = 0;
	for (int t : adj[x]) {
		s += getdp(t, mxallow);
	}
	for (int t : adj[x]) {
		setmax(ref, 1 + s + (getdp(t, mxd - 1) - getdp(t, mxallow)));
	}
	return ref;
}
 
int main() {
	scanf("%d %d", &N, &K);
	for (int i = 1; i < N; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
 
	//ok add this stuff
	dfs(1, 0);
	int ans = 0;
	memset(dp, -2, sizeof(dp));
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= K; j++) {
			setmax(ans, getdp(i, j));
		}
	}
	printf("%d\n", N - ans);
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  vec x(n),y(n);
  for(ll i=0;i<n;i++)cin >> x[i] >> y[i];

  ll ans=0;

  vec s(n);
  
  for(ll i=0;i<n;i++)s[i]=x[i]+y[i];
  sort(s.begin(),s.end());
  ans=max(ans,s[n-1]-s[0]);

  for(ll i=0;i<n;i++)s[i]=x[i]-y[i];
  sort(s.begin(),s.end());
  ans=max(ans,s[n-1]-s[0]);

  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 8008
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
char S[101];
int main() {

	int a=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>S[i];
		if(S[i]=='Y')a=1;
	}
	if(a==0)cout<<"Three"<<endl;
	else cout<<"Four"<<endl;

 	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(bf.readLine());
		bf.close();

		int cnt = 1;
		int sum = 0;
		for(int i = 1;;i++) {
			sum += i;
			if(sum >= X) {
				System.out.println(cnt);
				break;
			}
			cnt++;
		}
	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>

using namespace std;

int h,w;
char s[51][51];
int d[51][51];
int dx[4] = {0,0,1,-1}, dy[4] = {1,-1,0,0};

int bfs(){
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            d[i][j] = 1e7;
        }
    }

    queue<pair<int,int>> que;

    que.push(pair<int,int>(0,0));

    d[0][0] = 0;

    while(que.size()){

        pair<int,int> p = que.front(); que.pop();

        if(p.first == h-1 && p.second == w-1) break;

        for(int i = 0; i < 4; i++){

            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#' && d[nx][ny] == 1e7){
                que.push(pair<int,int>(nx,ny));

                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    return d[h-1][w-1];
}

int main(){
    int white = 0;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
            if(s[i][j] == '.') white++;
        }
    }

    int min_value = bfs();
    if(min_value == 1e7) cout << -1 << endl;
    else{
        min_value += 1;
        cout << white - min_value << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define ll long long

void main(){
    ll N,D;
    ll X[200002],Y[200002]; 
    int sum = 0;
    scanf("%lld%lld",&N,&D);
    for(int i = 0;i < N;i++){
        scanf("%lld%lld",X+i,Y+i);
        if(sqrt(X[i]*X[i]+Y[i]*Y[i]) <= D)sum++;
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 5280
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define loop(i,a,b) for(i=a;i<b;i++)
    #define rloop(i,a,b) for(i=a;i>=b;i--)
    #define vi vector<int>
    #define vl vector<ll>
    #define vii vector< vector<int> >
    #define vll vector< vector<ll> >
    #define vs vector<string>
    #define pii pair<int,int>
    #define pis pair<int,string>
    #define psi pair<string,int>
    const int inf=1000000001;
    const ll INF=1e16;
    #define MOD 1000000007
    #define mod 1000000009
    #define pi 3.14159265358979323846
    #define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
    int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
     
     
    int main(){
    	ll n,a,b,i,j;
    	cin>>n>>a>>b;
    	if(a>b){
    		cout<<0<<endl;
    	}else if(n==1){
    		if(a!=b){
    			cout<<0<<endl;
    		}else{
    			cout<<1<<endl;
    		}
    	}else{
    		ll m=a*(n-2);
    		ll M=b*(n-2);
    		cout<<M-m+1<<endl;
    	}
    }

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


int min_range = -1000000;
int max_range =  1000000;
int32_t main()
{
    int k, x;
    cin>>k;
    cin>>x;

    min_range = max(min_range, x-k+1);
    max_range = min(max_range, x+k-1);

    for(int i=min_range;i<=max_range;i++){
        cout<<i<<" ";
    }
    cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
p_idx = 0
p_diff = 10000.0
for i in range(N):
    if p_diff > abs(T - H[i]*0.006 - A):
        p_diff = abs(T - H[i]*0.006 - A)
        p_idx = i+1
print(p_idx)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n;

	cin>>n;

	if(n%2==0){
		cout<<n<<endl;
	}else{
		cout<<n*2<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    set<double> water;
    set<double> sugar;
    rep(i, 31)rep(j, 31){
        if(100 * (i * a + j * b) <= f) water.insert(100 * (i * a + j * b));
    }
    rep(i, 3001)rep(j, 3001){
        if(i * c + j * d <= f) sugar.insert(i * c + j * d);
    }
    double max_dens = 0;
    int ans_w = 100 * a, ans_s = 0;
    for(double w : water){
        for(double s : sugar){
            if(w == 0) continue;
            if(w + s > f) continue;
            if(((100 * s) / (w + s)) > (100 * e / (100 + e))) continue;
            if(max_dens < ((100 * s) / (w + s))){
                max_dens = (100 * s) / (w + s);
                ans_w = w, ans_s = s;
            }
        }
    }
    cout << ans_s + ans_w << " " << ans_s << endl;
}

Measured memory_bytes: 3880
class PriorityQueue

  def initialize(heap=[])
    @size = heap.size
    @heap = heap.sort
  end

  # log( log n )
  def push x
    i = @size
    @size += 1
    while i > 0
      par = ( i - 1 ) / 2
      break if @heap[par] <= x
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  # log( log n )
  # return nil if @size == 0
  def pop

    ret = @heap[0]
    x = @heap[@size-=1]


    i = 0
    while (child = i * 2 + 1) < @size
      child_1 = i * 2 + 2
      child = child_1 if child_1 < @size && @heap[child_1] < @heap[child]
      break if @heap[child] >= x
      @heap[i] = @heap[child]
      i = child
    end

    @heap[i] = x
    @heap.delete_at(-1)
    ret
  end

  def size
    @heap.size
  end

  def top
    @heap[0]
  end

  def any?
    @size > 0
  end

  def empty?
    @size == 0
  end

  def all
    @heap
  end

  def first
    @heap[0]
  end

  def second
    @size < 3 ? @heap[1] : [@heap[1], @heap[2]].min
  end

  def third
    @size < 3 ? nil : [@heap[1], @heap[2]].max
  end
end

class Array

  include Comparable

  def to_pq
    PriorityQueue.new(self)
  end
end

class Node

  attr_accessor :to, :cost
  def initialize(to, cost)
    @to = to
    @cost = cost
  end
end

INF = 10 ** 7
# INF = Float::INFINITY
# with PriorityQueue O(|E|log|V|)
def dijkstra(g, s)

  # inf = 10 ** 12
  inf = INF
  dist = Array.new(g.size, inf)
  dist[s] = 0

  que = []
  que.push( [0, s] )

  while que.any?

    d, v = que.shift
    next if dist[v] < d
    # p g[v]
    g[v].each do |e|
      next if dist[e.to] != inf || dist[v] == inf
      
      dist[e.to] = dist[v] + 1
      que.push( [dist[e.to], e.to ] )
      
    end
    # p que
  end

  dist
  # dist.map!{|d| d == inf ? "INF" : d }
end

n, m = gets.to_s.split.map{|t|t.to_i}

g = Array.new(n*3){ [] }

m.times do
  u, v = gets.to_s.split.map{|t|t.to_i-1}
  g[3*u+0] << Node.new(3*v+1, 1)
  g[3*u+1] << Node.new(3*v+2, 1)
  g[3*u+2] << Node.new(3*v+0, 1)
  # g[3*v+0] << Node.new(3*u+1, 1)
  # g[3*v+1] << Node.new(3*u+2, 1)
  # g[3*v+2] << Node.new(3*u+0, 1)
end

s, t = gets.to_s.split.map{|i|i.to_i-1}

dist = dijkstra(g, s*3+0)
# p [s*3+0, t*3+0]

puts dist[t*3+0] == INF ? -1 : dist[t*3+0]/3




Measured memory_bytes: 47740
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
   
   while(test--)
   solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
    string s;
    cin>>s;
    int l=s.length();
    if(l&1){
        cout<<"No";
        return;
    } 
    bool flag=true;
    for(int i=0;i<l;i+=2){
        if(s[i]!='h' or s[i+1]!='i'){
            flag=false;
            break;
        }
    }
    if(flag)
    cout<<"Yes";
    else
    cout<<"No";
}    


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
N = int(input())
alp = list("MARCH")
data = [0]*5
for i in range(N):
    s = list(input())
    for i in range(5):
        if alp[i] == s[0]: data[i] += 1

flag = 0
for i in range(5):
    if data[i] != 0: flag += 1

if flag < 3:
    print(0)
else:
    ans = 0
    for a in range(3):
        for b in range(a+1,4):
            for c in range(b+1,5):
                ans += data[a]*data[b]*data[c]
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	long N, M;
	while (cin >> N >> M && N != 0 || M != 0)
	{
		vector< pair<int,int> > dp(N);
		long long  ans = 0;
		for (int i = 0; i < N; i++)
		{
			cin >> dp[i].second >> dp[i].first;
			ans += dp[i].second * dp[i].first;
		}
		sort(dp.begin(), dp.end());
		reverse(dp.begin(), dp.end());

		for (int i = 0; i < N; i++)
		{
			if (M <= 0)break;
			if (M >= dp[i].second)
			{
				M -= dp[i].second;
				ans -= dp[i].second * dp[i].first;
			}
			else
			{
				ans -= M * dp[i].first;
				M = 0;
			}
		}

		cout << ans << endl;



	}
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll ans = 0;
  if(a+b>2*c){
    ll m = min(x,y);
    ans += 2*c*m;
    x -= m;
    y -= m;
  }
  if(a>2*c) ans += 2*c*x;
  else ans += a*x;
  if(b>2*c) ans += 2*c*y;
  else ans += b*y;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,x,w;
	scanf("%d",&n);
	x=0;
	w=0;
	for(i=1;i<=n;i++){
		x+=800;
		w+=1;
		if(w%15==0){
			x=x-200;
		}
	}
	printf("%d\n",x);
	return 0;
}


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

int main(){
  int N;
  string S;
  cin>>S;
  N=S.size();
  int res1=0,res2=0;
  
  for(int i=0;2*i+1<N;i++){
    if(S.at(2*i+1)=='0')
      res1++;
  }
  for(int i=0;2*i<N;i++){
    if(S.at(2*i)=='1')
      res1++;
  }
  
  for(int i=0;2*i+1<N;i++){
    if(S.at(2*i+1)=='1')
      res2++;
  }
  for(int i=0;2*i<N;i++){
    if(S.at(2*i)=='0')
      res2++;
  }
  
  cout<<min(res1,res2);
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
    int x,y;cin>>x>>y;
    double a=(4*x-y)/2.0;
    double b=x -a;
    if(a>=0 && b>=0 && a==int(a) && b==int(b)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 3620
n, m = map(int, input().split())
LR = [tuple(int(x) for x in input().split()) for _ in range(m)]

c = [0] * (n+1)

for L, R in LR:
    c[L - 1] += 1
    c[R] -= 1

ans = 0
temp = 0
for x in c:
    temp += x
    if temp == m:
        ans += 1

print(ans)

Measured memory_bytes: 17516
n = int(input())
a = [int(i) for i in input().split()]

hai = 0
tya = 0
midori = 0
mizu = 0
ao = 0
ki = 0
daidai = 0
aka = 0
iro = 0

for i in range(n):
    if a[i] <= 399:
        hai = 1
    elif a[i] <= 799:
        tya = 1
    elif a[i] <= 1199:
        midori = 1
    elif a[i] <= 1599:
        mizu = 1
    elif a[i] <= 1999:
        ao = 1
    elif a[i] <= 2399:
        ki = 1
    elif a[i] <= 2799:
        daidai = 1
    elif a[i] <= 3199:
        aka = 1
    else:
        iro += 1
        
min_iro = hai+tya+midori+mizu+ao+ki+daidai+aka

print(max(min_iro,1),min_iro+iro)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


int N;
string S;
vector<vector<int>> li;
vector<int> siz;
bool judge(int len){
	map<string,int> s;
	string now=S.substr(0,len);
	REP(i,0,N-len+1){
		if(s.find(now)!=s.end()){
			int t=s.find(now)->second;
			if(t+len<=i){
				return true;
			}
		}else{
			s[now]=i;
		}
		now=S.substr(i+1,len);
	}
	return false;
}


int main()
{
	int M;
	cin>>M;
	ll d[M],c[M];
	ll ans=0;
	ll pot=0;
	REP(i,0,M){
		cin>>d[i]>>c[i];
		ans+=c[i];
		pot+=c[i]*d[i];
	}

	ans=ans+(pot-1)/9-1;
	
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);		
		int n=in.nextInt();
		String s=in.next();
		int ans=1;
		for(int i=1;i<n;i++)
		{
			if(s.charAt(i)!=s.charAt(i-1))
				ans++;
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 26964
use proconio::input;
fn main() {
  input! {
  	n: u32,
    inr:[[u32; 2]; n],
  }
  let mut f = false;
  let mut f1 = true;
  let mut kai = 0;
  for i in inr.iter() {
    if i[0] == i[1] {
      kai += 1;
      if kai >= 3 {
        f = true;
      }
      f1 = true;
    } else {
      kai = 0;
      f1 = false;
    }
  }
  let ans = if f == true { "Yes" } else { "No" };
  println!("{}", ans);
}

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

int main() {
  string s;
  cin >> s;
  if(s[s.size()-1]=='s') s += "es";
  else s += "s";
  cout << s << endl;
}


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

#define int long long

template<typename T>
class BIT{
  vector<T> bit;
  int SIZE;
  
public:
  
  BIT(){
  }

  BIT(size_t size){
    init(size);
  }
  
  void init(size_t size){
    bit.clear();
    bit.resize(size+1);
    SIZE = size;
  }
  
  void add(int x, T  w){
    
    while(SIZE >= x){
      bit[x] += w;
      x += x & -x;
    }
  }

  T sum(int x){
    T res = 0;
    
    while(x > 0){
      res += bit[x];
      x -= x & -x;
    }
  }
  
};

signed main(){
  int N;
  int ans = -(1ll<<62);
  vector<int> A, maximum1, minimum2;
  multiset<int> se, se2;
  
  cin>>N;

  A.resize(N*3);
  maximum1.resize(N*3);
  minimum2.resize(N*3);
  
  for(int i = 0; i < N*3; i++){
    cin>>A[i];
  }

  for(int i = 0; i < N*3; i++){
    se.insert(A[i]);
    maximum1[i] += A[i];
    if(se.size() > N){
      auto it = se.begin();
      maximum1[i] -= *it;
      se.erase(it);
    }

    if(i) maximum1[i] += maximum1[i-1];
  }
  
  
  for(int i = N*3-1; i >= 0; i--){
    se2.insert(A[i]);
    minimum2[i] += A[i];
    if(se2.size() > N){
      auto it = se2.end(); it--;
      minimum2[i] -= *it;
      se2.erase(it);
    }
    if(i != N*3-1) minimum2[i] += minimum2[i+1];
  }

  for(int i = -1; i < N; i++){
    ans = max(ans, maximum1[N+i] - minimum2[N+i+1]);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	cin>>s;
	int le=0;
	int plusle=0;
	for(int i=0;i<n;i++){
		if(s[i]=='(')
			le++;
		else
			le--;
		if(le<0){
			le=0;
			plusle++;
		}
	}
	for(int i=1;i<=plusle;i++)
		cout<<"(";
	cout<<s;
	for(int i=1;i<=le;i++)
		cout<<")";
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class CWalkingTakahashi {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll x,k,d;
	    in >> x >> k >> d;
//	    if(k<abs(x)/d){
//	        out << abs(x-k*d) << endl;
//	        return;
//	    }
	    ll c1 = abs(x)%d;
	    ll c2 = d-c1;
	    ll t1 = abs(x)/d;
//	    out << c1 << " " << c2 << " " << t1 << endl;
        if(k-t1<0){
            out << abs(x)-k*d << endl;
            return;
        }
	    if((k-t1)%2==0) {
            out << c1 << endl;
        }else{
	        out << c2 << endl;
	    }
	}
};


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


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

using namespace std;
int main() {
	int h, w; cin >> h >> w;
	vector<vector<int>>dp(h + 1, vector<int>(w + 1)); vector<string>ban(h + 1);
	for (int j = 0; j <= w; j++)ban[0] += "#";
	for (int i = 1; i <= h; i++) { cin >> ban[i]; ban[i] = "#" + ban[i]; }
	dp[1][1] = 1;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (ban[i][j] == '.') {
				if (ban[i - 1][j] == '.')
					dp[i][j] += dp[i - 1][j];
				if (ban[i][j - 1] == '.')
					dp[i][j] += dp[i][j - 1];
			}
			dp[i][j] %= (int)1e9 + 7;
		}
	}
	cout << dp[h][w] << endl;
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> a;
	n %= 500;
	cout << ((n <= a) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
for i in range(k):
  if i%2==0:
    if a%2==0:
      a=int(a/2)
      b=b+a
    else:
      a=int((a-1)/2)
      b=b+a
  else:
    if b%2==0:
      b=int(b/2)
      a=a+b
    else:
      b=int((b-1)/2)
      a=a+b
print(a,b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

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

	while(1) {
		int count = 0;
		int n, x;
		cin >> n >> x;
	
		if(n == 0 && x == 0) break;
		
		vector<int> v;
		FOR(i, 1, n + 1) v.push_back(i);
		
		FOR(i, 1, n + 1) {
			FOR(j, i + 1, n + 1) {
				if(binary_search(v.begin() + j, v.end(), x - i - j)) count++;
			}
		}
		
		cout << count << "\n";
	}
			
	return 0;
}

Measured memory_bytes: 1220
from sys import exit

n, m = map(int, input().split())

a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 63940
H,W = map(int,input().split())
L = []
for i in range(H):
    l = list(input())
    L.append(l)

def judge(list,i,j):
    if i != 0:
        top = list[i-1][j]
    else:
        top = "."
    if j != 0:
        left = list[i][j-1]
    else:
        left = "."
    if i != H-1:
        bottom = list[i+1][j]
    else:
        bottom = "."
    if j != W-1:
        right = list[i][j+1]
    else:
        right = "."
    return top == "#" or left == "#" or bottom == "#" or right == "#"

for i in range(H):
    for j in range(W):
        if L[i][j] == "#" and judge(L,i,j) is False:
            print("No")
            exit()
print("Yes")

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

int main () {
    uint64_t n;
    cin >> n;

    string ans;

    while(n != 0) {
        n--;
        int a = n % 26LL;
        char c = 'a' + a;
        ans = c + ans;
        n /= 26LL;
    }

    cout << ans << endl;

    return 0;
}


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 100 * 1000 + 7;

int a[MAX], b[MAX], d[MAX];

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	scanf("%d", &n);
	FOR(i, 0, n)
		scanf("%d", a + i);
	FOR(i, 0, n)
		scanf("%d", b + i);
	LL sum = 0;
	int ans = 0;
	FOR(i, 0, n)
	{
		d[i] = a[i] - b[i];
		if(a[i] < b[i])
		{
			sum += b[i] - a[i];
			ans++;
		}
	}
	sort(d, d + n);
	RFOR(i, n, 0)
	{
		if(d[i] > 0 && sum > 0)
		{
			sum -= min(sum, (LL)d[i]);
			ans++;
		}
	}
	printf("%d", sum ? -1 : ans);
	return 0;
}

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

int main() {
    int N,r=-1,T,A,H,d=1e9+7;
    cin >> N >> T >> A;

    rep(i,N) {
        int t;
        cin >> H;
        t = abs(A*1000-(T*1000-H*6));
        if(t < d) {
            r = i+1;
            d = t;
        }
    }

    cout << r << endl;
}

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


int const MAX = 200005;
int const MAX_A = MAX;

stack<int> v[30];

//aの反転数を求める。
int a[MAX];
int l[MAX / 2 + 2], r[MAX / 2 + 2];

long long Merge(int a[], int n, int left, int mid, int right) {
	int i, j;
	long long cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++) {
		l[i] = a[left + i];
	}
	for (i = 0; i < n2; i++) {
		r[i] = a[mid + i];
	}
	l[n1] = MAX_A; r[n2] = MAX_A;
	i = 0; j = 0;
	for (int k = left; k < right; k++) {
		if (l[i] <= r[j]) {
			a[k] = l[i];
			i++;
		}
		else {
			a[k] = r[j];
			j++;
			cnt += n1 - i;
		}
	}
	return cnt;
}

int x[MAX], y[MAX / 2];

long long MergeSort(int A[], int n, int left, int right) {
	int mid;
	long long v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		v1 = MergeSort(A, n, left, mid);
		v2 = MergeSort(A, n, mid, right);
		v3 = Merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else { return 0; }
}

int alp(char c) {
	return c - 'a' + 1;
}

int main() {
	int n;
	string s;
	cin >> s;
	n = s.length();
	int letter[30];
	for (int i = 1; i <= 29; i++) {
		letter[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		letter[alp(s[i])]++;
	}
	int odd_letter = -1;
	int odd_cnt = 0;
	for (int i = 1; i <= 29; i++) {
		if (letter[i] % 2 == 1) {
			odd_cnt++;
			odd_letter = i;
		}
	}
	if (n % 2 == 0 && odd_cnt != 0) {
		cout << -1 << endl;
		return 0;
	}
	else if (n % 2 == 1 && odd_cnt != 1) {
		cout << -1 << endl;
		return 0;
	}
	long long ans = 0;
	int cnt_l, cnt_r;
	cnt_l = 0;
	int half;
	if (n % 2 == 0) {
		half = n / 2;
	}
	else {
		half = n / 2 + 1;
	}
	cnt_r = half;
	int letter_cnt[30];
	for (int i = 0; i <= 29; i++) {
		letter_cnt[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		int c = alp(s[i]);
		letter_cnt[c]++;
		if (c == odd_letter && letter_cnt[c] == letter[c] / 2 + 1) {
			x[i] = n / 2;
		}
		else if(letter_cnt[c] <= letter[c]/2){
			x[i] = cnt_l;
			v[c].push(half - cnt_l);

			cnt_l++;
		}
		else {
			x[i] = cnt_r;
			y[cnt_r - half] = v[c].top();
			v[c].pop();
			cnt_r++;

		}
	}
	/*
	for (int i = 0; i < n; i++) {
		cout << x[i] << " ";
	}cout << endl;
	for (int i = 0; i < n/2; i++) {
		cout << y[i] << " ";
	}cout << endl;
	*/
	ans = MergeSort(x, n, 0, n);
	ans += MergeSort(y, n/2, 0, n/2);
	cout << ans << endl;
}

Measured memory_bytes: 2820