akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N,M;
vector<int> par;
    
int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
}
    
void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
}
    
bool same(int x,int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
}

int main(void){
    cin>>N>>M;
    
    int p[N];
    par.resize(N);
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        p[i]=a-1;
        par[a-1]=a-1;
    }
    
    for(int i=0;i<M;i++){
        int x,y;
        cin>>x>>y;
        unite(x-1,y-1);
    }
    
    int count=0;
    for(int i=0;i<N;i++){
        if(p[i]==i){count++;continue;}
        if(same(p[i],i))count++;
    }
    
    cout<<count<<endl;
}


Measured memory_bytes: 1024
n, k = (int(x) for x in input().split())
ds = [int(x) for x in input().split()]
xs = list(filter(lambda x: x not in ds, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))
o = n
m = len(str(n))
ans = 0
c = False
for i in range(m):
    d = (o // 10 ** i) % 10
    ys = list(filter(lambda x: x >= d, xs))
    if len(ys) == 0:
        if i == m - 1:
            y = xs[0] * 11 if xs[0] != 0 else xs[1] * 10
        else:
            y = xs[0]
        o += (y - d) * 10 ** i + 10 ** (i + 1)
        ans += y * 10 ** i
    else:
        y = ys[0]
        if y > d:
            ans = y * 10 ** i
            for j in range(i):
                ans += xs[0] * 10 ** j
        else:
            ans += y * 10 ** i
print(ans)


Measured memory_bytes: 3064
n = int(input())
syou = n
n26 = []
while syou:
  amari = syou % 26
  syou = syou // 26
  n26.append(amari)
for i in range(len(n26)):
  if n26[i] <= 0:
    if i == len(n26)-1:
      n26.pop()
      break
    n26[i] += 26
    n26[i+1] -= 1
answer = ""
for i in range(len(n26)-1, -1, -1):
  answer += chr(n26[i]+96)
print(answer)

Measured memory_bytes: 9000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n;cin>>n;
    vector<pll>st(0);
    rep(i,n){
        ll a,b;cin>>a>>b;
        st.pb(mp(a,0));
        st.pb(mp(b,1));
    }
    sort(all(st));
    ll cnt=0;
    ll ma=0,mi=inf;
    ll ans=0;
    if(n%2){
        rep(i,n*2){ 
            pll k=st[i];
            if(k.second==0){
                cnt++;
                if(cnt==(n+1)/2)mi=min(k.first,mi);
            }
        }
        reverse(all(st));
        cnt=0;
        rep(i,n*2){ 
            pll k=st[i];
            if(k.second==1){
                cnt++;
                if(cnt==(n+1)/2)ma=max(k.first,ma);
            }
        }
        ans=ma-mi+1;
    }else{
        rep(i,n*2){ 
            pll k=st[i];
            if(k.second==0){
                cnt++;
                if(cnt==(n)/2)mi=min(k.first,mi);
            }
        }
        reverse(all(st));
        cnt=0;
        rep(i,n*2){ 
            pll k=st[i];
            if(k.second==1){
                cnt++;
                if(cnt==(n)/2)ma=max(k.first,ma);
            }
        }
        ll maa=0,mii=inf;
        reverse(all(st));
        cnt=0;
        rep(i,n*2){ 
            pll k=st[i];
            if(k.second==0){
                cnt++;
                if(cnt==(n)/2+1)mii=min(k.first,mii);
            }
        }
        reverse(all(st));
        cnt=0;
        rep(i,n*2){ 
            pll k=st[i];
            if(k.second==1){
                cnt++;
                if(cnt==(n)/2+1)maa=max(k.first,maa);
            }
        }
        ans=ma+maa-mi-mii+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11656
#include<stdio.h>

int main(){

int W,H,x,y,r;


scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if( W >= (x+r) && 0 <= (x-r) && H >= (y+r) && 0 <= (y-r)){

printf("Yes\n");

}else{

printf("No\n");

}

return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  string a,b;cin>>a>>b;
  a+=b;
  int c=stoi(a);
  int d=sqrt(c);
  if(c==d*d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i

M = []
A = []
R = []
C = []
H = []

pys = []

i = 0

n.times do
	pys << gets.chomp.split("").map(&:to_s)
end

pys.uniq!

while i < n

    if pys[i][0] == 'M'
	  M << pys[i].join
	end

	if pys[i][0] == 'A'
	  A << pys[i].join
	end

	if pys[i][0] == 'R'
	  R << pys[i].join
	end

	if pys[i][0] == 'C'
	  C << pys[i].join
	end

	if pys[i][0] == 'H'
	  H << pys[i].join
	end
	i += 1
end

puts (M.length*A.length*R.length)+(M.length*A.length*C.length)+(M.length*A.length*H.length)+(M.length*R.length*C.length)+(M.length*R.length*H.length)+(M.length*C.length*H.length)+(A.length*R.length*C.length)+(A.length*R.length*H.length)+(A.length*C.length*H.length)+(H.length*C.length*R.length)

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

using namespace std;

int main() {
    int n; cin >> n;
    string str; cin >> str;
    char prev = str[0];
    int ans = 1;
    for (int i = 1; i < str.size(); i++) {
        if (prev != str[i]) {
            ans++;
            prev = str[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
 
long long freq[26];
 
int main()
{
    
    int n;
    cin>>n;
    string s;
    cin>>s;
 
    long long mod=1e9+7;
 
    for(int i=0;i<n;i++)
    {
        freq[s[i]-'a']++;
 
    }
 
    long long ans=1;
 
    for(int i=0;i<26;i++)
    {
        if(freq[i]!=0)
 
        {
            ans*=(freq[i]+1);
            ans%=mod;
        }
    }
    cout<<ans-1<<endl;
 
 
}

Measured memory_bytes: 512
N = int(input())

pt, px, py = [0, 0, 0]
for _ in range(N):
    t, x, y = map(int, input().split())
    ts = abs(t - pt)
    xys = abs(x - px) + abs(y - py)
    if ts < xys:
        print('No')
        break

    if ts % 2 != xys % 2:
        print('No')
        break
    
    pt, px, py = t, x, y
else:
    print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>
int solve(int a, int b, int c) {
    int ta, tb, tc;
    int i = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        if(i >= 1000000) return -1;
        ta = a, tb = b, tc = c;
        a = tb / 2 + tc / 2;
        b = ta / 2 + tc / 2;
        c = ta / 2 + tb / 2;
        i++;
    }
    return i;
}
int main(void) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", solve(a, b, c));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){
  int n; cin>>n;
  vector<int> x(n); 
  REP(i,n)cin>>x[i];
  sort(ALL(x));
  ll res=MAX;
 
  FOR(p,x[0],x[n-1]+1){
     ll sum=0;
    for(auto xp:x)
     sum+=pow((xp-p),2);
      
      if(res>sum)res=sum; 
  }
cout<<res<<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		if (N == 1) {
			System.out.println("Yes");
			System.out.println(2);
			System.out.println(1 + " " + 1);
			System.out.println(1 + " " + 1);
			return;
		}
		int p = ok(N);
		if (p == -1) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");

		PrintWriter pw = new PrintWriter(System.out);
		ArrayList<Integer>[] s = new ArrayList[p];
		for (int i = 0; i < p; ++i) {
			s[i] = new ArrayList<>();
		}
		int cur = 1;
		for (int i = 0; i < p; ++i) {
			for (int j = i + 1; j < p; ++j) {
				s[i].add(cur);
				s[j].add(cur);
				++cur;
			}
		}
		if (cur - 1 != N)
			throw new AssertionError();
		System.out.println(p);
		for (int i = 0; i < p; ++i) {
			System.out.print(s[i].size() + " ");
			for (int j = 0; j < s[i].size(); ++j) {
				System.out.print(s[i].get(j) + (j == s[i].size() - 1 ? "\n" : " "));
			}
		}
		System.out.println();
		pw.close();
	}

	int ok(int N) {
		for (long i = 2; i <= 100000; ++i) {
			if (i * (i - 1) == 2 * N) {
				return (int) i;
			}
		}
		return -1;
	}

	static class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

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

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

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

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

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			return (int) nextLong();
		}
	}

	public static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 62728
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int n;
  cin >> n;
  float ans = 2 * n * 3.1415926535;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,c;
int main()
{
	map<int,int> m;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		m[a]++;
	}	
	bool no=false;
	map<int,int> ::iterator it;	
	for(it=m.begin();it!=m.end();it++)
		if(it->second>1)
		{
			no=true;
			break;
		}	
	if(no==true)
		 cout<<"NO"<<endl;	
	else
		cout<<"YES"<<endl;	 
} 

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int MAXN = 123456*2;
bool is_prime[MAXN+1];

int main() {
    int lim = (int)sqrt(MAXN);

    for(int i = 0; i <= MAXN; ++i) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= MAXN; ++i) {
        if(is_prime[i]) {
            if(i < lim) {
                for(int j = i*i; j <= MAXN; j += i) {
                    is_prime[j] = false;
                }
            }
        }
    }

    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        int cnt = 0;
        for(int i = N+1; i <= N*2; ++i) {
            if(is_prime[i]) ++cnt;
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 0
using System;

public class Program
{
    public static void Main()
    {
        while (true)
        {
            string input = Console.ReadLine();
            if (string.IsNullOrEmpty(input)) break;   //??\?????????????????°??????
            decimal[] num = Array.ConvertAll(input.Split(' '), value => decimal.Parse(value));
            Console.WriteLine(Math.Round((num[2]*num[4]-num[5]*num[1])/(num[4]*num[0]-num[1]*num[3]), 3, MidpointRounding.AwayFromZero).ToString()+" "+(Math.Round((num[2]*num[3]-num[5]*num[0])/(num[1]*num[3]-num[4]*num[0]), 3, MidpointRounding.AwayFromZero)).ToString());
        }
    }
}

Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
ll sum[maxn];
int find(int L,int R){
	if(L==R) return L;
	int l=L,r=R;
	while(L<=R){
		int Mid=(L+R)>>1;
		if(abs(sum[r]-sum[Mid]-sum[Mid]+sum[l-1])<abs(sum[r]-sum[Mid+1]-sum[Mid+1]+sum[l-1])) R=Mid-1;
		else L=Mid+1;
	}
	return R+1;
}
int main(){
	int n=read();
	REP(i,1,n) sum[i]=sum[i-1]+read();
	ll ans=1e18;
	REP(i,0,n){
		int l=find(0,i),r=find(i+1,n);
		ll Max=max(sum[i]-sum[l],sum[l]);
		chkmax(Max,max(sum[n]-sum[r],sum[r]-sum[i]));
		ll Min=min(sum[i]-sum[l],sum[l]);
		chkmin(Min,min(sum[n]-sum[r],sum[r]-sum[i]));
		chkmin(ans,Max-Min);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int N,L;
  cin >> N >> L;
  string S[120];
  for(int i=0 ; i < N ; i++) cin >> S[i];

  sort(S,S+N);

  for(int i=0; i<N ; i++) cout << S[i];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,k;
    cin>>a>>b>>k;
    cout<<max(0ll,a-k)<<" "<<max(0ll,b-max(0ll,k-a))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, d;
  cin >> x >> d;

  int64_t xi, yi, tmp;
  int ans = 0;
  double kyori;
  
  for(int i=0; i<x; i++) {
    cin >> xi >> yi;
    
    tmp = xi*xi + yi*yi;
    kyori = sqrt(tmp);

    // cout << "debug:x=" << xi << ",y=" << yi << ",tmp=" << tmp << " - " << kyori << endl;

    if(kyori <= d) {
      ans = ans + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 1e6+5, M = 1e6+6, OO = 0x3f3f3f3f;
int n, m;
int main()
{
    // FIO
    double r;
    cin>>r;
    cout<<2 * 3.141592 * r;
    return 0;
}

Measured memory_bytes: 3784
/*
**    When you consciously choose to be ordinary,
**    You become extraordinary.
**    -- Sadhguru
**
**    Author : Dhiraj Govindvira
**      Date : 05-Sep-2020 ~ Saturday
**      Time : 06:39:34 PM
*/

#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    char c;
    cin >> c;
    cout << ((isupper(c)) ? "A" : "a") << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
int main()
{
    int x, i;
    i = 1;
    x = 0;
    
    while (1) {
        scanf ("%d", &x);
        if (x == 0 || x < 1 || x > 10000) {
            break;
        }
        printf ("Case %d: %d\n", i, x);
        i++;
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define int long long

signed main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		// cout << tmp << endl;
		tmp *= n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
		// cout << tmp << endl;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;

vector<bool> IsPrime;
vector<int> primes;

void sieve(int max) {
    IsPrime.resize(max + 1, true);
    IsPrime[0] = IsPrime[1] = false;
    for (int i = 2; i * i <= max; ++i){
        if (IsPrime[i]){
            for (int j = i * i; j <= max; j += i) IsPrime[j] = false;
        }
    }
    for(int i = 0; i <= max; ++i) if(IsPrime[i]) primes.push_back(i);
}

int main(){
    int l, r;
    cin >> l >> r;
    sieve(int(sqrt(r)+0.1));

    vector<int> cnt(r-l+1), a(r-l+1);
    for(int i=0;i<r-l+1;i++){
        a[i] = l+i;
    }
    for(auto p : primes){
        for(int x=(l+p-1)/p*p; x<=r; x+=p){
            int idx = x-l;
            while(a[idx]%p == 0){
                cnt[idx]++;
                a[idx] /= p;
            }
        }
    }
    int ans = 0;
    for(int i=0;i<r-l+1;i++){
        if(a[i]!=1) cnt[i]++;
        if(IsPrime[cnt[i]]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10808
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(), A[]=new int[n];
		for(int i=0;i<n;i++)A[i]=in.nextInt();
		trace(A);
		insertSort(A);
	}
	
	static void insertSort(int[] A) {
		for(int i=1;i<A.length;i++) {
			int v=A[i], j=i-1;
			while(j>=0 && A[j]>v) {
				A[j+1]=A[j];
				j--;
			}
			A[j+1]=v;
			trace(A);
		}
		
	}
	
	static void trace(int[] A) {
		for(int i=0;i<A.length-1;i++)System.out.print(A[i]+" ");
		System.out.println(A[A.length-1]);
	}

}



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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    string s;
    cin>>s;
    char ch=s[0];
    int count=0;
    ffor(i,0,4) if(s[i]==ch) count++;
    if(count!=2)
    {
        cout<<"No"; return 0;
    }
    ffor(i,0,4)
    {
        if(s[i]!=ch)
        {
            ch=s[i];
            break;
        }
    }
    count=0;
    ffor(i,0,4) if(s[i]==ch) count++;
    if(count!=2)
    {
        cout<<"No"; return 0;
    }
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string n;
	cin >> n;

	int sz = n.size();
	int max_sum = (sz - 1) * 9;
	int curr = 0;
	for (int i = 0; i < sz; ++i) {
		curr += (n[i] - '0');
	}

	max_sum = max(max_sum, curr);
	curr = 0;
	for (int i = 0; i < sz; ++i) {
		if (n[i] > '1') {
			curr = (n[i] - '0' - 1) + (sz - i - 1) * 9;
			max_sum = max(max_sum, curr);
		}
	}

	cout << max_sum << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;


int main() {
	int A, B;
	cin >> A >> B;

	int ans = 0;
	for (int i = A; i <= B; i++)
	{
		string str = to_string(i);
		if (str[0] == str[4] && str[1] == str[3]) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/**
 *    Author:  AKASH-ALAM       
**/
#include <bits/stdc++.h>
#define endl        '\n'
#define pi          2*acos(0.0)
#define pb(a)       push_back(a)
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define mod         1000000007
#define inf         1000000000000000001
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b) 
#define Fast_io    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 32001
using namespace std;

int main(){
    Fast_io;
    char s[3];  cin >> s;
    int count = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R') count++;
    }
    if(s[1] == 'S' && count != 1 && count != 0) count--;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
bool r[100001];
int b[100001],N,M,xx,yy,num;
int main()
{
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)b[i]=1;r[1]=1;num=1;
	while(M--)
	{
		scanf("%d%d",&xx,&yy);
		if(b[xx]>0)
		{
			if(r[xx])
			{
				if(r[yy]==0){r[yy]=1;num++;}
				if(b[xx]==1){r[xx]=0;num--;}
			}
		b[xx]--;b[yy]++;
		}
	}
	cout<<num<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>


void bfs(int node, vi &seen, vi &answer, vector<set<int>> graphdata){
  
  seen.at(node)=1;
  
  queue<int> q;
  q.push(node);
  
  while (!q.empty()){
    int u=q.front();
    q.pop();
    for (int next:graphdata.at(u)){
      if (seen.at(next)==0){
        answer.at(next)=u;
        seen.at(next)=1;
        q.push(next);
      }
    }
  }
}


int main(){
  

  int n,m;
  cin>>n>>m;
  
  vector<set<int>> graphdata(n+1,set<int>());
  
  
  rep(i,m){
    int a,b;
    cin>>a>>b;
    graphdata.at(a).insert(b);
    graphdata.at(b).insert(a);
  }
  
  vi seen(n+1,0);
  vi answer(n+1);
  
  bfs(1,seen,answer,graphdata);
  
  cout<<"Yes"<<endl;
  
  for (int i=2;i<=n;i++){
    cout<<answer.at(i)<<endl;
  }
  
  
  

  
  
  
  
  
  
      
 

  
}

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

int main() {
string S; string T;
  cin>>S>>T;
  int A=0;
  for(int i=0; i<3; i++){
    if(S.at(i)==T.at(i)){
      A++;
    }
  else continue;
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
ll MAX_INF = 1e15;
ll MIN = -1;
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    ll dp[5][100005];
    for (int i = 0; i < n; i++)
    {
        dp[0][i + 1] = max(dp[1][i], dp[2][i]) + a[i];
        dp[1][i + 1] = max(dp[0][i], dp[2][i]) + b[i];
        dp[2][i + 1] = max(dp[0][i], dp[1][i]) + c[i];
    }
    ll ans = max({dp[0][n], dp[1][n], dp[2][n]});
    cout << ans << endl;
}

Measured memory_bytes: 5120
import java.util.*;
    import java.lang.*;
    import java.io.*;
     
    class Main
    {
    	public static void main (String[] args) throws java.lang.Exception
    	{
    		Scanner io = new Scanner(System.in);
    		int n = io.nextInt();
    		String a = io.next(), b = io.next();
    		for(int i = 0; i < n; i++)
    			System.out.print(""+a.charAt(i)+b.charAt(i));
    		System.out.println();
    	}
    }

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF = (1LL << 62);
const double inf = pow(10, 10);
double pi = 3.141592653589793;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};

int main()
{
  string s, t;
  ll n;
  cin >> n;
  cin >> s >> t;
  string ans;
  for (int i = 0; i < s.size();i++){
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
}

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

int main(void){
    int w,h,temp_w,temp_h;

	while(1){
		scanf("%d %d", &w, &h);
		temp_w = w;
		temp_h = h;

		for(;w != 0;w--){
			for(;h != 0;h--){
				if(w == temp_w || w == 1){
					printf("#");
				}else{
					if(h == temp_h || h ==1){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
			h = temp_h;
		}
		if(w == 0 && h == 0){
			break;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		sc.close();
		System.out.println(P + Q + R - (Math.max(P, Math.max(Q, R))));
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>
int main(void)
{
    int i,j,len,flag;
    char s[200],p[100],ss[100];
    scanf("%s",s);
    scanf("%s",p);
    len=strlen(p);
    strcpy(ss,s);
    strcat(s,ss);
    flag=0;
    for(i=0;i<100;i++){
        for(j=0;j<len;j++){
            if(s[i+j] != p[j]) break;
        }
        if(j==len) flag++;
    }
    if(flag==0) printf("No\n");
    else printf("Yes\n");
    return 0;
}

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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string bit;
string pattern[2];

int sw(string b,string p){
	int n=b.size();
	int res=0;
	for(int i=0;i<n;++i){
		if(b[i]==p[i])
			continue;
		for(int j=i+1;j<n;++j){
			if(b[j]==p[i]){
				res+=(j-i);
				swap(b[i],b[j]);
				break;
			}
		}
	}
	if(b==p)
		return res;
	return inf;
}

int run[15];

int main(void){
	int n,m;
	cin >> n >> m;
	rep(i,n){
		int in;
		cin >> in;
		bit+=(in+'0');
	}
	rep(i,m) cin >> run[i];

	rep(i,2){
		int cur=i;
		rep(j,m){
			rep(k,run[j]) pattern[i]+=('0'+cur);
			cur^=1;
		}
	}
	cout << min(sw(bit,pattern[0]),sw(bit,pattern[1])) << endl;
	return 0;
}

Measured memory_bytes: 1216
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  inputStr = input[1].split(" ");
  const B = inputStr.map(inputStr => Number.parseInt(inputStr));
  //格納用配列
  var ans = 0;
  ans += B[0];
  for(var i=1 ; i<N-1 ; i++ ){
    if(B[i]>B[i-1]){
      ans += B[i-1];
    } else {
      ans += B[i];
    }
  }
  ans += B[N-2];
  
  //結果出力
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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(){

	lli a,b,k;
	cin>>a>>b>>k;

	lli cnt=0;

	vector<lli> ans;

	REP(i,1,100000){
		if((a%i)==0 && (b%i)==0){
			ans.push_back(i);
		}
	}

	sort(ans.rbegin(),ans.rend());

	cout<<ans[k-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

H, W = map(int, input().split())

RED = ["" for _ in range(H)]
BLUE = ["" for _ in range(H)]
for y in range(H):
    s = input()
    RED[y] = s
    BLUE[y] = s
RED[0] = '#' * W
BLUE[-1] = '#' * W
for y in range(0, H-1):
    tmp = ''
    for x in range(0, W):
        if RED[y][x] == '#' or x % 2 == 0:
            tmp += '#'
        else:
            tmp += '.'
    RED[y] = tmp
for y in range(1, H-1):
    tmp = ''
    for x in range(0, W):
        if BLUE[y][x] == '#' or x % 2 != 0:
            tmp += '#'
        else:
            tmp += '.'
    BLUE[y] = tmp

for w in RED:
    print(w)
print()
for w in BLUE:
    print(w)


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

string func(int N, vector<int> vec, set<int> S) {
  
  if (S.size() > 2) return "No";
  
  else if (S.size() == 2) {
    
    int a = *rbegin(S);
    S.erase(a);
    int b = *rbegin(S);
    
    if (a-b != 1) return "No";
    
    int i = 0, j = 0;
    
    for (int k = 0; k < N; k++) {
      if (vec[k] == a) i++;
      else j++;
    }
    
    if ((a-j)*2 <= i && j <= b) return "Yes";
    else return "No";
    
  }
  
  else {
    
    int a = *rbegin(S);
    if (a == N - 1 || N >= 2*a) return "Yes";
    else return "No";
    
  }
  
}

int main() {

  int N;
  cin >> N;
  
  vector<int> vec(N);
  set<int> S;
  
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
    S.insert(vec[i]);
  }
  
  cout << func(N, vec, S) << endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};

int g[54][54];
bool used[54][54][4];
bool goal[4];
bool flag;
int h, w;

void dfs(int i, int j, int dir){
    
    int migi_i = i + di[(dir + 3) % 4];
    int migi_j = j + dj[(dir + 3) % 4];
    int mae_i = i + di[dir];
    int mae_j = j + dj[dir];
    
    /*
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
    */
    
    if(i == h and j == 1) goal[1] = true;
    if(i == 1 and j == w) goal[2] = true;
    if(i == h and j == w) goal[3] = true;

    int cnt = 0;
    for(int i = 1; i < 4; i++) if(goal[i]) cnt++;
    if(i == 1 and j == 1 and cnt == 3) flag = true;

    // (1) 右が空いてたら、右に曲がる
    if(g[migi_i][migi_j] == 1){
        int ni = migi_i;
        int nj = migi_j;
        int ndir = (dir + 3) % 4;
        if(!used[ni][nj][ndir]){
            used[ni][nj][ndir] = true;
            g[ni][nj] = 0;
            dfs(ni, nj, ndir);
        }
    }
    
    // (2) 右が塞がっていて、かつ、前が空いてたら、直進する
    if(g[migi_i][migi_j] == 0 and g[mae_i][mae_j] == 1){
        int ni = mae_i;
        int nj = mae_j;
        int ndir = dir;
        if(!used[ni][nj][ndir]){
            g[ni][nj] = 0;
            used[ni][nj][ndir] = true;
            dfs(ni, nj, ndir);
        }
    }
    

    // (3) 右も左も塞がっていたら、左に曲がる
    if(g[migi_i][migi_j] == 0 and g[mae_i][mae_j] == 0){
        int ni = i;
        int nj = j;
        int ndir = (dir + 1) % 4;
        if(!used[ni][nj][ndir]){
            g[ni][nj] = 0;
            used[ni][nj][ndir] = true;
            dfs(ni, nj, ndir);
        }
    }
    
    if(i == h and j == 1) goal[1] = false;
    if(i == 1 and j == w) goal[2] = false;
    if(i == h and j == w) goal[3] = false;


}

signed main(){
    
    while(1){

        cin >> h >> w;
        if(h == 0) break;
        memset(g, 0, sizeof(g));
        memset(used, false, sizeof(used));
        memset(goal, false, sizeof(goal));

        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                char c; cin >> c;
                if(c == '.') g[i][j] = 1;
            }
        }
        
        int dir = 0;
        int si = 1;
        int sj = 1;
        
        flag = false;
        dfs(si, sj, dir);
        if(flag) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
int main() {
    ll n, x;
    cin >> n >> x;
    cout << fixed << paty_counter(n, x) << endl;
}



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

int main(){
    string s1, s2, s3;

    cin >> s1 >> s2;

    s3 = s2.substr(0, s2.length() - 1);

    if(s1.length() < s2.length() && s1 == s3){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	int ans = 0;
	for(int i = k; i <= n + 1; i++) {
		ans += (n * (n + 1) / 2) - ((n - i) * (n - i + 1) / 2) - ((i - 1) * i / 2) + 1;
		ans %= mod;
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int,int> mp;
    int tmp;
    while(n--){
        cin>>tmp;
        mp[tmp-1]++;
        mp[tmp]++;
        mp[tmp+1]++;
    }
    int result=0;
    for(auto &x:mp){
        result=max(result,x.second);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=100010;
int n,m,mn=MAXN,mx;
ll a[MAXN],p=1;
int gcd (int a,int b) {return (b==0?a:gcd(b,a%b));}
int main () {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		p=(p/gcd(p,a[i]/2))*a[i]/2;
		if (p>m) {
			printf("0\n");
			return 0;
		}
		int tmp=0;
		while (!(a[i]&1)) {tmp++,a[i]>>=1;}
		mn=min(mn,tmp),mx=max(mx,tmp);
	}
	if (mn!=mx) {
		printf("0\n");
		return 0;
	}
	printf("%d\n",(m/p+1)/2);
	return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;

    ll sum = 0;
    for(int i=1; i<=n; i++){
        if(i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }

    cout << sum << endl;

    return 0;
}

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

int di[] = {0, 1, 0, -1};
int dj[] = {1, 0, -1, 0};

void setComponentByDFS(int i, int j, int comp_cnt, vector<string> &A, vector<vector<int>> &component, int H, int W) {
  component[i][j] = comp_cnt;
  for (int k = 0; k < 4; ++k) {
    int ni = i + di[k], nj = j + dj[k];
    if(ni >= 0 && ni < H && nj >= 0 && nj < W && A[ni][nj] == '.' && component[ni][nj] == -1)
      setComponentByDFS(ni, nj, comp_cnt, A, component, H, W);
  }
}

int main() {
  int H, W; cin >> H >> W;
  int Ch, Cw; cin >> Ch >> Cw;
  int Dh, Dw; cin >> Dh >> Dw;
  vector<string> A(H);
  for (int i = 0; i < H; ++i) cin >> A[i];
  // DFS를 이용하여 component로 묶기
  vector<vector<int>> component(H, vector<int>(W, -1));
  int comp_cnt = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if(A[i][j] == '.' && component[i][j] == -1) {
        setComponentByDFS(i, j, comp_cnt++, A, component, H, W);
      }
    }
  }
//   for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j)
//     cout << component[i][j] << " \n"[j == W - 1];
  // 각 component 들이 magic move를 통해 연결될 수 있는지 확인
  vector<set<int>> adj(comp_cnt);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if(A[i][j] == '.') {
        for (int xi = -2; xi <= 2; ++xi) {
          for (int xj = -2; xj <= 2; ++xj) {
            int ni = i + xi, nj = j + xj;
            if(ni >= 0 && ni < H && nj >= 0 && nj < W && A[ni][nj] == '.')
              adj[component[i][j]].insert(component[ni][nj]);
          }
        }
      }
    }
  }
  // BFS를 통해 최단거리를 계산함
  queue<int> Q;
  int src = component[Ch - 1][Cw - 1], dst = component[Dh - 1][Dw - 1];
  vector<int> dist(comp_cnt, -1);
  dist[src] = 0;
  Q.push(src);
  while(!Q.empty()){
    int here = Q.front(); Q.pop();
    for (auto next : adj[here]) {
      if(dist[next] == -1) {
        dist[next] = dist[here] + 1;
        Q.push(next);
      }
    }
  }
  cout << dist[dst] << endl;
  return 0;
}

Measured memory_bytes: 41200
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }
    print!("{}", s[0]);
    print!("{}", s.len()-2);
    println!("{}", s[s.len()-1]);
}

Measured memory_bytes: 4352
n, m = map(int, input().split())
max_l = 0
min_r = 10**5
for i in range(m):
  l, r = map(int, input().split())
  if l > max_l:
    max_l = l
  if r < min_r:
    min_r = r
max_l = min(n+1, max_l)
min_r = min(n+1, min_r)
res = min_r - max_l + 1
if res<0:
  res = 0
print(res)

Measured memory_bytes: 9208
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
b = [None for _ in range(n)]

cent = n//2
if n % 2 == 0:
    for i in range(n):
        if i%2 == 0:
            b[cent+ i//2] = a[i]
        else:
            b[cent-(i//2 +1)] = a[i]
else:
    for i in range(n):
        if i % 2 == 0:
            b[cent-i//2] = a[i]
        else:
            b[cent+i//2 +1] = a[i]

print(' '.join([str(x) for x in b]))


Measured memory_bytes: 29764
#include <stdio.h>

#define ROW_MAX 10
#define COLUMN_MAX 10000

bool osenbei[ROW_MAX][COLUMN_MAX];
int r, c, bake_max;

inline int count() {
	int cnt = 0;
	int i, j;

	for (i = 0; i < c; i++) {
		int tmp;
		for (j = tmp = 1; j < r; j++) {
			if (osenbei[j][i] == osenbei[0][i]) {
				tmp++;
			}
		}

		if (tmp < r - tmp) {
			cnt += r - tmp;
		}
		else {
			cnt += tmp;
		}
	}

	return cnt;
}

inline void step(int n) {
	int i;
	if (n--) {
		step(n);
		for (i = 0; i < c; i++) {
			osenbei[n][i] ^= 1;
		}
		step(n);
	}
	else {
		int tmp = count();
		if (bake_max < tmp) {
			bake_max = tmp;
		}
	}
}

int main() {
	int i, j;

	while (scanf("%d%d", &r, &c), r | c) {
		for (i = 0; i < r; i++) {
			for (j = 0; j < c; j++) {
				osenbei[i][j] = (getchar() | getchar()) & 1;
			}
		}

		bake_max = 0;
		step(r);
		printf("%d\n", bake_max);
	}

	return 0;
}

Measured memory_bytes: 2772