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

int main(void){
  int N,W;
  cin>>N>>W;
  int tables[N+1][W+1];
  for(int i=0;i<N+1;i++){
    for(int j=0;j<W+1;j++){
      tables[i][j]=0;
    }
  }
  int v[N+1];
  int w[N+1];
  v[0]=0;
  w[0]=0;
  for(int i=1;i<N+1;i++){
    cin>>v[i]>>w[i];
  }

  for(int i=1;i<N+1;i++){
    for(int j=0;j<W+1;j++){
      if(j>=w[i]){
        tables[i][j]=max(tables[i-1][j],tables[i-1][j-w[i]]+v[i]);
      }
      else{
        tables[i][j]=tables[i-1][j];
      }

    }
  }

  cout<<tables[N][W]<<endl;
  return 0;
}



Measured memory_bytes: 7036
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

#define rep(i, a, n) for(int i = a; i <= n; i++)

template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }

// 第一引数 == 第二引数 ? true : false
template<class T, class U>
bool check(T first, U second) {
    return (first == second);
}

// 約数列挙
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


// 数字和
template<class T>
T digitSum(T num) {
    T dig;
    T sum = 0;
    while (num) {
        dig = num % 10;
        sum += dig;
        num /= 10;
    }
    return sum;
}

string background_black(string s) { return "\x1b[40m" + s; }
string background_red(string s) { return "\x1b[41m" + s + "\x1b[40m"; }
string background_green(string s) { return "\x1b[42m" + s + "\x1b[40m"; }
string background_yellow(string s) { return "\x1b[43m" + s + "\x1b[40m"; }
string background_bleu(string s) { return "\x1b[44m" + s + "\x1b[40m"; }
string background_white(string s) { return "\x1b[47m" + s + "\x1b[40m"; }

string black(string s) { return "\x1b[30m" + s + "\x1b[37m"; }
string red(string s) {return "\x1b[31m" + s + "\x1b[37m"; }
string green(string s) { return "\x1b[32m" + s + "\x1b[37m"; }
string yellow(string s) { return "\x1b[33m" + s + "\x1b[37m"; }
string blue(string s) { return "\x1b[34m" + s + "\x1b[37m"; }
string white(string s) { return "\x1b[37m" + s + "\x1b[37m"; }

const int ten = 10;
const int hundred = 100;
const int thousand = 1000;

typedef long long ll;
typedef unsigned long long ull;

string tolower(string s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) {
        c.push_back((s[i] + 0x20));
    } else {
        c.push_back(s[i]);
    }
  }
  return c;
}
#include <cstdlib>
string solve() {
  string str = "";
// int->string: to_string, string->int: stoi
//=============================================================================


  
  int n; 
  cin >> n;
  if (n >= 1000) {
    str += "ABD";
  } else {
    str += "ABC";
  }



//=============================================================================
  str += "\n";
  return str;
}

int main() {	
  std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
  cout << solve() << endl;
}


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

int n,sum;

main() {
  cin >> n;
  for(int i=0;;++i) {
    sum += i;
    if (sum >= n) {
      sum -= n;
      n = i;
      break;
    }
  }
  for(int i=1;i<=n;++i) if (i != sum) cout << i << " ";
  cout << endl;
}
  


Measured memory_bytes: 256
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// //#pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pair<int, pii> a, pair<int, pii> b) {
	if (a.first == b.first) {
		return a.second.first < b.second.first;
	}
	return a.first < b.first;

}




signed main()
{
	haha
// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	int n;
	cin >> n;
	int arr[n];
	int s = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		s += arr[i];
	}
	s %= mod;
	int a = 0;
	for (int i = 0; i < n; i++) {
		int y = (s - arr[i] + mod) % mod;
		a += (y * arr[i]);
		a %= mod;
	}
	a *= modinv(2);
	a %= mod;
	cout << a << endl;













}

Measured memory_bytes: 5156
package main

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

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

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

type Dice struct {
	one   string
	two   string
	three string
	four  string
	five  string
	six   string
}

func (d *Dice) opN() *Dice {
	tmp := d.one // copy

	d.one = d.two
	d.two = d.six
	d.six = d.five
	d.five = tmp

	return d
}

func (d *Dice) opE() *Dice {
	tmp := d.one // copy

	d.one = d.four
	d.four = d.six
	d.six = d.three
	d.three = tmp

	return d
}

func (d *Dice) opS() *Dice {
	tmp := d.one // copy

	d.one = d.five
	d.five = d.six
	d.six = d.two
	d.two = tmp
	return d
}

func (d *Dice) opW() *Dice {
	tmp := d.one // copy

	d.one = d.three
	d.three = d.six
	d.six = d.four
	d.four = tmp
	return d
}

func main() {

	in1 := strings.Split(nextLine(), " ")
	in2 := strings.Split(nextLine(), " ")

	if reflect.DeepEqual(in1, in2) {
		fmt.Println("Yes")
		return
	}

	// create two dices
	dice1 := &Dice{in1[0], in1[1], in1[2], in1[3], in1[4], in1[5]}
	dice2 := &Dice{in2[0], in2[1], in2[2], in2[3], in2[4], in2[5]}

	// dice2を回転させてdice1になるかチェック
	detectTop(dice1, dice2)
	detectFront(dice1, dice2)

	if dice1.three == dice2.three && dice1.four == dice2.four {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func detectTop(dice1, dice2 *Dice) {
	switch dice1.one {
	case dice2.two:
		dice2.opN()
	case dice2.three:
		dice2.opW()
	case dice2.four:
		dice2.opE()
	case dice2.five:
		dice2.opS()
	case dice2.six:
		{
			dice2.opN()
			dice2.opN()
		}
	}
	return
}

func detectFront(dice1, dice2 *Dice) {
	switch dice1.two {
	case dice2.one:
		dice2.opS()
	case dice2.three:
		{
			dice2.opN()
			dice2.opW()
			dice2.opS()
		}
	case dice2.four:
		{
			dice2.opN()
			dice2.opE()
			dice2.opS()
		}

	case dice2.five:
		{
			dice2.opS()
			dice2.opS()
			dice2.opE()
			dice2.opE()
		}
	case dice2.six:
		dice2.opN()
	}
	return
}



Measured memory_bytes: 1172
fun main(args : Array<String>) {
        val l = (1..readLine()!!.toInt()).map { readLine()!![0] }.run {
            listOf(count { it == 'M' }, count { it == 'A' }, count { it == 'R' }, count { it == 'C' }, count { it == 'H' })
                    .map { it.toLong() }
                    .filter { it != 0L }
        }
        print((0 until l.size - 2).map { i ->
                    (i + 1 until l.size - 1).map { j ->
                        (j + 1 until l.size).map { k -> l[i] * l[j] * l[k] }.sum()
                    }.sum()
                }.sum())
}

Measured memory_bytes: 41024
(let* ((a (read))
       (b (read))
       (h (read))
       (m (read))
       (at (- (/ pi 2) (* (/ (+ (* 60 h) m) 720) 2 pi)))
       (bt (- (/ pi 2) (* (/ m 60) 2 pi)))
       (gamma (abs (- at bt)))
       (c (sqrt (+ (expt a 2) (expt b 2) (- (* 2 a b (cos gamma)))))))
  (format t "~F~%" c))


Measured memory_bytes: 23824
n,x=map(int,raw_input().split())
y=n-x
ans=x+y
if y>=x:
    while 1:
        if y%x==0:
            ans+=x+((y-x)/x)*x*2
            print(ans)
            break
        else:
            ans+=((y)/x)*x*2
            y,x=x,y%x
else:
    while 1:
        if x%y==0:
            ans+=y+((x-y)/y)*y*2
            print(ans)
            break
        else:
            ans+=((x)/y)*y*2
            x,y=y,x%y

Measured memory_bytes: 2568
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(N),b(N,N);

    int mi=0;
    if(N%2==1){
        REP2(i,1,(N-1)/2+1){
            a[i-1]=i;
            b[i-1]=N+1-i;
        }
    }else{
        REP2(i,1,(N-1)/2+1){
            if(N+1-2*i<=N/2&&mi==0) mi=1;
            a[i-1]=i;
            b[i-1]=N+1-i-mi;
            
        }
    }
        
    REP(i,M){
        cout << a[i] << " " << b[i] << endl;
    }
    
    
}

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string t, p;
  cin >> t >> p;
  // `pi[i]`: the length of the longest prefix of `p` that is a suffix
  // of p[1..i]
  vector<int> pi(p.size() + 1);
  pi[0] = -1;
  for (int i = 1, k = -1; i <= p.size(); ++i) {
    while (k >= 0 && p[i - 1] != p[k])
      k = pi[k];
    pi[i] = ++k; // either k=-1, so we want pi[i]=0, or we matched p[k] to
                 // p[i-1], so we want pi[i]=k+1
  }

  int j = 0;                           // number of matched characters
  for (int i = 0; i < t.size(); ++i) { // position in text
    while (j >= 0 && t[i] != p[j])
      j = pi[j];
    ++j; // either j=-1, so we want to record that we've matched 0 characters,
         // or we just matched the j+1th character of p with t[i], so we want to
         // increment j
    if (j == p.size()) {
      printf("%d\n", i - p.size() + 1);
      j = pi[j];
    }
  }
}


Measured memory_bytes: 4588
n = int(input())
nows = [0]*n
for i in range(n-1):
    c, s, f = list(map(int,input().split()))
    for j in range(i+1):
        if nows[j] < s:
            nows[j] = s + c
        else:
            nows[j] = s + f*(-(-nows[j]//f)- s//f) + c
for i in nows:
    print(i)

Measured memory_bytes: 3188
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
K = int(input())
q = deque()
q.append((1, 1))
visited = [False] * K
ans = 0
while True:
    s, x = q.popleft()
    if visited[x]:
        continue
    visited[x] = True
    if x == 0:
        ans = s
        break
    q.appendleft((s, (10 * x) % K))
    q.append((s + 1, (x + 1) % K))
print(ans)

Measured memory_bytes: 76724
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N, M;
    cin >> N >> M;

    int X, Y;
    cin >> X >> Y;

    vector<int> x(N), y(M);
    for (int i = 0; i < N; i++) cin >> x[i];
    for (int i = 0; i < M; i++) cin >> y[i];
    x.push_back(X);
    y.push_back(Y);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    bool good = false;
    for (int z = -100; z <= 100; z++) {
        if (x.back() < z && z <= y.front()) good = true;
    }

    if(good) cout << "No ";
    cout << "War";

}



























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct RollingHash{
  using ull = unsigned long long;
  vector<ull> hash,p;
  RollingHash(){}
  RollingHash(const string &s,ull B=1000000007LL){
    Int n=s.size();
    hash.assign(n+1,0);
    p.assign(n+1,1);
    for(Int i=0;i<n;i++){
      hash[i+1]=hash[i]*B+s[i];
      p[i+1]=p[i]*B;
    }
  }
  //S[l, r)
  ull find(Int l,Int r){
    return hash[r]-hash[l]*p[r-l];
  }
};


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string t;
  cin>>t;
  RollingHash rh1(t);
  string s=t;
  reverse(s.begin(),s.end());  
  
  RollingHash rh2(s);
  Int ans=n;
  for(Int i=2;i<n;i++){
    Int l=i*2-2;
    if(l+1<=n){
      auto h1=rh1.find(0,n-l);
      auto h2=rh1.find(l,n);

      auto x1=rh1.find(0,l+1);
      auto x2=rh2.find(n-(l+1),n);
      
      if(h1==h2&&x1==x2) chmin(ans,i);
      //cout<<ans<<":"<<i<<" "<<l<<endl;
      //cout<<h1<<" "<<h2<<":"<<x1<<" "<<x2<<endl;
    }else{
      Int w=(n-i)*2+1;
      auto x1=rh1.find(n-w,n);
      auto x2=rh2.find(0,w);
      if(x1==x2) chmin(ans,i);
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 36120
import java.util.*;
import java.io.*;
import java.lang.*;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
			if (a.equals(a.toUpperCase()))
				System.out.println("A");
			else
				System.out.println("a");
	}
}


Measured memory_bytes: 35688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			if(n==0) break;
			int s[]=new int[n];
			double sum=0;
			for(int i=0;i<n;i++) {
				s[i]=scan.nextInt();
				sum += s[i];
			}
			double ave=sum/n;
			double a=0;
			for(int i=0;i<n;i++) {
				a += Math.pow(s[i]-ave, 2)/n;
			}
			System.out.println(Math.sqrt(a));
		}
	}
}


Measured memory_bytes: 31428
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	int B[M];
	int A[N][M];
	rep(i, M) cin >> B[i];
	rep(i, N) {rep(j, M) cin >> A[i][j];}

	int ans = 0;
	rep(i, N) {
		int left = C;
		rep(j, M) {
			left += A[i][j]*B[j];
		}

		if(left>0) ans++;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using vi = vector<int>;

struct SegTree{
    int n; vector<int> dat;
    // 初期化
    SegTree(){}
    SegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<int>(2*n-1,0);
    }

    void add(int k, int a){
        k+=n-1;
        dat[k]=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=dat[2*k+1]+dat[2*k+2];
        }
    }
    // 内部的に投げられるクエリ
    int _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return 0;

        if(a<=l && r<=b) return dat[k];

        int vl=_query(a,b,2*k+1,l,(l+r)/2);
        int vr=_query(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
    // [a,b)
    int query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

const ll mod = 998244353;
const int N = 200002;
ll p2[N];

int main(){
    p2[0] = 1;
    for(int i=1; i<N; ++i) p2[i] = (p2[i-1]*2)%mod;

    int n;
    cin >>n;

    vi x(n),y(n);
    vi ux,uy;
    rep(i,n){
        cin >>x[i] >>y[i];
        ux.pb(x[i]);
        uy.pb(y[i]);
    }

    sort(all(ux));
    sort(all(uy));

    vector<int> h(n);
    rep(i,n){
        int idx = lower_bound(all(ux), x[i]) - ux.begin();
        h[idx] = lower_bound(all(uy), y[i]) - uy.begin();
    }

    // 0:lower, 1:upper
    vector<vi> L(n,vi(2)), R(n,vi(2));
    SegTree t;

    t = SegTree(n);
    rep(i,n){
        int Y = h[i];
        L[i][0] = t.query(0,Y);
        L[i][1] = t.query(Y+1,n);
        t.add(Y, 1);
    }
    t = SegTree(n);
    for(int i=n-1; i>=0; --i){
        int Y = h[i];
        R[i][0] = t.query(0,Y);
        R[i][1] = t.query(Y+1,n);
        t.add(Y, 1);
    }

    ll ans = 0;
    rep(i,n){
        // not include p[i]
        rep(lm,1<<2)rep(rm,1<<2){
            bool valid = false;
            rep(j,2){
                if((lm>>j&1) && (rm>>(!j)&1)) valid = true;
            }
            if(!valid) continue;

            ll add = 1;
            rep(j,2){
                if(lm>>j&1) (add *= (p2[L[i][j]]-1+mod)) %= mod;
                if(rm>>j&1) (add *= (p2[R[i][j]]-1+mod)) %= mod;
            }
            (ans += add) %= mod;
        }

        // include p[i]
        (ans += p2[n-1]) %= mod;
    }
    cout << ans << "\n";
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(x < a[i]){
            cout << ans << endl;
            return 0;
        }
        ans++;
        x -= a[i];
    }
    if(x != 0) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int a,b;
	cin >> a >> b;
	cout << ((a-1)*(b-1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;
 
const int INF = 1e9 + 7;
 
using namespace std;
 
ll gcd(ll n, ll k)
{
    if (k == 0)
	return n;
    ll mod = n % k;
    return gcd(k, mod);
}
 
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin >> n;
 
    vector<int> a(n);
    rep (i, 0, n)
	cin >> a[i];
 
    int l_gcd[n + 1];
    int r_gcd[n + 1];
    l_gcd[0] = 0;
    r_gcd[n] = 0;
 
    rep (i, 1, n) {
	l_gcd[i] = gcd(l_gcd[i - 1], a[i - 1]);
	r_gcd[n - i] = gcd(r_gcd[n - i + 1], a[n - i]);
    }
 
    int res = 0;
    rep (i, 0, n)
	res = max(res, (int)gcd(l_gcd[i], r_gcd[i + 1]));
 
    cout << res << endl;
 
    return 0;
}
  

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
#define MAX_N 1000007
long long A, B, W[MAX_N], cnt; bool prime[MAX_N];
vector<short>V[MAX_N];
void primesieve() {
	for (int i = 2; i*i <= 1000000; i++) {
		for (int j = i*i; j <= 1000000; j += i) prime[j] = true;
	}
	for (int i = 0; i <= 1000000; i++)prime[i] ^= true;
}
int main() {
	cin >> A >> B; long long L = A - B, R = A + B; primesieve(); if (L <= 0)L = 1;
	for (long long i = L; i <= R; i++) { W[i - L] = i; }
	for (long long i = 2; i <= 1000000; i++) {
		if (prime[i] == false)continue;
		long long F = (L / i)*i; if ((L%i) > 0)F += i;
		for (long long j = F; j <= R; j += i) {
			int cnts = 0;
			while (W[j - L] % i == 0) { W[j - L] /= i; cnts++; }
			if (cnts >= 1) { V[j - L].push_back(cnts); }
		}
	}
	for (long long i = L; i <= R; i++) { if (W[i - L] >= 2 && W[i - L] != i)V[i - L].push_back(1); }
	for (long long i = L; i <= R; i++) {
		bool OK = true; if (i <= 1LL)OK = false;
		for (int j = 1; j < V[i - L].size(); j++) {
			if (V[i - L][j - 1] < V[i - L][j])OK = false;
		}
		if (OK == true)cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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


int main(int argc, char *argv[])
{
    int n, a;
    long long min = 10000001, max = -10000001, sum = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        min = a < min ? a : min;
        max = a > max ? a : max;
        sum += a;
    }
    printf("%lld %lld %lld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
using namespace std;

string S;
size_t cur = 0;
int parse();
int number();
int expression();
int factor();
char readchar();
char peek();

//------ number ------

int digit()
{
    int n = readchar() - '0';
    return n;
}

int number()
{
    int n = digit();
    while (peek() != '=' && isdigit(peek()))
    {
        n = n * 10 + digit();
    }
    return n;
}

//------ expression ------

int term()
{
    int a = factor();
    while (peek() != '=' && peek() != ')' && (peek() == '*' || peek() == '/'))
    {
        char op = readchar();
        int b = factor();

        if (op == '*')
            a *= b;
        else if (op == '/')
            a /= b;
    }
    return a;
}

int expression()
{
    int a = term();
    while (peek() != '=' && peek() != ')' && (peek() == '+' || peek() == '-'))
    {
        char op = readchar();
        int b = term();

        if (op == '+')
            a += b;
        else if (op == '-')
            a -= b;
    }
    return a;
}

int factor()
{
    if (peek() != '(')
        return number();
    cur += 1;
    int n = expression();
    assert(peek() == ')');
    cur += 1;
    return n;
}

//------ parse ------

int parse()
{
    cur = 0;
    return expression();
}

//------ READ ------

char readchar()
{
    char ret = S[cur++];
    return ret;
}
char peek()
{
    return S[cur];
}

//------------------

int main()
{
    int N;
    cin >> N;
    for (size_t i = 0; i < (size_t)N; i++)
    {
        cin >> S;
        int ans = parse();
        cout << ans << endl;
    }
}


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

const int N = 110;

int cnt[N];

void no(){
	puts("Impossible");
	exit(0);
}

int main(){
	int n;
	scanf("%d", &n);
	int min = INT_MAX, max = 0;
	for (int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		++ cnt[x];
		min = std::min(min, x);
		max = std::max(max, x);
	}
	if (cnt[min] < 1 || cnt[min] > 2) no();
	if (cnt[min] == 1 && max != 2 * min || cnt[min] == 2 && max != 2 * min - 1) no();
	for (int i = min + 1; i <= max; ++ i){
		if (cnt[i] < 2) no();
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
alist = list(map(int, input().split()))
boxList = [0] * (n + 1)

m = 0
resultList = []

for i in range(1, n+1)[::-1]:
    sums = 0
    for j in range(1, n // i):
        sums += boxList[(j+1) * i]
    if sums % 2 != alist[i - 1]:
        boxList[i] = 1
        m+= 1
        resultList.append(i)

print(m)
if m != 0:
    print(' '.join(map(str, resultList)))


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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 n, k; cin >> n >> k;
  ll x = n/k;
  n -= k*x;
  while(abs(n-k) < n) n = abs(n-k);
  cout << n << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int a, b, q;
  scanf("%d %d %d", &a, &b, &q);
  vector<ll> s(a), t(b), o(q), is(a), it(b), st(a, LONG_LONG_MAX),
      ts(b, LONG_LONG_MAX);
  for(int i = 0; i < a; i++) {
    scanf("%lld", &s[i]);
    is[a - 1 - i] = -s[i];
  }
  for(int i = 0; i < b; i++) {
    scanf("%lld", &t[i]);
    it[b - 1 - i] = -t[i];
    auto itfw = upper_bound(s.begin(), s.end(), t[i]),
         itba = upper_bound(is.begin(), is.end(), -t[i]);
    if(itfw != s.end()) ts[i] = min(ts[i], *itfw - t[i]);
    if(itba != is.end()) ts[i] = min(ts[i], *itba + t[i]);
  }
  for(int i = 0; i < a; i++) {
    auto itfw = upper_bound(t.begin(), t.end(), s[i]),
         itba = upper_bound(it.begin(), it.end(), -s[i]);
    if(itfw != t.end()) st[i] = min(st[i], *itfw - s[i]);
    if(itba != it.end()) st[i] = min(st[i], *itba + s[i]);
  }
  for(int i = 0; i < q; i++) {
    ll x, m = LONG_LONG_MAX;
    scanf("%lld", &x);
    int sb = -distance(is.end(), upper_bound(is.begin(), is.end(), -x)) - 1,
        sf = distance(s.begin(), upper_bound(s.begin(), s.end(), x)),
        tb = -distance(it.end(), upper_bound(it.begin(), it.end(), -x)) - 1,
        tf = distance(t.begin(), upper_bound(t.begin(), t.end(), x));
    if(sb >= 0) m = min(m, x - s[sb] + st[sb]);
    if(sf < a) m = min(m, s[sf] - x + st[sf]);
    if(tb >= 0) m = min(m, x - t[tb] + ts[tb]);
    if(tf < b) m = min(m, t[tf] - x + ts[tf]);
    o[i] = m;
  }
  for(int i = 0; i < q; i++) printf("%lld\n", o[i]);
}

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

int main() {
	int h, w;
	int i, j;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (i = 0; i < h; i++) {
			if (i == 0 || i == h-1) {
				for (j = 0; j < w; j++) cout << "#";
			}
			else {
				cout << "#";
				for (j = 0; j < w-2; j++) cout << ".";
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> cnt(N);
    ll m=0;
    rep(i,N){
        ll d;
        cin >> d;
        if (i==0&&d!=0){
            cout << 0 << endl;
            return 0;
        }
        cnt[d]++;
        chmax(m,d);
    }
    if (cnt[0]!=1){
        cout << 0 << endl;
        return 0;
    }
    rep(i,m+1){
        if (cnt[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans=1;
    ll i=1;
    while(cnt[i]>0){
        rep(j,cnt[i]){
            ans*=cnt[i-1];
            ans%=MOD;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    if(s[s.size()-1]=='s'){
        s.push_back('e');
        s.push_back('s');
    }else{
        s.push_back('s');
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
        return 0;
    }
    cout << min((2 * n - b - a + 3) / 2 - 1, (a + b + 1) / 2 - 1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		run();
	}
	static void run(){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String tmp;
		StringBuilder eraser = new StringBuilder();
		String erasera[] = new String[10000];
		erasera = s.split("eraser");
		for(int i = 0; i < erasera.length; i++){
			eraser.append(erasera[i]);
		}
		StringBuilder dreamer = new StringBuilder();
		String dreamera[] = new String[10000];
		tmp = eraser.toString();
		dreamera = tmp.split("erase");
		for(int i = 0; i < dreamera.length; i++){
			dreamer.append(dreamera[i]);
		}
		StringBuilder erase = new StringBuilder();
		String erasea[] = new String[10000];
		tmp = dreamer.toString();
		erasea = tmp.split("dreamer");
		for(int i = 0; i < erasea.length; i++){
			erase.append(erasea[i]);
		}
		StringBuilder dream = new StringBuilder();
		String dreama[] = new String[10000];
		tmp = erase.toString();
		dreama = tmp.split("dream");
		for(int i = 0; i < dreama.length; i++){
			dream.append(dreama[i]);
		}
		dream.append("*");
		tmp = dream.toString();
		if(tmp.equals("*")){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 16312
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

int main() {
	int n, d;
	cin >> n >> d;
	int tree = 0, man = 0;
	while (tree < n) {
		man++;
		tree += (1 + 2 * d);
	}
	cout << man << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll cnt1 = b/c - a/c;
    ll cnt2 = b/d - a/d;
    if(a%c == 0)cnt1++;
    //if(b%c == 0)cnt1++;
    if(a%d == 0)cnt2++;
    //if(b%d == 0)cnt2++;
    ll e = c*d/gcd(c, d);
    ll cnt3 = b/e - a/e;
    if(a%e == 0)cnt3++;
    //if(b%e == 0)cnt3++;
    cout << (b-a+1)-(cnt1+cnt2-cnt3) <<endl; 
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<string>
#include <vector>

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

using namespace std;

int main(){

	int ans = 0;
	char s[4];
	scanf("%s", s);
	REP(i, 4){
		if (s[i] == '+'){
			ans++;
		}
		else if (s[i] == '-'){
			ans--;
		}
	}

	printf("%d\n", ans);
	return 0;
}

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

int main() {
    /*変数定義，入力*/
    ll N;
    cin >> N;
    
    //ll A, B;cin >> A >> B;
    //vector<ll> a(N);  rep(i, N) cin >> a[i];
    
    /*演算*/
    ll sum = 0; 
    for(int i = 1; i <= N; i++){
       if(i%3 == 0 || i%5 == 0){
       }else{
           sum += i;
       }
    }
    /*出力*/
    cout << sum << endl;
    /*終了*/
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
    int r,c,i,j,a[102][102]={0};
    scanf("%d%d",&r,&c);
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            scanf("%d",&a[i][j]);
            a[r][j]+=a[i][j];
            a[i][c]+=a[i][j];
        }
    }
    for(i=0; i<r; i++){
        a[r][c]+=a[i][c];
    }
    for(i=0; i<=r; i++){
        for(j=0; j<=c; j++){
            printf("%d",a[i][j]);
            if(j!=c) printf(" ");
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7 ;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int M=1000001;
vector<int>graph[M];
int deg[M];

int mapto(int x,int y){
    return min(x,y)*1000+max(x,y);
    }

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int last;
        cin>>last;
        last--;
        for(int j=0;j<n-2;j++){
            int cur;
            cin>>cur;
            cur--;
            int p1,p2;

            p1=mapto(i,last);p2=mapto(i,cur);
            graph[p1].push_back(p2);
            deg[p2]++;
            last=cur;
        }
    }
    vector<int>v;
    for(int i=0;i<M;i++){if(deg[i]==0)v.push_back(i);}
    int day=0;
    int c=0;
    while(v.size()!=0){
        day++;
        c+=v.size();
        vector<int>v1;
        for(int i=0;i<v.size();i++){
            int x=v[i];
            for(int j=0;j<graph[x].size();j++){
                deg[graph[x][j]]--;
                if(deg[graph[x][j]]==0){v1.push_back(graph[x][j]);}
            }
        }
        v=v1;
    }
    if(c!=M){cout<<-1<<endl;return 0;}
    cout<<day<<endl;
    return 0;
    }


Measured memory_bytes: 45432
#include <stdio.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    int b[n-1];
    for(i=0;i<n-1;i++) scanf("%d",&b[i]);
    int sum=b[0];
    for(i=0;i<n-2;i++){
        if(b[i]>b[i+1]) sum+=b[i+1];
        else sum+=b[i];
    }
    printf("%d",sum+b[n-2]);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main() {
	int n;
	int result = 0;
  int result2 = 0;
	int kai[130] = {};
	int num[130] = {};
	int sosu[26] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101 };
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		kai[i] = i;
	}
	for (int i = 0; sosu[i] <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= 6; k++) {
				if (kai[j] % sosu[i] == 0) {
					num[sosu[i]]++;
					kai[j] /= sosu[i];
				}
			}
		}
	}
	for (int i = 0; sosu[i] <= n; i++) {
		if (num[sosu[i]] >= 74) {
			result++;
		}
	}

	for (int i = 25;  i >= 0; i--) {
		if (num[sosu[i]] >= 2) {
			for (int j = 25; j >= 0; j--) {
				if (num[sosu[j]] >= 24) {
					if (sosu[i] != sosu[j]) {
						result++;
					}
				}
			}
		}
	}

	for (int i = 25;  i >= 0; i--) {
		if (num[sosu[i]] >= 4) {
			for (int j = 25;  j >= 0; j--) {
				if (num[sosu[j]] >= 14) {
					if (sosu[i] !=sosu[j]) {
						result++;
                      
					}
				}
			}
		}
	}

	for (int i = 25; i>=0; i--) {
		if (num[sosu[i]] >= 2) {
			for (int j = 25; j >= 0; j--) {
				if (num[sosu[j]] >= 4) {
					for (int k = 25;  k >= 0; k--) {
						if (num[sosu[k]] >= 4) {
                        
							if (sosu[i] != sosu[j] && sosu[i] !=sosu[k] && sosu[k] != sosu[j]) {
								result2++;
							}
						}
					}
				}
			}
		}
	}
  result+=result2/2;
	printf("%d", result);
  for (int i = 0; sosu[i] <= n; i++) {
	}
}

Measured memory_bytes: 128
n = int(input())
B = list(map(int, input().split()))

ans = []

for i in range(n):
    for j in range(len(B)-1, -1, -1):
        if B[j] == j+1:
            ans.append(B.pop(j))
            break
    else:
        print(-1)
        break
else:
    for a in ans[::-1]:
        print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	string a;
	int cnt[26];
	ll ans=0;
	cin>>a;
	fill(cnt,cnt+26,0);
	for(int i=0;i<a.size();i++)
		cnt[a[i]-'a']++;
	ans=(ll)a.size()*((ll)a.size()-1LL)/2;
	for(int i=0;i<26;i++)
		ans-=(ll)cnt[i]*(ll)(cnt[i]-1)/2;
	ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>

using namespace std;

int odd,even;

int main()
{
    int n,i,j,a[100005]={0};
    scanf("%d", &n);
    for(i=0;i<n;++i)
    {
        scanf("%d", &a[i]);
        if(a[i]%2==1)
        {
            odd++;
        }
        else{
            even++;
        }
    }
    if(odd%2==0)
    {
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

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

signed main(){
  ll H, W;
  cin >> H >> W;

  if (H == 1 || W == 1) cout << 1 << endl;
  else cout << (H * W - 1) / 2 + 1 << endl;

  return 0;
}

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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)


#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code	
    int n;
    cin >> n;
    ll v,ans=0;
    forn(i,n){
        cin >> v;
        while(v%2==0)
        {
            v/=2;
            ans++;
        }
    }
    cout << ans;
	
	return 0;

}



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

using namespace std;

#define foru(i, l, r) for (int i = l; i <= r; i++)
#define ford(i, r, l) for (int i = r; i >= l; i--)

int read() {
  int res = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

const int maxn = 1e6 + 6;
int N, M, d[maxn], cnt;

int main() {
  //  freopen("b.in", "r", stdin);
  //  freopen("b.out", "w", stdout);
  N = read(), M = read();
  foru(i, 1, M) d[read()]++, d[read()]++;
  foru(i, 1, N) cnt += d[i] & 1;
  puts(cnt > 1 ? "NO" : "YES");
  return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string a,b;cin>>a>>b;

  if(a.size()==b.size()){
    if(a==b){
      cout<<"EQUAL"<<endl;
    }else if(a<b){
      cout<<"LESS"<<endl;
    }else {
      cout<<"GREATER"<<endl;
    }
  }else if(a.size()<b.size()){
    cout<<"LESS"<<endl;
  }else {
    cout<<"GREATER"<<endl;
  }
  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll x;
  cin >> x;
  ll ans = (x/11)*2;
  ll ama = x%11;
  if(ama>6) ans += 2;
  else if(ama>0) ans += 1;
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a;
	cin>>b;
    cin>>c;
    cout<<a<<' '<<b<<' '<<3*c-a-b<<endl;
    cout<<4*c-2*a-b<<' '<<c<<' '<<-2*c+2*a+b<<endl;
    cout<<-c+a+b<<' '<<2*c-b<<' '<<2*c-a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char x[4];
    int i,count=0;
    for(i=0;i<4;i++)
    {
        scanf("%c",&x[i]);
    }
    for(i=0;i<4;i++)
    {
        if(x[i]=='+')
        {
            ++count;
        }

        if(x[i]=='-')
        {
            --count;
        }

    }
    printf("%d",count);
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((c > a && c < b) || (c > b && c < a))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll ans,M[100007];

ll compME(ll b, ll e, ll m){  // bのe乗のmod m を返す
    if (e == 0) return 1;
    ans = compME(b, e / 2, m);
    ans = (ans * ans) % m;
    if (e % 2 == 1) ans = (ans * b) % m;
    return ans;
}

int main(){
    ll N,A[100007],T=1,C=1;
    cin >> N;
    rep(i,N){
        cin >> A[i];
        if(A[i]%2==0){
            T*=2;
        }
        C*=3;
    }
    cout << C-T << endl;
}


Measured memory_bytes: 256