akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * http://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		Map<Integer,Integer> d = new HashMap<Integer,Integer>();
		
		final int N = sc.nextInt();
		for(int i=0; i<N; i++){
			int j = sc.nextInt();
			int num = d.containsKey(j) ? d.get(j) : 0;
			d.put(j, num+1);
		}
		final int M = sc.nextInt();
		int[] t = new int[M];
		for(int i=0; i<M; i++) t[i] = sc.nextInt();
		sc.close();
		
		boolean ans = true;
		for(int i=0; i<M; i++){
			if(!d.containsKey(t[i]) || d.get(t[i])==0){
				ans=false;
				break;
			}else{
				d.put(t[i], d.get(t[i])-1);
			}
		}
		
		System.out.println(ans ? "YES" : "NO");

	}

}


Measured memory_bytes: 144644
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;

std::string S;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);
	in >> S;
	auto iter = "AKIHABARA";
	for (int32_t i = 0;;)
	{
		if (i == S.size()) {
			if (*iter == 'A') {
				++iter;
				continue;
			}
			if (*iter == '\0') { break; }
			out << "NO" << endl; return 0;
		}
		if (*iter == S[i]) {
			++iter;
			++i;
		}
		else if(*iter == 'A'){
			++iter;
			continue;
		}
		else {
			out << "NO" << endl; return 0;
		}
	}
	out << "YES" << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main()
{
  ll num = 0;
  int K, S;
  cin >> K >> S;
  for (int i = 0; i <= K && i <= S; i++)
  {
    for (int j = 0; j <= K && j <= S - i; j++)
    {
      int z = S - i - j;
      if (0 <= z && z <= K)
        num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args){
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int D=sc.nextInt();
		int[][] map=new int[H*W+1][2];
		int[][] ary=new int[H][W];
		int[][] ans=new int[D][H*W/D+2];
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				ary[i][j]=sc.nextInt();
				map[ary[i][j]][0]=i;
				map[ary[i][j]][1]=j;
			}
		}
		for(int i=0; i<D; i++) {
			for(int j=i; j<=H*W; j+=D) {
				if(j==i) {
					ans[i][0]=0;
				}
				else {
					ans[i][(j-i)/D]=Math.abs(map[j][0]-map[j-D][0])+Math.abs(map[j][1]-map[j-D][1]);
					ans[i][(j-i)/D]+=ans[i][(j-i)/D-1];
				}
			}
		}
		int Q=sc.nextInt();
		for(int i=0; i<Q; i++) {
			int from=sc.nextInt();
			int to=sc.nextInt();
			int mod=from%D;
			if(from<D) {
				System.out.println(ans[mod][(to-mod)/D]);
			}
			else{
				System.out.println(ans[mod][(to-mod)/D]-ans[mod][(from-mod)/D]);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 121556
#import <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n)  for(ll i = 0; i < (n); ++i)
#define  repp(i,n) for(ll i = 1; i <=(n); ++i)
#define  red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main(){
    ll l,r,mi=INF; cin>>l>>r;
    if(r-l>=2019)cout<<"0\n",exit(0);
    for(ll i=l;i<r;i++)for(ll j=i+1;j<=r;j++)mi=min((i*j)%2019,mi);
    cout<<mi<<endl;
}

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

string S, T;
vector<int> X[26];
typedef long long ll;

ll solve()
{
  ll q = 0, r = -1;
  for (int i = 0; i < T.size(); ++i)
  {
    int c = T[i] - 'a';
    if (X[c].empty())
    {
      return -1;
    }
    int k = upper_bound(X[c].begin(), X[c].end(), r) - X[c].begin();
    if (k == X[c].size())
    {
      ++q;
      r = X[c][0];
    }
    else
    {
      r = X[c][k];
    }
  }
  return q * S.size() + r + 1;
}

int main()
{
  cin >> S >> T;
  for (int i = 0; i < S.size(); ++i)
  {
    X[S[i] - 'a'].push_back(i);
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 1216
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main() {
    int n; cin >> n;
    int b[n-1];
    rep(i,n-1) cin >> b[i];

    int ans = b[0];
    for (int i = 1; i < n - 1; ++i) ans += min(b[i-1], b[i]);
    ans += b[n-2];

    out(ans);

    return 0;
}






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

const int MOD = 1e+09 + 7;

int main() {
    int64_t N,M;
    cin >> N >> M;
    if ( M > 0 ){
        vector<int64_t> a(M);
        for ( int64_t i = 0; i < M; ++i){
            cin >> a.at(i);
        }
        
        vector<int64_t> dp(N+1,0);
        dp.at(0) = 1;
        
        int64_t cnt = 0;
        for ( int64_t i = 1; i <= N; ++i){
            if ( i == a.at(cnt) ) {
                dp.at(i) = 0;
                cnt = min(cnt+1,M-1);
                continue;
            } else {
                if ( i - 2 < 0 ) {
                    dp.at(i) = dp.at(i-1);
                } else {
                    dp.at(i) = ( dp.at(i-1) + dp.at(i-2) ) % MOD;
                }
            }
        }
        
        cout << dp.at(N) << endl;
    } else {
        vector<int64_t> dp(N+1,0);
        dp.at(0) = 1;
        for ( int64_t i = 1; i <= N; ++i){
            if ( i - 2 < 0 ) {
                dp.at(i) = dp.at(i-1);
            } else {
                dp.at(i) = ( dp.at(i-1) + dp.at(i-2) ) % MOD;
            }
        }
        cout << dp.at(N) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1792
N, M = list(map(int, input().split()))
boxes = [1] * N
boxes_status = [False] * N
boxes_status[0] = True

for i in range(M):
  x, y = list(map(int, input().split()))
  x -= 1
  y -= 1
  if boxes_status[x]:
    if boxes[x] == 1:
      boxes_status[x] = False
    boxes_status[y] = True
  boxes[x] -= 1
  boxes[y] += 1

print(boxes_status.count(True))

Measured memory_bytes: 47080
<?php
list($n) = ints();
$a = ints();
for ($i = 0; $i < $n; ++$i) $sum[$i] = ($sum[$i - 1] ?? 0) + $a[$i];
$ans = PHP_INT_MAX;
for ($i = 0; $i < $n - 1; ++$i) $ans = min($ans, abs($sum[$i] - ($sum[$n - 1] - $sum[$i])));
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 29168
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int K = cin.nextint;
        int Q = cin.nextint;
        var A = cin.scanint;
        var ans = long.MaxValue;

        for (int i = 0; i < N; i++)
        {
            var Y = A[i];
            var W = new List<int>();

            var P = new List<int>();

            for (int r = 0; r <= N; r++)
            {
                if (r == N || A[r] < Y)//Zより小さいものは使えない，部分列の区切りになる
                {
                    P.Sort();
                    for (int j = 0; j < P.Count - K + 1; j++)
                    {
                        W.Add(P[j]);
                    }
                    P = new List<int>();
                }
                else
                {
                    P.Add(A[r]);
                }
            }
            if (W.Count < Q) continue;
            W.Sort();
            chmin(ref ans, W[Q - 1] - W[0]);
        }

        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 38596
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

const int INF = 1050000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}


int main() //input->compute->output
{
        int M, D;
        cin >> M >> D;

        int ans = 0;

        rep2(i, 2, M + 1)
        {
                rep2(j, 21, D + 1)
                {
                        int D2 = j / 10;
                        int D1 = j % 10;
                        if (D1 < 2 || D2 < 2)
                        {
                                continue;
                        }

                        if (i == D1 * D2)
                        {
                                ans++;
                        }
                }
        }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
from fractions import Fraction


#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2] != 1:
        q = r[2] // w[2]
        r2 = w
        w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0], w[1]]


# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a, m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m


def comb(N, K):
    return comb_array[N] * comb_inv_array[K] * comb_inv_array[N - K] % mod_num


N, A, B, C = map(int, input().split())
mod_num = 10**9 + 7
mod_array_a = [1] * (N + 1)
mod_array_b = [1] * (N + 1)

j = 1
for i in range(N):
    j = (j * A) % mod_num
    mod_array_a[i + 1] = j
j = 1
for i in range(N):
    j = (j * B) % mod_num
    mod_array_b[i + 1] = j
# print(mod_array_a, mod_array_b)
comb_array = [1] * (2 * N - 1)
j = 1
for i in range(2 * N - 1):
    if i == 0:
        continue
    j = (j * i) % mod_num
    comb_array[i] = j
# print(comb_array)
comb_inv_array = [mod_inv(comb_array[i], mod_num) for i in range(N)]

array_ab_inv = [0] * N

init_ab = pow((A + B), N, mod_num) * (100 - C) % mod_num
array_ab_inv[0] = mod_inv(init_ab, mod_num)
for i in range(1, N):
    init_ab = (init_ab * (A + B)) % mod_num
    array_ab_inv[i] = mod_inv(init_ab, mod_num)

ans = 0
for n in range(N, 2 * N):
    combination = comb(n - 1, N - 1)
    # print(combination)
    AB = (mod_array_a[N] * mod_array_b[n - N] +
          mod_array_a[n - N] * mod_array_b[N]) % mod_num
    # print(AB)
    # print(mod_inv(array_ab_inv[0], mod_num))
    ans += (((((combination * AB) % mod_num) * n * 100) % mod_num
             ) * array_ab_inv[n - N]) % mod_num
    # print("ans=", ans)

print(ans % mod_num)

Measured memory_bytes: 82224
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(check1(s) && check2(s) && check3(s)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }  
  static boolean check1(String s){
    StringBuffer buf = new StringBuffer(s);
    String str = buf.reverse().toString();
    if(s.equals(str)){
      return true;
    }else{
      return false;
    }
  }
  static boolean check2(String s){
    String str1 = s.substring(0,s.length()/2);
    StringBuffer buf = new StringBuffer(str1);
    String str = buf.reverse().toString();
    if(str1.equals(str)){
      return true;
    }else{
      return false;
    }
  }
  static boolean check3(String s){
    String str1 = s.substring(s.length()/2+1);
    StringBuffer buf = new StringBuffer(str1);
    String str = buf.reverse().toString();
    if(str1.equals(str)){
      return true;
    }else{
      return false;
    }
  }
}

Measured memory_bytes: 35624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
int main(){
  ll N;cin>>N;
  vll A(N);rep(i,N)cin>>A[i];
  bool flag=true;
  ll ans=1;
  rep(i,N){
    ans = ans * A[i];
    if(ans > ll(1e18) || ans <= 0) flag = false;
  }
  bool flag2 = false;
  rep(i,N){
    if(A[i]==0) flag2 = true;
  }
  if(flag2) cout << 0 << endl;
  else if(flag) cout << ans << endl;
  else cout << -1 << endl;
}

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

using namespace std;

char S[10101];
int n, m, k;

int main()
{
	int i, j;
	
	scanf("%d%d%s", &n, &k, S);
	
	for(i=0; i<n; i++){
		S[n + i] = S[n - i - 1];
	}
	
	for(i=0, m=0; i<=n; i++){
		for(j=0; j<n; j++){
			if(S[i + j] != S[m + j]){
				if(S[i + j] < S[m + j])	m = i;
				break;
			}
		}
	}
	
	for(i=0; S[m + i] == S[m] && i<n; i++);
	m += i;
	
	for(; --k && i<n; i<<=1); i = min(n, i);
	
	S[m + n - i] = '\0';
	
	for(; i--; ) printf("%c", S[m - 1]);
	printf("%s\n", S + m);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    string n;
    cin >> n;
    string ans;
    if(n[0] == n[1] && n[1] == n[2]){
        ans = "Yes";
    }else if(n[1] == n[2] && n[2] == n[3]){
        ans = "Yes";
    }else{
        ans = "No";
    }

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

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

#define int long long

using namespace std;

const int N = 5005;
int dp[N][N], p[N], cnt[N][N], a, b, n;

int solve(int i, int j) {
  if (i == 0 || j == 0) {
    return 0;
  }
  if (~dp[i][j]) {
    return dp[i][j];
  }
  if (p[i - 1] >= j) {
    return solve(i - 1, j);
  }
  int cur = cnt[i][j] - cnt[i][p[i - 1] + 1];
  return dp[i][j] = min(solve(i - 1, j) + b, solve(i - 1, min(p[i - 1], j)) + cur * a);
}

signed main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    --p[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < N; j++) {
      cnt[i + 1][j] = cnt[i][j] + (p[i] < j);
    }
  }
  cout << solve(n, n) << '\n';
  return 0;
}



Measured memory_bytes: 395128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
//#define pq priority_que
int main() {
  int A, B;
  priority_queue<int> pq;
  cin >> A >> B;
  pq.push(A + B);
  pq.push(A - B);
  pq.push(A * B);
  cout << pq.top() << endl;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll q,i,x;
  char ch;
  string s;
  bool rev=false;
  cin>>s;
  cin>>q;
  deque<char>deq;
  for(char c:s)
    deq.push_back(c);
  while(q--)
  {
    cin>>x;
    if(x==1)
    {
      rev=!rev;
    }
    else
    {
      cin>>i>>ch;
      if(rev)
      {
        if(i==2)
          deq.push_front(ch);
        else
          deq.push_back(ch);
      }
      else
      {
        if(i==1)
          deq.push_front(ch);
        else
          deq.push_back(ch);
      }
    }
    
  }
  //s=pre+s+suff;
  if(rev)
    reverse(deq.begin(),deq.end());
  for(char c:deq)
  	cout<<c;
  return 0;
}

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

using namespace std;
typedef long long ll;

int work(int n,int m)
{
    int ans=2100000000;
    for (int i=1;i<n;i++)
    {
        long long mx=max((long long)i*m,(long long)(m+1)/2*(n-i));
        long long minn=min((long long)i*m,(long long)m/2*(n-i));
        ans=min((long long)ans,mx-minn);
    }
    return ans;
}
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    if ((n%3==0)||(m%3==0)) printf("0\n");
    else
    {
        int ans=min(n,m);
        ans=min(ans,work(n,m));
        ans=min(ans,work(m,n));
        printf("%d\n",ans);
    }
}



Measured memory_bytes: 256
N = int(input())
C = list(map(int, input().split()))

C.sort()

ans = 0

mod = 10 ** 9 + 7

pattern = (2 ** (N - 2)) % mod

if N != 1:
    for i in range(N):
        c = C[i]
        ans += c * (N + 1 - i) * pattern
        ans %= mod
    ans *= 2 ** N
else:
    ans = C[0] * 2

ans %= mod

print(ans)


Measured memory_bytes: 25768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  int N, C;
  int s,t,c,ans=0,temp;
  bool tv[30][100000]={};
  cin>> N >> C;
  for(int i=0;i<N;i++){
    cin>>s>>t>>c;
    for(int j=s-1;j<t-1;j++){
      tv[c-1][j]=true;
    }
  }
  for(int i=0;i<99999;i++){
    temp=0;
    for(int j=0;j<C;j++){
      if(tv[j][i]||tv[j][i+1]){
        temp++;
      }
      ans=max(ans,temp);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

int gcd(int a, int b) {
	if (a > b) {
		swap(a, b);
	}

	if (a == 0) {
		return b;
	}

	return gcd(b%a, a);
}

int main() {
	int n,x;
	cin >> n >> x;
	vector<int> xi;
	for (int i = 0; i < n;i++) {
		int tmp_x;
		cin >> tmp_x;
		xi.emplace_back(abs(tmp_x - x));
	}

	int g = xi[0];

	for (int i = 1; i < n; i++) {
		g = gcd(g, xi[i]);
	}

	cout << g << endl;

	
}

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

int main()
{
  int a, b, c, k;
  cin>>a>>b>>c>>k;
  while(k and b<=a)
  {
    k--;
    b*=2;
  }
  while(k and c<=b)
  {
    k--;
    c*=2;
  }
  
  if(c>b and b>a) cout<<"Yes";
  else cout<<"No";
  
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	string s, t = "AKIHABAR";
	cin >> s;
	int now = 0;
	bool ans = false;
	rep(i, 8) {
		if (now >= s.size())break;
		if (t[i] == s[now]) {
			now++;
		}
		else if (t[i] != 'A') {
			break;
		}
		if (i == 7) {
			if (now + 1 < s.size()) {
				break;
			}
			ans = true;
		}
	}
	YES(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,b,n,c=0;
    cin>>x>>b;
    n=x+b+1;
    char a[n];
    cin>>a;

    if(a[x]!='-') cout<<"No";
    else
    {
        for(int i=0; i<n; i++)
        {
            if(i!=x)
            {
                if(a[i]=='0' || a[i]=='1' || a[i]=='2' || a[i]=='3' || a[i]=='4' || a[i]=='5' || a[i]=='6' || a[i]=='7' || a[i]=='8' || a[i]=='9')
                {
                    c++;
                }
                else{
                    cout<<"No";
                    return 0;
                }
            }
        }
        cout<<"Yes";
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

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

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

mint mpow(int x, int n){
  if(n==0)return 1;

  mint y = mpow(x, n/2);
  y *= y;

  if(n%2==1) y *=x;
  return y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int n,k;

  cin >> n >> k;

  combination combi(500000);


  if(k>=n-1){
    cout << combi(2*n-1, n-1).x << endl;
  }else{
    mint ans=0;
    REP(i,k+1){
      ans += combi(n,i) * combi(n-1, n-i-1);
    }

    cout << ans.x << endl;
  }


}



Measured memory_bytes: 8064
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
ll pl[303030], tm[303030];
int main()
{
	int num, len;
	scanf("%d%d", &num, &len);
	for (int i = 0; i < num; i++)scanf("%lld", &pl[i]);
	ll ad = 0;
	vector<ll>v1, v2;
	set<ll>se;
	ll maxi = 0, v3 = -1;
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		ad += (z - 1) / (len * 2);
		z = (z - 1) % (len * 2) + 1;
		bool f1 = (z <= (len - pl[i]) * 2), f2 = (z <= pl[i] * 2);
		if (f1&&f2)se.insert(pl[i]);
		if (f1&&!f2)v1.push_back(pl[i]);
		if (!f1&&f2)v2.push_back(pl[i]);
		if (!f1&&!f2)v3 = pl[i], ad++;
		if (f1 || f2)maxi = pl[i];
	}
	if (!v2.empty())
	{
		ll ans = v1.size() + v2.size() + 1;
		for (int i = 0; i < v1.size(); i++)
		{
			set<ll>::iterator it = se.begin();
			if (it != se.end() && (*it) < v1[i])se.erase(it);
		}
		v2.push_back(v2[v2.size() - 1]);
		for (int i = v2.size() - 1; i >= 0; i--)
		{
			set<ll>::iterator it = se.end();
			bool zz = false;
			if (it != se.begin())
			{
				it--;
				if (v2[i] < (*it))se.erase(it), zz = true;
			}
			if (!zz)maxi = len;
		}
		ans += (se.size() + 1) / 2;
		if (se.size() % 2 == 1)maxi = len;
		if (maxi < v3)ans++;
		printf("%lld\n", (ad + ans)*len * 2);
	}
	else
	{
		if (!v1.empty())
		{
			for (int i = 0; i < v1.size(); i++)
			{
				if (se.empty() && v3 < maxi)
				{
					printf("%lld\n", (ad + v1.size())*len * 2);
					return 0;
				}
				set<ll>::iterator it = se.begin();
				if (it != se.end() && (*it) < v1[i])se.erase(it);
			}
			ll ans = v1.size() + 1;
			ans += se.size() / 2;
			if (se.size() % 2 == 0)maxi = len;
			if (maxi < v3)ans++;
			printf("%lld\n", (ad + ans)*len * 2);			
		}
		else
		{
			ll ans = 1;
			ans += se.size() / 2;
			if (se.size() % 2 == 0)maxi = len;
			if (maxi < v3)ans++;
			printf("%lld\n", (ad + ans)*len * 2);
		}
	}
}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 2011, max_val = 100111, inf = 1000111222;
const ll mod = 1000000007LL;

ll dp[max_n][max_n];
ll sum[max_n][max_n];

ll m1[max_n];
ll m2[max_n];

ll n, m;

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> m1[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> m2[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (m1[i] != m2[j]) {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = 1;
            if (i && j) {
                dp[i][j] += sum[i - 1][j - 1];
                dp[i][j] %= mod;
            }
        }
        ll curs = 0;
        for (int j = 0; j < m; ++j) {
            curs += dp[i][j];
            curs %= mod;
            sum[i][j] = curs;
            if (i) {
                sum[i][j] += sum[i - 1][j];
            }
            sum[i][j] %= mod;
        }
    }
    ll ans = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            ans += dp[i][j];
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 63232
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e5+100;
ll dep[sz];
vector<PII> ad[sz];
void DFS(ll p,ll parent,ll tot)
{
      dep[p]=tot;
      for (auto xx: ad[p])
      {
          if(xx.s != parent){
              DFS(xx.s,p,tot+xx.f);
          }
      }
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        ll rot;
        for(i=0;i<=n;i++) ad[i].clear();
        for(i=1;i<n;i++){
            cin>>p>>q>>x;
            ad[p].pb({x,q});
            ad[q].pb({x,p});
        }
        ll root;
        cin>>a>>root;
        DFS(root,-1,0);

        while(a--)
        {
            cin>>p>>q;
            ll ans=dep[p]+dep[q];
            cout<<ans<<endl;
        }
       
    }





}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int tot = 0, abr = 0;
    string S;
    cin >> S;
    for(int i = 0; i < N; i++) {
        if(S.at(i) == 'c') {
            cout << "No" << endl;
        } else {
            if(S.at(i) == 'a' && tot < A + B) {
                tot++;
                cout << "Yes" << endl;
            } else if(S.at(i) == 'b' && tot < A + B && abr < B) {
                tot++;
                abr++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;
vector<int> a;

bool isOK(int index,int key){
  if(a[index]<key)return true;
  else return false;
}

int binary_search(int key) {
    int left = -1;
    int right = (int)a.size();

   while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    return right;
}

int main(void){
  int n,t,x,i,c;
  cin>>n>>x;
  a.push_back(x);
  for(i=1;i<n;i++){
    cin>>x;
    t=binary_search(x);
    if(t==a.size()){
      a.push_back(x);
    }
    else{
      a[t]=x;
    }
  }

  cout<<a.size()<<endl;

	return 0;
}


Measured memory_bytes: 892
#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 FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    int n, k, ans;
    ans=0;
    vector<int> a;
    REP(i,3){
        cin >> n;
        a.push_back(n);
    }
    cin >> k;
    sort(a.begin(), a.end(), greater<int>());
    a[0] *= pow(2, k);
    ans = accumulate(a.begin(), a.end(), 0);
    cout << ans << endl;
    return 0;
}


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

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

ll ans;

int main()
{
	ll n;
	cin >> n;
	ll a, b;
	vector<ll> T(n), A(n);
	rep(i, n)
	{
		cin >> T[i] >> A[i];
	}
	a = T[0]; b = A[0];
	repi(i, 1, n)
	{
		if (T[i] == A[i])
		{
			if (a < b)
			{
				a = b;
			}
			else{
				b = a;
			}
		}
		else{
			ll p_a = a; ll p_b = b;
			ll MAX = 1;
			MAX = max((ll)1, p_a / T[i]);
			MAX = max(MAX, p_b / A[i]);

			if (T[i] * (MAX-1) >= a && A[i] * (MAX-1) >= b)
			{
				a = T[i] * (MAX - 1);
				b = A[i] * (MAX - 1);
			}
			else if (T[i] * MAX >= a && A[i] * MAX >= b)
			{
				a = T[i] * MAX;
				b = A[i] * MAX;
			}
			else{
				a = T[i] * (MAX + 1);
				b = A[i] * (MAX + 1);
			}
		}
	}
	cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
long long n,d,a,cnt[202020],ans;
pair<long long,long long>x[202020];
vector<long long>v;
long long js(long long p)
{
	long long nw=lower_bound(v.begin(),v.end(),p)-v.begin(),nn=cnt[v.size()-1]-cnt[nw-1];
	return nn;
}
int main()
{
	cin>>n>>d>>a;
	for(int i=0;i<n;i++)
	{
		cin>>x[i].f>>x[i].s;
	}
	sort(x,x+n);
	v.push_back(-1);
	for(int i=0;i<n;i++)
	{
		long long sum=js(x[i].f);
		if(x[i].s<=sum*a)
		{
			continue;
		}
		x[i].s-=sum*a;
		long long nd=(x[i].s+a-1)/a;
		ans+=nd;
		v.push_back(x[i].f+2*d);
		cnt[v.size()-1]=cnt[v.size()-2]+nd;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6644
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define UNWORDS(vec, str) for(int i = 0; i < (vec).size(); ++i) cout << (i ? str : "") << (vec)[i]
#define UNLINES(vec) for(int i = 0; i < (vec).size(); ++i) cout << (vec)[i] << endl
#define RS resize
#define CLR clear
#define PB push_back
using namespace std;

int main(){
	int q, c, a, n;
	int can, cca, ccc;
	
	cin >> q;
	REP(i, q){
		cin >> c >> a >> n;
		
		can = min(c, min(a, n));
		c -= can;
		a -= can;
		n -= can;
		
		cca = min(c / 2, a);
		c -= 2 * cca;
		a -= cca;
		
		ccc = c / 3;
		
		cout << can + cca + ccc << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,q,l,r,i,a[100000],sum[100000],x;
	char s[100001];
	scanf("%d %d",&n,&q);
	scanf("%s",s);
	for(i=0;i<n-1;i++)	{
		if(s[i]=='A' && s[i+1]=='C')	a[i]=1;
		else a[i]=0;
	}
	sum[0]=0;
	for(i=1;i<n;i++)	{
		sum[i]=sum[i-1]+a[i-1];
	}
	for(i=0;i<q;i++)	{
		scanf("%d %d",&l,&r);
		x=sum[r-1]-sum[l-1];
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    long h = Long.valueOf(sc.next());

    int step = 0;
    for (long n = h; h > 0; h /= 2) {
      step++;
    }

    System.out.println((long)Math.pow(2, step)-1);

    sc.close();
  }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()) cout<<"GREATER"<<endl;
    else if(a.size()<b.size()) cout<<"LESS"<<endl;
    else{
        for(int i=0;i<a.size();i++){
            if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }
            if(b[i]>a[i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
        cout<<"EQUAL"<<endl;
    }
    return 0;
}

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

int w, a, b, x, y;
int main () {
	cin >> w >> a >> b;
	x = w + a;
	y = w + b;
	
	if (a > y){
		cout << a - y << endl;
	} else if (x < b){
		cout << b - x << endl;
	} else{
		cout << 0 << endl;
}
	}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

int depth = 0;
int sum = 0;

int dfs (int currs, int currd, int j)
{
	int count = 0;
	int i;

	if (currd == depth ){
		if (sum == currs ){
			return 1;
		}else{
			return 0;
		} // end if
	} // end if
	
	for (i = min(j, sum ); i >= 0; --i){
		currs += i;
		count += dfs (currs, currd + 1, i - 1 );
		currs -= i;
	} // end for

	return count;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.si", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int n, s;
		int res = 0;
		stringstream ss(str);
		ss >> n >> s;

		if (n == 0 && s == 0){
			break;
		} // end if
		
		depth = n;
		sum = s;

		res = dfs (0, 0, 9 );

		cout << res << endl;
	} // end while
	
	return 0;
}

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

int main(){
    //input
    int X;
    cin >> X;
    int ma = 1;
    for(int i=2;i<=int(sqrt(X));i++){
        for(int j=1;int(pow(i,j))<=X;j++){
            ma = max(ma,int(pow(i,j)));
        }
    }

    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i<n)ans+=i;
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































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

int64_t lucas(int n){
  	if(n==0){return 2LL;}
  	else if(n==1){return 1LL;}
  	else{
    	vector<int64_t> L(n+1);
      	L.at(0)=2LL;
      	L.at(1)=1LL;
      	for(int i=2; i<=n;i++){
        	L.at(i)=L.at(i-1) + L.at(i-2);
        }
      	return L.at(n);
    }
}

int main(){
	int N;
  	cin >> N;
  	int64_t ans;
  	ans = lucas(N);
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
long long MOD = pow(10, 9) + 7;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long calc(long long n, long long a) {
  long long bunshi = 1, bunbo = 1;
  for (long long i = 1; i <= a; i++) {
    bunshi = (bunshi * (n - i + 1)) % MOD;
    bunbo = (bunbo * i) % MOD;
  }
  return  bunshi * modpow(bunbo, MOD-2, MOD) % MOD;
}

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  int64_t ans = modpow(2, n, MOD) - 1;
  // cout << ans << endl;
  // cout << calc(n, a) << endl;
  ans = (ans - calc(n, a));
  ans = (ans - calc(n, b));
  while (ans < 0) ans += MOD;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a > 0 && a < 10) && (b > 0 && b < 10)) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 25172
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	text := stdin.Text()

	switch {
	case text == "Sunny":
		fmt.Println("Cloudy")
	case text == "Cloudy":
		fmt.Println("Rainy")
	case text == "Rainy":
		fmt.Println("Sunny")
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(vector<string> C) {
  REP(i, 3) {
    if (C[0][i] != C[1][2 - i]) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  vector<string> C(2 - 1 + 1);
  for (int i = 0; i <= 2 - 1; i++) {
    cin >> C[i];
  }
  solve(C);
  return 0;
}


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

#define int long long

map<string, int> mp;
vector<string> v;

int ncr ( int n ) {
    return n * (n-1) / 2;
}

signed main ( ) {

    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
        v.emplace_back(s);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    int ans = 0;

    for ( string s : v ) {
        ans += ncr ( mp[s] );
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 16628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

vector <vector <vector <ld>>> dp;
int n;

ld solve(int a, int b, int c) {
    if (dp[a][b][c] > -0.5)
        return dp[a][b][c];
    if (a == 0 && b == 0 && c == 0)
        return dp[a][b][c] = 0;
    dp[a][b][c] = 1.0 * n / (a + b + c);
    if (a)
        dp[a][b][c] += 1.0 * a / (a + b + c) * solve(a - 1, b, c);
    if (b)
        dp[a][b][c] += 1.0 * b / (a + b + c) * solve(a + 1, b - 1, c);
    if (c)
        dp[a][b][c] += 1.0 * c / (a + b + c) * solve(a, b + 1, c - 1);
    return dp[a][b][c];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    int a = 0, b = 0, c = 0;
    forn (i, 0, n) {
        int x;
        cin >> x;
        if (x == 1)
            ++a;
        if (x == 2)
            ++b;
        if (x == 3)
            ++c;
    }
    const int MX_N = 305;
    dp.resize(MX_N, vector <vector <ld>> (MX_N, vector <ld> (MX_N, -1)));
    cout << fixed << setprecision(10) << solve(a, b, c);
    return 0;
}

Measured memory_bytes: 450816