akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

const int M = 1e9+7,N = 1e3+1;

int freq[N];

int main()
{
    int n;long div=1;
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        int x=i;
        for(int j=2;j*j<=x;j++)
        {
            while(x%j==0)
            {
            	x/=j;
                freq[j]++;
            }
        }
        if(x!=1)
          freq[x]++;
    }
    for(int i=2;i<=n;i++){
        div*=(freq[i]+1);
        div%=M;
    }
    printf("%ld\n",div);
    return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}


ll getFirstSetBitPos(ll n) 
{ 
    return log2(n & -n) + 1; 
} 

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

    if(a <= 9  && b <= 9) cout << a*b << "\n";
    else cout << -1 << "\n";
}


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    string s;
    cin >> s;

    set<char> used;
    for (char c : s) {
        if (used.find(c) == used.end()) used.insert(c);
        else {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<vector<int> > c(h,vector<int>(w));
  int d = 1;
  int cnt = 0;
  rep(i,h) {
    if (i%2 == 0) {
      for (int j = 0; j < w; j++) {
        c[i][j] = d;
        cnt++;
        if (cnt == a[d-1]) d++,cnt = 0;
      }
    } else {
      for (int j = w-1; j >= 0; j--) {
        c[i][j] = d;
        cnt++;
        if (cnt == a[d-1]) d++,cnt = 0;
      }
    }
  }
  rep(i,h) {
    rep(j,w) {
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}

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

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int num = 0;
  int ans = 0;
  int i;
  for(i = 1; i <= n; i++)
  {
    num += i/10000;
    num += i/1000%10;
    num += i/100%10;
    num += i/10%10;
    num += i%10;
    if(num >= a && num <= b) ans += i;
    num = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel rui(19, 1);
vel kai(1000007, 1);
vel ink(1000007, 1);
vel par;
int root(int ser) {
	if (par[ser] == -1) { return ser; }
	int ans = root(par[ser]);
	par[ser] = ans;
	return ans;
}
bool marge(pin a) {
	int x = root(a.first);
	int y = root(a.second);
	if (x != y) { par[x] = y; }
	return x != y;
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
signed main() {
	int n; cin >> n;
	vel a(n);
	rep(i, n) { cin >> a[i]; }
	if (a[0] != 0) { cout << -1 << endl; return 0; }
	reverse(a.begin(), a.end());
	rep(i, n) { a[i] += i; }
	rep(i, n - 1) {
		if (a[i] > a[i + 1]) { cout << -1 << endl; return 0; }
	}
	set<int> se;
	int ans = 0;
	rep(i, n) {
		if (a[i] > i) { se.insert(a[i]); }
		auto itr = se.begin();
		if (*itr == i) { se.erase(i); }
		ans += se.size();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22144
// AtCoder Beginner Contest 172
// ABC B - Minor Change

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;

int main()
{
	string S, T;

	cin >> S;
	cin >> T;
	
	int cnt = 0;
	for (int i=0; i<S.size(); i++) {
		if (S[i] != T[i]) cnt++;
	}
	cout << cnt << endl;
}



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int h, w;
char s, t;
string mas[55];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> h >> w >> s >> t;
  rep(i, h) cin >> mas[i];

  vector<Pi> pos(30, Pi(-1, -1));
  rep(i, h) {
    rep(j, w) {
      if(isalpha(mas[i][j])) {
	pos[mas[i][j]-'A'] = Pi(i, j);
      }
    }
  }

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

  auto in = [&](int i, int j) {
    return 0<=i&&i<h&&0<=j&&j<w;
  };

  int ss = s-'A', tt = t-'A';
  queue<int>  que;
  vint dist(30, -1);
  que.push(ss);
  dist[ss] = 0;
  while(!que.empty()) {
    int u = que.front(); que.pop();
    rep(i, 4) {
      int ny = pos[u].first+dy[i], nx = pos[u].second+dx[i];
      ny += dy[i];
      nx += dx[i];
      int cnt = 0;
      while(in(ny, nx) && (((i==0||i==2) && mas[ny][nx] == '|') || ((i==1||i==3) && mas[ny][nx] == '-'))) {
	ny += dy[i];
	nx += dx[i];
	++cnt;
      }
      if(cnt == 0) continue;
      ny += dy[i];
      nx += dx[i];
      if(!in(ny, nx) || !isalpha(mas[ny][nx])) continue;
      int v = mas[ny][nx]-'A';
      if(dist[v] != -1) continue;
      dist[v] = dist[u]+1;
      que.push(v);
    }
  }

  cout << dist[tt] << endl;

  return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    int sum = 0;
    for(int i=0;i<N;i++){
        if(vec.at(i)%2==0){
            if((vec.at(i)%3!=0)&&(vec.at(i)%5!=0)){
                sum++;
                break;
            }
        }
    }
    if(sum==0){
        cout<< "APPROVED" << endl;
        }
    else{cout << "DENIED"<<endl;}

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (glass1Max, glass1current, glass2current) = readLine()!!.split(" ").map { it.toInt() }
    val canMoveToGlass1 = glass1Max - glass1current

    when {
        glass2current - canMoveToGlass1 > 0 -> print(glass2current - canMoveToGlass1)
        else -> print(0)
    }
}

Measured memory_bytes: 38028
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
typedef long long ll;
using namespace std;

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; }

const long long INF = 1LL << 60;
int main() {
	ll n,m;
	cin >> n >> m;
	ll res =0;
	vector<ll> a(n);
	vector<ll> b(n);
	for (ll i = 0;i < n;i++) {
		cin >> a[i] >> b[i];
	}
	map<ll, ll> p;
	vector<ll> d(n);
	for (ll i = 0;i < n;i++) {
		if (p[a[i]] != 0) {
			p[a[i]] += b[i];
			
		}
		else {
			p[a[i]] = b[i];
			
		}
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	ll c = 0;
	for (ll i = 0;i < n;i++) {
			c += p[a[i]];
			res += a[i] * p[a[i]];
		if (c >= m) {
			if (c > m) {
				res -= (c - m)*a[i];
			}
			break;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 9344
def bubble_sort(A, n):
	for i in range(n):
		for j in range(n-1, i, -1):
			if A[j][1] < A[j-1][1]:
				A[j], A[j-1] = A[j-1], A[j]

	print(' '.join(A))

def selection_sort(A, n):
	for i in range(n):
		minj = i
		for j in range(i, n):
			if A[j][1] < A[minj][1]:
				minj = j

		A[i], A[minj] = A[minj], A[i]

	print(' '.join(A))

if __name__ == '__main__':
	n = int(input())
	A = list(input().split())
	B = A[:]

	bubble_sort(A, n)
	print('Stable')

	selection_sort(B, n)
	print('Stable' if A == B else 'Not stable')

Measured memory_bytes: 7740
function main(input){
  var val = input.split(' ');
  var K = parseInt(val[0]);
  var S = parseInt(val[1]);
  var sum = 0;
  for(let i=0;i<=K;i++){
    for(let j=0;j<=K;j++){
      var value = S-(i+j);
      if(value >= 0 && value <= K){
        sum++;
      }
    }
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int k,x;cin>>k>>x;
  
  for(int i=k-1;i>0;i--){
    cout<<x-i<<" ";
  }
  cout<<x<<" ";
  for(int i=1;i<k;i++){
    cout<<x+i<<" ";
  }
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int t,x;
    cin >> x >> t;
    cout << max(0, x-t) << endl;
}

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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;
int inf=-1;
typedef pair<int,int> P;
int main(void){
    ll n,m,i,x;
    cin>>n>>m;
    ll dan[n+10]={1,1,2},f[n+10];
    for(i=0;i<n+1;i++)f[i]=1;
    for(i=0;i<m;i++){
        cin>>x;
        f[x]=0;
    }
    for(i=2;i<=n;i++){
   
        dan[i]=(dan[i-1]*f[i-1]+dan[i-2]*f[i-2])%1000000007;
      }
    cout<<dan[n]%1000000007<<endl;
}


Measured memory_bytes: 1792
def main():
	N = int(input())
	A = list(map(int, input().split()))
	dp_l = [0]*(N+2)
	dp_r = [0]*(N+2)

	for i in range(N):
		dp_l[i+1] = gcd(dp_l[i], A[i])

	for i in range(N-1, 0, -1):
		dp_r[i] = gcd(dp_r[i+1], A[i])

	ans = 1
	for i in range(1, N+1):
		this_ans=gcd(dp_l[i-1], dp_r[i])
		ans = max(ans, this_ans)

	print(ans)



def gcd(a, b):
	if a < b:
		a, b = b, a
	if b == 0:
		return a
	c = a % b
	return gcd(b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14076
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

Node treeSearch(Node u, int k) {
  if( u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

void printInorder(Node u) {
  if(u->left != NIL)printInorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL)printInorder(u->right);
}

void printPreorder(Node u) {
  printf(" %d", u->key);
  if(u->left != NIL)printPreorder(u->left);
  if(u->right != NIL)printPreorder(u->right);
}


int main(){
  int n, i, x;
  char command[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", command);
    if ( command[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if( command[0] == 'f') {
      scanf("%d", &x);
      if( treeSearch(root, x) != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if ( command[0] == 'p' ){
      printInorder(root);
      printf("\n");
      printPreorder(root);
      printf("\n");
    }
  }

  return 0;
}

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

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

int main() {
	long long a, b, t, cnt;
	cin >> a >> b;
	t = gcd(a, b);

	vector<long long> p(1000001,1);
	p[0] = 0;
	p[1] = 0;
	for (long long i=0; i < 500001; i++) {
		if (p[i] == 0) continue;
		for (long long q = 2 * i; q < 1000001; q += i) p[q] = 0;
	}
	bool f = true;
	cnt = 1;
	while (f) {
		f = false;
		for (long long i = 0; i < 1000002; i++) {
			if (t < i) break;
			if (p[i] == 1 and t%i == 0) {
				f = true;
				t /= i;
				cnt += 1;
				p[i] = 2;
			}
			else if (p[i] == 2 and t%i == 0) {
				f = true;
				t /= i;
			}
		}
	}
	if (t != 1) cnt += 1;
	cout << cnt << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e6 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    vector<int> a, b;
    for(int i=1;i<200;i++){
        int x = i*(i+1)*(i+2)/6;
        a.push_back(x);
        if(x%2)b.push_back(x);
    }
    reverse(ALL(a));
    reverse(ALL(b));

    int dp1[MAX_N], dp2[MAX_N];
    fill(dp1,dp1+MAX_N,IINF);
    fill(dp2,dp2+MAX_N,IINF);
    dp1[0] = dp2[0] = 0;
    for(int i=1;i<MAX_N;i++){
        for(auto j : a){
            if(i >= j){
                dp1[i] = min(dp1[i], dp1[i-j]+1);
            }
        }
    }
    for(int i=1;i<MAX_N;i++){
        for(auto j : b){
            if(i >= j){
                dp2[i] = min(dp2[i], dp2[i-j]+1);
            }
        }
    }

    int n;
    while(cin >> n, n){
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 10868
#include<iostream>
#include<cstdlib>
#include<math.h>
using namespace std;

int main(){
    int n, z, w, a[2010];
    cin >> n >> z >> w;
    for(int i=1;i<=n;i++) cin >> a[i];
    if(n==1) {
        cout << llabs(a[n]-w);
    }
    else{
        cout << max(llabs(a[n]- a[n-1]), llabs(a[n] - w))<<endl;
    }
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int a,b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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

using ll = long long;
using ld = long double;

const int INF = 1e9;

int num[100];

int main(){
	int N;
	cin >> N;
	int res = INF;
	REP(i, N) cin >> num[i];
	REP(i, 201){
		int target = -100 + i;
		int tmp = 0;
		REP(j, N)	tmp += (target - num[j]) * (target - num[j]);
		chmin(res, tmp);
	}
	cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    vector<int> P;
    rep(i, n) {
        int p;
        cin >> p;
        P.push_back(p);
    }
    sort(P.begin(), P.end());
    cout << P[n / 2] - P[n / 2 - 1] << endl;

}


Measured memory_bytes: 892
#include<stdio.h>
int main(void){
	int W,H,x,y,r ;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r) ;
	if(x<-100){
		printf("??¨??????\n") ;
	}
	else{
		if(x>100){
			printf("??¨??????\n") ;
		}
		else{
			if(y<-100){
				printf("??¨??????\n") ;
			}
			else{
				if(y>100){
					printf("??¨??????\n") ;
				}
				else{
					if(W<=0){
						printf("??¨??????\n") ;
					}
					else{
						if(W>100){
							printf("??¨??????\n") ;
						}
						else{
							if(H<=0){
								printf("??¨??????\n") ;
							}
							else{
								if(H>100){
									printf("??¨??????\n") ;
								}
								else{
									if(x-r<0){
										printf("No\n") ;
									}
									else{
										if(x+r>W){
											printf("No\n") ;
										}
										else{
											if(y-r<0){
												printf("No\n") ;
											}
											else{
												if(y+r>H){
													printf("No\n") ;
												}
												else{
													printf("Yes\n") ;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return 0 ;
}

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

typedef struct {
    double x, y;
    double rot;
} person;

person me;

static const double PI = 6*asin( 0.5 );

void move(int f, int r){
    me.x += f * cos(me.rot * PI / 180);
    me.y += f * sin(me.rot * PI / 180);
    me.rot -= r;
}

int main(){
    int f, r; char c;
    me.x = 0, me.y = 0, me.rot = 0;
    while (cin >> f >> c >> r, f || r){
	move(f, r);
    }
    cout << -(int)me.y << endl;
    cout << (int)me.x << endl;
}

Measured memory_bytes: 0
package main
import "fmt"
func main() {
  var l,k,n,m int
  fmt.Scan(&l)
  var d []int = make([]int,20)
  d[0] = 1
  k = 0
  for i:=1;i<20;i++ {
    d[i] = 2*d[i-1]
    if d[i] <= l { k = i }
  }
  n = k + 1
  ps := Paths{}
  for i:=0;i<k;i++ {
    ps = append(ps,Path{i+1,i+2,0})
    ps = append(ps,Path{i+1,i+2,d[i]})
  }
  for i:=k;i>-1;i-- {
    if l-d[i] >= d[k] {
      l -= d[i]
      ps = append(ps,Path{i+1,n,l})
    }
  }
  m = len(ps)
  fmt.Println(n,m)
  for i:=0;i<m;i++ {
    fmt.Println(ps[i].u,ps[i].v,ps[i].w)
  }
}
type Path struct {
  u int
  v int
  w int
}
type Paths []Path

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

int main(){
	int D,N;
	cin>>D>>N;
	int ans=0;
	int i=0;
	while(true){
		if (i%100==0){
			ans=ans;
			i=i+1;
		}else{
			ans=ans+1;
			i=i+1;
		}
		if(ans==N){
			break;
		}
	}
	int I;
	I=(i-1)*pow(100,D);
	cout<<I<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, mx;
string s;
map<string, int> mp;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        mp[s]++;
        mx = max(mp[s], mx);
    }
    for (auto x : mp) {
        if (x.se == mx) {
            cout << x.fi << E;
        }
    }
    //system("pause");
    return 0;
}

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

#define fst first
#define snd second
#define fore(i,a,b) for(int i=a, ThxDem=b; i<ThxDem; ++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define SZ(s) int(s.size())
#define DBG(x) cerr <<#x << " = " << (x) << "\n"

#define SQR(x) ((x) * (x))

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 11

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<bool> vbool;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vbool> vvbool;

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

const ll MOD = 1000000007;
vector<vector<char>> M;
vvll dp;
ll solve(ll x, ll y){
	ll & d = dp[x][y];
	if(d!=-1) return d;
	d = 0;
	ll nx,ny;
	fore(i,0,2){
		nx = x+dx[i];
		ny = y+dy[i];
		if(nx<SZ(M) && nx>=0 && ny>=0 && ny<SZ(M[0]) && M[nx][ny]=='.'){
			solve(nx,ny);
			d=(d%MOD+(dp[nx][ny]%MOD))%MOD;
		}
		
	}
	return d;
}

int main(){FIN
	ll n,m;
	cin >> n >> m;
	M.assign(n,vector<char>(m));
	dp.assign(n,vll(m,-1));
	fore(i,0,n)
		fore(j,0,m)
			cin >> M[i][j];
	dp[n-1][m-1]=1;
	cout << solve(0,0) << "\n";
	return 0;
}


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

#define rep(i, n) for(int i = 0;i < (n);i++)
#define all(c) (c).begin(),(c).end()

#define INF INT_MAX

typedef unsigned int uint;

using namespace std;

vector<list<int>> graph;
set<int> nodes;
bool visited[100];

int solve(int start, int dist) {
  int res = -1;
  for(int to : graph[start]) {
    if(visited[to]) continue;

    visited[to] = true;
    res = max(res, solve(to, dist + 1));
    visited[to] = false;
  }
  if(res == -1) return dist;
  return res;
}

int main() {
  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;

    graph.clear(); nodes.clear();
    graph.resize(100);
    memset(visited, 0, 100 * sizeof(bool));

    rep(i, n) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      graph[a].push_back(b);
      graph[b].push_back(a);
      nodes.insert(a); nodes.insert(b);
    }

    int ans = 0;

    for(int node : nodes) {
      visited[node] = true;
      ans = max(solve(node, 0), ans);
      visited[node] = false;
    }

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

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    vector<bitset<64>> sums;
    for (int i = 0; cin >> a[i]; i++) {
        long long sum = 0;
        for (int j = i; j >= 0; j--) {
            sum += a[j];
            sums.emplace_back(sum);
        }
    }
    for (int i = 63; i >= 0; i--) {
        vector<bitset<64>> next;
        for (auto& j : sums) {
            if (j[i]) {
                next.emplace_back(j);
            }
        }
        if (next.size() >= k) {
            sums = move(next);
        }
    }
    bitset<64> result = sums.front();
    for (int i = 1; i < sums.size() && i < k; i++) {
        result = result & sums[i];
    }
    cout << result.to_ullong();
    return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  string S;
  cin >> S;
  if (S=="RRR") cout << 3 << endl;
  else if (S=="RRS"||S=="SRR") cout << 2 << endl;
  else if (S=="SSS") cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

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

int n,a[maxn],b[maxn],c[maxn],ans=0;
int main()
{
	cin>>n;
	a[0]=-1;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n;++i) 
	{
		cin>>b[i];
		ans+=b[i];
	}
	for(int i=1;i<n;++i) 
		cin>>c[i];
	for(int i=1;i<n;++i)
	{		
		for(int j=1;j<n;++j) if(a[j]==i && a[j]==a[j+1]-1) ans+=c[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
	int N, M;
	int X[100010];
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> X[i];
	}
	sort(X, X + M, greater<int>());

	int Xb[100010];
	int tmp = 0;
	int ans = 0;

	for (int i = 0; i < M - 1; i++)
	{
		//差の数列つくる
		Xb[i] = X[i] - X[i + 1];
	}
	sort(Xb, Xb + M - 1, greater<int>());

	for (int i = 0; i < M - 1; i++)
	{
		if (tmp < N - 1) tmp++;
		else
		{
			ans += Xb[i];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
import bisect

#　入力
n,m,k = map(int,input().split())

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

# A,Bの累積和を取る
sumA = [0]*(n+1)
sumB = [0]*(m+1)
for i in range(n):
    sumA[i+1] = sumA[i] + A[i]
for i in range(m):
    sumB[i+1] = sumB[i] + B[i]


ans = 0
# 二分探索
for i,a in enumerate(sumA):
    if a > k:break
    j = bisect.bisect_right(sumB,k-a)
    ans = max(i + j - 1, ans)
print(ans)


Measured memory_bytes: 47452
#include <stdio.h>
#include <string.h>

int main(void)
{
    int N;
    int P[101];
    int p;
    int i;
    
    memset(P, 0, sizeof(P));

    scanf("%d", &N);
    for (i = 0; i < N; i++){
        scanf("%d", &p);
        P[p]++;
    }
    
    for (i = 99; i >= 1; i--){
        P[i] += P[i + 1];
    }
    
    for (i = 100; P[i] < i; i--);
    
    printf("%d\n", i);
    
    return (0);
}




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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  if(abs(n-m) > 1) {
    cout << 0 << endl;
    return 0;
  }
  mint ans = 1;
  for(int i = 1; i <= n; ++i) ans *= i;
  for(int i = 1; i <= m; ++i) ans *= i;
  if(n == m) ans *= 2;
  cout << ans.x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string X; cin >> X;
    int cs = 0, ct = 0;
    REP(i, X.length())
    {
        if(X[i] == 'S')
        {
            cs++;
        }
        else
        {
            if(cs == 0) ct++;
            else cs--;
        }
    }
    cout << cs + ct << endl;
}

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

m = 1000
s = 0

def buy(p):
  global m, s
  s += m // p
  m = m % p

def sell(p):
  global m, s
  m += s * p
  s = 0

for i in range(n-1):
  cur = a[i]
  nxt = a[i+1]
  if cur < nxt:
    if s == 0:
      buy(cur)
  elif cur > nxt:
    if s > 0:
      sell(cur)
if s > 0:
  sell(a[n-1])
print(m)

Measured memory_bytes: 61824
package main
  
import (
    "fmt"
)

func main() {
    var a, b, c int
    fmt.Scan(&a, &b, &c)
    fmt.Println(max(c-(a-b), 0))
}

func max(a, b int) int {
    if a > b {
        return a
    }
    return b
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
int  main()
{
	string s; cin >> s;
	rep(i, 3)
	{
		if (s[i] == s[i+1])
		{
			cout << "Bad\n"; return 0;
		}
	}
	cout << "Good\n";
	return (0);
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main(void)
{
	int i, j;
	for (j = 1; j <= 9; j++)
	{
		for (i = 1; i <= 9; i++)
		{
			printf("%dx%d=%d\n", j, i, j*i);
		}

	}
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace  std;
#define rep(i,n) for(int i=0;i<n;i++)

char masu[1010][1010];
int maxs[1010][1010];

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)break;
        memset(masu,'*',sizeof(masu));
        memset(maxs,0,sizeof(maxs));
        rep(j,n)rep(i,n){
            cin>>masu[i+1][j+1];
        }
        int ms = 0;
        int hen = 0;
        int temp=0;
        int count=0;
        rep(j,n)rep(i,n){
            count ++;
            if(masu[i+1][j+1] =='*'){maxs[i+1][j+1]=0; continue;}
            temp = min(maxs[i][j+1],maxs[i][j]);
            temp = min(temp,maxs[i+1][j]);
            temp++;
            maxs[i+1][j+1] = temp;
            ms = max(ms,maxs[i+1][j+1]);
        }
        cout << ms << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		if(c >= a && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
#define N 100000
#define Q 500

int linearSearch(int);
int S[N];
int n;

int main(){
  int i, q, C = 0;
  int T[Q];
  
  scanf("%d", &n);
  for( i=0 ; i<n ; i++ ){
    scanf("%d", &S[i]);
  }
  
  scanf("%d", &q);
  for( i=0 ; i<q ; i++ ){
    scanf("%d", &T[i]);
  }
  
  for( i=0 ; i<q ; i++ ){
    if( linearSearch(T[i])==1 )
      C++;
  }
  printf("%d\n", C);
  return 0;
}

int linearSearch(int key){
  int j = 0;
  S[n] = key;
  while(S[j]!=key)
    j++;
  if( j==n ) return 0;
  else return 1;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;

int K, N;
int A[200005];

void read(){
    cin >> K >> N;
    for( int i = 0; i < N; i++ ){
        cin >> A[i];
        A[i] %= K;
    }
}

void solve(){
    int res = -1;

    sort( A, A+N );
    for( int i = 0; i < N-1; i++ ){
        res = max( res, A[i+1] - A[i]);
    }
    res = max( res, A[0]-A[N-1]+K );
    cout << K-res << endl;
}

int main(void){
    read();
    solve();
}


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

int main() {
  // ここにプログラムを追記
  int n, a, b, x;
  cin >> n >> a >> b;
  x = n * a;
  if(x > b){
    cout << b << endl;
  }
  else if(x == b){
    cout << x << endl;
  }
  else{
    cout << x << endl;
  }
}

Measured memory_bytes: 256
class DualSegmentTree():

    def __init__(self, n, op, e):
        """
        :param n: 配列の要素数
        :param op: 作用素（モノイド＝結合則＋単位元存在）
        :param e:  単位元
        """
        self.n = n
        self.op = op
        self.e = e
        self.size = 1 << (self.n - 1).bit_length()
        self.lazy = [self.e] * (self.size << 1)

    def update(self, l, r, x):
        """
        半開区間 [l, r) の値を x に更新 （ 0-indexed ）　（ O(logN) ）
        """
        l += (self.size - 1)
        r += (self.size - 1)
        self.propagate(l)
        self.propagate(r-1)
        while l < r:
            if r&1 == 0:
                r -= 1              # 半開区間なので先に引いてる
                self.lazy[r] = x
            if l&1 == 0:
                self.lazy[l] = x
                l += 1
            l = (l - 1) // 2
            r = (r - 1) // 2

    def propagate(self, i):
        """
        根から葉に伝搬させる。可換モノイドの場合は更新時の伝搬をサボれる。　（ O(logN) ）
        """
        tmp = []
        while i>0:
            i -= 1
            i >>= 1
            tmp.append(i)
        for x in reversed(tmp):
            if self.lazy[x] == self.e:
                continue
            self.lazy[2*x+1] = self.lazy[x]
            self.lazy[2*x+2] = self.lazy[x]
            self.lazy[x] = self.e

    def get(self, i):
        """
        i 番目の値を取得（ 0-indexed ） ( O(logN) )
        """
        i += (self.size - 1)
        self.propagate(i)
        return self.lazy[i]

    def __getitem__(self, i):
        return self.get(i)

    def __iter__(self):
        for x in range(self.size-1):
            if self.lazy[x] == self.e:
                continue
            self.lazy[2*x+1] = self.lazy[x]
            self.lazy[2*x+2] = self.lazy[x]
            self.lazy[x] = self.e
        for a in self.lazy[self.size-1:self.size-1+self.n]:
            yield a

    def __str__(self):
        for x in range(self.size-1):
            if self.lazy[x] == self.e:
                continue
            self.lazy[2*x+1] = self.lazy[x]
            self.lazy[2*x+2] = self.lazy[x]
            self.lazy[x] = self.e
        return str(self.lazy[self.size-1:self.size-1 + self.n])

##################################################################################################################
import sys
from bisect import *
input = sys.stdin.readline

N, Q = map(int, input().split())

e = -1
op = lambda x, y: x if x != e else y
st = DualSegmentTree(Q, op, e)

Qu = [list(map(int, input().split())) for _ in range(N)]
Qu.sort(key=lambda x:x[2], reverse=True)

D = [int(input()) for _ in range(Q)]

for q in Qu:
    S, T, X = q
    L = bisect_left(D,S-X)
    R = bisect_left(D,T-X)
    st.update(L, R, X)
print(*st, sep="\n")

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

typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)
 
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)
#define trav(a, x) for(auto& a : x)
 
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)
 
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;


int main()
{
    int N;
    cin >> N;
    bool is = false;
    rep(i,N / 4 + 1)
    {
        rep(j,N / 7 + 1)
        {
            if(N == 4 * i + 7 * j)
            {
                is = true;
            }
        }
    }
    Yes(is);
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> u(n), v(n);
  bool flag = true;
  ll m = -1;
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    if(i == 0) m = ((x+y)%2+2)%2;
    else if(m != ((x+y)%2+2)%2) flag = false;
    u[i] = x + y;
    v[i] = x - y;
  }

  if(!flag) {
    cout << -1 << endl;
    return 0;
  }

  vector<ll> d(31);
  REP(i, 31) d[i] = 1LL<<i;
  if(m == 0) d.push_back(1), sort(ALL(d));

  cout << d.size() << endl;
  REP(i, d.size()) cout << d[i] << (i==d.size()-1?'\n':' ');

  REP(i, n) {
    ll st = 0;
    if(m == 0) {
      st = 1;
      u[i]++;
      v[i]++;
      cout << "L";
    }
    ll uu = (u[i]+(1LL<<31)-1)/2, vv = (v[i]+(1LL<<31)-1)/2;
    REP(j, 31) {
      bool up = uu & 1LL<<j, vp = vv & 1LL<<j;
      if(up && vp) cout << "R";
      else if(up) cout << "U";
      else if(vp) cout << "D";
      else cout << "L";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define LLONG_MAX     9223372036854775807i64

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int N;
	string S;
	cin >> N >> S;

	vi dir(N + 1, 0);
	rep(i, N) if (S[i] == 'E') dir[i + 1] = 1;
	rep(i, N) dir[i + 1] += dir[i];

	int ans = N;
	rep(i, N) {
		int w, e;
		w = i - dir[i];
		e = dir[N] - dir[i + 1];
		ans = min(ans, w + e);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1796
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

class cake {
public:
    long long a;
    long long b;
    long long c;
    long long score;
    bool operator < (const cake &arg) const{
        return score < arg.score;
    }
};

int main(){
    std::ios::sync_with_stdio(false);
    int n, m;
    long long a, b, c;
    vector<cake> cakes = vector<cake>();
    cin >> n >> m;
    for(int i=0;i<n;++i)
    {
        cin >> a >> b >> c;
        cake cake;
        cake.a = a;
        cake.b = b;
        cake.c = c;
        cake.score = 0;
        cakes.push_back(cake);
    }    

    ll ans = (1ull << 63);
    for(int b=0;b<2;++b)
    {
        for(int d=0;d<2;++d)
        {
            for(int p=0;p<2;++p)
            {
                for(size_t i=0;i<cakes.size();++i)
                {
                    cakes[i].score = cakes[i].a * (b == 0 ? 1 : -1) + cakes[i].b * (d == 0 ? 1 : -1) + cakes[i].c * (p == 0 ? 1 : -1);
                }

                sort(cakes.rbegin(), cakes.rend());
                long long temp[3] = {0};
                for(int i=0;i<m;++i)
                {
                    temp[0] += cakes[i].a;
                    temp[1] += cakes[i].b;
                    temp[2] += cakes[i].c;
                }
                ans = max(ans, abs(temp[0]) + abs(temp[1]) + abs(temp[2]));
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int NMAX = 410;

ll dp[NMAX][NMAX]; // inclusive
ll pfx[NMAX];
ll sum[NMAX][NMAX];
vector<int> A;
int N;

ll solve(int a, int b) {
	assert(b>a);
	if(dp[a][b] != INF) return dp[a][b];
	if(b == a+1) {
		return dp[a][b] = A[a]+A[b];
	}
	dp[a][b] = min(dp[a][b], A[a]+solve(a+1, b)+sum[a+1][b]);
	dp[a][b] = min(dp[a][b], A[b]+solve(a, b-1)+sum[a][b-1]);
	for(int i=a+1;b-i>=2;++i) {
		dp[a][b] = min(dp[a][b], solve(a,i)+solve(i+1,b)+sum[a][b]);
	}
	return dp[a][b];
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	memset(dp, INF, sizeof dp);
	cin >> N;
	A.resize(N);
	for(auto& x : A) cin >> x;
	for(int i=0;i<N;++i) {
		pfx[i+1] = pfx[i]+A[i];
	}
	for(int i=0;i<N;++i) {
		for(int j=i;j<N;++j) {
			sum[i][j] = pfx[j+1]-pfx[i];
		}
	}
	cout << solve(0, N-1) << endl;
	return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
int main() {
	int n;				/*要素数*/
	long int A[1000000];/*配列*/
	int i, j, k;		/*ループ用変数*/
	long int v;			/*ソート用変数*/
	int m = 0;			/*間隔の数*/
	int G[100];			/*間隔の配列*/
	int g;				/*間隔*/
	int cnt = 0;		/*要素が移動させられた回数*/

	/*要素数の入力*/
	scanf("%d", &n);

	/*間隔の作成*/
	int x = 1;
	for (i = 0; x <= n; i++) {
		/*mを増やす*/
		m++;
		/*配列に間隔を格納*/
		G[i] = x;
		/*4,13,40...*/
		x = x * 3 + 1;
	}
	
	/*要素の入力*/
	for (i = 0; i < n; i++) {
		scanf("%ld", &A[i]);
	}

	/*シェルソート*/
	for (i = 0; i < m; i++) {
		g = G[m - i - 1];
		/*挿入ソート*/
		for (j = g; j < n; j++) {
			v = A[j];
			k = j - g;
			/*入れ替え処理*/
			while (k >= 0 && A[k] > v) {
				A[k + g] = A[k];
				k = k - g;
				cnt++;
			}
			A[k + g] = v;
		}
	}

	/*mの出力*/
	printf("%d\n", m);

	/*Gの出力*/
	for (i = m - 1; i >= 0; i--) {
		if (i == 0) {
			printf("%d\n", G[i]);
		}
		else {
			printf("%d ", G[i]);
		}
	}

	/*cntの出力*/
	printf("%d\n", cnt);

	/*配列（ソート済み）の出力*/
	for (i = 0; i < n; i++) {
		printf("%d\n", A[i]);
	}

	return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int N;
	cin >> N;

	FOR(i,1,10){
		FOR(j,1,10){
			if(i*j == N){
				cout << "Yes" << "\n";
				return 0;
			}
		}
	}

	cout << "No" << "\n";

return 0;
}

Measured memory_bytes: 256