akhauriyash/Code-Regression huggingface dataset:
import sys
H, W = map(int, input().split())
s = [input() for _ in range(H)]
s = ["." * W] + s + ["." * W]
for _ in range(H + 2):
    s[_] = "." + s[_] + "."
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if s[i][j] == "#":
            if any([
                    s[i - 1][j] == "#", s[i][j - 1] == "#", s[i][j + 1] == "#",
                    s[i + 1][j] == "#"
            ]):
                continue
            else:
                print("No")
                sys.exit()
else:
    print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*
願はくは花の下にて春死なんそのきさらぎの望月のころ（西行 1118-1190）
--This is old Japanese poem expressing the desire to die under tree on the full moon night.(written by Saigyo)
In my research, there is possibility that the tree may be seg-tree.
*/

/*Coding Space*/
int main(){
  string in; cin >> in;
  vt<string> vs = {
    "AKIHABARA",
    "KIHABARA",
    "AKIHBARA",
    "AKIHABRA",
    "AKIHABAR",
    "KIHBARA",
    "KIHABRA",
    "KIHABAR",
    "AKIHBRA",
    "AKIHBAR",
    "AKIHABR",
    "KIHBRA",
    "KIHBAR",
    "AKIHBR",
    "KIHABR",
    "KIHBR"
  };
  for(auto str:vs)
    if(str == in){
      cout << "YES" << endl;
      exit(0);
    }
  cout << "NO" << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    Vl sep = {0, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
    Vl nums(9);

    for (ll i = 0; i < N; i++) {
        int idx = upper_bound(sep.begin(), sep.end(), A[i]) - sep.begin() - 1;
        ++nums[idx];
    }

    ll mn = 0, mx = 0;
    for (ll i = 0; i < 8; i++) {
        mn += (nums[i] > 0 ? 1 : 0);
    }
    mx = mn;
    mx += nums[8];

    if (mn == 0) mn = 1;

    cout << mn << " " << mx << endl;

    return 0;
}

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

signed main(void){ 
 
  int N; cin >> N;
  int check = 0;
  vector<int> A(N);
  vector<int> vec;
  map<int,int> mp;
 
  int sum = 0;
  
  for(int i = 0; i < N; i++){ 
    cin >> A[i]; mp[A[i]]++; sum += A[i];
    if( check < A[i] ){ vec.push_back(i); check = A[i]; }
  }
  
  int m = vec.size(); 
  
  vector<int> ans(N,0);

  
  for(int i = m-1; i > 0; i--){
    int res = 0;
    while( mp.rbegin()->first > A[vec[i-1]] ){ 
      
      int a = mp.rbegin()->first;
      int b = mp.rbegin()->second;
      
      res += (a-A[vec[i-1]])*b;
      
      mp[A[vec[i-1]]] += b;
      
      mp.erase(a);
      
    }
    
    ans[vec[i]] = res;
    
    sum -= res;
        
    
  }
  
  ans[0] = sum;
  
  for(int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<bool> used(1000001);
  int a;
  cin >> a;
  int crr = 1;
  bool flag;
  while (true) {
    if (used[a]) {
      flag = true;
      break;
    }
    used[a] = true;
    if (a & 1) {
      a = a * 3 + 1;
    } else {
      a /= 2;
    }
    crr++;
  }
  cout << crr << '\n';
  return 0;
}

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

if ~(a - b) & 1:
	print((b - a) // 2)
else:
	moves = (a - 1 + (b - 1 - (a - 1) - 1) // 2)
	moves = min(moves, n - b + (n - a - (n - b) - 1) // 2)
	print(moves + 1)

Measured memory_bytes: 3060
main :: IO ()
main = do
  n <- readLn
  s <- getLine
  putStrLn $ solve n s

solve :: Int -> String -> String
solve n s
  | coresp ss s = ss
  | coresp sw s = sw
  | coresp ws s = ws
  | coresp ww s = ww
  | otherwise = "-1"
  where
    ss = "SS" ++ g 'S' 'S' s
    sw = "SW" ++ g 'S' 'W' s
    ws = "WS" ++ g 'W' 'S' s
    ww = "WW" ++ g 'W' 'W' s
    coresp (x:y:rest) (z:zx) =
      let
        l = last rest
        ll = last.init $ (y:rest)
        z' = last zx
      in
        c x z l y && c l z' ll x

g a b (x:y:[]) = []
g a b (x:y:rest) =
  c : g b c (y:rest)
  where
    not 'S' = 'W'
    not 'W' = 'S'
    c = case (b, y) of
          ('S', 'o') -> a
          ('S', 'x') -> not a
          ('W', 'o') -> not a
          ('W', 'x') -> a
g a b _ = []

c :: Char -> Char -> Char -> Char -> Bool
c sw xo l r =
  case (sw, xo) of
    ('S', 'o') -> l == r
    ('S', 'x') -> l /= r
    ('W', 'o') -> l /= r
    ('W', 'x') -> l == r


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


int main() {
	int N, T, A;
	cin >> N >> T >> A;
	vector<int> H(N), Ti(N);
	for (int i = 0; i < N; ++i) {
		cin >> H.at(i);
		Ti.at(i) = abs(T*1000 - H.at(i) * 6 - A*1000);
	}
	int mini = 0, min = Ti.at(0); 
	for (int i = 1; i < N; ++i){
		if (Ti.at(i) < min) {
			min = Ti.at(i);
			mini = i;
		}
	}
	cout << mini + 1 << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int h, w;
    for (;;) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) {
            break;
        }
        else {
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>

int main()
{
	int n=1,m=1;
	int obj[1001],max,min,temp=0;
	while(1)
	{
		max=0;
		min=2000000;
		
		scanf("%d",&n);
		scanf("%d",&m);
		
		if(n==0 && m==0) break;
		
		for(int i=0;i<n;i++)
		{
			scanf("%d",&obj[i]);
		}
		for(int i=0;i<n;i++)
		{
			for(int t=i+1;t<n;t++)
			{
				temp=obj[i]+obj[t];
				if(temp>max && temp<=m) max=temp;
				if(temp<min) min=temp;
			}
		}
		if(min>m) printf("NONE\n");
		else printf("%d\n",max);
	}
	
	return 0;
}


Measured memory_bytes: 2684
def dv(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.remove(1)
    return divisors
n=int(input())
x=dv(n)
ans=0
for i in x:
    if n//(i-1)==n%(i-1):
        ans+=i-1

print(ans)


Measured memory_bytes: 3264
#include<stdio.h>

int main(){
	int h, a;
	scanf("%d %d", &h, &a);
	int check=0;
	check=h-a;
	if(check<0){
		printf("1\n");
	}
	else{
		if(h%a==0){
			printf("%d\n", h/a);
		}
		else{
			printf("%d\n", h/a+1);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1700
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

bool accepted[100000+5];
int ps[100000+5];

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int ac = 0;
  ll penalty = 0;
  REP(i, m) {
    int v;
    char buf[5];
    scanf("%d %s", &v, buf);
    --v;
    if(!accepted[v]) {
      if(buf[0] == 'A') {
        accepted[v] = true;
        ++ac;
        penalty += ps[v];
      } else {
        ps[v]++;
      }
    }
  }
  cout << ac << " " << penalty << endl;
  return 0;
}


Measured memory_bytes: 768
/*author : Yashvardhan
Sunday, August 18, 2019
5:32 PM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod(pow(takemod(a), mod-2,mod));}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin>>n;
	vi arr(n);
	double val = 0;
	for(int i = 0; i < n; i++){
		cin>>arr[i];
		val += ((double) 1) / arr[i];
	}

	double ans = 1/val;
	cout<<setprecision(10)<<fixed;
	cout<<ans<<endl;

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 700000;
int n,ans=1e9,qzw[N],hze[N];
char s[N];
int main() {
	read(n);scanf("%s",s+1);
	rep(i,1,n) qzw[i]=qzw[i-1]+(s[i]=='W');
	per(i,n,1) hze[i]=hze[i+1]+(s[i]=='E');
	rep(i,1,n) ans=min(ans,qzw[i-1]+hze[i+1]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5760
a, b, c = map(int, input().split())

if a == b and b == c:
  result = 1
elif a == b and b != c:
  result = 2
elif b == c and a != b:
  result = 2
elif a == c and a != b:
  result = 2
else:
  result = 3
  
print(result)

Measured memory_bytes: 3064
def resolve():
    N, M = map(int, input().split())

    start_index = 1
    last_index = N
    for _ in range(M):
        pp, ss = map(int, input().split())
        start_index = max(start_index, pp)
        last_index = min(last_index, ss)

    print(max(0, last_index - start_index + 1))


resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
  int D, G;
  cin >> D >> G;
  vector<vector<int>> v(D);
  for(int i=0; i<D; i++){
    int num, point;
    cin >> num >> point;
    v[i].push_back(num);
    v[i].push_back(point);
  }
  
  int sum;
  int cardNum;
  int minCardNum = 1001;
  for(int i=0; i<pow(2, D); i++){
    sum = 0;
    cardNum = 0;
    for(int j=D-1; j>=0; j--){
      if(i & 1<<j){
        sum += (j+1) * 100 * v[j][0] + v[j][1];
        cardNum += v[j][0];
      }
    }
    if(sum >= G){
      if(cardNum < minCardNum) minCardNum = cardNum;
    }else{
      for(int j=D-1; j>=0; j--){
        if(!(i & 1<<j)){
          for(int k=0; k<v[j][0] - 1; k++){
            sum += (j+1) * 100;
            cardNum++;
            if(sum >= G){
              break;
            }
          }
          break;
        }
      }
      if(sum < G) continue;
      if(cardNum < minCardNum) minCardNum = cardNum;
    }
  }
  cout << minCardNum;
  return 0;
}
  
  
  

Measured memory_bytes: 256
// MAGRANT - GNC19 - TEMPLATE 2.1
// 2017/8/6 - AtCoder Regular Contest 080 - Alpha
// Significant Time Tags:
// Algorithm: #, #min/
// Coding: #, #min.
// Overall Summary:

#define _CRT_SECURE_NO_WARNINGS

#define N (1<<17)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <complex>
using namespace std;

namespace MRAND
{
	class MRNDS
	{
	public:
		int ngf;
		unsigned int lgf;
		MRNDS()
		{
			ngf = HA1*HA2;
			lgf = HA1 - HA2*ngf;
		}
		MRNDS(long long rgf)
		{
			lgf = rgf&((1LL << 32) - 1LL);
			ngf = (rgf >> 31);
			ngf += 2LL * lgf;
			ngf *= HA2;
			lgf += HA1;
		}
		MRNDS operator* (const MRNDS &mrs)const
		{
			MRNDS Res;
			Res.ngf += ngf*mrs.lgf;
			Res.ngf -= mrs.ngf*lgf;
			Res.ngf *= HA1;
			Res.lgf *= HA2;
			return Res;
		}
	}curl, curr;
	inline void InitRand(MRNDS &Lmrs, MRNDS &Rmrs)
	{
		curl = Lmrs;
		curr = Rmrs;
		curl = curl*curr;
		curl.ngf += HA2;
	}
	inline int GetRand()
	{
		curl = curl*curr;
		return (curl.lgf*HA1 - curr.ngf*HA2);
	}
}

int n;
int a[N];
int c1, c2, c3;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
		if (a[i] % 4 == 0)
		{
			c1++;
		}
		else if (a[i] % 2 == 0)
		{
			c2++;
		}
		else
		{
			c3++;
		}
	}
	if (c2 == 0)
	{
		if (c3 <= c1 + 1)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		if (c3 <= c1)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int[] a = ir.nextIntArray(4);
		out.println((int) Math.min(a[0], a[1]) + (int) Math.min(a[2], a[3]));
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 21204
#include<cstdio>
#include<cstring>

#define MIN(X,Y) ((X)<(Y) ? (X) : (Y))

short tbl[2000000], otbl[2000000];

int main(void) {
    memset(tbl,0x7F, sizeof(tbl));
    memset(otbl,0x7F, sizeof(otbl));

    for(int i=1; i*(i+1)*(i+2)/6<1050000; i++)
        tbl[i*(i+1)*(i+2)/6] = 1;
    for(int i=1; i<1005000; i++)
        for(int j=1; i-j*(j+1)*(j+2)/6>=0; j++)
            tbl[i] = MIN(tbl[i], 1+tbl[i-j*(j+1)*(j+2)/6]);

    for(int i=1; i*(i+1)*(i+2)/6<1050000; i+=4)
        otbl[i*(i+1)*(i+2)/6] = 1;
    for(int i=1; i<1005000; i++)
        for(int j=1; i-j*(j+1)*(j+2)/6>=0; j+=4)
            otbl[i] = MIN(otbl[i], 1+otbl[i-j*(j+1)*(j+2)/6]);

    while(1) {
        int n;
        scanf("%d",&n);
        if(!n) break;
        printf("%d %d\n",tbl[n],otbl[n]);
    }
    return 0;
}

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

ll N,M,x;

const int MAX = 10000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX],cnt,ans;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    COMinit();
    cin >> N >> M;
    x = M;
    ans = 1;
    for(ll i=2;i*i<=M;i++){
        cnt = 0;
        while(x%i==0){x/=i;cnt++;}
        ans = (COM(N-1+cnt,cnt)*ans)%MOD;
        //cout << i <<" " << cnt<<endl;
    }
    if(x != 1) ans = (ans*N)%MOD;
    cout << ans << endl;
    
}


Measured memory_bytes: 234752
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef pair<int, int> Pair;



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

	vector<Pair> red, blue;

	REP(i, N) {
		cin >> a >> b;
		red.push_back(Pair(a, b));
	}
	REP(i, N) {
		cin >> a >> b;
		blue.push_back(Pair(a, b));
	}

	sort(red.begin(), red.end());
	sort(blue.begin(), blue.end());

	int x = 0;
	REP(i, N) {
		int k = -1;
		REP(j, N) {
			if (red[j].first < blue[i].first&&red[j].second< blue[i].second) {
				if (k == -1) {
					k = j;
				}
				else {
					if (red[k].second < red[j].second) {
						k = j;
					}
				}
			}
		}
		if (k == -1) {
			continue;
		}
		x++;
		red[k].first = 2 * N + 1;
		red[k].second = 2 * N + 1;
	}

	cout << x << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SUN")
  {
      cout<<7;
  }
  else if(s=="MON")
  {
      cout<<6;
  }
  else if(s=="TUE")
  {
      cout<<5;
  }
  else if(s=="WED")
  {
      cout<<4;
  }
  else if(s=="THU")
  {
      cout<<3;
  }
  else if(s=="FRI")
  {
      cout<<2;
  }
  else if(s=="SAT")
  {
      cout<<1;
  }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){
    
    int H,W; cin>>H>>W;
    vector< vector<string> > snuke;
    REP(i,H){
        vector<string> t;
        REP(j,W){
            string a; cin>>a;
            t.push_back(a);
        }
        snuke.push_back(t);
    }
    
    for(int i=1;i<=H;i++){
        for(char j='A';j<='A'+W-1;j++){
            if(snuke[i-1][j-'A']=="snuke"){
                cout<<j<<i<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}


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

int main(){
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  n = n%k;
  ans = min(n,k-n);
  cout << ans << 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 ll              int
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n;
    cin>>n;
    ll arr[1000001];
    rep(x,1,101){
        rep(y,1,101){
            rep(z,1,101){
                //cout<<"HI"<<endl;
                arr[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }
    //cout<<"HI";
    rep(i,1,n+1){
        cout<<arr[i]<<endl;
    }
    cout<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

using namespace std;

int main(int argc, char* argv[])
{
    vector<int> haiku(3); cin >> haiku[0] >> haiku[1] >> haiku[2];

    sort(haiku.begin(), haiku.end());

    cout << ((haiku[0] == 5 && haiku[1] == 5 && haiku[2] == 7) ? "YES" : "NO") << endl;
    return 0;
}


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


int main() {
    long long n,t;
    cin >> n ;
    long long arr[n];
    for(long long i=0;i<n;i++)
        arr[i]=0;
    for(long long i=0;i<n-1;i++)
    {
        cin >> t;
        arr[t-1]++;
    }
    for(long long i=0;i<n;i++)
        cout << arr[i] << "\n";
    return 0;
}

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

int main()
{
	int n,h,w;
	cin >> n >> h >> w;
	int ans = 0;
	for(int i = 1 ; i <= n ; i++)
	{
		int a,b;
		cin >> a >> b;
		if(a >= h and b >= w)ans++;
	}
	cout << ans;
}

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

long long f(long long b, long long n) {
  if (b < 2) return -1;
  long long ans = 0;
  while (n > 0) {
    ans += n % b;
    n /= b;
  }
  return ans;
}

int main() {
  long long n, s;
  cin >> n >> s;
  if (s > n) return cout << "-1\n", 0;
  if (n == s) return cout << n + 1 << '\n', 0;

  for (long long i = 2; i <= 1e6; ++i) {
    if (f(i, n) == s) cout << i << '\n', exit(0);
  }

  long long rs = n;
  for (long long i = 1; i <= 1e6; ++i) {
    long long x = n / i;
    if (f(x, n) == s) rs = min(rs, x);
    x = n / i + 1;
    if (f(x, n) == s) rs = min(rs, x);

    x = s / i;
    if (f(x, n) == s) rs = min(rs, x);
    x = s / i + 1;
    if (f(x, n) == s) rs = min(rs, x);

    x = (n - s) / i;
    if (f(x, n) == s) rs = min(rs, x);
    x = (n - s) / i + 1;
    if (f(x, n) == s) rs = min(rs, x);
  }
  if (f(rs, n) != s) return cout << "-1\n", 0;
  cout << rs << '\n';
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in();
	vector<pair<ll, ll>>vec;
	vec.reserve(n);
	REP(i, n) {
		ll a = in(), v = in();
		vec.push_back(make_pair(a, v));
	}
	sort(ALL(vec), [](const pair<ll, ll>&p1, const pair<ll, ll>&p2) {return p1.second<p2.second || p1.second == p2.second&&p1.first>p2.first; });
	cout << vec.back().first << ' ' << vec.back().second << endl;
}


Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<algorithm>
#include<set>

using namespace std;
int main(){
  int n;
  cin >> n;
  while(n > 0){
    string ori,train,trainf,trainb;
    cin >> ori;
    set<string> ptn;
    for(int i = 1 ; i < ori.size() ; i++){
      trainf = ori.substr(0,i);
      trainb = ori.substr(i,ori.size()-i);
      train = trainf +trainb;
      ptn.insert(train);
      train = trainb + trainf;
      ptn.insert(train);

      reverse(trainf.begin(),trainf.end());
      train = trainf + trainb;
      ptn.insert(train);
      train = trainb + trainf;
      ptn.insert(train);

      reverse(trainb.begin(),trainb.end());
      train = trainf + trainb;
      ptn.insert(train);
      train = trainb + trainf;
      ptn.insert(train);

      reverse(trainf.begin(),trainf.end());
      train = trainf +  trainb;
      ptn.insert(train);
      train = trainb +  trainf;
      ptn.insert(train);

    }
    cout << ptn.size() << endl;
    n--;
  }
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int H, W, M;
    cin >> H >> W >> M;
    int cnt1[H], cnt2[W];
    fill(cnt1, cnt1+H, 0), fill(cnt2, cnt2+W, 0);
    int h[M], w[M];
    rep(i, M){
        cin >> h[i] >> w[i]; h[i]--, w[i]--;
        cnt1[h[i]]++, cnt2[w[i]]++;
    }
    int memo1[H], memo2[W];
    rep(i, H) memo1[i] = cnt1[i];
    rep(i, W) memo2[i] = cnt2[i];
    sort(cnt1, cnt1+H, greater<int>());
    sort(cnt2, cnt2+W, greater<int>());
    ll x = 0, y = 0;
    rep(i, H) if(cnt1[i] == cnt1[0]) x++;
    rep(i, W) if(cnt2[i] == cnt2[0]) y++;
    int ans = cnt1[0]+cnt2[0];
    ll cnt = 0;
    rep(i, M){
        if(memo1[h[i]]+memo2[w[i]] == ans) cnt++;
    }
    cout << (x*y == cnt? ans-1 : ans) << endl;
}

Measured memory_bytes: 10660
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;


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 N;
  cin >> N;
  vector<ll> an(100010, 0);
  vector<ll> bn(100010, 0);
  vector<ll> cn(100010, 0);

  vector<vector<ll>> dp(100010, vector<ll>(3, 0));

  REP(n,N)cin >> an.at(n) >> bn.at(n) >> cn.at(n);


  for (int n = 0; n<N; n++){
    // a
    chmax(dp[n+1][0], dp[n][1] + an[n]);
    chmax(dp[n+1][0], dp[n][2] + an[n]);
    // b
    chmax(dp[n+1][1], dp[n][0] + bn[n]);
    chmax(dp[n+1][1], dp[n][2] + bn[n]);
    // c
    chmax(dp[n+1][2], dp[n][0] + cn[n]);
    chmax(dp[n+1][2], dp[n][1] + cn[n]);
  }

  int ans = max({max({dp[N][0], dp[N][1]}), dp[N][2]});
  cout << ans << endl;

}


Measured memory_bytes: 8064
import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

mod=1000000007
n,k=mp()
ans=0
for i in range(k,n+2):
    ans+=((n*(n+1)-(n-i+1)*(n-i)-i*(i-1))//2+1)%mod
print(ans%mod)

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;string s;
    cin >> n >> s;
    ll r=0,g=0,b=0;
    for(char t:s){
        if(t=='R')r++;
        else if(t=='G')g++;
        else b++;
    }
    ll ans1 = r*g*b;
    ll ans2 = 0;
    REP(i,n-2){
        FOR(j,i+1,n-1){
            if (s[i]==s[j]) continue;
            int k = 2*j-i;
            if(k>=n||s[i]==s[k]||s[j]==s[k])continue;
            ans2++;
        }
    }
    COUT(ans1-ans2);
    return 0;
}
    

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

int main(){
  int N,Y;
  cin>>N>>Y;
  int a,b,c;
  for(int x=0;x<=N;x++){
    for(int y=0;y<=N;y++){
      if(x*10000+y*5000+(N-x-y)*1000==Y&&N-x-y>=0){
        cout<<x<<" "<<y<<" "<<N-x-y<<endl;
        return 0;}
      
        }
  }
   cout<<"-1 -1 -1"<<endl;
}

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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// ***************************************



int main()
{
	ll N;
	cin >> N;

	ll a;
	vector<ll> cum(N+1, 0);
	REP(i, N) {
		cin >> a;
		cum[i + 1] = a + cum[i];
	}

	vector<vector<ll>> dp(N+2, vector<ll>(N+2, 1e15));
	REP(i, N) {
		dp[i][i] = 0;
	}

	FOR(w, 1, N) {
		REP(i, N - w) {
			ll j = i + w;
			FOR(k, i, j) {
				chmin<ll>(dp[i][j], dp[i][k] + dp[k+1][j] + cum[j+1] - cum[i]);
			}
		}
	}


	cout << dp[0][N-1] << endl;

}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;
int cnt0,cnt1,sum,ans;
double per=-1.0,lim;
int main() {
	cin>>a>>b>>c>>d>>e>>f;
	a*=100;
	b*=100;
	lim=(double)e*100.0/(100.0+e);
	int l1=f/a,l2=f/b,l3=f/c,l4=f/d;
	for(int i=0;i<=l1;i++) {
		for(int j=0;j<=l2;j++) {
			if(i*a+j*b>f||(i==j&&j==0))
				continue;
			for(int k=0;k<=l3;k++) {
				if(i*a+j*b+c*k>f)
					continue;
				for(int p=0;p<l4;p++) {
					if(i*a+j*b+k*c+p*d>f)
						continue;
					cnt0=i*a+j*b;
					cnt1=k*c+p*d;
					double now=(double)cnt1*100.0/(double)(cnt0+cnt1);
//					cout<<cnt0<<" "<<cnt1<<" "<<now<<endl;
					if(now>lim)
						continue;
					if(now>per) {
						per=now;
						sum=cnt0+cnt1;
						ans=cnt1;
					}
				}
			}
		}
	}
	printf("%d %d\n",sum,ans);
	return 0;
} 

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

using namespace std;

int main() {
  int a,b;
  scanf("%d %d", &a, &b);
  char pie[16];

  if (a > 8 || b > 8) {
    printf(":(\n");
  } else {
    printf("Yay!\n");
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	int n,r;
	cin>>n>>r;
	cout<<(r+max(10-n,0LL)*100);
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

S = input()
T = input()

print('Yes' if any(T[i:] + T[:i] == S for i in range(len(S))) else 'No')

Measured memory_bytes: 38356
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
li = [list(map(int, input().split())) for i in range(n)]
li = [[0,0,0]] + li

for i in range(n):
    t_diff = li[i+1][0] - li[i][0]
    xy_diff = sum(li[i+1][1:]) - sum(li[i][1:])

    if t_diff < xy_diff or t_diff % 2 != xy_diff % 2:
        print("No")
        exit()
print("Yes")

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

signed main() {
  int N;
  cin >> N;

  static int h[101010];
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

  static int dp[101010];
  for (int i = 0; i < 101010; i++) {
    dp[i] = 1e18; // INF
  }

  dp[0] = 0, dp[1] = abs(h[1] - h[0]);
  for (int i = 0; i + 2 < N; i++) {
    dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 1] + abs(h[i + 2] - h[i + 1]));
  }

  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE UndecidableInstances #-}

module Main where

import Control.Category hiding (id, (.))
import Control.Exception (assert)
import Control.Monad
import Control.Monad.ST
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as BS
import Data.List as List
import Data.Maybe
import Data.Set as Set
import Data.Vector.Unboxing ((!))
import qualified Data.Vector.Unboxing as U
import qualified Data.Vector.Unboxing.Mutable as UM
import Debug.Trace
import GHC.Generics

-- import System.TimeIt as Time

readInt = fst . fromJust . BS.readInt

readIntList = Prelude.map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

range begin end = [begin .. (end - 1)]

partitionIdx vec pred =
  assert (U.length vec >= 0) $
    if pred (vec U.! 0) == False
      then 0
      else loop 0 (U.length vec)
  where
    loop begin end =
      if end == begin + 1
        then end
        else
          let !mid = (begin + end) `div` 2
           in if pred (vec U.! mid) then loop mid end else loop begin mid

-- data Point = Pt {-# UNPACK #-} Int {-# UNPACK #-} Int
--   deriving (Generic)
--   deriving (U.Unboxable) via U.Generics Point

-- ptX :: Point -> Int
-- ptX (Pt x y) = x

-- ptY :: Point -> Int
-- ptY (Pt x y) = y

main :: IO ()
main = do
  n <- getInt
  s <- BS.getLine
  let table = U.constructN (n + 1) f
        where
          f vec = case (U.length vec) of
            0 -> 0 :: Int
            i -> prev + diff
              where
                prev = vec ! (i - 1)
                paren = BS.index s (i - 1)
                diff = case paren of
                  '(' -> 1
                  ')' -> -1
      openCnt = - (U.minimum table)
      closeCnt = (table ! n) + openCnt
  BS.putStrLn $ BS.concat [BS.pack (replicate openCnt '('), s, BS.pack (replicate closeCnt ')')]

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

using namespace std;

int North(void);
int East(void);
int West(void);
int South(void);
int Right(void);
int Left(void);

int top,front,r,l,back,bottom;

int main(void){
  int n,sum;
  string s;
  
  while(1){
    cin >>n;
    if(n==0)break;

    top=1;
    front=2;
    r=3;
    l=4;
    back=5;
    bottom=6;

    sum=top;

    for(int i=0;i<n;i++){
      cin >>s;
      if(s=="North")sum+=North();
      else if(s=="East")sum+=East();
      else if(s=="South")sum+=South();
      else if(s=="West")sum+=West();
      else if(s=="Left")sum+=Left();
      else if(s=="Right")sum+=Right();
    }
    cout << sum << endl;
  }
  return 0;
}

int North(void){
  int t;

  t=top;
  top=front;
  front=bottom;
  bottom=back;
  back=t;

  return top;
}

int East(void){
  int t;

  t=top;
  top=l;
  l=bottom;
  bottom=r;
  r=t;

  return top;
}

int West(void){
  int t;

  t=top;
  top=r;
  r=bottom;
  bottom=l;
  l=t;

  return top;
}

int South(void){
  int t;

  t=top;
  top=back;
  back=bottom;
  bottom=front;
  front=t;

  return top;
}

int Right(void){
  int t;

  t=front;
  front=r;
  r=back;
  back=l;
  l=t;

  return top;
}

int Left(void){
  int t;

  t=front;
  front=l;
  l=back;
  back=r;
  r=t;

  return top;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
const ll MOD=(998244353);

class Fermat{
  private:
	int z;
	vector<ll> fact_mod, fact_invmod;
	ll modpow(ll a, ll n){
		if(n==1)return a;
		ll half=modpow(a,n/2);
		return half*half%MOD*(n%2?a:1)%MOD;
	}
  public:
	Fermat(int Z):z(Z){
		fact_mod=vector<ll>(z+1,1);
		fact_invmod.resize(z+1);
		range(i,1,z+1) fact_mod[i]=fact_mod[i-1]*i%MOD;
		fact_invmod[z]=modpow(fact_mod[z],MOD-2);
		for(int i=z-1;i>=0;i--) fact_invmod[i]=fact_invmod[i+1]*(i+1)%MOD;
	}
	ll comb(int n,int r){return fact_mod[n] * fact_invmod[r]%MOD * fact_invmod[n-r]%MOD;}
};

int main(){
    ll n,a,b,k;
    cin>>n>>a>>b>>k;
    if(b<a)swap(a,b);
    
    Fermat f(n);
    ll ans=0;
    rep(i,n+1){
        if((k-a*i)%b==0 and (k-a*i)/b>=0 and (k-a*i)/b<=n){
            ans=(ans+f.comb(n,i)*f.comb(n,(k-a*i)/b))%MOD;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll N;
	cin >> N;
	map<string, ll> S;
	REP(i, N) {
		string tmp;
		cin >> tmp;
		S[tmp]++;
	}

	ll ans = S.size();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19232
using System;
using System.Linq;

namespace AtCoderPractice0704
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

            int A = input[0];
            int B = input[1];
            int T = input[2];
            int ans = 0;
            for(var t =1; t<= T+0.5; t++)
            {
                if(t%A == 0) { ans += B; }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28300
def Main(N, A):
    for z in A:
        if (z % 2 == 0):
            if (z % 3 == 0) or (z % 5 == 0):
                continue
            else:
                return 'DENIED'
    return 'APPROVED'  

def main():
    N = int(input())
    A = list(map(int, input().split()))
    print(Main(N, A))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
#define sz 109
long long int weight[sz];
long long int profit[sz];
long long int dp[sz][100003],n;
    long long int solve(long long int i,long long int w){
        if(i == n || w <= 0) return 0;
        if(dp[i][w] != -1) return dp[i][w];
        long long int x = 0,y = 0;
        if(w - weight[i] >= 0){
              x = profit[i] + solve(i + 1,w - weight[i]);
        }
         y = solve(i+1,w);
         return dp[i][w] = max(x,y);
    }
int main(){
    
    memset(dp,-1,sizeof(dp));
    long long int w,v,i,j;
    
    cin >> n >> w;
    
    for(i = 0;i<n;i++) cin >> weight[i] >> profit[i];
    
    cout << solve(0,w) << endl;
    
    return 0;
}

Measured memory_bytes: 88792
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;

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

	int arr[3][n];
	
	for(int i=0; i<n; i++){
		cin>>arr[0][i]>>arr[1][i]>>arr[2][i];
	}
	
	int dp[3][n];
	
	dp[0][0]=arr[0][0];
	dp[1][0]=arr[1][0];
	dp[2][0]=arr[2][0];
	
	for(int i=1; i<n; i++){
		dp[0][i]= arr[0][i] + max(dp[1][i-1], dp[2][i-1]);
		dp[1][i]= arr[1][i] + max(dp[0][i-1], dp[2][i-1]);
		dp[2][i]= arr[2][i] + max(dp[0][i-1], dp[1][i-1]);
	}
	
	int ans=max(dp[0][n-1], dp[1][n-1]);
	ans=max(ans, dp[2][n-1]);
	
	cout<<ans;
	
    return 0;
}

Measured memory_bytes: 4992