akhauriyash/Code-Regression huggingface dataset:
@s=<>=~/./g;
$\=100;
for$a(a..z){
	$c=0;
	for(@t=@s;grep!/$a/,@t;pop@t){
		for$i(0..$#t-1){
			if($t[$i+1]eq$a){
				$t[$i]=$a
			}
		}
		++$c
	}
	$\-=$-=$\-$c
}
print


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a, b, c, ans, mx;
int main () {
    cin >> a >> b >> c;
    mx = max(a, max(b, c));
    if (a >= b && a >= c)
	ans += (a - b) / 2 + (a - c) / 2;
    else if (b >= a && b >= c)
	ans += (b - a) / 2 + (b - c) / 2;
    else
	ans += (c - a) / 2 + (c - b) / 2;
    if (!(a % 2 == b % 2 && a % 2 == c % 2)) {
	int cur = 0;
	if (a % 2 == mx % 2)
	    cur++;
	if (b % 2 == mx % 2)
	    cur++;
	if (c % 2 == mx % 2)
	    cur++;
	if (cur == 2)
	    ans++;
	ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
program c
implicit none
integer(8) :: n,i,cut2,b1,c1,b2,c2,d1,e1,d2,e2,tmp1,tmp2,tmp3,tmp4
integer(8),parameter :: ten = 10
integer(8) :: ans = ten ** 15.
integer(8) :: a(200000)=0,s(200000)=0
integer(8) :: low,high,mid
double precision :: target

read(*,*) n
read(*,*) (a(i),i=1,n)

!まず累計和をとる
do i=1,n
	if(i == 1) then
		s(i) = a(i)
	else
		s(i) = s(i-1) + a(i)
	endif
enddo

!部分列Cの末尾のiをcut2とする
do cut2 = 2,n-2

	!部分列Bの末尾を2分探査する
	low = 1
	high = cut2-1
	target = s(cut2)/2.
	
	do while(low <= high)
		mid = (low + high) / 2
		if (s(mid) > target) then
			high = mid - 1
		else
			low = mid + 1
		endif
	enddo
	
	if(s(mid) > target) then
		mid = mid - 1
	endif
	
	b1 = s(max(mid,1))
	c1 = s(cut2)-b1
	b2 = s(min(mid+1,cut2-1))
	c2 = s(cut2)-b2

	!同様に部分列Dの末尾を2分探査する
	!部分列Bの末尾を2分探査する
	low = cut2+1
	high = n-1
	target = (s(n)-s(cut2))/2.
	
	do while(low <= high)
		mid = (low + high) / 2
		if (s(mid)-s(cut2) > target) then
			high = mid - 1
		else
			low = mid + 1
		endif
	enddo
	
	if(s(mid)-s(cut2) > target) then
		mid = mid - 1
	endif
	
	d1 = s(max(mid,cut2+1))-s(cut2)
	e1 = s(n)-s(cut2)-d1
	d2 = s(min(mid+1,n-1))-s(cut2)
	e2 = s(n)-s(cut2)-d2
	tmp1 = max(b1,c1,d1,e1)-min(b1,c1,d1,e1)
	tmp2 = max(b2,c2,d2,e2)-min(b2,c2,d2,e2)
	tmp3 = max(b1,c1,d2,e2)-min(b1,c1,d2,e2)
	tmp4 = max(b2,c2,d1,e1)-min(b2,c2,d1,e1)
	ans = min(ans,tmp1,tmp2,tmp3,tmp4)
	
enddo

	write(*,*) ans

end program

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> ans;
    for (int i = 0; i < k && a + i <= b; i++) ans.push_back(a + i);
    for (int i = 0; i < k && b - i >= a; i++) ans.push_back(b - i);
    sort(begin(ans), end(ans));
    for (auto itr = begin(ans), eitr = unique(begin(ans), end(ans)); itr != eitr; itr++) cout << *itr << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#define maxn 1000000
using namespace std;
int prime[maxn],number[maxn];
void getprime()
{
    int m=sqrt(maxn+0.5);
    for(int i=2;i<=m;i++)
    {
        if(!prime[i])
        {
            for(int j=i+i;j<maxn;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    int sum = 0;
    for(int i=2;i<maxn;i++)
    {
        if(!prime[i])
        {
            sum++;
        }
        number[i]=sum;
    }
}
int main ()
{
    int n;
    getprime();
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",number[n]);
    }
}
/**
--------------------- 
???zhaiqiming2010 
???CSDN 
???https://blog.csdn.net/zhaiqiming2010/article/details/62281598 
?????????????????????????
**/


Measured memory_bytes: 10976
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    String ans = "Yes";
    
    if(y%2 != 0||2*x > y||4*x < y){
      ans = "No";
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 35700
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	deque<int> dq;
	int N; cin >> N;
	REP(i, N) {
		int a; cin >> a;
		if (i % 2 == 0)dq.push_back(a);
		else dq.push_front(a);
	}
	while (!dq.empty()) {
		if (N % 2 == 0) {

			auto show = dq.front(); dq.pop_front();
			cout << show << " ";
		}
		else {
			auto show = dq.back(); dq.pop_back();
			cout << show << " ";
		}
	}
	cout << endl;






	return 0;
}


Measured memory_bytes: 4444
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b
end #for auto indent of eclipse

n = inp[0]
k = inp
min = 1e20
s1 = 0
s2 = k.inject(:+)
k.each do |d|
  s1 += d
  s2 -= d
  s = s1 - s2
  min = [min, s.abs].min
end
p min

#puts ()? "Yes" : "No"
#puts ()? "YES" : "NO"
#puts ()? "yes" : "no"

Measured memory_bytes: 3836
N,M = map(int,input().split())

adj = [list() for _ in range(N)]

for i in range(M):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)


res = 0

color = [None]*N

for x in range(N):
    if color[x] is not None:
        continue
    
    cnt = [0,1]
    stack = [x]
    color[x] = True
    flag = True
    while stack:
        v = stack.pop()
        c = not color[v]
        for u in adj[v]:
            if color[u] is None:
                stack.append(u)
                color[u] = c
                cnt[c] += 1
            elif flag:
                flag = c == color[u]

    if flag:
        res += cnt[0]*cnt[1]
    else:
        cnt = sum(cnt)
        res += cnt*(cnt-1)//2

print(res-M)



Measured memory_bytes: 22064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int i,j;
  cin>>s;
  for(i=0;i<s.length()-1;++i){
    for(j=i+1;j<s.length();++j){
      if(s[i]==s[j]){
        cout<<"no";
        return 0;
      }
    }
  }
  cout<<"yes";
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  
  for (int i=0; i<W+2; i++){
    cout << '#';
  }
  
  cout << endl;
  
  for (int i=0; i<H; i++){
    cin >> vec.at(i);
    string present;
    present = "#" + vec.at(i) + "#";
    vec.at(i) = present;
    cout << vec.at(i) << endl;
  }
    
  for (int i=0; i<W+2; i++){
    cout << '#';
  }
  
  cout << endl;  
}

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

int main(){ 
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T inv[N+1];
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i = 0; i < N; i++)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i = N-1; i >= 0; i--)
            ifact[i] = (ifact[i+1]*(i+1))%M;
        inv[0] = 0;
        for (int i = 0; i < N; i++)
            inv[i+1] = (fact[i]*ifact[i+1])%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ModFact<100000, ll, MOD> fact;

ll N;

int main() {
    fastio();
    ll N, ans = 0, prev, now;
    N = getint();
    prev = getint();
    // cin >> N;
    // cin >> prev;
    ll a = 0;
    REP(i, N-1) {
        now = getint();
        // cin >> now;
        a = (a + fact.inv[i+1]) % MOD;
        ans = (ans + a * (now - prev)) % MOD;
        prev = now;
    }
    cout << (ans * fact.fact[N-1])%MOD << "\n";
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	ld d, e;
	while (cin >> d >> e, d)
	{
		ld ans = INF;
		FOR(i, 0, d)
		{
			int j = d - i;
			chmin(ans, abs(sqrt(i*i + j*j) - e));
		}
		cout << D10 << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <utility>
#include <string>

using namespace std;

int main()
{
	vector<pair<int, pair<int, string> > > team;
	int n, pt[10][3];
	string str[10];
	bool flag = true;

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

		if(flag)    flag = false;
		else		cout << endl;

		for(int i = 0; i < n; i++)
			cin >> str[i] >> pt[i][0] >> pt[i][1] >> pt[i][2];

		for(int i = 0; i < n; i++)
			team.push_back(make_pair(((pt[i][0] * -3) - pt[i][2]), make_pair(i, str[i])));

		stable_sort(team.begin(), team.end());

		for(int i = 0; i < n; i++)
			cout << team[i].second.second << "," << -(team[i].first) << endl;
		
		team.clear();
	}

	return 0;
}

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

int main()
{
  string s, t; cin >> s >> t;
  reverse(s.begin(), s.end()); 
  reverse(t.begin(), t.end());
  if (t.size() > s.size()) {
	cout << "UNRESTORABLE" << endl;
	return 0;
  }
  bool found = false;
  for (int i = 0; i <= s.size() - t.size(); i++) {
	bool flag = true;
	for (int j = i; j < t.size()+ i; j++) {
	  if (s[j] != '?' && s[j] != t[j - i]) {
		flag = false;
		break;
	  }
	}
	if (flag) {
	  found = true;
	  for (int j = i; j < t.size() + i; j++) {
		s[j] = t[j - i];
	  }
	  break;
	}
  }
  if (!found) {
	cout << "UNRESTORABLE" << endl;
	return 0;
  }
  for (int i = 0; i < s.size(); i++) {
	if (s[i] == '?') {
	  s[i] = 'a';
	}
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}



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

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >>Y;
  int x[N],y[M];
  for(int i; i<N; i++){
    cin >>x[i];
  }
    for(int i; i<M; i++){
    cin >>y[i];
  }
  
int xm = X;
for(int i; i<N; i++){
  if(xm < x[i]){
  xm = x[i];
}
}
  
bool flag=true;
if(xm+1>Y){
  flag=false;
}
  
for(int i; i<M;i++){
  if(xm+1 > y[i]) flag=false;
}

if(flag == false){
  cout << "War" << endl;
}
  
if(flag == true){
 cout << "No War" << endl;
} 
// cout << y[0] <<endl;
// cout << y[1] <<endl;
// cout << xm <<endl;
  
}
  
  

Measured memory_bytes: 256
#include<stdio.h>
long long int modpow(long long int a, long long int n, long long int p)
{
	if (n < 0)
		return 0;
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i, j;
	long long int x[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &x[i]);
	long long int p = 1000000007;
	long long int ans = 0;
	long long int f = 1;
	for (i = 1; i < n; i++)
		f = f * i % p;
	long long int sum[100005];
	sum[0] = 0;
	for (i = 0; i < n; i++)
		sum[i + 1] = (sum[i] + modpow(i + 1, p - 2, p)) % p;
	for (i = 1; i < n; i++)
		ans = (ans + (x[i] - x[i - 1]) * f % p * sum[i] % p) % p;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1664
// inputに入力データ全体が入る
function Main(input) {
  var n = input.split(" ")[0];
  var d = input.split(" ")[1];
  console.log(Math.ceil(n/(2*d+1)));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    int x = 0;
    rep(i,n)x = x ^ a[i];
    int count[32] = {};
    rep(i,n){
        int a_ = a[i];
        int b = 0;
        while(true){
            if(a_ % 2 == 1){
                break;
            }else{
                a_ /= 2;
                b++;
            }
        }
        count[b]++;
    }
    vector<int> v;
    while(x>0){
        int x_ = x;
        int i = 0;
        while(x_>0){
            x_ /= 2;
            i++;
        }
        v.push_back(i-1);
        x = x ^ (int)pow(2,i-1);
        x = x ^ ((int)pow(2,i-1) - 1);
    }

    int ans = v.size();

    rep(i,ans){
        if(count[v[i]] == 0){
            cout << "-1" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 640
#include<iostream>

int main(){
  int x,y;
  std::cin >> x >> y;
  int t2 = y-2*x;
  if(t2>=0 && t2%2==0 && t2<=(2*x)){
    std::cout << "Yes\n";
  }else{
    std::cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
    
    S[++top] = x;
}

int pop(){
    top--;
    
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        } else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        } else{
            push(atoi(s));
        }
    }
    
    printf("%d\n",pop());
    
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int a[52], b[52];
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    int lar;
    for(lar = 0; lar < 50; lar++){
        bool able = true;
        for(int i = 0; i < n; i++){
            int dp[51] {0};
            dp[a[i]] = 1;
            for(int j = lar; j > 0; j--){
                for(int k = 0; k <= 50; k++){
                    dp[k % j] |= dp[k];
                }
            }
            if(dp[b[i]] == 0){
                able = false;
                break;
            }
        }
        if(able) break;
    }
    if(lar == 50){
        cout << -1 << endl;
        return 0;
    }
    bool use[52];
    fill(use, use + n, false);
    fill(use, use + lar + 1, true);
    for(int d = lar - 1; d > 0; d--){
        use[d] = false;
        bool able = true;
        for(int i = 0; i < n; i++){
            int dp[51] {0};
            dp[a[i]] = 1;
            for(int j = lar; j > 0; j--){
                if(!use[j]) continue;
                for(int k = 0; k <= 50; k++){
                    dp[k % j] |= dp[k];
                }
            }
            if(dp[b[i]] == 0){
                able = false;
                break;
            }
        }
        if(!able) use[d] = true;
    }
    ll ans = 0;
    ll id = 1;
    for(int i = 1; i <= lar; i++){
        id *= 2;
        if(use[i]) ans += id;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
mod = 10**9+7
n = int(input())
arr = list(map(int , input().split()))
dp = [ [0 for i in range(67)] for j in range(0, n+6)]
for i in range(n-1,0 , -1):
	for j in range( 0 , 61):
		dp[i+1][j]=dp[i+2][j]
	for j in range(0 , 61):
		if (arr[i] &(1<<j)):
			dp[i+1][j]+=1
ans = 0
for i in range(1 , n+1):
	for j in range(0 , 61):
		if (arr[i-1]&(1<<j)):
			ust = n-i-dp[i+1][j]
			ans = ans + (ust*(1<<j))
			ans = ans%mod
		else:
			st = dp[i+1][j]
			ans = ans+(st*(1<<j))
			ans = ans%mod
print(ans)

Measured memory_bytes: 287124
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std ;
typedef long long ll ;
int main(){
int A,B,C,X;
int count = 0;
cin >> A >> B >> C >> X;
for (int i = 0; i<=A;i++){
    for (int j = 0; j <= B; j++){
        for (int k = 0; k <= C; k++){
            if (X == 500*i+100*j+50*k){
                count += 1;
            }
        }
    }
}

cout << count << endl;
// 


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t A, x,answer;
  int N, K;
  answer=0;
  cin >> N >> K;
  for(x=K;x<N+2;x++){
    A=x*N+1-x*(x-1);
    answer=(answer+A)%1000000007;
  }
  cout << answer%1000000007 << endl;
}



Measured memory_bytes: 3644
#include <cstdio>
#include <string>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

int main() {
    int a;
    scanf("%d", &a);
    if (a < 1200) printf("ABC\n");
    else printf("ARC\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\n'

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{
    ll n;
    cin>>n;
    cout<<!n<<endl;
    return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
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();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

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

    LL N;
    cin >> N;

    LL x[N];
    LL y[N] = {0};

    REP(i,N){
        cin >> x[i];
        y[i] = x[i];
    }


    sort(y, y + N);


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

        if( x[i] < y[N/2]){
            cout << y[ N/2] << endl;
        }else{
            cout << y[ N/2 -1] << endl;
        }
    }



    return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

class Main {
    public static void main(String[] z) {
        Scanner sc = new Scanner(System.in);
        int[] l=new int[sc.nextInt()];
        for(int i=0;i<l.length;i++) {
            l[i]=i;
        }
        int n=sc.nextInt();
        while(n-->0) {
            String[] lines=sc.next().split(",");
            int a=Integer.parseInt(lines[0])-1;
            int b=Integer.parseInt(lines[1])-1;
            int temp=l[a];
            l[a]=l[b];
            l[b]=temp;
        }
        for(int i:l) {
            System.out.println(i+1);
        }
    }
}



Measured memory_bytes: 26340
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 2e5 + 100;

void nhap()
{
}

void solve()
{
    int a,b,c;
    cin >> a >> b >> c;
    if (a + b >= c - 1) {
        cout << b + c;
        return;
    }
    cout << b + c - (c - 1 - a - b);
}
int main()
{
    nhap();
    solve();
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int n;
	cin >> n;
	cout << (n + 1) / 2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int f(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  cout << (n % f(n) == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<set<int>> v(26);
    rep(i, n){
        v[s[i] - 'a'].insert(i);
    }

    int q;
    cin >> q;
    rep(i, q){
        int t;
        cin >> t;
        if(t == 1){
            int k;
            char c;
            cin >> k >> c;
            k--;
            v[s[k] - 'a'].erase(k);
            v[c - 'a'].insert(k);
            s[k] = c;
        }else{
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int cnt = 0;
            rep(j, 26){
                auto it = v[j].lower_bound(l);
                if(it != v[j].end()){
                    if(*it <= r)cnt++;
                }
            }
            cout << cnt << endl;
        }
    }
    
}

Measured memory_bytes: 24196
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

vector <int> sieve_of_eratosthenes(int n) {
    vector <bool> is(n+1, true);
    vector <int> res;
    is[0] = false;
    is[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is[i]) {
            res.emplace_back(i);
            for (int j = i*2; j <= n; j+=i) {
                is[j] = false;
            }
        }
    }
    return res;
}

void solve(int n) {
    auto v = sieve_of_eratosthenes(n * 2);
    REP(i, v.size()) {
        if (v[i] > n) {
            cout << v.size() - i << endl;
            return;
        }
    }
    return;
}

int main(void) {
    int n, p, m, w, h;
    string s;
    int a, b, c;
    while (cin >> n) {
        if (n == 0) return 0;
        solve(n);
        //return 0;
    }
}

Measured memory_bytes: 3284
#include<stdio.h>
int main(void){

int H,W,i,j;

while(1){
scanf("%d %d",&H,&W);

if(H==0 && W==0) break;

for(i=0;i<H;i++){

for(j=0;j<W;j++){

printf("#");
}

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

return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,H,W;
	int a[10000];
	int c[100][100];
	scan(H);scan(W);scan(N);
	rep(i,N){
		scan(a[i]);
	}
	int iro=1;
	int x=0,y=0;
	while(y<H){
		if(a[iro-1]>0){
			c[y][x]=iro;
		}
		else if(a[iro-1]==0){
			iro++;
			c[y][x]=iro;
		}
		a[iro-1]--;
		if(y%2==0){
			if(x==W-1){
				y++;
			}
			else{
				x++;
			}
		}
		else{
			if(x==0){
				y++;
			}
			else{
				x--;
			}
		}
	}
	rep(i,H){
		rep(j,W){
			printf("%d ",c[i][j]);
		}
		kaigyo;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	long long int N, A, B; 
	cin >> N >> A >> B; 
	long long int H[114514] = {}; 
	for(int i = 0; i < N; i++){
		cin >> H[i]; 
	}
	long long int L = 0, R = 1e9; 
	while(R - L > 1){
		long long int K = (L + R) / 2; 
		long long int S = 0; 
		for(int i = 0; i < N; i++){
			S += (max(H[i] - K * B, (long long) 0) + A - B - 1) / (A - B); 
		}
		if(S > K){L = (L + R) / 2;}
		else if(S <= K){R = (L + R) / 2;}
	}
	cout << R << endl; 
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main(){
    int n;
    cin>>n;
    cout<<n*(n+1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b,c,x,ans=0;
    cin >> a >> b >> c >> x;

    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            int k=(x-500*i-100*j)/50;
            if(0 <= k && k <= c) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	string s;
	cin >> s;
	vector<int> a(1000);
	for (int i = 0; i < s.size(); i++) {
		if (a.at(s.at(i)) == 1) {
			cout << "no" << endl;
			return 0;
		}
		a.at(s.at(i))++;
	}
	cout << "yes" << endl;
}



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

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

// code
// ------------------------------------------------
int main() {

  string s;
  cin >> s;

  s[3] = '8';

  cout << s;



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
N, M, C = map(int, raw_input().split())
B = map(int , raw_input().split())
ans = 0
for i in range(0, N):
    A = map(int , raw_input().split())
    tmp = [A[m] * B[m] for m in range(M)]

    if sum(tmp) + C > 0:
        ans+=1

print(ans)


Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
#define l_ength size
typedef long long ll;
typedef pair<int, int> P;
vector<P> v,u;

int a[555][555];

int main(void){
int h, w, i, j, n=0,x,y,p;
bool flag=false;
cin >> h >> w;
for(i=0;i<h;++i){
for(j=0;j<w;++j){
cin >> a[i][j];
}
}
for(i=0;i<h;++i){
for(j=0;j<w;++j){
if(i%2){ p = w-j-1; }else{ p = j; }
if(flag){
v.push_back(P(x,y));
u.push_back(P(i,p));
++n;
}
if(a[i][p]%2){
flag = (!flag);
}
x = i; y = p;
}
}
cout << n << endl;
for(i=0;i<n;++i){
cout << (v[i].first+1) << " " << (v[i].second+1) << " " << (u[i].first+1) << " " <<  (u[i].second+1) << endl;
}
return 0;
}


Measured memory_bytes: 5356
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define int64 long long

int main()
{
	int64 dd, gg, min = LLONG_MAX, xx;
	scanf("%lld %lld", &dd, &gg);
	int64 pp[dd], cc[dd], score[dd];
	for(int64 ii = 0;ii < dd;ii++)
	{
		scanf("%lld %lld", &pp[ii], &cc[ii]);
		score[ii] = pp[ii] * (ii + 1) * 100 + cc[ii];
	}
	int64 tmp, kosu;
	for(int64 bit = 0;bit < (1 << dd);bit++)
	{
		tmp = 0;
		kosu = 0;
		for(int64 ii = 0;ii < dd;ii++)
		{
			if(bit & (1 << ii))
			{
				tmp += score[ii];
				kosu += pp[ii];
			}
		}
		if(tmp < gg)
		{
			for(int64 ii = dd - 1;ii >= 0;ii--)
			{
				if(!(bit & (1 << ii)))
				{
					xx = (gg - tmp) / ((ii + 1) * 100);
					if((gg - tmp) % ((ii + 1) * 100))
					{
						xx++;
					}
					if(xx > pp[ii])
					{
						break;
					}
					tmp += xx * (ii + 1) * 100;
					kosu += xx;
					break;
				}
			}
		}
		
		if(min > kosu && tmp >= gg)
		{
			min = kosu;
		}
	}
	printf("%lld\n", min);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a;
  for(int i=0;i<n;i++){
    a.push_back(0);
  }
  int k;
  for(int i=1;i<n;i++){
    cin >> k;
    a[k-1]++;
  }
  for(int i=0;i<n;i++){
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4324
from time import time
from random import random

limit_secs = 2
start_time = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

def calc_score(t):
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution():
    t = None
    score = -1
    for i in range(26):
        nt = [(i + j) % 26 for j in range(D)]
        if calc_score(nt) > score:
            t = nt
    return t

t = solution()
score = calc_score(t)
while time() - start_time + 0.15 < limit_secs:
    d = int(random() * D)
    q = int(random() * 26)
    old = t[d]
    t[d] = q
    new_score = calc_score(t)
    if new_score < score:
        t[d] = old
    else:
        score = new_score
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 84776
a = list(open(0))

for i in a:
    s = i.replace('\n','')
    ss = s.split(' ')

txt = []
for i in ss:
    txt.append(int(i))
txt = sorted(txt)

res = 0
for j in range(len(txt))[:-1]:
    if j == 0:
        res += (txt[j] + txt[j+1]) / 2
    else:
        res = (res + txt[j+1]) / 2
print(res)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int MAX = 1000000000;
const int MOD = 1000000007;
int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll xa=1,ya=1,xb=1,yb=1;
  REP(i,a){
    xa*=(n-i);xa%=MOD;
  }
  REP(i,a){
    ya*=(i+1);ya%=MOD;
  }
  REP(i,b){
    xb*=(n-i);xb%=MOD;
  }
  REP(i,b){
    yb*=(i+1);yb%=MOD;
  }
  ll ans=modPow(2,n,MOD)-1,A=mod(xa*modPow(ya,1e9+5,MOD),MOD),B=mod(xb*modPow(yb,1e9+5,MOD),MOD);
  cout<<mod(ans-A-B,MOD)<<endl;
}

Measured memory_bytes: 256
//////// Takoyaki 
// https://atcoder.jp/contests/abc176/tasks/abc176_a
// date: 2020-08-22T21:00:10.586231
// memo: 
    
//<editor-fold desc="my macro">

#include<bits/stdc++.h>
#ifdef LOCAL
    #include<my/dump.h>
#else
    #define dump(...) 42 
    #define dumpi(x) 42 
#endif

typedef long long ll;
using namespace std;

#define foe(x, a) for(auto& (x) : (a))
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rep3(i, a, b) for(ll i=a, i##_len=(b);i<i##_len;i++)
#define _rep2(i, n) _rep3(i,0,n)
#define repd(...) _overload3(__VA_ARGS__,_repd3,_repd2,)(__VA_ARGS__)
#define _repd3(i, a, b) for(ll i=b-1, i##_len=(a);i>=i##_len;i--)
#define _repd2(i, n) _repd3(i,0,n)
#define loop(...) _overload3(__VA_ARGS__,,_loop2,_loop1)(__VA_ARGS__)
#define _loop2(i, a) for(ll i=a;; i++)
#define _loop1(i) _loop2(i,0)

#define all(x) x.begin(),x.end()
#define SIZE(x) ((ll)(x).size())

#define pb(a) push_back(a)
#define mp make_pair
#define F first
#define S second
#define vec vector
#define umap unordered_map
#define uset unordered_set

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

#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), 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<typename T, typename ...Args>
void ci(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args)); //C++17
}

template<char Sep, typename T, typename ...Args>
void print_seq(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args)); //C++17
}

void co(){ cout << endl; }
template<typename... Words>
void co(Words... words) {
    print_seq<' '>(words...);
    cout << endl;
}
#define coi(x) cout<<(x)<<" "

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define sankou(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define asrt(expr...) assert((expr))
//</editor-fold>

#define INF 1e19
#define MOD 1e9+7
#define MAXR 1e5

int solve() {
    ll N,X,T;
    ci(N,X,T);
    ll t = ((ll) ceil (N / (float)X)) * T;
    co(t);
    return 0;
}

int main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    
    solve();
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int s1 = a*b;
        int s2 = c*d;

        if(s1 < s2){
            System.out.println(s2);
        }else if(s1 > s2){
            System.out.println(s1);
        }else{
            System.out.println(s1);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
    #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 INF 2e9
    #define ALL(v) v.begin(), v.end()
    using namespace std;
    typedef long long ll;
    int main()
    {
      string s ;
      int a ;
      cin >> a >> s;
      if(a >= 3200){
        cout << s <<endl;
      }
      else{
        cout << "red" << endl;
      }
    }

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char s[11];
    int ns = 0;
    int nt = 20190501;

    scanf("%s",s);

    for(int i = 0; i < 10 ; i++){
        if(i != 4 && i != 7){
            ns *= 10;
            ns += s[i] - '0';
        }
    }

    if(ns < nt)printf("Heisei\n");
    else printf("TBD\n");

    return 0;
}

Measured memory_bytes: 128
H,W=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
ans_l=[[0]*W for i in range(H)]
for i in range(H):
   for j in range(W):
      if l[i][j] == ".":
         tmp=0
         for x in range(max(0,j-1),min(W-1,j+1)+1):
            for y in range(max(0,i-1),min(H-1,i+1)+1):
               if l[y][x]=="#":
                  tmp+=1
         ans_l[i][j]=str(tmp)
      else:
         ans_l[i][j]="#"
for i in ans_l:
   print(*i,sep="")

Measured memory_bytes: 9276
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Station and Bus
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 3;

/* typedef */

/* global variables */

char s[N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  int an = 0, bn = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'A') an++;
    else bn++;
  }

  if (an > 0 && bn > 0) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

int main()
{
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int xx=x2-x1,yy=y2-y1;
    int x3=x2-yy,y3=y2+xx;
    xx=x3-x2,yy=y3-y2;
    int x4=x3-yy,y4=y3+xx;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	const int maxn = 1e7 + 5;
	vector<int> f(maxn);

	for(int i = 1; i < maxn; i++)
		for(int j = i; j < maxn; j += i)
			f[j]++;

	int n;
	cin >> n;

	ll ans = 0;
	for(int k = 1; k <= n; k++)
		ans += 1ll * k * f[k];

	cout << ans << endl;


	return 0;	
}

Measured memory_bytes: 42200
/// meowa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
  
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

vector<int> v;

int n;

ll brute(int cur = 0) {
    if (cur == n) {
        bool z = 0, nn = 0;
        for (int x : v) {
            if (x == 0) {
                z = 1;
            }
            if (x == 9) {
                nn = 1;
            }
        }
        return (z & nn);
    }
    ll ans = 0;
    for (int i = 0; i < 10; ++i) {
        v.pb(i);
        ans += brute(cur+1);
        ans %= MOD;
        v.pop_back();
    }
    return ans%MOD;
}

const int N = 1e6;

ll dp[3][N];

int mult(ll a, ll b) {
    return (a * 1ll * b) % MOD;
}

int add(int a, int b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }
    return a;
}

void ma1n() {
    cin >> n;
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[0][i] = mult(dp[0][i-1], 8);
        dp[1][i] = add(mult(dp[1][i-1], 9), mult(dp[0][i-1], 2));
        dp[2][i] = add(mult(dp[2][i-1], 10), dp[1][i-1]);
    }
    cout << dp[2][n];// << " " << brute();
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 27016
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[][] a=new int[s[0]][];
		for(int i=0;i<s[0];i++){a[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}
		Array.Sort(a,(u,v)=>v[1]-u[1]);
		int[] h=new int[s[0]+1];
		long q=0,t=0,ans=0;
		for(int i=0,j=s[1]-1;i<s[0];i++){
			if(i<s[1]){
				if(h[a[i][0]]==0){t++;}
				h[a[i][0]]++;
				q+=a[i][1];
			}
			else if(h[a[i][0]]==0){
				while(j>0&&h[a[j][0]]<=1){j--;}
				if(j==0){break;}
				h[a[j][0]]--;
				q-=a[j][1];
				t++;j--;
				h[a[i][0]]++;
				q+=a[i][1];
			}
			ans=Math.Max(ans,t*t+q);
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 23500
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	n, _ := strconv.Atoi(readLine())
	as := strings.Split(readLine(), " ")

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(as[i])
	}

	x := make([]int, n)
	var asum int
	for i := 0; i < len(a); i++ {
		if i%2 == 0 {
			asum += a[i]
		} else {
			asum -= a[i]
		}
	}
	x[0] = asum / 2

	for i := 0; i < len(a)-1; i++ {
		x[i+1] = a[i] - x[i]
	}

	for i := 0; i < len(x); i++ {
		x[i] *= 2
	}

	for i, v := range x {
		if i == len(x)-1 {
			fmt.Println(v)
		} else {
			fmt.Print(fmt.Sprintf("%v ", v))
		}
	}
}


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

struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }
  vector<int> cnt(n, 0);
  for (int i = 0; i < n; i++) cnt[uf.find(i)]++;
  cout << *max_element(cnt.begin(), cnt.end()) << endl;
  return 0;
}


Measured memory_bytes: 4828
package main

import "fmt"

func main() {
	var x string
	fmt.Scan(&x)

	stack := make([]rune, 0)
	for _, c := range x {
		l := len(stack)
		p := '0'
		if l > 0 {
			p = stack[l-1]
		}
		if p == 'S' && c == 'T' {
			stack = stack[0 : l-1]
		} else {
			stack = append(stack, c)
		}
	}

	fmt.Println(len(stack))
}


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

int main() {
  int N;
  int min = 0;
  int before=1,countbefore,countafter;
  bool flag = false;
  cin >> N;
  int a[N+1];
  for(int i=1;i<=N;i++) cin >> a[i];

  int counter=1;
  for(int i=1;i<=N;i++){
    if(a[i]==counter) counter++;
    else min++;
  }
  
  if(min == N) cout << -1 << endl;
  else cout << min << endl;
  return 0;
}


Measured memory_bytes: 1024