akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define VI vector<int>  
#define PII pair<int,int>
#define MII map<int,int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define usual int t; cin>>t; while(t--)
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    string s1,s2; cin>>s1>>s2;
    int count=0;
    REP(i,0,s1.size()) {
        if(s1[i]!=s2[i]) count++;
    }

    cout<<count;

    return 0;
    
}

Measured memory_bytes: 3812
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (int i = 0; i < n-1; i++) {
    if(h[i+1] > h[i]){
      h[i+1] -= 1;
    }else if (h[i+1] < h[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
A=[["."]*n for i in range(n)]
B=[["."]*m for i in range(m)]
for i in range(n):
  A[i]=list(input())
for i in range(m):
  B[i]=list(input())
for i in range(n-m+1):
  for j in range(n-m+1):
    a=0
    for x in range(m):
      for y in range(m):
        if A[i+x][j+y]!=B[x][y]:
          a=1
          break
    if a==0:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 3064
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(args){
    var input = args.split("\n");
    var S = input[0];
    var diffFlag = true;

    for(var i = 0; i<S.length; i++){
        for(var j=i+1; j<=S.length; j++){
            if(S[i] === S[j]){
                diffFlag = false;
                break;
            }
        }
    }

    console.log( diffFlag ? 'yes' : 'no' );
}

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int m; cin >> m;
	while(m-- != 0){
		int start, year, n; cin >> start >> year >> n;
		int ans = start;
		for(int i=0; i<n; i++){
			int type, fee;
			double rate;
			cin >> type >> rate >> fee;

			int tmp = start;
			if(type == 0){
				int  interest_sum=0;
				for(int j=0; j<year; j++){
					interest_sum += tmp*rate;
					tmp -= fee;
				}
				tmp = tmp+interest_sum;
			} else{
				for(int j=0; j<year; j++){
					tmp += tmp*rate;
					tmp -= fee;
				}
			}
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
using Arr = array<ll, 4>;

int main() {
    init();
    ll H, W, K, h1, w1, h2, w2;
    cin >> H >> W >> K >> h1 >> w1 >> h2 >> w2;
    h1--, w1--, h2--, w2--;
    vc<string> S(H);
    rep(i, H) cin >> S[i];

    vvc<Arr> D(H, vc<Arr>(W, {INF, INF, INF, INF}));
    rep(i,4) D[h1][w1][i] = 0;

    vvc<bool> used(H, vc<bool>(W));
    vl dh = {0, 0, 1, -1}, dw = {1, -1, 0, 0};

    auto comp = [](Arr a1, Arr a2) { return a1[2] > a2[2]; };
    priority_queue<Arr, vc<Arr>, decltype(comp)> pq{comp};
    pq.emplace(Arr({h1, w1, 0, -1}));

    while(!pq.empty()){
        auto [h, w, d, m] = pq.top();
        pq.pop();

        rep(i,4){
            ll th = h + dh[i], tw = w + dw[i];
            if (th < 0 or th >= H or tw < 0 or tw >= W or S[th][tw]=='@') continue;

            ll td = (i==m ? d : (d + K - 1) / K * K);

            if (!chmin(D[th][tw][i], td + 1)) continue;

            rep(j, 4) if (i != j) chmin(D[th][tw][j], (td + K) / K * K);
            pq.emplace(Arr({th, tw, td + 1, i}));
        }
    }

    ll ans = *min_element(all(D[h2][w2]));
    cout << (ans == INF ? -1 : (ans + K - 1) / K) << endl;
}

Measured memory_bytes: 66828
N,M = map(int,input().split())
maL = 0
miR = N
for g in range(M):
  L,R = map(int,input().split())
  maL = max(maL,L)
  miR = min(miR,R)
if maL <= miR:
  print(miR-maL+1)
else:
  print(0)
  
  

Measured memory_bytes: 9036
#include<bits/stdc++.h>
using namespace std;
#define ll              long long int
#define ull             unsigned long long int
#define mod             1000000007 
#define pb              push_back
#define mp              make_pair
#define count_1(n)      __builtin_popcountll(n) //set bits


bool isPrime(ll n) {

  if (n == 1) {
    return false;
  }

  for (ll i = 2; i*i <=n; i++) {
    if (n % i == 0) return false;
  }

  return true;
}

 
   
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     
    x = x % p;  
                
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    return -1; 
} 

  

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,x,t;
    cin>>n>>x>>t;
    n+=(x-1);
    n/=x;
    n*=t;
    cout<<n;
}

Measured memory_bytes: 3628
//#pragma GCC optimize(2)


#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#include<ext/rope>*/
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//void err(istream_iterator<string> it){cerr<<endl;}
//template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args){cerr << *it << " = " << a << " , ";err(++it, args...);}
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mem(a,b) memset((a),b,sizeof((a)))
#define fpre(x) cout<<fixed<<setprecision(x)
#define clr(v) (v).clear()
#define pii pair<int,int>
#define pdd pair<double,double>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp make_pair
#define eb emplace_back
#define pb emplace_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define uint unsigned int
#define ushort unsigned short
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lowbit(i) (i&(-i))
#define lson rt<<1
#define rson lson|1
#define fi first
#define se second
const double eps=1e-7;
const double pi=acos(-1);
inline int dcmp(double x)
{
    if(x<-eps)
        return -1;
    if(x>eps)
        return 1;
    return 0;
}
//-----------------------------------------------head


int main()
{
    int a,b;
    while(cin>>a>>b)
        cout<<a-b+1<<endl;
}
















/*
























*/









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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> AB(M);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a > M) continue;
    a--;
    AB[a].emplace_back(b);
  }
  priority_queue<int> que;
  int res = 0;
  for (int i = 0; i < M; i++) {
    for (int x : AB[i]) {
      que.push(x);
    }
    if (que.empty()) continue;
    res += que.top();
    que.pop();
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    cin.tie();
    ios::sync_with_stdio(false);
    
    // input
    int A, B, C;
    cin >> A >> B >> C;
    
    cout << A + B + C - max(A, max(B, C)) << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
"""
0からLまで行き、LからRまで行く = abs(L) + (R-L)
0からRまで行き、RからLまで行く = abs(R) + (R-L)
"""

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 1<<60

for i in range(0, N-K+1):
  left = A[i]
  right = A[i+K-1]
  ans = min(ans, min(abs(left), abs(right)) + right - left)
print(ans)

Measured memory_bytes: 14696
# coding: utf-8
# Your code here!
N,A,B,C,D=map(int,input().split())
S=input()
A-=1
B-=1
C-=1
D-=1

"""
ABDCとか順番が逆転するなら3つ以上連続の空きがないとアウト
ABCDならAからDにいけないとアウト ACBDの可能性があるので注意
"""
if C<D:
    if C<B:
        if "##" in S[A:C+1] or "##" in S[B:D+1]:#ACBD
            print("No")
        else:
            print("Yes")
    else:
        if "##" in S[A:D+1]:#ABCD
            print("No")
        else:
            print("Yes")
else:
    if "..." in S[A:C+1] and not "##" in S[A:C+1]:#ABDC
        if S[B+1]=="#" and not "..." in S[B:C+1]:#A.B#..#..#..対策
            print("No")
        elif S[D-1]=="#" and not "..." in S[A:D+1]:#AB.#..#D.C...対策
            print("No")
        else:
            print("Yes")
    else:
        print("No")


Measured memory_bytes: 3516
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int N = 1005;
int a[N],b[N*N];
bool judge(int n)
{
    int tmp = n % 10;
    n /= 10;
    while(n > 0)
    {
        if(n % 10 != tmp-1)
            return false;
        tmp = n % 10;
        n /= 10;
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    for(int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    int num = 0;
    for(int i = 1;i <= n-1;i++)
        for(int j = i+1;j <= n;j++)
            b[num++] = a[i]*a[j];

    sort(b,b+num);
    int nu = unique(b,b+num)-b;
    for(int i = nu-1;i >= 0;i--)
    {
        if(judge(b[i]))
            return 0*printf("%d\n",b[i]);
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 5168
#include <algorithm>
#include <cstdio>
#include <set>

const int P=1000000007;
inline int add(int a,const int &b){a+=b;return (a>=P)?a-P:a;}
int n,m,x[100001],top,orig[200001],lim,ans=1,c[200001];
std::pair<int,int>num[100001];
std::set<int>set;
bool cmp(std::pair<int,int> a,std::pair<int,int> b){return a.first<b.first||(a.first==b.first&&a.second>b.second);}
void update(int ind,int num){ans=add(ans,num);for(;ind<=lim;ind+=ind&-ind)c[ind]=add(c[ind],num);}
int query(int ind){int tot=0;for(;ind;ind-=ind&-ind)tot=add(tot,c[ind]);return tot;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",x+i);
	for(int i=1,tem;i<=m;i++)scanf("%d",&tem),set.insert(tem);
	for(int i=1;i<=n;i++)
		if(x[i]>=*set.begin()&&x[i]<=*set.rbegin()&&!set.count(x[i]))
			num[++top]=std::make_pair(x[i]-*(--set.lower_bound(x[i])),*set.lower_bound(x[i])-x[i]);
	std::sort(num+1,num+top+1,cmp);
	top=std::unique(num+1,num+top+1)-num-1;
	for(int i=1;i<=top;i++)orig[(i<<1)-1]=num[i].first,orig[i<<1]=num[i].second;
	std::sort(orig+1,orig+(lim=(top<<1))+1);
	lim=std::unique(orig+1,orig+lim+1)-orig-1;
	for(int i=1;i<=top;i++){
		int N=std::lower_bound(orig+1,orig+lim+1,num[i].second)-orig;
		update(N,query(N-1)+1);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 7040
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long x = scan.nextLong();
		double n = 100;
		int year = 1;
		
		while(true) {
			n = Math.floor(n*1.01);
			if(n>=x) {
				System.out.println(year);
				System.exit(0);
			}else {
				year += 1;
			}
			
		}
		
	}	
	
	
	//最小公約数
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int NN = N;
  int SN = 0;
  while (N > 0) {
    SN += N % 10;
    N /= 10;
  }
  if (NN % SN == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
a = int(s[0:2])
b = int(s[2:4])

def isM(x: int):
  if 1 <= x <= 12:
    return True
  else:
    return False

if isM(a) and isM(b):
  print("AMBIGUOUS")
elif isM(a) and not isM(b):
  print("MMYY")
elif not isM(a) and isM(b):
  print("YYMM")
elif not isM(a) and not isM(b):
  print("NA")  

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;
int ans = 0;

void selectionSort(vector<int>& vec)
{
	for (int i = 0; i < vec.size(); ++i)
	{
		int minj = i;
		bool flag = false;
		for (int j = i; j < vec.size(); ++j)
		{
			if (vec[j] < vec[minj])
			{
				minj = j;
				flag = true;
			}
		}
		if (flag)
		{
			int temp = vec[i];
			vec[i] = vec[minj];
			vec[minj] = temp;
			++ans;
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> vec[i];
	}
	selectionSort(vec);
	for (int i = 0; i < n - 1; ++i)
	{
		cout << vec[i] << " ";
	}
	cout << vec[vec.size() - 1] << endl;
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll 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>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< 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 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    // ll a;
    // string b;
    // cin >> a >> b;
    // rep (i, b.size()) {
    //     if (b[i] == '.') {
    //         b.erase(b.begin() + i);
    //         break;
    //     }
    // }
    // ll bb = stol(b);
    // cout << a * bb / 100 << endl;

}

Measured memory_bytes: 3672
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;
typedef long long ll;

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

int main()
{
	// greedy
	int N;
	cin >> N;
	vector<int> A(N + 1);
	rep(i, N) {
		cin >> A[i];
	}
	ll ans = 0;
	rep(i, N) {
		int x = A[i] / 2;
		ans += x;
		A[i] -= 2 * x;
		int y = min(A[i], A[i + 1]);
		ans += y;
		A[i + 1] -= y;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int64 ans = 0;
    unordered_map<int, unordered_map<char, int>> cnt;
    cnt[0][s[0]]++;
    string x = "RGB";
    for(int i = 1; i < n; i++){
        for(int j = 0; j < 3; j++){
            char c = x[j];
            if(c == s[i])
            cnt[i][c] = cnt[i - 1][c] + 1;
            else
            cnt[i][c] = cnt[i - 1][c];
        }
    }
          /*  for(int j = 0; j < 3; j++){
                    char c = x[j];
            cout << c << endl;
    for(int i = 0; i < n; i++){
            cout << cnt[i][c] << " ";

        }
        cout << endl;
    }*/
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            int diff = j - i;
            if(s[i] == s[j]) continue;
            //cout << "i = " << i << " " << " j = " << j << endl;
            if(s[i] == 'R' && s[j] == 'G'){
                int c = 0;
                c = cnt[min(n - 1, j + diff - 1)]['B'] - cnt[j]['B'];
                if(j + diff < n)
                c += cnt[n - 1]['B'] - cnt[j + diff]['B'];
                //cout << "c = " << c << endl;

                ans += c;
            }
            else if(s[i] == 'R' && s[j] == 'B'){
                int c = 0;
                c = cnt[min(n - 1, j + diff - 1)]['G'] - cnt[j]['G'];
                if(j + diff < n)
                c += cnt[n - 1]['G'] - cnt[j + diff]['G'];
                //cout << "c = " << c << endl;

                ans += c;
            }
            else if(s[i] == 'G' && s[j] == 'R'){
                int c = 0;


                c = cnt[min(n - 1, j + diff - 1)]['B'] - cnt[j]['B'];
                if(j + diff < n)
                c += cnt[n - 1]['B'] - cnt[j + diff]['B'];
                //cout << "c = " << c << endl;

                ans += c;
            }
            else if(s[i] == 'G' && s[j] == 'B'){
                int c = 0;

                c = cnt[min(n - 1, j + diff - 1)]['R'] - cnt[j]['R'];
                if(j + diff < n)
                c += cnt[n - 1]['R'] - cnt[j + diff]['R'];
                //cout << "c = " << c << endl;

                ans += c;
            }
            else if(s[i] == 'B' && s[j] == 'G'){
                int c = 0;


                c = cnt[min(n - 1, j + diff - 1)]['R'] - cnt[j]['R'];
                if(j + diff < n)
                c += cnt[n - 1]['R'] - cnt[j + diff]['R'];
                //cout << "c = " << c << endl;

                ans += c;
            }
            else if(s[i] == 'B' && s[j] == 'R'){

                int c = 0;

                c = cnt[min(n - 1, j + diff - 1)]['G'] - cnt[j]['G'];
                if(j + diff < n)
                c += cnt[n - 1]['G'] - cnt[j + diff]['G'];
                //cout << "c = " << c << endl;

                ans += c;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4500
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [int(input().rstrip('\n')) for _ in range(n)]
    cnt = 0
    t = 0
    for v in a:
        if v == 0:
            cnt += (t // 2)
            t = 0
        else:
            t += v
    cnt += (t // 2)
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 44636
#a=int(input())
#a,b,c=map(int, input().split())
#c=list(map(int, input().split()))
A='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
N=int(input())
S=str(input())
res=''
for i in range(len(S)):
  aN=A.index(S[i])+N
  if aN>25:
    aN-=26
  res+=A[aN]

print(res)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var s = sc.next();
		var t = sc.next();
		sc.close();

		var count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (!s.substring(i, i + 1).equals(t.substring(i, i + 1))) {
				count++;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 55128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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; }
};

int main(){
  ll L,R;
  cin >> L >> R;
  vector<vector<vector<vector<mint>>>> dp(65, vector<vector<vector<mint>>>(2, vector<vector<mint>>(2,vector<mint>(2,0))));
  //dp[i][j][k][l]: i ketamemade j upper? k lower? l done(1,1)
  dp[61][0][0][0] = 1;
  for(int i=60; i>=0; i--)rep(j,2)rep(k,2)rep(f,2){
    int rb = bit(R,i);
    int lb = bit(L,i);
    int uplim = (j?1:rb);
    int lolim = (k?0:lb);
    for(int l=0; l<=uplim; l++){
      if(l==1 && f==0){lolim=1;}
      for(int r=lolim; r<=l; r++){
        dp[i][j|(l<rb)][k|(lb<r)][f|l] += dp[i+1][j][k][f];
      }
    }
  }
  mint ans = 0;
  rep(j,2)rep(k,2){
    ans += dp[0][j][k][1];
  }
  cout << ans.x << ln;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
   int n,k; cin >> n >> k;
   vector<int> a(n + 100);

   rep(i,n){
       int num;
       cin >> num;
       a[num]++;
   }

   sort(a.begin(),a.end(),greater<>());

   int count = 0;
   int sum = 0;

    while(count < k) {
        sum += a[count];
        count++;
    }
   print(n - sum);
}

Measured memory_bytes: 1024
// D - Chat in a Circle
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N); rep(i, N) cin>>A[i];
	sort(A.rbegin(), A.rend());
	int64_t ans = -A[0];
	rep(i, N) ans += A[i/2];
	cout<< ans <<endl;
}


Measured memory_bytes: 4040
class Node
  attr_reader :left, :right
  def initialize(left,right)
    @left = left
    @right = right
  end
  def to_s
    "(#{@left||""},#{@right||""})"
  end
end

class Parser
  def initialize(str)
    @str = str
    @idx = 0
  end
  def read
    if @str[@idx] == ?(
      @idx += 1
      l = read
      @idx += 1
      r = read
      @idx += 1
      Node.new(l,r)
    else
      nil
    end
  end
end

def its (a,b)
  if a && b
    Node.new(its(a.left,b.left),its(a.right,b.right))
  else
    nil
  end
end

def uni (a,b)
  if !a
    b
  elsif !b
    a
  else
    Node.new(uni(a.left,b.left),uni(a.right,b.right))
  end
end

while line = gets
  ch, a, b = line.split
  c = Parser.new(a).read
  d = Parser.new(b).read

  if ch=="i"
    puts its(c,d)
  elsif ch=="u"
    puts uni(c,d)
  end
end

Measured memory_bytes: 2996
# -*- coding: utf-8 -*-
import itertools
def main():
    number = input()
    for prod in list(itertools.product([0, 1], repeat=3)):
        ans = number[0]
        sum = int(ans)
        for i, p in enumerate(prod):
            if p == 0:
                sum += int(number[i+1])
                ans += '+' + number[i+1]
            else:
                sum -= int(number[i+1])
                ans += '-' + number[i+1]
        if sum == 7:
            print(ans + '=7')
            return
                
if __name__ == '__main__':
    main()

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

int main() {
    int H,N;cin>>H>>N;
    for (int i = 0; i < N; i++){
        int A;cin>>A;
        H-=A;
    }
    if(H<=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<int,P> P2;

int main() {
  int n,m,k;
  while(cin >> n >> m >> k && n) {
    P2 a[m];
    for(int i=0; i<m; i++) cin >> a[i].F >> a[i].S.F >> a[i].S.S;
    sort(a,a+m,greater<P2>());
    for(int i=0; i<m; i++) {
      if(a[i].S.F==k) k=a[i].S.S;
      else if(a[i].S.S==k) k=a[i].S.F;
    }
    cout << k << endl;
  }
  return 0;
}


Measured memory_bytes: 1176
//
// Created by admin on 2020/6/7.
//
#include<bits/stdc++.h>
using namespace std;
unsigned  long long a,re,b1;
long double b;
int main()
{
    cin>>a>>b;
    b1=b*100+0.5;
    re=a*b1/100;
    cout<<re<<endl;
    return 0;
}


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

int main(int argc, char *argv[])
{
    int r, d, x_2000;
    int i, x;
    int ans;

    scanf("%d %d %d", &r, &d, &x_2000);

    x = x_2000;
    for (i = 2001; i <= 2010; i++) {
        x = r * x - d;
        printf("%d\n", x);
    }

    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if(a>b) {
        	System.out.println(a-1);
        }else {
        	System.out.println(a);
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

int n, k, a[100004];
int main() {
	int n,k;
	cin>>n>>k;
	for(int i = 0;i<n;i++)	cin>>a[i];
	int ans = 987654321;
	for(int l = 0; l <= n-k; l++){
		int r = l+k-1;
		ans = min(a[r] - a[l] + min(abs(a[l]), abs(a[r])), ans);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main(void) {
	int num;
	int dan=1;
	cin >> num;
	int mochi[100];

	for (int i = 0; i < num; i++) {
		cin >> mochi[i];
	}
	sort(mochi, mochi+num);

	for (int i = 0; i < num - 1; i++) {
		if (mochi[i] != mochi[i + 1]) {
			dan++;
		}
	}
	cout << dan;


}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), D = sc.nextInt();
    int[][] X = new int[N][D];
    for (int i = 0; i < N; i++)
      for (int j = 0; j < D; j++) X[i][j] = sc.nextInt();
    int ans = 0;
    for (int i = 0; i < N; i++)
      for (int j = 0; j < i; j++) {
        int tmp = 0;
        for (int k = 0; k < D; k++) tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
        if (Math.sqrt(tmp) == (int)Math.sqrt(tmp)) ans++;
      }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
n, k = map(int, input().split())
a = [int(input()) for i in range(n)]

def check(a, p):
    if max(a) > p:
        return False
    else:
        tr = 0
        count = 1
        for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
        if count > k:
            return False
        else:
            return True
Min = 0
Max = max(a) * (n // k + 1)

while Min + 1 < Max:
    if check(a, (Min + Max) // 2) == True:
        Max = (Min + Max) // 2
    else:
        Min = (Min + Max) // 2
print(Max)



Measured memory_bytes: 9560
#include <iostream>
#include <map>

typedef long long ll;
int N, M;
ll A[100001];
std::map<int, ll> B;

int main() {
  std::cin>>N>>M;
  for (int i = 0; i < N; ++i)
    std::cin>>A[i];

  ll sum = 0;
  B[0]++;
  for (int i = 0; i < N; ++i) {
    sum = (sum + A[i]) % M;
    B[sum]++;
    //std::cout<<A[i]<<" ";
  }
  //std::cout<<"\n";

  ll ans = 0;
  for (auto k : B) {
    ans += B[k.first] * (B[k.first] - 1) / 2;
    //std::cout<<k.first<<"\n";
  }
  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
 
int main(){
    int H, W;
    cin >> H >> W;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            string S;
            cin >> S;
            if(S == "snuke"){
                cout << (char)('A' + j) << i+1 << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
w,h,n=map(int,input().split())
xa=[0]
xb=[w]
ya=[0]
yb=[h]
for i in range(n):
  x1,y1,a1=map(int,input().split())
  if a1==1:
    xa.append(x1)
  elif a1==2:
    xb.append(x1)
  elif a1==3:
    ya.append(y1)
  elif a1==4:
    yb.append(y1)

if min(xb)<=max(xa) or min(yb)<=max(ya):
  print(0)
else:
  print((min(xb)-max(xa))*(min(yb)-max(ya)))

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

int main(){
	int N,M,C,sum,ans=0;
	cin>>N>>M>>C;
	int B[M];
	for(int i=0;i<M;i++){
		cin>>B[i];
	}
	int A[N][M];
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cin>>A[i][j];
		}
	}
	for(int i=0;i<N;i++){
		sum=0;
		for(int j=0;j<M;j++){
			sum+=A[i][j]*B[j];
		}
		sum+=C;
		if(sum>0){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read};

fn main() {
    let mut nd = String::new();
    let mut table = String::new();
    stdin().read_line(&mut nd);
    stdin().read_to_string(&mut table);
    let nd: Vec<usize> = nd.trim().split_whitespace().filter_map(|it|it.parse().ok()).collect();
    let (n, d) = (nd[0], nd[1]);
    let table: Vec<Vec<i32>> = table.trim().lines().map(|line| line.split_whitespace().filter_map(|it|it.parse().ok()).collect()).collect();
    let get_distance = |i: usize, j: usize| table[i].iter().zip(table[j].iter()).fold(0, |acc, (&a, &b)| acc + (a - b) * (a - b));
    let has_square_root = |value: i32| (0..).take_while(|&it| it * it <= value).any(|it| it * it == value);

    println!("{}", (0..n).fold(0, |acc1, i| acc1 + (i+1..n).fold(0, |acc2, j| acc2 + if has_square_root(get_distance(i, j)) {1} else {0})));
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n;
    cin >> n;
    priority_queue<pair<int, int> , vector<pair<int, int> > , greater<pair<int, int> > > q;
    rep(i, n){
        int a;
        cin >> a;
        q.push(make_pair(a, i+1));
    }
    
    while(!q.empty()){
        pair<int, int> f = q.top(); q.pop();
        cout << f.second;
        if(!q.empty())cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1780
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
            var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var n = firstLine[0];
			var x = firstLine[1] - 1;
			var y = firstLine[2] - 1;

			var normalPath = new List<int>();
			var routeAPath = new List<int>();
			var routeBPath = new List<int>();
			var routeCPath = new List<int>();

			for (int i = 0; i < n; i++)
			{
				normalPath.Add(i);

				if (i <= x || i >= y)
				{
					routeAPath.Add(i);
				}

				if(i <= x || y == i)
				{
					routeBPath.Add(i);
				}

				if(i <= y)
				{
					routeCPath.Add(i);
				}
			}

			for(int i = y - 1; i > x; i--)
			{
				routeBPath.Add(i);
			}

			for(int i = x; i < n; i++)
			{
				if(i == x || i >= y)
				{
					routeBPath.Add(i);
				}

				routeCPath.Add(i);
			}

			var distances = new List<List<int>>();
			var answer = new Dictionary<int, int>();

			for (int i = 0; i < n; i++)
			{
				distances.Add(new List<int>());
				if (i != n - 1)
				{
					answer.Add(i + 1, 0);
				}

				for (int j = 0; j < n; j++)
				{
					distances[i].Add(int.MaxValue);
				}
			}

			var normalLength = normalPath.Count();
			for(int i = 0; i < normalLength - 1; i++)
			{
				for(int j = i + 1; j < normalLength; j++)
				{
					distances[normalPath[i]][normalPath[j]] = j - i;
				}
			}

			var routeALength = routeAPath.Count();
			for (int i = 0; i < routeALength - 1; i++)
			{
				for (int j = i + 1; j < routeALength; j++)
				{
					int source, destination;
					if (routeAPath[i] < routeAPath[j])
					{
						source = routeAPath[i];
						destination = routeAPath[j];
					}
					else
					{
						source = routeAPath[j];
						destination = routeAPath[i];
					}
					distances[source][destination] = Math.Min(distances[source][destination], j - i);
				}
			}

			var routeBLength = routeBPath.Count();
			for (int i = 0; i < routeBLength - 1; i++)
			{
				for (int j = i + 1; j < routeBLength; j++)
				{
					int source, destination;
					if(routeBPath[i] < routeBPath[j])
					{
						source = routeBPath[i];
						destination = routeBPath[j];
					}
					else
					{
						source = routeBPath[j];
						destination = routeBPath[i]; 
					}
					distances[source][destination] = Math.Min(distances[source][destination], j - i);
				}
			}

			var routeCLength = routeCPath.Count();
			for (int i = 0; i < routeCLength - 1; i++)
			{
				for (int j = i + 1; j < routeCLength; j++)
				{
					int source, destination;
					if (routeCPath[i] < routeCPath[j])
					{
						source = routeCPath[i];
						destination = routeCPath[j];
					}
					else
					{
						source = routeCPath[j];
						destination = routeCPath[i];
					}
					distances[source][destination] = Math.Min(distances[source][destination], j - i);
				}
			}

			for (int i = 0; i < n; i++)
			{
				for(int j = i + 1; j < n; j++)
				{
					answer[distances[i][j]]++;
				}
			}

			foreach (var value in answer.Values)
			{
				Console.WriteLine(value);
			}
		}
	}
}


Measured memory_bytes: 43848
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	string s;
	map<string,int>qw;
	cin>>n;
	while(n--){
		cin>>s;
		if(!qw[s]){
			ans++;
		}
		qw[s]++;
	}
	cout<<ans<<endl;
	return 0;
}


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

char s[1000];

bool check(int L , int R){
	for(int i = L; i <= (L + R) / 2; i++)
		if(s[i] != s[R - i + 1]) return false;
	return true;
}

int main(){
	cin >> s + 1;
	int n = strlen(s + 1);
	if(check(1 , n) && check(1 , n / 2) && check(n / 2 + 1 , n))
		puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

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

    lint tak = A;
    lint ao = B;

    if (K > A) {
        tak = 0;
        lint t = K - A;
        if (t > B) {
            ao = 0;
        }
        else {
            ao -= t;
        }
    }
    else {
        tak = A - K;
    }

    cout << tak << " " << ao << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		long N = nextLong();
		long res = (N-1)*N/2;
		out.println(res);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <time.h>
#include <string>
#include <iomanip>
#include <algorithm>
#include <map>


using namespace std;

int main(){
  int a;
  cin>>a;
  cout<<(a==7|a==5|a==3 ? "YES":"NO")<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint dp[65][2][2];

int main(void)
{
	cin >> n;
	
	dp[0][0][0]++, dp[0][0][1]++;
	if(n%2) dp[0][0][0]++; else dp[0][1][0]++;
	
	for(int i = 0; i <= 60; i++){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				
				for(int l = 0; l < 2; l++){
					for(int m = 0; m < 2; m++){
						if(l == 0 && m == 1) continue;
						int x = (k+l+m)%2, nk = (k+l+m)/2, nj = j;
						if( (n & (1LL<<(i+1))) == 0 && x == 1 ) nj = 1;
						if( (n & (1LL<<(i+1))) > 0 && x == 0 ) nj = 0;
						(dp[i+1][nj][nk] += dp[i][j][k]) %= mod;
					}
				}
				
			}
		}
	}
	cout << dp[61][0][0] << endl;
	
	return 0;
}

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

int main()
{
    int n, b, f, r, v;
    int A[4][3][10];
    for (int i = 0; i != 4; ++i)
    {
        for (int j = 0; j != 3; ++j)
        {
            for (int k = 0; k != 10; ++k)
            {
                A[i][j][k] = 0;
            }
        }
    }
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        cin >> b >> f >> r >> v;
        A[b-1][f-1][r-1] += v;
    }
    for (int i = 0; i != 4; ++i)
    {
        if (i)
        {
            for (int j = 0; j != 20; ++j)
            {
                cout << "#";
            }
            cout << endl;
        }
        for (int j = 0; j != 3; ++j)
        {
            for (int k = 0; k != 10; ++k)
            {
                cout << " " << A[i][j][k];
            }
            cout << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main(){
 long n;
   cin >> n;
   
  long t[n+1],v[n+1];
  t[0]=0;
  v[0]=0;
  for(long i=1;i<=n;i++) {
    cin >> t[i];
    t[i]+=t[i-1];
  }
  for(long i=1;i<=n;i++) cin >> v[i];

  long res=0;
  long right=0;
  for(long i=1;i<2*t[n]+1;i++){
   long left=right;
   right=min(i,2*t[n]-i);
    for(long j=1;j<=n;j++){
     if(i<=2*t[j-1]) right=min(right,2*v[j]+2*t[j-1]-i);
     else if(2*t[j]<=i) right=min(right,2*v[j]+i-2*t[j]);
     else right=min(right,2*v[j]);
    }
    res+=(left+right);
  }
  
   cout << setprecision(12) << double(res)/8.0 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        ArrayList<Integer> list= new ArrayList<Integer>();
        int sum = 0;
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            sum += A[i];
            list.add(A[i]);
        }

        Collections.sort(list);

        if(list.get(N - M)>=sum/4.0/M){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void l(char* str) {
	for (int i = 0; i < strlen(str); i++) {
		str[i] = tolower(str[i]);
	}
}

int main() {
	char W[10+1] = "";
	char T[1000+1] = "";

	int count = 0;
	scanf("%s", W);
	l(W);
	while (1) {
		scanf("%s", T);
		if (strcmp(T, "END_OF_TEXT") == 0) { break; }
		l(T);

		if (strlen(T) != strlen(W)) { continue; }
		if (strcmp(T, W) == 0) { count++; }
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1852
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define sort_i sort((i).begin(),(i).end())

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b - a <= 0) {
		cout << "delicious\n";
	}
	else if (b - a <= x) {
		cout << "safe\n";
	}
	else {
		cout << "dangerous\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int X; cin>>X;
  bool ans = X==3 || X==5 || X==7;
  cout << (ans ? "YES" : "NO") << endl;
  return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    ll a[n],sum=0;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n,greater<int>{});
    sum+=a[0];
    for(int i=1;i<n/2;i++) sum+=a[i]*2;
    if(n%2) sum+=a[n/2];
    cout<<sum;
}


Measured memory_bytes: 5208
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \|     |//  `.
            /  \|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            pass the Test!
*/
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll INF=10000000000000000;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> x(N,0);
    for(ll i=0;i<N;i++){
        cin>>x[i]
    ;}
    //markは負の整数の数
    ll mark=lower_bound(x.begin(), x.end(), 0)-x.begin();
        ll ans=INF;
        vector<ll> time(mark+1,0);
        for(ll i=max(0LL,mark-K);i<=min(N-K,mark);i++){
            if(i!=mark-K&&i!=mark){time[i]=abs(x[i])+abs(x[i+K-1]);time[i]+=min(abs(x[i]),abs(x[i+K-1]));}
            else if(i==mark-K){time[i]=abs(x[i]);}
            else if(i==mark){time[i]=abs(x[i+K-1]);}
            //cout<<time[i]<<endl;
            ans=min(ans,time[i])
        ;}
        cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 1792