akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
int n;
cin>>n;
vector<int> d(n);
rep(i,n)cin>>d[i];
int ans=0;
rep(i,n){for (int j = i+1; j < n; ++ j) {
	ans+=d[i]*d[j];
}
}
cout<<ans<<endl;

return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  string s, e, ans;
  cin >> s >> e;
  for(int i = 0; i < s.length() + e.length(); i++){
    if(i%2 == 0){
      ans += s[i / 2];
    }else{
      ans += e[i / 2];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(void) {
	int n, m;
	int p;
	char s[2];
 
	scanf("%d%d", &n, &m);
	int ac[100000] = { 0 }, wa[100000] = { 0 };
	for (int i = 0; i < m; i++) {
		scanf("%d%s", &p, s);
		if (!strcmp(s, "AC"))
			ac[p]++;
		else if (ac[p] <= 0)
			wa[p]++;
	}
 
	int correct = 0, failed = 0;
	for (int i = 1; i <= n; i++) {
		if (ac[i] > 0) {
			correct++;
			if (wa[i] > 0)
				failed += wa[i];
		}
	}
 
	printf("%d %d", correct, failed);
	return 0;
}

Measured memory_bytes: 896
#https://atcoder.jp/contests/abc075/submissions/15509548

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

def lowlink(g, root=0):
    n = len(g)
    order = [n]*n
    low = [n]*n

    s = [root]
    cnt = 0
    par = [-1]*n
    seq = []
    while s:
        v = s.pop()
        if order[v] != n:
            continue
        order[v] = cnt
        seq.append(v)
        low[v] = cnt
        cnt += 1
        for u in g[v]:
            if order[u] < cnt:
                if par[v] != u:
                    low[v] = min(low[v], order[u])
                    continue
            else:
                par[u] = v
                s.append(u)
    child = [[] for _ in range(n)]
    for v in range(n):
        if par[v] != -1:
            child[par[v]].append(v)
    seq.reverse()
    for v in seq:
        for u in child[v]:
            low[v] = min(low[v], low[u])
    # bridge
    bridge = []
    for p in range(n):
        for c in child[p]:
            if order[p] < low[c]:
                bridge.append((p, c))

    # articulation points
    AP = []
    for v in range(n):
        if v == root:
            if len(child[v]) >= 2:
                AP.append(v)
        else:
            for c in child[v]:
                if order[v] <= low[c]:
                    AP.append(v)
                    break
    return AP, bridge

_, bridge = lowlink(g, 0)
print(len(bridge))


Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define LL long long
using namespace std;
int n,s[55][55];
int main()
{
	RI i,j,t,u,v;long long x;char c;for(scanf("%d",&n),i=1;i<=n;++i)
	{
		x=t=0;W(!isdigit(c=getchar()));W(x=(x<<3)+(x<<1)+(c&15),isdigit(c=getchar()));
		if(c=='.') W(isdigit(c=getchar())) x=(x<<3)+(x<<1)+(c&15),++t;
		u=v=0;W(t<9) ++t,++u,++v;W(!(x%2)) x/=2,++u;W(!(x%5)) x/=5,++v;++s[u][v];
	}
	long long ans=0;for(i=0;i<=50;++i) for(j=0;j<=50;++j) for(u=0;u<=50;++u)
		for(v=0;v<=50;++v) min(i+u,j+v)>=18&&(ans+=1LL*s[i][j]*(s[u][v]-(i==u&&j==v)));
	return printf("%lld\n",ans>>1),0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000003;

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

int mod_inv(int X){
	int a = X, b = MOD, u = 1, v = 0;
	while(b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if(u < 0) u += MOD;
	return u;
}

vector<int> fact,factinv;

void nCr_init(int N){
	N = min(N,(int)MOD);
	fact.resize(N + 1);
	factinv.resize(N + 1);
	fact[0] = 1;
	for(int i = 1;i <= N;i++) fact[i] = fact[i - 1] * i % MOD;
	factinv[N] = mod_inv(fact[N]);
	for(int i = N;i >= 1;i--) factinv[i - 1] = factinv[i] * i % MOD;
}

int nCr(int ncr_n,int ncr_r){
	if(ncr_n >= MOD) return nCr(ncr_n % MOD, ncr_r % MOD) * nCr(ncr_n / MOD, ncr_r / MOD) % MOD;
	return ncr_r > ncr_n ? 0 : fact[ncr_n] * factinv[ncr_n - ncr_r] % MOD * factinv[ncr_r] % MOD;
}

int pow2(int a,int b){
	if(!b) return 1;
	int tmp = pow2(a * a % MOD,b / 2);
	if(b % 2) tmp = (tmp * a) % MOD;
	return tmp;
}

signed main(){
	int q;
	cin >> q;
	nCr_init(MOD - 1);
	for(int i = 0;i < q;i++){
		int x,d,n;
		cin >> x >> d >> n;
		if(!d) cout << pow2(x,n) << endl;
		else if(n >= MOD) cout << 0 << endl;
		else cout << fact[n] * nCr(MOD - x * mod_inv(d) % MOD,n) % MOD * pow2(MOD - d,n) % MOD << endl;
	}
}


Measured memory_bytes: 16512
from sys import exit
s = input()[::-1]
while True:
  if s == '':
    print('YES')
    exit()
  for w in ['maerd', 'remaerd', 'esare', 'resare']:
    if s.startswith(w):
      s = s[len(w):]
      break
  else:
    print('NO')
    exit()


Measured memory_bytes: 3236
{-# LANGUAGE BangPatterns     #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiWayIf       #-}
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State
import           Control.Monad.Trans.State
import           Data.Array.IArray
import           Data.Array.ST
import           Data.Array.Unboxed        (UArray)
import qualified Data.Array.Unboxed        as U
import           Data.Bits
import           Data.ByteString.Char8     (ByteString)
import qualified Data.ByteString.Char8     as BS
import           Data.Char
import           Data.Graph
import           Data.Int                  (Int64)
import           Data.List
import           Data.Maybe
import           Data.Proxy
import           Data.Sequence             (Seq, (<|), (><), (|>))
import qualified Data.Sequence             as Seq
import qualified Data.Set                  as S
import           Data.STRef
import qualified Data.Vector               as V
import qualified Data.Vector.Unboxed       as VU
import           Numeric

main :: IO ()
main = do
  [a,b,c] <- readLnAsListWith unconsInt
  k <- readLn
  putStrLn $ if solve k a b c then "Yes" else "No"





solve :: Int -> Int -> Int -> Int -> Bool
solve 0 a b c = if a < b && b < c then True else False
solve k a b c = let b' = b * 2
                    c' = c * 2
                in if (a < b' && b' < c) || (a < b && b < c')
                   then True
                   else (solve (k-1) a b' c) || (solve (k-1) a b c')


-- converter
unconsChar :: StateT BS.ByteString Maybe Char
unconsChar = StateT BS.uncons

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

unconsInteger :: StateT BS.ByteString Maybe Integer
unconsInteger = StateT $ BS.readInteger . BS.dropWhile isSpace

-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith st = unfoldr (runStateT st) <$> BS.getLine

-- for unboxed vector
readLnAsUVecNWith :: VU.Unbox a => Int -> StateT BS.ByteString Maybe a -> IO (VU.Vector a)
readLnAsUVecNWith !n !st = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- for boxed vector
readLnAsVecNWith :: Int -> StateT BS.ByteString Maybe a -> IO (V.Vector a)
readLnAsVecNWith !n !st = V.unfoldrN n (runStateT st) <$> BS.getLine

getAsString :: IO [String]
getAsString = map BS.unpack . BS.words <$> BS.getLine

getAsCharArray1DWithLength :: IO (Int, UArray Int Char)
getAsCharArray1DWithLength = BS.getLine >>= \ !cs ->
  let !n = BS.length cs
      !ary = (U.listArray (1,n) $ unfoldr BS.uncons cs) :: UArray Int Char
  in return (n, ary)

-- n: number of lines
-- m: number of chars per a line
getAsCharArray2D :: Int -> Int -> IO (UArray (Int,Int) Char)
getAsCharArray2D !n !m = U.listArray ((1,1),(n,m)) . unfoldr BS.uncons . BS.concat <$> replicateM n BS.getLine


Measured memory_bytes: 3908
#include<string>
#include<iomanip>
#include<iostream>
#include<math.h>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;
#define NUM 100001
typedef long long ll;

bool desc(pair<string, int > a, pair<string, int > b)
{
	if (a.first != b.first)
		return a.first < b.first;
	else
		return (a.second > b.second);
}

int main() {
	long N, M;
	long k[10];
	long s[10][10];
	long p[10];
	cin >> N >> M;

	long sw[10] = { 0 };

	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}

	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}

	
	int sum = 0;
	
	// all
	for (int i = 0; i < pow(2,N); i++) {

		// select sw
		for (int j = 0; j < N; j++) {
			sw[j] = (i / int(pow(2, j)) )% 2;
		}


		int boo = 1;
		
		for (int ind = 0; ind < M; ind++) {
			int swsum = 0;
			// swsum
			for (int l = 0; l < k[ind]; l++) {
				if (sw[s[ind][l]] == 1)
					swsum++;
			}
			if (swsum % 2 != p[ind]) {
				boo = 0;
				break;
			}
				
		}

		if (boo == 1)
			sum++;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+100;
int n,a[N],m,nxt[N];
int MAX,ans[N],sh[N];
vector <int> color[N];
struct query
{
	int l,r,id;
}q[N];
bool cmp(query a,query b)
{
	return a.l<b.l;
}
int lowbit(int x){return(x&(-x));}
void change(int x,int v)
{
	while (x<=n)
	{
		sh[x]+=v;
		x+=lowbit(x);
	}
}
int query(int x)
{
	int ans=0;
	while (x>0)
	{
		ans+=sh[x];
		x-=lowbit(x);
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		MAX=max(MAX,a[i]);
		color[a[i]].push_back(i);
	}
	for (int i=1;i<=MAX;i++)
	{
		if ((int)color[i].size()==0) continue;
		for (int j=0;j<(int)color[i].size()-1;j++)
		  nxt[color[i][j]]=color[i][j+1];
		nxt[color[i][(int)color[i].size()-1]]=n+1;
	}
	for (int i=1;i<=n;i++)
	{
		if (nxt[i]>n) continue;
		change(nxt[i],1);
	}
	for (int i=1;i<=m;i++) scanf("%d%d",&q[i].l,&q[i].r);
	for (int i=1;i<=m;i++) q[i].id=i;
	sort(q+1,q+1+m,cmp);
	int tl=1;
	for (int i=1;i<=m;i++)
	{
		while (tl<q[i].l && tl<=n)
		{
			if (nxt[tl]<=n) change(nxt[tl],-1);
			tl++;
		}
		ans[q[i].id]=q[i].r-q[i].l+1-query(q[i].r);
	}
	for (int i=1;i<=m;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 54620
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, M; cin >> N >> M;
    vec A(M); cin >> A;
    REP(i, M) N -= A[i];
    Ans(N >= 0, N, -1);

    return 0;
}


Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [][] graph = new int[n + 1][n + 1];
        int edges = 0;
        solve(1, n, graph);
        for (int i = 1; i < n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (graph[i][j] == 1) {
                    edges++;
                }
            }
        }
        System.out.println(edges);
        for (int i = 1; i < n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (graph[i][j] == 1) {
                    System.out.println(i + " " + j);
                }
            }
        }
    }

    public static void solve (int n1, int n2, int[][] graph) {
        if (n2 < n1) {
            return;
        }
        if ((n2 - n1 + 1) % 2 == 1) {
            for (int i = n1; i < n2; ++i) {
                graph[n2][i] = 1;
                graph[i][n2] = 1;
                solve(n1, n2 - 1, graph);
            }
        } else {
            for (int i = n1 + 1; i < n2; ++i) {
                graph[i][n1] = 1;
                graph[n1][i] = 1;
                graph[i][n2] = 1;
                graph[n2][i] = 1;
            }
            solve(n1 + 1, n2 - 1, graph);
        }
    }
}


Measured memory_bytes: 24788
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c;cin>>a>>b>>c;
  cout<<a+b+c-max({a,b,c})<<endl;

  return 0;

}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S, T;
    cin >> S >> T;
    ll N = SZ(S);
    bool f = false;
    REP(i,0,N) {
        S = S[N-1] + S.substr(0, N-1);
        if(S == T) f = true;
    }
    if(f) PR("Yes");
    else PR("No");
    

    return 0;
}

/*



*/

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

H,W = map(int, input().split())
vP = ["." * (W+2),]
mM = vP+["."+input()+"." for _ in [0,]*H]+vP
mD = [(-1,0),(1,0),(0,-1),(0,1)]

for i in range(1,H+1):
  for j in range(1,W+1):
    if (mM[i][j]=="#" and
        all(mM[i+x][j+y]=="."
            for x,y in mD)):
      print("No")
      exit(0)

print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  int l = 0;
  int r = 0;
  int id;
  bool isR = true;
  vector<int> ans(S.length(), 0);
  rep(i, S.length()) {

    if (isR) {

      if (S[i] == 'R') {
        r++;
      } else {
        isR = false;
        id = i-1;
        l++;
      }

    } else {
      
      if (S[i] == 'L') {
        l++;
      } else {

        int cnt = l + r;
        if (cnt % 2 == 0) {
          ans[id] = cnt / 2;
          ans[id+1] = cnt / 2;
        } else {
          int reven = r / 2;
          int rodd = r - reven;
          int leven = l / 2;
          int lodd = l - leven;
          ans[id] = rodd + leven;
          ans[id+1] = reven + lodd;
        }
          
        isR = true;
        r = 1;
        l = 0;
      }

    }

  }


  int cnt = l + r;
  if (cnt % 2 == 0) {
    ans[id] = cnt / 2;
    ans[id+1] = cnt / 2;
  } else {
    int reven = r / 2;
    int rodd = r - reven;
    int leven = l / 2;
    int lodd = l - leven;
    ans[id] = rodd + leven;
    ans[id+1] = reven + lodd;
  }


  rep(i, S.length()) {
    cout << ans[i] << " ";
  }

  return 0;
}

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

typedef long long ll;
ll A, B, P;

// 1-indexed
class BIT{
private:
    vector<ll> bit;
    
public:
    BIT(int n){
        bit.resize(n+1);
    }
    
    ll sum(int i){
        ll s = 0;
        while(i > 0){
            s = (s + bit[i]) % P;
            i -= i&-i;
        }
        return s;
    }
    
    void add(int i, ll v){
        while(i <= bit.size()){
            bit[i] = (bit[i] + v) % P;
            i += i&-i;
        }
    }
};

string ltos(ll a){
    string res = "";
    while(a){
        res += a%10 + '0';
        a /= 10;
    }
    reverse(res.begin(), res.end());
    return res;
}

void solve(){
    int D = B - A + 1;
    
    vector<pair<string, int>> vec;
    for(ll i=0; i<D; i++)
        vec.push_back(make_pair(ltos(A+i), i));
    sort(vec.begin(), vec.end());
    
    vector<int> lexorders(D);
    for(int i=0; i<D; i++)
        lexorders[vec[i].second] = i;
    
    vector<ll> dp(D);
    ll ans = 0;
    
    BIT bit = BIT(D);
    for(int i=0; i<D; i++){
        dp[i] = (1 + bit.sum(lexorders[i])) % P;
        ans = (ans + dp[i]) % P;
        bit.add(lexorders[i]+1, dp[i]);
    }
    cout << ans << endl;
}

int main(){
    while(cin >> A >> B >> P, A|B|P)
        solve();
    
    return 0;
}

Measured memory_bytes: 12460
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int R;
	scanf("%d",&R);
	puts(R<1200?"ABC":R<2800?"ARC":"AGC");
	return 0;
}


Measured memory_bytes: 256
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()

using namespace std;

template <typename T>
void in(T &t){ //標準入力
    cin >> t;
    return;
}

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::greater<int>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::less<int>());
    return;
}

int main(){
    string s;
    int count = 0;

    cin >> s;

    if(s[0] == 'A'){
        for(int i = 1; i < s.length(); i++){
            if(i == 1 || i == s.length() - 1){
                if(s[i] < 'a'){
                    printf("WA\n");
                    return 0;
                }
            }
            else{
                if(s[i] == 'C'){
                    count++;
                }
            }

        }
    }

    if(count == 1) printf("AC\n");
    else printf("WA\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int c = 0;
  cin>>s;
  for(int i=0;i<4;i++){
    if(s[i] == '+'){
      c++;
    }
    else{
      c--;
    }
  }
  cout<<c<<'\n';
  return 0;
}
  


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

int main() {
	int n; cin >> n; bool ok = false; int c = 0;
	for (int i = 0; i < n; i++) {
		int d1, d2; cin >> d1 >> d2;
		if (d1 != d2) { c = 0; continue; }
		c++; if (c == 3) { ok = true; }
	}
	cout << (ok ? "Yes" : "No") << '\n';
	cin.ignore(2); return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	cin >> N;
	vector<int64> sum(N+1, 0);
	REP(i, N){
		cin >> sum[i+1];
		sum[i+1] += sum[i];
	}
	map<int64, int64> cnt;
	cnt[0] = 1;
	int64 res = 0;
	FOR(i, 1, N+1){
		res += cnt[sum[i]];
		cnt[sum[i]]++;
	}
	cout << res << endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  for (int i = 0; i < s.size() - 8; i++) cout << s.at(i);
  cout << '\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

set<ll> st;
map<ll, int> cnt;

int main(void){
	int n,i,ans=0;
	ll a,v;
	cin >> n;
	st.insert(INFLL);
	for(i=0; i<n; ++i){
		cin >> a;
		v = *st.upper_bound(-a);
		if(v==INFLL){
			++ans;
		}else{
			--cnt[-v];
			if(!cnt[-v]){
				st.erase(v);
			}
		}
		st.insert(-a);
		++cnt[a];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11008
n = int(input())

a= 0
b= 0

for i in range(n) :
    A,B= map(str, input().split())
    
    if A > B :
        a+= 3
    elif A< B :
        b+= 3
    else :
        a+= 1
        b+= 1
        
print(a,b)


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

typedef long long ll;
const int maxn = 200005;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n, a[maxn], ans, f[3], g[3], h[3];

int main()
{
	n = gi();
	for (int i = 1; i <= n; ++i) a[i] = gi();

	for (int i = 1; i <= n + 1; ++i) {
		f[0] = 0; f[1] = a[i] - a[i - 1];
		if (f[0] < f[1]) swap(f[0], f[1]);
		g[0] = g[1] = 1e9; g[2] = 0;
		for (int j = 0; j < 2; ++j)
			for (int k = 0; k < 2; ++k) g[j + k] = min(g[j + k], max(0, f[j] + h[k]));
		int d = g[0] > a[i]; ans += d;
		for (int j = 0; j < 2; ++j) h[j] = g[j + d];
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
int main(){
    int k, x, i;
    scanf("%d%d", &k, &x);
    for(i=x-k+1; i<x; i++){
        printf("%d ", i);
    }
    for(i=x; i<k+x; i++){
        printf("%d ", i);
    }
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    cin>>a>>b>>n;
    ll p;
    if(n>=b) p=b-1;
    else p=n;
    cout<<a*p/b<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<bitset>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
const int N=405,M=100005;
int n,m,u[M],v[M],ans; bitset<N> s[N];
int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,m) scanf("%d%d",&u[i],&v[i]);
	rep (i,1,n){
		s[i].set(i);
		for (int j=m;j;j--){
			if (s[i][u[j]]&&s[i][v[j]]){s[i].set(); break;}
			if (s[i][u[j]]||s[i][v[j]]) s[i][u[j]]=s[i][v[j]]=1;
		}
	}
	int ans=0;
	rep (i,1,n)
		rep (j,i+1,n)
			if (!(s[i]&s[j]).any()) ans++;
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define forr(a,b,c) for(int a=b;a<c;a++)

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a,b;

	cin>>a>>b;
	if(a%(2*b+1)==0) cout<<a/(2*b+1);
	else cout<<a/(2*b+1)+1;              			
		
	return 0;
}



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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

int main()
{
    ll H,W,K;
    cin >> H >> W >> K;

    vector<vector<bool>> Graph(H,vector<bool>(W));
    for(ll i=0;i<H;i++)
    {
        string s;
        cin >> s;

        for(ll j=0;j<W;j++)
        {
            if(s[j]=='.') Graph[i][j] = true;
            else Graph[i][j] = false;
        }
    }

    ll ans = 0;

    for(ll i=0;i<(1<<H);i++)
    {
        for(ll j=0;j<(1<<W);j++)
        {
            ll counter = 0;
            for(ll a=0;a<H;a++)
            {
                for(ll b=0;b<W;b++)
                {
                    if((i & (1<<a))==0 && (j & (1<<b))==0 && !Graph[a][b])
                    {
                        counter++;
                    }
                }
            }
            if(counter==K) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#define ll long long
#include <string>
#include <algorithm>
int main()
{
	string a;
	cin>>a;
	char c=a[0];
	int count=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]!=c)
		{
			c=a[i];
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
} 


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  double t,a;
  cin >> n >> t >> a;
  double h[n];
  rep(i,n) cin >> h[i];
  double diff=abs(t-h[0]*0.006 - a);
  int ans=1;
  rep(i,n){
    if(diff>abs(t-h[i]*0.006 -a)){
      diff=abs(t-h[i]*0.006 -a);
      ans=i+1;
    }
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner (System.in);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int [] d = new int [n];
		int i, j;
		int temp;
		int max = 0;
		int calorie;

		for (i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}

		for (i = 0; i < n - 1; i++) {
			for (j = i + 1; j < n; j++) {
				if (d[i] < d[j]) {
					temp = d[i];
					d[i] = d[j];
					d[j] = temp;
				}
			}
		}

		for (i = 0; i < n; i++) {
			int sum = 0;
			for (j = 0; j < i; j++) {
				sum += d[j];
				calorie = (c + sum) / (a + i * b);
				if (max < calorie) {
					max = calorie;
				}
			}
		}
		
		System.out.println(max);

	}

}

Measured memory_bytes: 18208
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
  int a,b;cin>>a>>b;
  int tmp=1,cnt=0;

  while(tmp<b){
    tmp+=a;
    tmp--;
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


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


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

int main(void) {

    string S;
    cin >> S;

    int a = 0;
    for (int i=0; i<S.length(); i++)
    {
        if (i%2==0)
        {
            if ( S[i]=='R' || S[i]=='U' || S[i] == 'D')
            {
            }
            else
            {
                a = 1;
                break;
            }
        }
        else 
        {
            if ( S[i]=='L' || S[i]=='U' || S[i] == 'D')
            {
            }
            else
            {
                a = 1;
                break;
            }
        }
    }
    if (a==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
from math import sqrt as r
from math import floor

N = int(input())

ans = 10 ** 20

for i in range(1, floor(r(N)) + 1, 1):
    if N % i == 0:
        a = i - 1
        b = (N // i) - 1
        ans_ = a + b
        ans = min(ans, ans_)

print(ans)


Measured memory_bytes: 9184
s = int(input())
l = [s]
n = 2
while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = s * 3 + 1
    if l.count(s) != 0:
        break
    l.append(s)
    n += 1
print(n)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;
 
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
 
ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
    if (n == 0)return 1;
    if (n == 1)return x%MOD;
    ll res = sq(mod_pow(x, n / 2));
    res %= MOD;
    if (n % 2 == 1) {
        res *= x;
        res %= MOD;
    }
    return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }
 
int h, w;
int f[1010][1010];
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
 
bool of(int y,int x) {
    return y < 0 || y >= h || x < 0 || x >= w;
}

ll ans;

ll solve(int y, int x,ll cnt) {
    if (cnt >= 10)return INF;
    // cout << y << " " << x << endl;
    ll res = INF;
    rep(i, 4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (f[ny][nx] == 1)continue;
        while (!f[ny][nx]) {
            nx += dx[i];
            ny += dy[i];
            if (of(ny, nx))break;
        }
        if (of(ny, nx))continue;
        // cout << ny << " " << nx << " " << cnt << endl;
        
        if (f[ny][nx] == 3){
            ans = min(ans, cnt + 1); return 1;
        }
        f[ny][nx] = 0;
        nx -= dx[i];
        ny -= dy[i];
        res = min(solve(ny, nx, cnt + 1) + 1, res);
        nx += dx[i];
        ny += dy[i];
        f[ny][nx] = 1;
    }
    //cout << res << endl;
    return res;
}
 
int main() {
    while (cin >> w >> h&&h + w) {
        int sy, sx;
        rep(i, h) {
            rep(j, w) {
                cin >> f[i][j];
                if (f[i][j] == 2) {
                    f[i][j] = 0;
                    sy = i;
                    sx = j;
                }
            }
        }
        ans = INF;        
        ll res = solve(sy, sx, 0);
        if (ans == INF)cout << -1 << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, ans = 0;
  std::cin >> N;
  std::vector<ll> l(N);
  for(int i=0;i<N;i++) std::cin >> l[i];
  sort(l.begin(), l.end());
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      ll a = l[i], b = l[j];
      ll ok = upper_bound(l.begin(), l.end(), a - b) - l.begin();
      //std::cout << ok << '\n';
      if(ok>=j) continue;
      else ans += j - ok;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
  int w,q,c,l,i,b;
  char t;
  while(true){
    cin >> w >> q;
    if (!w&&!q)
      break;
    int place[w];
    for(i=0;i<w;i++)
      place[i] = -1;
    for(;q>0;q--){
      cin >> t;
      if (t == 's'){
	cin >> c >> l;
	for(i=0;i<=w-l;i++){
	  bool bb = true;
	  for(int j=0;j<l;j++)
	    if (place[i+j] != -1)
	      bb = false;
	  if (bb){
	    cout << i << endl;
	    for(int j=0;j<l;j++)
	      place[i+j] = c;
	    break;
	  }
	}
	if (i == w-l+1)
	  cout << "impossible" << endl;
      }
      if (t == 'w'){
	cin >>c;
	for(i=0;i<w;i++)
	  if (place[i] == c)
	    place[i] = -1;
      }
    }
    cout << "END" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int q;
    cin>>s>>q;
    int kai=0;//even=last,odd=top
    vector<string> to(2,"");
    for(int i=0; i<q; i++){
        int t;
        cin>>t;
        if(t==1) kai++;
        else if(t==2){
            int tm;
            char c;
            cin>>tm>>c;
            to.at( (tm+kai)%2 ).push_back(c);
        }
    }
    if(kai%2==1) reverse(s.begin(),s.end());
    s += to.at(kai%2);
    reverse(s.begin(),s.end());
    s += to.at(( kai+1) %2);
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,a,b;
  cin>>n>>a>>b;
  int64_t c=n/(a+b);
  int64_t d=n%(a+b);
  if(d>a)d=a;
  
  cout<<(a*c)+d<<endl;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N;
    cin >> N;
    V<ll> A(N);
    rep(i, N) cin >> A[i];

    V<int> cnt(20);

    auto can = [&](ll x) {
        bool ok = 1;
        rep(i, 20) {
            int a = cnt[i];
            if (x >> i & 1) {
                a++;
            }
            if (a > 1) {
                ok = 0;
            }
        }
        return ok;
    };

    ll ans = 0;

    int r = 0;
    rep(l, N) {
        while (r < N && can(A[r])) {
            rep(i, 20) {
                if (A[r] >> i & 1) {
                    cnt[i]++;
                }
            }
            r++;
        }
        ans += r - l;
        rep(i, 20) {
            if (A[l] >> i & 1) {
                cnt[i]--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	int n,i;cin>>n;
	vi v(n+1,0);for(i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i) v[j]++;
	}ll c=0;for(i=1;i<=n;i++) c+=i*v[i];
	cout<<c<<endl;
}


Measured memory_bytes: 81380
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a12, a13, a23,d1,d2,d3,mini;
    cin >>a12 >>a13>>a23;
    d1=a12+a13;
    d2=a12+a23;
    d3=a13+a23;
    mini=min({d1,d2,d3});
    cout << mini ;
    return 0;
}


Measured memory_bytes: 3564
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	k := getNextInt(scanner)
	ss := make([]int, n+1)
	im := IntMap{}
	im.increment(0)

	ans := 0
	for i := 0; i < n; i++ {
		ss[i+1] = (ss[i] + getNextInt(scanner)) % k
	}
	for i := 0; i <= n; i++ {
		ss[i] = (((ss[i] - i) % k) + k) % k
	}
	for i := 1; i <= n; i++ {
		if i >= k {
			im[ss[i-k]]--
		}
		ans += im.get(ss[i])
		im.increment(ss[i])
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}

func (m IntMap) increment(key int) {
	m[key] = m.get(key) + 1
}


Measured memory_bytes: 14336
#include<stdio.h>
long long MAX(long long a,long long b){return a<b?b:a;}
  long long a,d[200020][2][4]={};
int main(){
  int n,i,j,k;
  scanf("%d",&n);
  for(i=0;i<n+2;i++){
    for(j=0;j<8;j++)d[i][j/4][j%4]=-1e18;
  }
  d[0][0][0]=0;
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    for(j=0;j<2;j++){
      for(k=0;k<3;k++){	
	if(j==0){
	  d[i+1][1][k  ]=MAX(d[i+1][1][k  ],d[i][j][k]+a);
	  d[i+1][0][k+1]=MAX(d[i+1][0][k+1],d[i][j][k]  );
	}
	else{
	  d[i+1][0][k  ]=MAX(d[i+1][0][k  ],d[i][j][k]  );
	}
      }
    }
  }
  for(j=0;j<2;j++){
    for(k=0;k<3;k++){
      if(j==0){
	d[n+1][0][k+1]=MAX(d[n+1][0][k+1],d[n][j][k]);
      }
      else{
	d[n+1][0][k  ]=MAX(d[n+1][0][k  ],d[n][j][k]);
      }
    }
  }
  a=-1e18;
  for(j=0;j<2;j++)a=MAX(a,d[n+1][j][1+n%2]);
  printf("%lld\n",a);
  return 0;
}


Measured memory_bytes: 14236
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



string s;

int main () {
  cin >> s;

  int n = s.size();

  int ct = 0;

  if (n % 2 == 0) {
    Rep(k, n/2) {
      if (s[k] != s[n-1-k]) ct++;
    }
  } else {
    Rep(k, n/2) {
      if (s[k] != s[n-1-k]) ct++;
    }
  }

  cout << ct << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main() {
    int n,m;
    cin >> n >> m;

    vector<PII> p(m);
    rep(i,m) {
        cin >> p[i].first >> p[i].second;
    }
    rep(x,1000) {
        int keta = 1;
        int nx = x/10;
        VI d(1,x%10);
        while(nx) {
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }

        if(keta != n) continue;
        bool ok = true;
        REVE(d);
        rep(i,m) {
            if(d[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef struct Card{
	char suit;
	int value;
}Card;
void bubblesort(Card c[], int n)
{
	int flag = 1;
	while(flag)
	{
		flag = 0;
		for (int i = n-1; i >= 1; --i)
		{
			if(c[i].value < c[i-1].value)
			{
				Card temp = c[i];
				c[i] = c[i-1];
				c[i-1] = temp;
				flag =1;
			}

		}
	}
}

void selectionsort(Card c[], int n)
{
	for (int i = 0; i < n; ++i)
	{
		int minj = i;
		for (int j = i; j < n; ++j)
		{
			if(c[j].value < c[minj].value) minj = j;
		}
		if(minj != i)
		{
			Card temp = c[i];
			c[i] = c[minj];
			c[minj] = temp;
		}
	}

}

bool isstable(Card c1[], Card c2[], int n)
{
	for (int i = 0; i < n; ++i)
	{
		if(c1[i].value==c2[i].value && c1[i].suit!=c2[i].suit) return false;
	}
	return true;
}

void print(Card c[], int n)
{
	for (int i = 0; i < n-1; ++i)
	{
		cout<<c[i].suit<<c[i].value<<" ";
	}
	cout<<c[n-1].suit<<c[n-1].value<<endl;
}
int main()
{
	int n;
	cin>>n;
	Card c1[36], c2[36];
	for (int i = 0; i < n; ++i)
	{
		cin>>c1[i].suit>>c1[i].value;
	}
	for (int i = 0; i < n; ++i)
	{
		c2[i] = c1[i];
	}

	bubblesort(c1, n);
	selectionsort(c2, n);

	print(c1,n);
	cout<<"Stable"<<endl;

	
	print(c2,n);
	if(isstable(c1,c2,n)) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  
  int AB = A + B,XY = min(X,Y);
  X -= XY; Y -= XY; C *= 2; 
  
  int res = min( AB, C) * XY;
  if (X) res += min( A, C) * X;
  if (Y) res += min( B, C) * Y;
 
  cout << res << endl;
  
}

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

int main()
{
    string N;
    int count = 0;
    cin >> N;
    // N = "1222";

    for (int n = 0; n < N.size(); n++)
    {
        if (N[n] == '2')
        {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256