akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
	while(1) {
		char p[14][14];
		int k = 0;

		for(int i = 0; i < 14; i++) {
			for(int j = 0; j < 14; j++) {
				p[i][j] = '0';
			}
		}

		for(int i = 1; i <= 12; i++) {
			for(int j = 1; j <= 12; j++) {
				cin >> p[i][j];
			}
		}

		if(cin.eof()) break;

		while(1) {
			bool nk = false;
			for(int i = 1; i <= 12; i++) {
				for(int j = 1; j <= 12; j++) {
					if(p[i][j] == '1') {
						p[i][j] = '2';
						nk = true;
						goto loop;
					}
				}
			}

			if(nk == false) break;
			loop:
			k++;

			while(1) {
				bool np = false;
				for(int i = 1; i <= 12; i++) {
					for(int j = 1; j <= 12; j++) {
						if(p[i][j] == '1' && (p[i-1][j] == '2' || p[i+1][j] == '2' || p[i][j+1] == '2' || p[i][j-1] == '2')) {
							p[i][j] = '2';
							np = true;
						}
					}
				}

				if(np == false) break;
			}
		} 
		cout << k << endl;
	}
	return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

int main(){
    int N;cin >> N;
    LL K;cin >> K;
    vector<LL> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    LL p=K;
    int k=0;
    while(p){
        k++;
        p/=2;
    }
    vector<LL> x(100,0);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= k; j++) {
            if(a[i]&(1LL<<j)) x[j]++;
        }
    }
    LL t=0;
    bool c=true;
    for (int i = k; i >=0 ; i--) {
        if(2*x[i]<N){
            if(c) t+=K&(1LL<<i);
            else t+=1LL<<i;
        }
        else if((1LL<<i)&K) c=false;
    }
    LL ans=0;
    for (int i = 0; i < N; i++) {
        ans+=t^a[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

struct edge{
  int to,id;
};

vector<vector<edge> > g;
vector<int> ans;

void dfs(int v,int p=-1,int c=-1){
  int k=1;
  rep(i,g[v].size()){
    int nv=g[v][i].to;
    int ei=g[v][i].id;
    if(nv==p) continue;
    if(k==c) k++;
    ans[ei]=k;
    k++;
    dfs(nv,v,ans[ei]);
  }
}

int main(){
  int N; cin >> N;
  g.resize(N);
  ans.resize(N-1);
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(edge{b,i});
    g[b].push_back(edge{a,i});
  }
  dfs(0);
  int mx=0;
  rep(i,N-1){
    chmax(mx,int(g[i].size()));
  }
  cout << mx << endl;
  rep(i,N-1){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  bool a, b;
  a = b = false;
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == 'C') a = true;
    if (a && s[i] == 'F') b = true;
  }
  dump(b ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
bool compare(pair<int,int>a,pair<int,int>b)
{
	 return a.second>b.second;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	vector<int>v(n+1);
	for(int i=1;i<=n;i++)
	{
		   cin>>v[i];
	}
	sort(v.begin()+1,v.end());
	vector<pair<int,int> >b;
	for(int i=0;i<m;i++)
	{
	      int x,y;
	      cin>>x>>y;
	      b.emplace_back(make_pair(x,y));
	}
	sort(b.begin(),b.end(),compare);
	int res=0;
	int current=0;
	for(int i=1;i<=n;i++)
	{
		   if(current>m)
		   {
		   	    res+=v[i];
		   	    continue;
		   }
		   if(b[current].second>v[i]&&b[current].first>0)
		   {
		   	   res+=b[current].second;
		   	   b[current].first--;
		   }
		   else
		   	res+=v[i];
		   if(b[current].first==0)
		   	current++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3188
use std::io::*;
use std::cmp;

fn gcd(a: u32, b: u32) -> u32 {
    if a < b {
        if b % a == 0 {
            return a;
        }
        return gcd(b % a, a);
    }
    if a % b == 0 {
        return b;
    }
    gcd(a, a % b)
}


fn solve(n: usize, mut a: Vec<u32>) -> u32 {
    let mut dp = vec![vec![0; 2]; 100010];
    dp[0][0] = *a.get(0).unwrap();
    dp[1][0] = gcd(*a.get(0).unwrap(),*a.get(1).unwrap());
    dp[1][1] = *a.get(1).unwrap();
    for i in 2..n {
        dp[i][0]=gcd((*dp.get(i-1).unwrap())[0],
                     *a.get(i).unwrap());
        dp[i][1]=cmp::max(gcd((*dp.get(i-2).unwrap())[0],
                              *a.get(i).unwrap()),
                          gcd((*dp.get(i-1).unwrap())[1],
                              *a.get(i).unwrap()));
    }
    cmp::max((*dp.get(n-2).unwrap())[0],
             (*dp.get(n-1).unwrap())[1])
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<u32> = (0..n)
        .map(|_| {
            iter.next().unwrap().parse().unwrap()
        }).collect();

    println!("{}", solve(n, a));
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
class dice{
public:
  int d[6];
  void rotate(char a){
    if(a=='N'){
      int top=d[0];
      d[0]=d[1];
      d[1]=d[5];
      d[5]=d[4];
      d[4]=top;
    }
    else if(a=='S'){
      int top=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=top;
    }
    else if(a=='E'){
      int top=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=top;
    }
    else if(a=='W'){
      int top=d[0];
      d[0]=d[2];
      d[2]=d[5];
      d[5]=d[3];
      d[3]=top;
    }
    else if(a=='R'){
      rotate('N');
      rotate('E');
      rotate('S');
    }
    else if(a=='L'){
      rotate('N');
      rotate('W');
      rotate('S');
    }
    return;
  }
  void rotate2(int t,int f){
    int i;
    for(i=0;i<6;i++) if(d[i]==t) break;
      if(i==1) rotate('N');
      else if(i==2) rotate('W');
      else if(i==3) rotate('E');
      else if(i==4) rotate('S');
      else if(i==5) rotate('S'),rotate('S');

      for(i=1;i<5;i++) if(d[i]==f) break;
      if(i==2) rotate('L');
      else if(i==3) rotate('R');
      else if(i==4) rotate('R'),rotate('R');

      return;
  }
};
int main(){
  dice d;
  int q,t,f;
  for(int i=0;i<6;i++){
    cin>>d.d[i];
  }
  cin>>q;
  for(int j=0;j<q;j++){
    cin>>t>>f;
    d.rotate2(t,f);
    cout<<d.d[2]<<endl;
  }
  return 0;
}



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

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

    int l[60];
    for (int i = 0; i < n; i++)
        cin >> l[i];
    sort(l, l + n, greater<int>());

    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 5e5 + 10 , inf = 1e9 + 7;
int n , K , p[N] , a[N << 2];
int Min(int c,int l,int r,int L,int R) {
  if(L > R) return inf;
  if(L <= l && r <= R) return a[c];
  int m = (l + r) >> 1;
  int res = inf;
  if(L <= m) res = min(res , Min(c << 1 , l , m , L , R));
  if(R > m) res = min(res , Min(c << 1 | 1 , m + 1 , r , L , R));
  return res;
}
void Update(int c,int l,int r,int p,int x) {
  if(l == r) a[c] = x;
  else {
    int m = (l + r) >> 1;
    if(p <= m) Update(c << 1 , l , m , p , x);
    else Update(c << 1 | 1 , m + 1 , r , p , x);
    a[c] = min(a[c << 1] , a[c << 1 | 1]);
  }
}

int tot , vis[N] , ans[N];

void solve(int c) {
  while(true) {
    int t = Min(1 , 0 , n - 1 , 0 , p[c] - 1);
    if(t >= c + K) break;
    solve(t);
  }
  ans[c] = ++tot;
  vis[c] = true;
  Update(1 , 0 , n - 1 , p[c] , inf);
}

int main(){
  scanf("%d%d",&n,&K);
  rep(i,0,n) scanf("%d",p+i) , Update(1 , 0 , n - 1 , --p[i] , i);
  rep(i,0,n) if(!vis[i]) solve(i);
  rep(i,0,n) printf("%d\n",ans[i]);
  return 0;
}


Measured memory_bytes: 38656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
  ll int x;
  cin>>x;
  ll int ans=0;

  ll tmp;
  tmp=x/500;
  ans+=tmp*1000;

  x-=tmp*500;
  tmp=x/5;
  ans+=tmp*5;

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;int n;
while(cin>>n>>s){

if(n%2!=0){cout<<"No"<<endl;continue;}
int i,j;
j=n/2;
int k=j;
bool fl=false;
for(i=0;i<k;i++,j++){
if(s[i]!=s[j])fl=true;

}

if(fl){cout<<"No"<<endl;}
else cout<<"Yes"<<endl;



}

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

int main(){
	int N,num;
   	scanf("%d",&N);
  	if(N<10){
    	printf("%d",N);
    }
  else if(N<100){
  	printf("9");
  }
  else if(N<1000){
  	printf("%d",9+N-99);
  }
  else if(N<10000){
  	printf("909");
  }
  else if(N<100000){
  	printf("%d",909+N-9999);
  }
  else{
  	printf("90909");
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
	int a[10] , max , min;
	for(int i = 0 ; i < 10 ; i++)
	{
		scanf("%d" , &a[i]);
	}
	for(int i = 0 ; i < 9 ; i++)
	{
		for(int j = i + 1 ; j <= 9 ; j++)
		{
			if(a[j] > a[i])
			{
				int z;
				z = a[j];
				a[j] = a[i];
				a[i] = z;
			}
		}
	}
	for(int i = 0 ; i < 3 ; i++)
	{
		printf("%d\n" , a[i]);
	}
	return 0;
}


Measured memory_bytes: 2036
object Main {
  val Pattern = Array('#', '.')

  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .map { line =>
        val arr = line.split(" ").map(_.toInt)
        (arr(0), arr(1))
      }
      .takeWhile {
        case (0, 0) => false
        case _ => true
      }
      .foreach { case (h, w) =>
        val sb = StringBuilder.newBuilder
        for (y <- 0 until h) {
          val base = y % 2
          for (x <- 0 until w) {
            sb.append(Pattern((base + x) % 2))
          }
          sb.append('\n')
        }
        sb.append('\n')
        print(sb.toString())
      }
  }
}

Measured memory_bytes: 45008
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(string, a);
    Cin(string, b);
    //Cout();
    //Cout(() ? "Yes" : "No");
    Cout((a==b) ? "H" : "D");
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, k;
  cin >> n >> k;
  f80 ans = 0;
  reps(i, n) {
    int c = 0, sum = i;
    while (sum < k) c++, sum *= 2;
    ans += 1 / power((f80) 2, c) / (f80) n;
  }
  cout << ans << '\n';
}


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

int main()
{
	char a[5];
	int n = 0;

	cin.getline(a, 5);

	for (int i = 0; i < 4; i++) {
		if (a[i] == '+')
			n++;
		else
			n--;
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{


    class Program
    {

        static void Main(string[] args)
        {
            //var W = long.Parse(Console.ReadLine());
            var ABC = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long A = ABC[0];
            long B = ABC[1];
            long C = ABC[2];
            //Array.Sort(A);
            long D = C - (A + B);
            if (4*A*B < D*D && D > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            //Console.WriteLine(double.MinValue);
        }
    }
}


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

int N, K, mem[100][4][4], decided[100];

int dp(int n, int b1, int b2)
{
  if(n == N)
    return 1;
  if(mem[n][b1][b2] != -1)
    return mem[n][b1][b2];
  int ans = 0;
  if(decided[n] != 0)
  {
    if(b1 == b2 && decided[n] == b1)
      return 0;
    mem[n][b1][b2] = dp(n + 1, decided[n], b1);
    return mem[n][b1][b2];
  }
  for(int i = 1; i <= 3; i++)
  {
    if(b1 == b2 && b1 == i)
      continue;
    ans += dp(n + 1, i, b1);
  }
  mem[n][b1][b2] = ans % 10000;
  return ans % 10000;
}

int main()
{
  cin >> N >> K;
  for(int i = 0; i < 100; i++)
    for(int j = 0; j < 4; j++)
      for(int k = 0; k < 4; k++)
        mem[i][j][k] = -1;
  for(int i = 0; i < K; i++)
  {
    int a, b;
    cin >> a >> b;
    decided[a - 1] = b;
  }
  cout << dp(0, 0, 0) << endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Thousand "Hello World"
    int R, G;
    cin >> R >> G;
    if (R + ((G - R) * 2) / 2 == G){
        cout <<R + ((G - R) * 2) << endl;
    }
    else{
        cout << (R - G) * -1 << endl;
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n,p; cin>>n>>p;
map<ll,ll> a;
for (ll i = 2; i * i <=p; ++i) {
        if (p % i != 0) continue;
        ll ex = 0;
        while (p % i == 0) {
            ++ex;
            p /= i;
        }
        a[i]=ex;
    }
    if (p != 1) a[p]=1;
ll ans = 1;
for(auto p :a){
if(p.second>=n){
ll ca = p.second/n;
ans *= pow(p.first,ca);}}
cout << ans << endl;}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

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); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a[5],ans = 0,mi = 10;
	for(int i = 0;i < 5;i++) cin >> a[i];
	for(int i = 0;i < 5;i++){
		if(a[i] % 10) mi = min(mi,a[i] % 10);
		if(a[i] % 10) ans += 10 * ((a[i] / 10) + 1);
		else ans += a[i];
	}
	if(mi == 10) cout << ans << endl;
	else cout << ans - 10 + mi << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int out=0,runner=0,point=0;
	int n;
	int i,j,k;
	char str[10];
	//HIT
	//HOMERUN
	//OUT
	scanf("%d",&n);
	for(i=0;i<n;i++){
		out=0,runner=0,point=0;
		while(out!=3){
			scanf("%s",str);	
			switch(strcmp(str,"HOMERUN")){
				case -1:
					runner<<=1;runner++;
					if(runner>=8){
						point++;
						runner-=8;
						
					}
					//point+=runner&8?1,runner-=8,put("osidasi"):0;
					break;
				case  0:
					point++;
					point+=runner&4?1:0;
					point+=runner&2?1:0;
					point+=runner&1?1:0;
					runner=0;
					break;
				case  1:
					out++;
					break;
			}
			if(out>=3){
				printf("%d\n",point);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int add(int N){
  int S=0,a;
  for(int i=1;i<=10;i++){
    a=N%10;
    S+=a;
    N/=10;
  }
  return S;
}

int main(){
  int N;
  cin >> N;
  int S=0;
  S=add(N);
  if(N%S==0)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
for i in range(4):
    t,n = map(int,input().split())
    if t == 1:
        print ( n * 6000 )
    elif t == 2:
        print ( n * 4000 )
    elif t == 3:
        print ( n * 3000 )
    elif t == 4:
        print ( n * 2000 )


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

int main() {

  int A, B; cin >> A >> B;
  int answer = 0;
  if (A > B) {
    answer = A + (A - 1);
  } else if (B > A) {
    answer = B + (B - 1);
  } else {
    answer = A + B;
  }

  cout << answer << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    int num;
    cin >> num;

    int t[100001];
    int x[100001];
    int y[100001];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i = 0; i < num; i++)
    {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }

    bool flag = true;
    for (int i = 0; i < num; i++)
    {
        // 最低移動回数
        int d_min = (x[i + 1] - x[i]) + (y[i + 1] - y[i]);

        // 使用する移動回数
        int d_use = t[i + 1] - t[i];

        int deff = d_use - d_min;

        // そもそも移動回数が足りない
        if (deff < 0)
        {
            flag = false;
            break;
        }

        if (deff % 2 == 0)
        {
            flag = true;
        }
        else
        {
            flag = false;
            break;
        }
    }

    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    if(a <= 0 and b >= 0) cout << "Zero" << endl;
    else if(b < 0 and (b-a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

d = [x[i+1] - x[i] for i in range(n-1)]
ans = 0
mod = 10 **9 + 7
fac = 1
for i in range(1, n):
    fac *= i
    fac %= mod

tmp = 0
for i in range(n-1):
    tmp += fac * pow(i+1, mod-2, mod)
    tmp %= mod

    ans += d[i] * tmp
    ans %= mod

print(ans)

Measured memory_bytes: 14252
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		long t = 1l;
		double d = 0d;
		for ( int i=0; i<n; i++ ) {
			long a = sc.nextLong();

			if ( a==0 ) {
				System.out.println(0);
				System.exit(0);
			}

			d += Math.log10((double)a);
			t *= a;

		}

		if ( d>18 ) {
			System.out.println(-1);
		} else if ( t>1000000000000000000l ) {
			System.out.println(-1);
		} else {
			System.out.println(t);
		}
	}
}

Measured memory_bytes: 59488
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstring>
#define Maxn 100010
int t[Maxn],x[Maxn],y[Maxn];
using namespace std;
int main()  
{  
    int n;
	t[0]=0;
	x[0]=0;
	y[0]=0;
	int i;  
    while(scanf("%d",&n)!=EOF)  
    {  
        for(i=1;i<=n;i++)  
        {  
            cin>>t[i];
			cin>>x[i];
			cin>>y[i];  
        }  
        for(i=1;i<=n;i++)  
        {  
            if((t[i]-t[i-1])%2==0&&(x[i]+y[i]-x[i-1]-y[i-1])%2!=0||(x[i]+y[i]-x[i-1]-y[i-1])%2==0&&(t[i]-t[i-1])%2!=0)  
                break;  
            if((t[i]-t[i-1])%2==0&&(x[i]+y[i]-x[i-1]-y[i-1])%2==0||(x[i]+y[i]-x[i-1]-y[i-1])%2!=0&&(t[i]-t[i-1])%2!=0)  
                if(x[i]+y[i]>t[i])  
                    break;  
        }  
        if(i==n+1)  
            cout<<"Yes"<<endl;  
        else  
            cout<<"No"<<endl;  
    }  
    return 0;  
}  

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

char c;
char exchange(char c){
  if('A' <= c && c <= 'Z') {
    return c + ('a' - 'A');
  }
  if('a' <= c && c <= 'z') {
    return c + ('A' - 'a');
  }
  
  return c;
}

int main(void){
int i,len;
char s[4906];
scanf("%[a-z,A-Z, .0-9,',(), -]", s);

  len = strlen(s);
  for(i = 0; i < len;i++) {
    s[i] = exchange(s[i]);
  }
  
  printf("%s",s);
  

printf("\n");
return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<algorithm>

using namespace std;
#define MOD 1000000007
int n, t;
int d[108000];
int dp[108000];
int main(){
	cin >> n >> t;
	for(int i = 0;i < n;i++)cin >> d[i];
	sort(d, d + n);
	dp[0] = 1;
	for(int i = 1;i < n;i++){
		dp[i] = dp[i-1] * (i - (lower_bound(d, d + i, d[i]-t) - d) + 1) % MOD;
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 3924
S = input()
Q = int(input())
rev = 1
head = []
tail = []
for _ in range(Q):
    lst = input().split() 
    if (lst[0] == '1'):
        rev *= -1
    else:
        if (lst[1] == '1'):
            pos = rev
        else:
            pos = -1 * rev
        if (pos == 1):
            head.append(lst[2])
        else:
            tail.append(lst[2])
ans = ''.join(head[::-1]) + S + ''.join(tail)
print(ans[::rev])


Measured memory_bytes: 69848
#include <iostream>
using namespace std;
/*３のつく数字ならtrue*/
bool has3(int x){
    while(x){
        if(x % 10 == 3)return true;
        x /= 10;
    }
    return false;
}

void call(int n){
    for(int x=1; x <= n; x++){
        if(x %3 == 0 || has3(x)){
            cout << " " << x;
        }
    }
    cout << endl;
}

int main(void){
    int n;
    cin >> n;
    call(n);
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    bool f = true;
    for (int i = 0, v = s.size(); i < v; i += 2) {
        if (s[i] == 'h' && s[i+1] == 'i') {}
        else {
            f = false;
        }
    }
    if (!f) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<ll> a[200050];
ll b[200050];
ll ans[200050];
bool flag[200050];

void dfs(ll x,ll sum)
{
	flag[x]=false;
	ans[x]=sum+b[x];
	for(int i=0;i<a[x].size();i++)
	{
		ll temp=a[x][i];
		if(flag[temp])
			dfs(temp,sum+b[x]);
	}
}
int  main()
{
	memset(flag,true,sizeof(flag));
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<n-1;i++)
	{
		ll x;
		ll y;
		cin>>x;
		cin>>y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(int i=0;i<m;i++)
	{
		ll x;
		ll y;
		cin>>x>>y;
		b[x]+=y;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
	if(i!=n)
		cout<<ans[i]<<" ";else cout<<ans[i]<<endl;
}

Measured memory_bytes: 25856
#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 ALL(n) begin(n),end(n)
typedef long long ll;
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() {
    int A,B,C,D;
    cin >> A>>B>>C>>D;

    int NMAX=110;
    vector<int> a(NMAX, 0);
    vector<int> b(NMAX, 0);

    REP2(i, A, B) a[i] = 1;
    REP2(i, C, D) b[i] = 1;

    REP(i, NMAX) a[i]&=b[i];
    
    int cnt=0;
    REP(i, NMAX) if(a[i]) cnt++;

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
// {{{ Template
// Author:  wenxing
// Date:    2017-12-30 20:46 +0800
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r; i >= l; --i)
#define repv(ele, vec) for (auto &ele : vec)
#define zero(mem) memset(mem, 0, sizeof(mem))
#define sd(_) scanf("%d", &_)
#define sdd(_, __) scanf("%d%d", &_, &__)
#define sddd(_, __, ___) scanf("%d%d%d", &_, &__, &___)
#define sdddd(_, __, ___, ____) scanf("%d%d%d%d", &_, &__, &___, &____)
#define sl(_) scanf("%ld", &_)
#define sll(_, __) scanf("%ld%ld", &_, &__)
#define slll(_, __, ___) scanf("%ld%ld%ld", &_, &__, &___)
#define sc(_) scanf("%c", &_)
#define ss(_) scanf("%s", _)
#define mid(a, b) (((a) + (b)) >> 1)
#define lft(x) x << 1
#define rht(x) x << 1 | 1
#define inf 0x3f3f3f3f
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
// }}}

// - Pseudocode -

// {{{ Global Variables
int a, b;
char s[100];
// }}}

int check() {
    if (strlen(s) != a + b + 1 || s[a] != '-') return 0;

    rep(i, 0, a) if (s[i] < '0' || s[i] > '9') return 0;
    rep(i, a + 1, a + b + 1) if (s[i] < '0' || s[i] > '9') return 0;

    return 1;
}

int main() {
    sdd(a, b);
    ss(s);

    if (check())
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl "\n"


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

    int n; cin >> n;
    vector<ll> nums(n);
    for_(i, 0, n) cin >> nums[i];
    sort(nums.begin(), nums.end(), greater<ll>());
    ll ans = nums[0];
    int pt = 1, ct = 0;
    for_(i, 2, n) {
        ans += nums[pt];
        ct++;
        if (ct == 2) {
            ct = 0;
            pt++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4744
#include <iostream>
#include <vector>
int main() {
  int N;
  std::cin >> N;
  std::vector<int> V(N);
  for(auto &v:V) std::cin >> v;
  std::vector<int> C(N);
  for(auto &c:C) std::cin >> c;
  int xy=0;
  for(int i=0;i<N;i++){
    if(V[i]>C[i]) xy+= V[i]-C[i];
  }
  std::cout << xy << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int H,W;
  cin>>H>>W;
  if(W < H)swap(H,W);
  if(H ==1 || W ==1)
  {
    cout<<1<<endl;
    return;
  }

  int ANS = 0;

      ANS += (W/2 + W%2)*(H/2 + H%2);
      ANS += (W/2)*(H/2);
      cout<<ANS<<endl;

  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;
using Graph = vector<vector<long long>>;


bool find(string S,int s0,int s1,int s2) {
    bool finda = false;
    bool findb = false;
    bool findc = false;
    bool ok = false;
    for (ll i=0;i<S.length();i++) {
        if (S.at(i) - '0' == s2 && findb) findc = true;
        if (S.at(i) - '0' == s1 && finda) findb = true;
        if (S.at(i) - '0' == s0) finda = true;
    }
    return findc;
}

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll cnt = 0;
    for (int s0 = 0;s0<=9;s0++) {
        for (int s1 = 0;s1<=9;s1++) {
            for (int s2 = 0;s2<=9;s2++) {
                if (find(S,s0,s1,s2)) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


# sys.setrecursionlimit(10**5)


def main():
    n, k = geta(int)
    h = list(geta(int))

    h.sort()

    if n <= k:
        print(0)
    else:
        print(sum(h[0:n - k]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 75760
cnt = 0

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    L.append(float('inf'))
    R.append(float('inf'))
    i = 0
    j = 0
    global cnt
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
        cnt += 1
    return A

def merge_sort(A, left, right):
    if left+1 < right:
        mid = (left + right) >> 1
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        return merge(A, left, mid, right)

n = int(input())
A = [int(i) for i in input().split()]
print(*merge_sort(A, 0, n), sep=" ")
print(cnt)


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

int main() {
    int a=0,b=0,H[100],W[100];
    while (1) {
        cin >> H[a] >> W[a];
        if (H[a] == 0 && W[a] == 0) break;
        a++;
        
    }
    
    while (b<a) {

        for (int i = 0; i < H[b]; i++) {
            for (int j = 0; j < W[b]; j++) {
                if(i==0||j==0||i==H[b]-1|| j==W[b] - 1) printf("#");
                else printf(".");
            }
        printf("\n");
        }
        b++;
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 3016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int h, w, rowcnt, colcnt;
    cin >> h >> w >> rowcnt >> colcnt;

    cout << (h * w - rowcnt * w - colcnt * h + rowcnt * colcnt) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  string s;
  cin >> s;

  int cnt = 0;
  if (s[0] == '1') {cnt += 1;}
  if (s[1] == '1') {cnt += 1;}
  if (s[2] == '1') {cnt += 1;}

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s;
    cin>>s;

    int divisor = 2019;
    int rem_count[2019] = {1};
    int num = 0;
    int pow10 = 1;
    int total = 0;

    int charac[s.length()];
    for(int i=0;i<s.length();i++){
        charac[i]=s[i]-48;
    }
    for(int i=s.length()-1;i>=0;i--){
        int dig = charac[i];
        num += dig*pow10;
        int rem = num%divisor;
        total += rem_count[rem];
        pow10 *=10;
        rem_count[rem] +=1;

        num=rem;
        pow10%=divisor;

    }

    cout<<total;
}

Measured memory_bytes: 4076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
#include <cstdint>
#include <cstring>

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int main()
{
	int K, X;

	cin >> K >> X;

	//if (K == 1){
	//	cout << X << endl;
	//}

	int count = 2 * K - 1;
	int begin = X - K + 1;

	for (int i = 0; i < count; i++){
		cout << begin << ' ' << endl;
		++begin;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut a:String = read();
    let mut b:String = read();
    let mut c:String = read();
    let mut t:char = 'a';
    loop {
        match t {
            'a' => {
                if a.len() == 0 {
                    println!("A");
                    return;
                } else {
                    t = a.remove(0);
                }
            },
            'b' => {
                if b.len() == 0 {
                    println!("B");
                    return;
                } else {
                    t = b.remove(0);
                }
            },
            'c' => {
                if c.len() == 0 {
                    println!("C");
                    return;
                } else {
                    t = c.remove(0);
                }
            },
            _ => (),
        }
    }
}

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


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n, k;
	cin >> m >> n >> k;

	ll si, sj, ti, tj;
	cin >> si >> sj >> ti >> tj;
	si--, sj--, ti--, tj--;
	
	vector<string> a(m);
	FOR(i,0,m) cin >> a[i];
	
	auto wall = [&](ll i, ll j) {
		return i < 0 || i >= m || j < 0 || j >= n || a[i][j] == '@';
	};
	assert(!wall(si,sj));
	assert(!wall(ti,tj));
	
	vvl dist(m, vl(n, oo));
	vector<set<ll>> row(m), col(n);
	FOR(i,0,m) FOR(j,0,n) {
		row[i].insert(j);
		col[j].insert(i);
	}
	
	queue<pll> q;

	auto update = [&](ll i, ll j, ll d) {
		if (wall(i,j) || d >= dist[i][j]) return;
		q.push({i,j});
		dist[i][j] = d;
	};

	update(si,sj,0);

	while (sz(q)) {
		ll i, j;
		tie(i,j) = q.front();
		q.pop();

		auto valid = [&](ll ni, ll nj) { return !wall(ni,nj) && abs(i-ni) + abs(j-nj) <= k; };
		{
			auto lo = col[j].lower_bound(i);
			while (lo != begin(col[j]) && valid(*prev(lo),j)) --lo;

			auto hi = col[j].upper_bound(i);
			while (hi != end(col[j]) && valid(*hi,j)) ++hi;
			
			for (auto it = lo; it != hi; it++) update(*it, j, dist[i][j]+1);
			col[j].erase(lo,hi);
		}
		{
			auto lo = row[i].lower_bound(j);
			while (lo != begin(row[i]) && valid(i,*prev(lo))) --lo;

			auto hi = row[i].upper_bound(j);
			while (hi != end(row[i]) && valid(i,*hi)) ++hi;
			
			for (auto it = lo; it != hi; it++) update(i, *it, dist[i][j]+1);
			row[i].erase(lo,hi);
		}
	}
	
	ll res = dist[ti][tj];
	if (res == oo) res = -1;
	cout << res << endl;
}



Measured memory_bytes: 152700
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, x, max;
	int a, b, c;
	int ans;

	while (1) {
		scanf("%d%d", &n, &x);
		if (n == 0 && x == 0) break;

		ans = 0;
		max = x; if (max > n) max = n;
		for (a = 1; a <= max; a++) {
			for (b = a + 1; b <= max; b++) {
				c = x - a - b;
				if (c > b && c <= n) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

ll sum(ll n) {
    return n*(n+1)/2;
}

int main() {
	int n;
	cin >> n;
    ll ans;
    ans = sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3600
function f()
	n,m=map(x->parse(Int,x),split(readline()))
	s=map(x->parse(Int,x),split(readline()))
	t=map(x->parse(Int,x),split(readline()))
	sum=ones(Int,m+1)
	mod=10^9+7
	for ss=s
		sum[2:m+1]+=cumsum([ss==tt?sum%mod:0 for (tt,sum) in zip(t,sum[1:m])])
	end
	println(sum[m+1]%mod)
end
f()

Measured memory_bytes: 155444
#include <iostream>
int main() {
	int W;
	int H;
	int x;
	int y;
	int r;
	std :: cin >> W;
	std :: cin >> H;
	std :: cin >> x;
	std :: cin >> y;
	std :: cin >> r;
	if (x > W - r || y > H - r|| r > x || r > y) {
		std::cout << "No" << std::endl;
	}
	else {
		std::cout << "Yes" <<std::endl;
	}
	
}


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

int main(){
    int n, m; cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m) cin >> l[i] >> r[i];
    sort(all(l));
    sort(all(r));
    int ans = r[0] - l[m-1] + 1;
    if(ans > 0) cout << ans << endl;
    else cout << 0 << endl;
}
   

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin >> n;
  ll xma = -1000000000, xmi = 2000000000, yma = -1000000000, ymi = 2000000000;
  rep(i, n){
    ll X,Y;
    cin >> X >> Y;
    ll x = X - Y;
    ll y = X + Y;
    xma = max(xma, x);
    xmi = min(xmi, x);
    yma = max(yma, y);
    ymi = min(ymi, y);
  }
  ll ans = max(abs(xma - xmi), abs(yma - ymi));
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int d[5];

int main() {
    for (int i = 1; i <= 3; i++) {
        int x, y;
        cin >> x >> y;
        d[x]++;
        d[y]++;
    }
    for (int i = 1; i <= 4; i++) if (d[i] == 3) {
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	vector<int> a = {400, 600, 800, 1000, 1200, 1400, 1600, 1800};
	vector<int> b = {599, 799, 999, 1199, 1399, 1599, 1799, 1999};
	int x;
	cin >> x;
	for(int i = 0; i < a.size(); i++) {
		if(x >= a[i] && x <= b[i]) {
			cout << 8 - i;
			return;
		}
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;

int s[N];
unordered_map<int, vector<int>> v;
void dfs(int node)
{
    if (!s[node])
    {
        s[node] = 1;
        for (int it : v[node])
        {
            dfs(it);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int res = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (!s[i])
        {
            ++res;
            dfs(i);
        }
    }
    cout << res - 1 << endl;
}

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

int main(){
  int n;
  cin >> n;
  int v[n], c[n];
  for(int i=0; i<n; i++){
    cin >> v[i];
  }
  int ans=0;
  for(int i=0; i<n; i++){
    cin >> c[i];
    if(v[i] > c[i]) ans += (v[i] - c[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        string o,e;
        cin >> o>>e;
        string ans;
if(o.length() == e.length())
{
        for(int i= 0; i< o.length(); i++)
        {       
                ans += o[i];
                ans += e[i];
        }
}  
else{
for(int i= 0; i< e.length() + 1; i++)
        {       
                ans += o[i];
if(i == e.length())
break;
                ans += e[i];
        }
}
        cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC62 C

import math
h,w = map(int,input().split())

def solve(H,W):
    mid = math.floor(W/2)
    ans = float('inf')
    for i in range(1,H):
        Smin = min(i*W,mid*(H-i),(W-mid)*(H-i))
        Smax = max(i*W,mid*(H-i),(W-mid)*(H-i))
        ans = min(ans,Smax-Smin)
    return min(ans,H)
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    print(min(solve(h,w),solve(w,h)))


Measured memory_bytes: 3064
#include<stdio.h>
#define N 10000

int main(){

  int num,i;
  int F[N];
 
  scanf("%d",&num);

  F[0]=F[1]=1;

  for(i=2;i<=num;i++){
    F[i]=F[i-2]+F[i-1];
  }

  printf("%d\n",F[num]);

  return 0;
}

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

int n;
string s;

bool isBad(vector<bool> &v) {
  for (int i = 0; i < n; i++) {
    int prev = i-1, nxt = i+1;
    if (i == 0) prev = n-1;
    if (i == n-1) nxt = 0;
    if (s[i] == 'o' and v[i] == true and v[prev] != v[nxt]) return true;
    if (s[i] == 'o' and v[i] == false and v[prev] == v[nxt]) return true;
    if (s[i] == 'x' and v[i] == true and v[prev] == v[nxt]) return true;
    if (s[i] == 'x' and v[i] == false and v[prev] != v[nxt]) return true;
  }
  return false;
}

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

  for (int i = 0; i < 4; i++) {
    vector<bool> tmp(n);
    if (i == 0) {
      tmp[0] = tmp[1] = false;
    } else if (i == 1) {
      tmp[0] = tmp[1] = true;
    } else if (i == 2) {
      tmp[0] = false;
      tmp[1] = true;
    } else {
      tmp[0] = true;
      tmp[1] = false;
    }
    for (int i = 2; i < n; i++) {
      if ((s[i-1] == 'o' and tmp[i-1] == true) or (s[i-1] == 'x' and tmp[i-1] == false)) {
        tmp[i] = tmp[i-2];
      } else {
        tmp[i] = !tmp[i-2];
      }
    }

    if (!isBad(tmp)) {
      for (int i = 0; i < n; i++) {
        cout << (tmp[i] ? 'S' : 'W');
      }
      cout << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    sort(ALL(a));
    reverse(ALL(a));
    ll res = a[0];
    reps(i,2,N) res += a[i/2];
    cout<<res<<endl;
}


Measured memory_bytes: 4848