akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;
    vi A(N);
    vll s(N);

    REP(i, N) {
        cin >> A[i];
        s[i] = A[i];
        if (i > 0) s[i] += s[i-1];
    }

    ll diff = (1LL << 50);
    int li = 0;
    int ri = 2;
    // i -> max index of left side
    // li -> max index of left side of left side
    // ri -> min index of right side of right side
    FOR(i, 1, N - 2) {

        ll aa, ab, ba, bb;

        while (abs(s[i] - 2 * s[li]) > abs(s[i] - 2 * s[li + 1])) li++;
        aa = s[li];
        ab = s[i] - s[li];

        while (abs(s[N - 1] - 2 * s[ri] + s[i]) > abs(s[N - 1] - 2 * s[ri + 1] + s[i])) ri++;
        ba = s[ri] - s[i];
        bb = s[N - 1] - s[ri];

        // cout << li << " " << i << " " << ri << endl;

        ll x = min({aa, ab, ba, bb});
        ll y = max({aa, ab, ba, bb});

        diff = min(diff, y - x);
        
    }

    cout << diff << endl;

    return 0;
}


Measured memory_bytes: 2560
K=int(input())
import queue
q=queue.Queue()
for i in range(1,10):
  q.put(i)
for j in range(1,K+1):
  x=q.get(j)
  if x%10!=0:
    q.put(10*x+x%10-1)
  q.put(10*x+x%10)
  if x%10!=9:
    q.put(10*x+x%10+1)
print(x)

Measured memory_bytes: 18828
X, Y = map(int, input().split())
Z = [0, 300000, 200000, 100000, 0]

X = min(X, 4)
Y = min(Y, 4)
if (X == 1) and (Y == 1):
    print(1000000)

else:
    print(Z[X] + Z[Y])


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>

int main()
{
    int n;
    long comfort = 0;
    long array[300000];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%ld", &array[i]);
    }
    std::sort(array, array + n);
    std::reverse(array, array + n);

    //comfort += array[0];
        for (int i = 1; i < n; i++) {
            comfort += array[i / 2];
            //printf("%d ", array[i / 2]);
    }
    /*for (int i = 0; i < n; i++)
    {
        printf("%d ", array[i]);
    }*/
    printf("%ld\n", comfort);
    return 0;
}

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

int main()
{
    string str;
    cin >> str;
    int n = str.size();
    bool pali = true;
    if(n%2 == 0)
        pali = false;
    for(int i = 0, j = n-1; pali && i < j;i++, j--)
    {
        if(str[i] != str[j])
        {
            pali=false;
            break;
        }
    }
    for(int i = 0, j = (n-1)/2 - 1; pali && i < j;i++, j--)
    {
        if(str[i] != str[j])
        {
            pali=false;
            break;
        }
    }
    for(int i = (n+3)/2-1, j = n- 1; pali &&  i < j;i++, j--)
    {
        if(str[i] != str[j])
        {
            pali=false;
            break;
        }
    }
    if(pali)
        cout << "Yes";
    else
        cout <<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c=0,aa[200000],ab[200000],ac[200000]={0};
string s;
signed main()
{
	cin>>a>>b>>s;
	rep(i,a){
		if(s[i]=='C'&&s[i-1]=='A'){
			ac[i]=ac[i-1]+1;
		}else{
			ac[i]=ac[i-1];
		}
	}
	rep(i,b){
		cin>>aa[i]>>ab[i];
	}
	rep(i,b){
		cout<<ac[ab[i]-1]-ac[aa[i]-1]<<endl;
	}
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
Nc = 0
e = 0
A.sort()
if N % 2 == 0:
    B = [2*i - 1 for i in range(1, N//2 + 1)]
    B = B + B
    B.sort()
    if A == B:
        Nc = 2**(N//2)
else:
    B = [2*i for i in range(1, (N-1)//2 + 1)]
    B = B + B + [0]
    B.sort()
    if A == B:
        Nc = 2**((N-1)//2)

print(Nc%1000000007)

Measured memory_bytes: 14008
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;

string hand = "qwertasdfgzxcvb";

int main(){
	
	string str;
	
	while(cin >> str, str[0]!='#'){
		
		int cnt = 0;
		
		for(int i=0; i<str.size()-1; ++i){
			if( count(hand.begin(), hand.end(), str[i]) ^  count(hand.begin(), hand.end(), str[i+1])  )
				cnt++;
		}
		
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1188
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int sum = 0;
		
		Scanner sc = new Scanner (System.in);
		int[] a = new int[sc.nextInt()]; 
		
		for(int i = 0; i < a.length; i++)
		{
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		
		for(int i = 0; i < a.length - 1; i++)
		{
			sum = sum + a[i];
		}
		
		if(a[a.length - 1] >= sum){
			System.out.println("No");
		} else 
		{
			System.out.println("Yes");
		}
		
	}
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    vector<int> B(N);
    int C = 0;

    for (int i = 0; i < N; i++) {
        B.at(i) = A.at(i);
    }

    sort (A.begin(),A.end());

    int A_max = A.at(N - 1);
    int A_second = A.at(N -2);

    for (int i = 0; i < N; i++) { //sortを外に出せば早く終わるし、Bもいらないかもいやいるわ

        if (B.at(i) == A_max) {
            C = A_second;;
        }

        else {
            C = A_max;
        }

        cout << C << endl;
    }

}

Measured memory_bytes: 3200
#include <iostream>
#include <numeric>
#include <cmath>
#include <queue>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


int main() {
	ll N;
	ll an = 0;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	rep(i, N - 1) {
		an += A.at(N-1 - (i + 1) / 2);
	}
	cout << an << endl;
}

Measured memory_bytes: 4820
# -*- coding: utf-8 -*-
s = input()

n = len(s)
n_ = n-1
fin = [0 for _ in range(n)]

r = 0
for i in range(n_):
    if s[i] == "L":
        r = 0
        continue

    if s[i] == "R":
        r += 1

    if s[i+1] == "L":
        fin[i] = r // 2 + r % 2
        fin[i+1] = r // 2

l = 0
for i in range(n_):
    j = n_ - i
    if s[j] == "R":
        l = 0
        continue

    if s[j] == "L":
        l += 1

    if s[j-1] == "R":
        fin[j] += l // 2 + l % 2
        fin[j-1] += l // 2

print(" ".join(map(str, fin)))


Measured memory_bytes: 10492
#include<stdio.h>
int main(){
  char s[200010];
  scanf("%s",&s);
  int st = 0,tt = 0;
  for(int i = strlen(s) - 1;i > -1;i--){
    if(s[i] == 'T'){
      tt++;
    }else if(tt > 0){
      tt--;
    }else{
      st++;
    }
  }
  printf("%d",st + tt);
  return 0;
}

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

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var axis = CRL().ArrayLongs();
        long val = 0;
        for (int i = 0; i < n; i++)
        {
            val += axis[i] - 1;
        }

        CWL(val);
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array)
    {
        var list = array.ToList();
        list.Sort();
        return list.ToArray();
    }
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    //テンプレここまで
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N; 
  cin >> N;
  vector<int> data(N);
  int un, ov;
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  int ans = 100000000;
  for(int i = 1; i < N; i++){
    un = 0, ov = 0;
    for(int j = 0; j < N; j++){
      if(j <= i - 1) un += data.at(j);
      else ov += data.at(j);
    }
    ans = min(ans, abs(ov - un));
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  int a[N];
  for (int i=0; i<N; i++) {
    cin>>a[i];
  }
  sort(a,a+N,greater<int>());
  int Alice=0,Bob=0;
  for (int i=0; i<N; i++) {
    if (i%2==0) {
      Alice+=a[i];
    } else {
      Bob+=a[i];
    }
  }
  cout<<Alice-Bob<<endl;
  return 0;
}


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

int main()
{
  int a, b, c, ans;
  cin >> a >> b >> c;
  if(a == b)
  {
    ans = c;
  }
  else if(b == c)
  {
    ans = a;
  }
  else
  {
    ans = b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	A, B := getInt(), getInt()
	ans := 0
	for i := 1; i <= N; i++ {
		n := i
		cnt := 0
		for n > 0 {
			cnt += n % 10
			n /= 10
		}
		if A <= cnt && cnt <= B {
			ans += i
		}
	}
	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    map<int,int> mp;
    rep(i,n){
        int k;cin>>k;
        rep(j,k){
            int a;cin>>a;a--;
            mp[a]++;
        }
    }
    int res=0;
    for(auto& p:mp){
        if(p.second==n)res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

struct V {
	double x, y;
	V(double x = 0, double y = 0) : x(x), y(y) {}
	V& operator+=(const V& v) { x += v.x; y += v.y; return *this; }
	V operator+(const V& v) const { return V(*this) += v; }
	V& operator-=(const V& v) { x -= v.x; y -= v.y; return *this; }
	V operator-(const V& v) const { return V(*this) -= v; }
	V& operator*=(double s) { x *= s; y *= s; return *this; }
	V operator*(double s) const { return V(*this) *= s; }
	V& operator/=(double s) { x /= s; y /= s; return *this; }
	V operator/(double s) const { return V(*this) /= s; }
	double dot(const V& v) const { return x * v.x + y * v.y; }
	double cross(const V& v) const { return x * v.y - v.x*y; }
	double norm2() const { return x * x + y * y; }
	double norm() const { return sqrt(norm2()); }

	int ort() const { // orthant
		if (y > 0) return x > 0 ? 1 : 2;
		else return x > 0 ? 4 : 3;
	}
	bool operator<(const V& v) const {
		int o = ort(), vo = v.ort();
		if (o != vo) return o < vo;
		return cross(v) > 0;
	}
};
istream& operator>>(istream& is, V& v) {
	is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
	os << "(" << v.x << "," << v.y << ")"; return os;
}

int main() {
	int n;
	cin >> n;
	vector<V> v(n);
	rep(i, n) cin >> v[i];
	sort(v.begin(), v.end());
	double ans = 0;
	rep(l, n) {
		int r = l;
		V now;
		rep(i, n) {
			now += v[r];
			ans = max(ans, now.norm());
			r = (r + 1) % n;
		}
	}
	printf("%.12f\n", ans);
	return 0;
}


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

using namespace std;

typedef long long ll;

#define INF 10000000
#define mp make_pair
#define fi first
#define se second

int cnt[26];

int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;
    cin >> s;
    for(int i = 0;i<s.size();i++){
        cnt[s[i]-97]++;
    }
    for(int i = 0;i<26;i++){
        if(cnt[i] == 0){
            cout << char(i+97);
            return 0;
        }
    }
    cout << "None";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> vec(n - 1);
    REP(i, n - 1)
    cin >> vec[i];
    vector<ll> a(n);
    a[0] = vec[0];
    REP(i, n - 1)
    {
        ll cand = max(a[i], vec[i]);
        if (i < n - 2)
        {
            cand = min(cand, vec[i + 1]);
        }
        a[i + 1] = cand;
    }
    cout << accumulate(ALL(a), (ll)0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
using Int = int64_t;
template <class T> T gcd(T a, T b) { return a % b ? gcd(b, a % b) : b; }
template <class T> T lcm(T a, T b) { return a * b / gcd(a, b); }
Int solve() {
    Int N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    Int L = lcm(N, M);
    Int g = gcd(N, M), n = N / g, m = M / g;
    for (Int k = 0; k < g; k++) {
        Int a = k * n, b = k * m;
        if (S[a] != T[b]) return -1;
    }
    return L;
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
    int N;
    int X;
    int temp1,temp2;

    scanf("%d\n",&N);

    X=N/1.08;

    temp1=X*1.08;
    temp2=(X+1)*1.08;

    if(N==temp1){
        printf("%d\n",X);
    }
  	else if(N==temp2){
      	printf("%d\n",X+1);
    }
    else{
        printf(":(\n");
    }

    return 0;
}

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

long long a[105];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n, s, cur = 1000;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n-1; i++)
    {
        s = 0;
        if (a[i+1] > a[i]) s = cur/a[i];
        cur += (a[i+1]-a[i])*s;
    }
    cout << cur;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    rep(i,0,n) {
        cin>>a[i];
        a[i]--;
    }
    rep(i,0,n) cin>>b[i];
    rep(i,0,n-1) cin>>c[i];
    
    int ans=0;
    rep(i,0,n){
        ans+=b[a[i]];
        if(i<n-1 && a[i+1]-a[i]==1) ans+=c[a[i]];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll ans = N*(N-1)/2 + M*(M-1)/2;
    print(ans);

    

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin>>n;
    int dounts=7;
    int cake=4;
    bool flag=false;
    int count=1;
    for(int i=0;i<25;i++){
        for(int j=0;j<25;j++){
            if(cake*i+dounts*j==n){
                flag = true;
            }
        }
    }
    if(flag==true) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<string,int> m;
  for (int i=0; i<N; i++) {
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    m[S]++;
  }
  ll ret = 0;
  for (auto it : m) {
    ll c = it.second;
    ret += c * (c-1) / 2;
  }
  cout << ret << endl;
}

Measured memory_bytes: 11264
#include <stdio.h>

int main (void){
	int a, b, n = 0;
	
	scanf("%d",&n);
	a = n/10;
	b = n - a*10;
	
	if(a == 9 || b == 9)printf("Yes");
	else printf("No");	
	
	return 0;
}

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

using namespace std;

const int RADIX = 4;

void transfer(int n) {
	string Result;

	do {
		Result += n % RADIX + '0';
		n /= RADIX;
	} while (n);

	reverse(Result.begin(), Result.end());
	cout << Result << endl;
}

int main() {
	int n;
	
	while (cin >> n, n != -1) {
		transfer(n);
	}
	
	return 0;
}


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

vector <int> v;
int val;

int main() {
	int n = 0, k = 0;
	cin>>n>>k;
	
	for(int i = 0; i < n ; ++i)
	{
		cin>>val;
		v.push_back(val);
	}
	
	sort(v.begin() , v.end() );
	
	int sum = 0;
	for(int i = 0; i < k ; ++i)
	{
		sum += v[i];
	}
	
	/*Testing 
	for(int i = 0; i < n ; ++i)
	{
		cout<<v[i]<<endl;
	}
	*/
	
	cout<< sum << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
//#define cin fin
//#define cout fout
using namespace std;

//ifstream fin("file.in");
//ofstream fout("file.out");

const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;

string g;


int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> g;
    for(int i=0;i<=2;i++){
        if(g[i]==g[i+1]) rc("Bad");
    }
    rc("Good");

}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#define PI 3.14159265

using namespace std;
/*  u
p s   t q
*/



void koch(double px, double py, double qx, double qy, int times) {
	
	if(times > 0) {

		//sの座標を求める
		double sx = (2 * px + qx) / 3;
		double sy = (2 * py + qy) / 3;

		//tの座標を求める
		double tx = (px + 2 * qx) / 3;
		double ty = (py + 2 * qy) / 3;

		//uの座標を求める(sを30°回転させる)
		double ux = (tx - sx) * cos(PI / 3) - (ty - sy) * sin(PI / 3) + sx;
		double uy = (tx - sx) * sin(PI / 3) + (ty - sy) * cos(PI / 3) + sy;

		//pとsを端点とする
		koch(px, py, sx, sy, times - 1);

		//sを表示
		printf("%f %f\n", sx, sy);

		//sとuを端点とする
		koch(sx, sy, ux, uy, times - 1);

		//uを表示
		printf("%f %f\n", ux, uy);

		//uとtを端点とする
		koch(ux, uy, tx, ty, times - 1);

		//tを表示
		printf("%f %f\n", tx, ty);

		//tとqを端点とする
		koch(tx, ty, qx, qy, times - 1);
	}
}

int main(){
	int n;
	scanf("%d", &n);
	printf("%f %f\n", 0.00000000, 0.00000000);
	koch(0, 0, 100, 0, n);
	printf("%f %f\n", 100.00000000, 0.00000000);
	return 0;
}


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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() {

	ll N,Y;
	cin >> N >> Y;
	for(ll i = 0; i <= N; i++) {
		for(ll j = 0; j <= N - i; j++) {
			if(i * 10000 + j * 5000 + (N-i-j) * 1000 == Y) {
				cout << i << ' ' << j << ' ' << N-i-j << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << ' ' << -1 << endl;
	return 0;
}

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

namespace MyProgram
{
    public class Program
    {
        public static void Main(string[] args)
        {
             int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
             int N = n[0];
             int X = n[1];
             
             int[] dif = new int[N];
             n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
             for(int i = 0 ; i < N ; i++)
             {
                 dif[i] = Math.Abs(n[i]-X);
             }
             
             Array.Sort(dif);
             
             int a = dif[0];
             
             for(int i = 1 ; i < N ; i++)
             {
                 a = GCD(a, dif[i]);
             }
             Console.WriteLine(a);
        }
        public static int GCD(int a , int b)
        {
            int c = 0;
            if(a < b) return GCD(b,a);
            while(b != 0)
            {
                c = a % b;
                a = b;
                b = c;
            }
            return a;
        }
    }
}

Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,mod,f[100010],ans[100010],head[100010];
vector <ll> l[100010],r[100010],t1[100010];
struct node
{
	int u,v,next;
};
node t[200020];
void build(ll u1,ll v1,ll tot)
{
	t[tot].u=u1;t[tot].v=v1;
	t[tot].next=head[u1];head[u1]=tot;
}
void dfs(ll fa,ll p)
{
	ll cnt=0;
	f[p]=1;
	for(int i=head[p];i;i=t[i].next)
	{
		if(t[i].v!=fa)
		{
			t1[p].push_back(t[i].v);
			dfs(p,t[i].v);
			(f[p]*=(f[t[i].v]+1))%=mod;
			l[p].push_back(0);
			r[p].push_back(0);
			cnt++;
		}
	}
	for(int i=0;i<cnt;i++)
	{
		l[p][i]=(i==0)?1:l[p][i-1];
		(l[p][i]*=(f[t1[p][i]]+1))%=mod;
	}
	for(int i=cnt-1;i>=0;i--)
	{
		r[p][i]=(i==cnt-1)?1:r[p][i+1];
		(r[p][i]*=(f[t1[p][i]]+1))%=mod;
	}
}
void dfs1(ll fa,ll p,ll sum)
{
	ans[p]=(f[p]*(sum+1))%mod;
	for(int i=0;i<t1[p].size();i++)
	{
		int sum1=(i==0)?1:l[p][i-1],sum2=(i==t1[p].size()-1)?1:r[p][i+1];
		dfs1(p,t1[p][i],(sum1%mod*sum2%mod*(sum+1))%mod);
	}
}
int main()
{
	cin>>n>>mod;
	for(int i=1;i<n;i++)
	{
		ll u1,v1;
		cin>>u1>>v1;
		build(u1,v1,i*2);
		build(v1,u1,i*2+1);
	}
	dfs(0,1);
	dfs1(0,1,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]%mod<<endl;
	return 0;
} 

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

int main()
{
    int N, D;
    int X[20][20] = {0};
    cin >> N >> D;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            int temp;
            cin >> temp;
            X[i][j] = temp;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int norm = 0;
            for (int k = 0; k < D; k++)
            {
                int temp = abs(X[i][k] - X[j][k]);
                norm += temp * temp;
            }
            for (int k = 0; k <= norm; k++)
            {
                if (k * k == norm)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans;
}

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

const int MAX = 100000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	int N,K,A[100001];
	long long sum=0;
	cin>>N>>K;
	for(int i=1;i<=N;i++)cin>>A[i];
	sort(A+1,A+N+1);
	COMinit();
	/*for(int t=1;t<=N-K+1;t++){
		for(int s=K-1;s<=N-t;s++){
			sum+=((long long int)(A[t+s]-A[t])*COM(s-1,K-2))%MOD;
			sum%=MOD;
		}
	}*/
	for(int i=K;i<=N;i++){
		sum+=((long long int)A[i]*COM(i-1,K-1))%MOD;
		sum%=MOD;
	}
	for(int i=1;i<=N-K+1;i++){
		sum-=((long long int)A[i]*COM(N-i,K-1))%MOD;
		sum%=MOD;
	}
	if(sum<0)sum+=MOD;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int x;
    cin >> x;
    vector<int> a(N);
    rep(i, 0, N) { cin >> a[i]; }
    sort(all(a));
    int ans = 0;
    rep(i, 0, N) {
        if (a[i] <= x) {
            if (i == N - 1 && a[i] != x) continue;
            ans++;
            x -= a[i];
        } else
            break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
class city
{
  public:
  int pr,yr,index,x;
  string code;
  void calc_code()
  {
    string h=to_string(pr),l=to_string(x);
    int j=6-h.length();
    while(j--)
      h = "0"+h;
    j = 6-l.length();
    while(j--)
      l = "0"+l;
    code = h+l;
  }
};
bool cmp(city a,city b)
{
  if(a.pr==b.pr)
    return a.yr<b.yr;
  return a.pr<b.pr;
}
bool cmpi(city a,city b)
{
  return a.index<b.index;
}
int main()
{
  int n,m;
  cin>>n>>m;
  vector<city> v,d(m);
  for(int i=0;i<m;i++)
    cin>>d[i].pr>>d[i].yr,d[i].index=i;
  sort(d.begin(),d.end(),cmp);
  d[0].x=1;d[0].calc_code();
  for(int i=1;i<m;i++)
  {
    if(d[i].pr==d[i-1].pr)
      d[i].x=d[i-1].x+1;
    else
      d[i].x=1;
    d[i].calc_code();
  }
  sort(d.begin(),d.end(),cmpi);
  for(auto i:d)
    cout<<i.code<<"\n";
  return 0; 
}

Measured memory_bytes: 8576
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=605;
const int mod=1000000007;
template<typename _Tp1,typename _Tp2>Finline void add(_Tp1 &a,_Tp2 b){(a+=b)>=mod&&(a-=mod);}
template<typename _Tp1,typename _Tp2>Finline void sub(_Tp1 &a,_Tp2 b){(a-=b)<0&&(a+=mod);}
int a[N],f[305][305],g[305][305];
bool mark[N],qwq[N];
int main()
{
	int n;read(n);
	for(int i=1;i<=n+n;++i) read(a[i]);
	int cnt=0;
	for(int i=1;i<=n+n;i+=2)
	{
		if(a[i]==-1&&a[i+1]==-1) ++cnt;
		else if(a[i]!=-1&&a[i+1]!=-1) qwq[a[i]]=qwq[a[i+1]]=true;
		else if(~a[i]) mark[a[i]]=true;
		else mark[a[i+1]]=true;
	}
	g[0][0]=1;
	for(int i=n+n;i>=1;--i)
	{
		if(qwq[i]) continue;
		memset(f,0,sizeof(f));
		if(mark[i])
		{
			for(int j=0;j<=n;++j)
			{
				for(int k=0;k<=n;++k)
				{
					add(f[j+1][k],g[j][k]);
					if(k) add(f[j][k-1],g[j][k]);
				}
			}
		}
		else
		{
			for(int j=0;j<=n;++j)
			{
				for(int k=0;k<=n;++k)
				{
					add(f[j][k+1],g[j][k]);
					if(j) add(f[j-1][k],1ll*j*g[j][k]%mod);
					add(f[j][k-1],g[j][k]);
				}
			}
		}
		memcpy(g,f,sizeof(f));
	}
	int ans=g[0][0];
	for(int i=1;i<=cnt;++i) ans=1ll*ans*i%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4440
#include<bits/stdc++.h>
#define N 3050
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
using namespace std;
int n,s;
int dp[N],ar[N];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>s;
    for(int i=0;i<n;i++)
        cin>>ar[i];
    int ans = 0;
  	int mod = 998244353;
    for(int i=0;i<n;i++){
        for(int j=s-ar[i];j>0;j--){
            dp[j+ar[i]] += dp[j];
          dp[j+ar[i]]%=mod;
        }
        dp[ar[i]]+=i+1;
      	dp[ar[i]]%=mod;
      ans += dp[s];ans%=mod;
    }
 	cout<<ans;
        return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	S = [int(s) for s in str(N)]
	# print(S)

	A = []
	smaller = False
	for i in range(len(S)-1):
		if smaller:
			A.append(9)
		else:
			if S[i] == 9 and S[i+1] == 9:
				A.append(9)
			elif S[i+1] == 9:
				A.append(S[i])
			else:
				smaller = True
				A.append(S[i]-1)

	if smaller: A.append(9)
	else: A.append(S[-1])

	# print(A)
	print(sum(A))

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<math.h>
#include <cstdio>
#include<iomanip>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int inf = 10e9 + 7;
int a[100010];
int b[100010];
int c[100010];
signed main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n) {
		cin >> a[i] >> b[i];
		ans -= b[i];
		c[i] = a[i] + b[i];
	}
	sort(c, c + n);
	reverse(c, c + n);
	for (int i = 0; i < n; i += 2) {
		ans += c[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	if(S=="ABC"){
		cout<<"ARC"<<endl;
	}
	else{
		cout<<"ABC"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int a, b, c, d, e, n;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &n);
  if(e-a<=n){
    printf("Yay!");
  }else{
    printf(":(");
  }
  return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //Use String arraylist
		//Very similar to "permutations" on LeetCode (look into List data structure)
		//Can use this to generate all unique anagrams of a word with a complementary hashset
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		double[][] coords = new double[N][2];
		for (int i = 0; i < N; i++) {
			coords[i][0] = input.nextDouble();
			coords[i][1] = input.nextDouble();
		}
		double ans = 0.0;
		ArrayList<String> seq = recur(N,N);
		for (int i = 0; i < seq.size(); i++) {
			String[] curPos = seq.get(i).trim().split(" ");
			int STARTtown = Integer.parseInt(curPos[0])-1; //0 based indexing adjustment
			double curX = coords[STARTtown][0];
			double curY = coords[STARTtown][1];
			for (int town = 1; town < N; town++) {
				int ENDtown = Integer.parseInt(curPos[town])-1;
				double EndX = coords[ENDtown][0];
				double EndY = coords[ENDtown][1];
				double X = Math.abs(curX-EndX);
				double Y = Math.abs(curY-EndY);
				double distance = Math.sqrt(X*X+Y*Y);
				ans+=distance;
				curX = EndX;
				curY = EndY; //Re-updating current position
			}
		}
		double perms = (double)(seq.size());
		ans/=perms; //Going from sum to average of distances
		System.out.println(ans);
	}	
	public static ArrayList<String> recur(int N,int total) {
		ArrayList<String> ans = new ArrayList<String>();
		if (N==1) {
			for (int i = 1; i <= total; i++) {
				String curans = Integer.toString(i)+" ";
				ans.add(curans);
			}
			return ans;
		}
		ArrayList<String> seq = recur(N-1,total);
		for (int i = 0; i < seq.size(); i++) {
			String[] prev = seq.get(i).split(" ");
			boolean[] used = new boolean[total+1]; 
			for (int j = 0; j < prev.length; j++) {
				int number = Integer.parseInt(prev[j]);
				used[number]=true;
			}
			for (int pos = 1; pos <= total; pos++) {
				if (!used[pos]) {
					String cur = seq.get(i).trim();
					cur+=" "+Integer.toString(pos)+" ";
					ans.add(cur);
				}
			}
		}
		return ans;
	}
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;

  int ans = 0;
  for(int i=0; i<N; i++){
    set<char> set1, set2;
    int count = 0;
    for(int j=0; j<N; j++){
      if(j < i){
        set1.insert(S[j]);
      }else{
        set2.insert(S[j]);
      }
    }
    for(char val : set2){
      if(set1.find(val) != set1.end()){
        count++;
      }
    }
    ans = max(count, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	fmt.Println(n * (n + 1) / 2)
}


Measured memory_bytes: 1772
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (j%2)+(i%2) == 1:
                print(".", end = "")
            else:
                print("#", end = "")
        print()
    print()


Measured memory_bytes: 7008
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    X = int(input())

    for i in range(1, 1001):
        if 100 * i <= X and 105 * i >= X:
            print(1)
            return

    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64020
N = int(input())
Bs = list(map(int, input().split()))
result = 0
if N > 2:
    for i in range(1,N-1):
        Ai = min(Bs[i],Bs[i-1])
        result += Ai
    result += Bs[0] +  Bs[-1]
else:
    result = 2 * Bs[0]
print(result)

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char x;
		cin >> x;
		if (x == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
}

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

int main(){
        int N,t,x,y;
        int now_t=0;
        int now_x=0;
        int now_y=0;
        cin >> N;

        for(int i=0;i<N;i++){
                //cout << now_x << "," << now_y << endl;
                cin >> t >> x >> y;
                //cout << t << "," << x << "," << y << endl;
                if(( t-now_t >= abs(x-now_x)+abs(y-now_y) ) &&
                        ((abs(x-now_x)+abs(y-now_y)-(t-now_t))%2 == 0))
                {
                        now_t=t;
                        now_x=x;
                        now_y=y;
                }else{
                        cout << "No" << endl;
                        return 0;
                }
        }
        cout << "Yes" << endl;
        return 0;
}


Measured memory_bytes: 256
s = gets.chomp

l = []
(0..(s.size-1)).each do |num_plus|
  (1..(s.size-1)).to_a.combination(num_plus).each do |positions|
    ss = s.dup
    positions.reverse.each do |pos|
      ss.insert(pos, '+')
    end
    l << ss
  end
end

puts l.map {|s| s.split('+').map(&:to_i).reduce(&:+)}.reduce(&:+)

Measured memory_bytes: 1916
import sys

def resolve():
    a, b = map(int, input().split())

    if b == 1:
        print(0)
        return

    ans = 1
    b -= a

    tmp = (b) // (a-1)
    if (b % (a-1)) > 0:
        tmp += 1

    print(ans + tmp)

if __name__ == "__main__":
    resolve()


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

using namespace std;

int main()
{
    int n, i;
    cin >> n;
    vector<int> A(n);
    for (i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[n - 1] - A[0] << "\n";
    return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
if x > y:
    x, y = y, x
    a, b = b, a
i = 0
total = a*(x-i) + (y-i)*b + 2*i*c
while True:
    # 1枚ずつ変えていく
    i += 1
    ntotal = a*max(0 ,x-i) + b*max(0, (y-i)) + 2*i*c
    if total < ntotal:
        break
    total = ntotal
print(total)

Measured memory_bytes: 3064
#include<iostream>

int main() {
	int N, K;
	int input;
	int answer = 0;

	std::cin >> N >> K;

	for (int i = 0; i < N; i++)
		std::cin >> input;

	answer = (N - 1) / (K - 1);
	if ((N - 1) % (K - 1) != 0)
		answer += 1;

	std::cout << answer << std::endl;

	return 0;
}

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

int main()
{
    int a, b;
    
    cin>> a >> b;
    
    if ( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else cout << "a == b" << endl;
    
    return 0;

}

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

int main(int argc, char const *argv[]) {
  int i, j, length, cnt;
  char lead;
  char str[100001];
  scanf("%s", str);
  // printf("%s %lu", str, strlen(str));
  for(i=0; i<strlen(str)-2; i++){
    if(str[i]==str[i+1]){
      printf("%d %d\n", i+1, i+2);
      return 0;
    }else if(str[i]==str[i+2]){
      printf("%d %d\n", i+1, i+3);
      return 0;
    }
  }
  if( str[strlen(str)-2]==str[strlen(str)-1]){
    printf("%lu %lu\n", strlen(str)-1, strlen(str));
    return 0;
  }
  printf("-1 -1\n");
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{


			  while(true){
				  //????????\???
			     String ab = input.readLine();
		         String []strAry = ab.split(" ");
		         int  a=Integer.parseInt(strAry[0]);
	             int b=Integer.parseInt(strAry[1]);
	             int count=0;
	             int countb=0;
	              if(a==0&&b==0){
	        	      break;
	               }
	                  //a?????°?????????
	                  for(int i=0; i<a; i++){
	                	  //countb????????????????????¨??§else???????????????????????????
	                	  countb=0;
	        	          for(int j=0; j<b; j++){
	        	        	  //count???????????????a???????????????
	        	        	  if(count==a-1||count==0){
	        	        		  //????????????,??????????????¨??????????????????????????????????????????
	        	                 System.out.print('#');
	        	                 //count???????????\????????????????????¨??????????????\?????????
	        	        	  }else{
	        	        		  //countb??????????????¨????????????????????????????????????
	        	        		  countb++;
	        	        		  //countb???????????????????????????
	        	        		  if(countb==1||countb==b){
	        	        			  System.out.print('#');
	        	        			  //countb???????????\???
	        	        		  }else{
                                       System.out.print('.');
	        	        		  }
	        	        	  }


	        	           }
	        	          count++;
	        	          System.out.println("");

	                  }


	                  System.out.println("");
	              }



		    }catch(IOException e) {   System.out.println("Exception : " + e);
		    }

	}
}

Measured memory_bytes: 34192
P32 = 3.times.to_a.permutation(2) # no dup

def init
  [0] * 3
end

n = gets.to_i
# [a, b, c][]
ts = Array.new(n) { gets.split.map(&:to_i) }

dp = [init]
n.times do |i|
  # dp[i + 1] ||= init
  dp << init
  P32.each do |(j, k)|
    # change max
    cost = dp[i][j] + ts[i][k]
    dp[i + 1][k] = cost if dp[i + 1][k] < cost
  end
end

p dp.last.max


Measured memory_bytes: 18040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<double> vec;
    double sum = 0;
    for(int i = 0; i < n; i++)
    {
        double get;
        cin >> get;
        sum += get;
        vec.push_back(get);
    }
    sort(vec.begin(), vec.end(), greater<double>());
    for(int i = 0; i < m; i++)
    {
        if(vec.at(i) < sum / (4 * m))
        {
            cout << "No";
            return 0;
        }
        else if(i == m - 1)
        {
            cout << "Yes";
            return 0;
        }
    }

}



Measured memory_bytes: 256
x,k,d=map(int, input().split())
x=abs(x)
k=abs(k)
d=abs(d)
ans=[]
if x<k*d:
    div=x//d
    if (k-div)%2==0:
        ans.append(abs(x-d*(div)))
    else:
        ans.append(abs(x-d*(div+1)))
    #ans.append(abs(x-d*(div+1)))
else:
    ans.append(x-k*d)

print(min(ans))

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

int main(){
  int N;
  cin >> N;
  long long sum=0;
  vector<int> num(200000);
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    sum+=A;
    num.at(A)++;
  }
  int Q;
  cin >> Q;
  for(int i=0;i<Q;i++){
    int B,C;
    cin >> B >> C;
    sum+=(C-B)*num.at(B);
    num.at(C)+=num.at(B);
    num.at(B)=0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 4052