akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int A,B;
    cin >> A>>B;

    cout << ((A*B%2)==0 ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}
int main(){
int N ,A ,B; cin >> N >> A >> B;
int sum = 0;
int ans = 0;
string n;
for(int i = 1; i <= N;i++){
  n = to_string(i);
  for(int j = 0; j < n.size(); j++){
    ans += ctoi(n[j]);
  }
  if(A <= ans & ans <= B){
    sum +=i;
  }
  ans = 0;
}
cout << sum << endl;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, c, d;
	ll k;
	//string s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> a >> b >> c >> d;

	cout << max(a*b, c*d) << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7

S = int(input())
memo = {1:0,2:0,3:1,4:1,5:1}

def Redi(n):
    if n in memo:
        return memo[n]
    else:
        ans = 1
        for i in range(3,n-2):
            ans += Redi(n-i)
        memo[n] = ans % MOD
        return memo[n]

print(Redi(S))

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

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

    int B[N-1];
    rep(i,N-1){
        cin >> B[i];
    }

    int A[N]={0};

    int sum = 0;

    A[0] = B[0];
    for(int i=1;i<N-1;i++){
        A[i] = B[i];
        if(A[i] > B[i-1]){
            A[i] = B[i-1];
        }
    }
    A[N-1] = B[N-2];

    rep(i,N){

        sum += A[i];
    }

    printf("%d\n",sum);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

vector<pair<int, int>> arr;

long long calc(long long q){
    return q * (q + 1) / 2;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    for(int a, i = 0; i < n; ++i){
        cin >> a;
        arr.push_back(make_pair(a, i));
    }

    sort(arr.begin(), arr.end());
    reverse(arr.begin(), arr.end());

    multiset<long long> pos = {-1, -1, n, n};
    long long tot = 0;

    for(auto item : arr){

        auto it = pos.lower_bound(item.second);
        auto it2 = next(it);
        auto it3 = prev(it);
        auto it4 = prev(it3);

        pos.insert(item.second);

        tot += item.first * ((*it2 - *it) * (item.second - *it3) + (*it3 - *it4) * (*it - item.second));

    }

    cout << tot;

    return 0;

}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind cards(n);
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		cards.unite(x, y);
	}
	set<int>ans;
	for (int i = 0; i < n; i++) ans.insert(cards.root(i));
	cout << ans.size() << endl;
}

Measured memory_bytes: 8276
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

H, N = map(int, readline().split())
AB = np.array([list(map(int,
                        readline().split())) for _ in range(N)],
              dtype=np.int64)

A = AB[:, 0]
B = AB[:, 1]

dp = np.zeros(H + 1, dtype=np.int64)
for n in range(1, H + 1):
    dp[n] = np.amin(dp[np.maximum(n - A, 0)] + B)

print(dp[H])

Measured memory_bytes: 14540
#include "bits/stdc++.h"
using namespace std;

const int maxn = 3005;
int dp[maxn][maxn];
pair<int, int> dir[maxn][maxn];
string a, b;

int main(int argc, char const *argv[])
{
//	freopen("in.txt", "r", stdin);
	cin >> a >> b;
	int n = a.size(), m = b.size();
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
				dir[i][j] = make_pair(i, j);
			}else if(a[i-1] == b[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
				dir[i][j] = make_pair(i-1, j-1);
			}else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
				if(dp[i][j] == dp[i-1][j]){
					dir[i][j] = make_pair(i-1, j);
				}else {
					dir[i][j] = make_pair(i, j-1);
				}
			}
		}
	}	
	string ans;
	pair<int, int> cur = make_pair(n, m);
	while(cur.first != 0 && cur.second != 0){
		int i = cur.first, j = cur.second;
		if(dir[i][j] == make_pair(i-1, j-1)){
			ans += a[i-1];
			cur = make_pair(i-1, j-1);
		}else if(dir[i][j] == make_pair(i-1, j)){
			cur = make_pair(i-1, j);
		}else {
			cur = make_pair(i, j-1);
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

ll extgcd(int a, int b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}

void cmb_init(int n, vll &fac, vll &finv) {
  ll x, y;
  for (int i = 2; i <= n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    extgcd(i, MOD, x, y);
    finv[i] = finv[i - 1] * (MOD + x % MOD) % MOD;
  }
}

// void cmb_init(int n, vll &fac, vll &finv) {
//   vll inv(n + 1, 1);
//   for (int i = 2; i <= n; i++) {
//     fac[i] = fac[i - 1] * i % MOD;
//     inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
//     finv[i] = finv[i - 1] * inv[i] % MOD;
//   }
// }

ll cmb(int n, int k, vll &fac, vll &finv) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve() {
  int N, K;
  cin >> N >> K;
  vi A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vll fac(N + 1, 1), finv(N + 1, 1);
  cmb_init(N, fac, finv);
  sort(all(A));
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum -= A[i] * cmb(N - i - 1, K - 1, fac, finv) % MOD;
    sum += A[i] * cmb(i, K - 1, fac, finv) % MOD;
    sum %= MOD;
  }
  cout << sum << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int i,p,m=0,N;
  cin>>N;
  
  for(i=N;i!=m;i--)
  {
  	p=sqrt(N);
  	m=p*p;
  	if(i==m)break;
  }
  cout<<i;
  return 0;
} 

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    int lr = N/R;
    int lg = N/G;
    for (int r = 0; r <= lr; r++) {
        for (int g = 0; g <= lg; g++) {
            int temp = N - R*r - G*g;
            if (temp >= 0 && temp % B == 0) ans++;
        }
    }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void){

  double s[1000];
  int n;
  double a,avg;
  register int i;
  
  while(1){
  	
  	a = 0;
  	avg = 0;
  	
    scanf("%d",&n);
    if(n == 0){
      break;
    }
    for(i = 0;i < n;i++){
      scanf("%lf",&s[i]);
      avg += s[i];
    }
    avg = avg / n;
    
    for(i = 0;i < n;i++){
     a += pow(s[i] - avg,2);
    }
    a = a / n;
    a = sqrt(a);
 
    printf("%f\n",a);
  }
  return 0;
}

Measured memory_bytes: 664
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Api = [ai + i for i, ai in enumerate(A)]
jmA = [j - aj for j, aj in enumerate(A)]
count_Api = Counter(Api)
count_jmA = Counter(jmA)
ans = 0
for api, count in count_Api.items():
    ans += count * count_jmA[api]
print(ans)

Measured memory_bytes: 143364
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int a,b,c,sum=0,ta,tb,tc;
    scanf("%d %d %d",&a,&b,&c);
    while(1){
        if(a==b&&b==c&&a%2==0){
            printf("-1\n");
            return 0;
        }
        if(a%2||b%2||c%2){
            printf("%d\n",sum);
            return 0;

        }
        ta=a;tb=b;tc=c;
        a=(tb+tc)/2;
        b=(ta+tc)/2;
        c=(ta+tb)/2;
    sum++;

    }

}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
N = int(input())

rates = []
for _ in range(N):
    t, a = map(int, input().split())
    rates.append((t, a))

ans = 0
for i in range(N-1):
    t1, a1 = rates[i]
    t2, a2 = rates[i+1]

    rate = max((t1 - 1) // t2, (a1 - 1) // a2) + 1
    rates[i+1] = (t2 * rate, a2 * rate)

print(sum(rates[N-1]))

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
            System.out.println(0);
            return;
        }

        long ans = Math.min(a * b, Math.min(b * c, c * a));
        System.out.println(ans);
    }
}

Measured memory_bytes: 20948
import os
import sys


def manhatten(tupleA,tupleB):
	return abs(tupleA[0]-tupleB[0]) + abs(tupleA[1]-tupleB[1])

header = input().split()
N,M = int(header[0]),int(header[1])
students = []
checkpoints = []

for i in range(N):
	student = input().split()
	student = [int(x) for x in student]
	students.append(tuple(student))

for i in range(M):
	checkpoint =input().split()
	checkpoint = [int(x) for x in checkpoint]
	checkpoints.append(tuple(checkpoint))

for student in students:
	distance = []
	for checkpoint in checkpoints:
		d = manhatten(student,checkpoint)
		distance.append(d)
	print(distance.index(min(distance))+ 1)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
char a[100050][13];
int main(){
	long long n,dis1,dis2,dis3,dis4,dis5;
	scanf("%lld",&n);
	dis1=0;
	dis2=0;
	dis3=0;
	dis4=0;
	dis5=0;
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]+1);
		if(a[i][1]=='M') dis1++;
		else if(a[i][1]=='A') dis2++;
		else if(a[i][1]=='R') dis3++;
		else if(a[i][1]=='C') dis4++;
		else if(a[i][1]=='H') dis5++;
	}
	printf("%lld\n",dis1*dis2*(dis3+dis4+dis5)+dis1*dis3*(dis4+dis5)+dis1*dis4*dis5+dis2*dis3*(dis4+dis5)+dis2*dis4*dis5+dis3*dis4*dis5);
}

Measured memory_bytes: 1536
n = int(input())
a = list(map(int, input().split()))
a = a + [0]
state = a[0]
money = 1000
stock = 0
for i in range(1, n+1):
  if state < a[i] and stock == 0:
    stock += (money // state)
    money %= state
  elif state > a[i] and stock > 0:
    money += (stock * state)
    stock = 0
  state = a[i]
print(money)


Measured memory_bytes: 9076
def main ():
    H, W = map(int, input().split())
    MAP = [list('#' for i in range(W + 2)) for j in range(H + 2)]
    for i in range(H):
        line = list(input())
        for j, dot in enumerate(line):
            MAP[i + 1][j + 1] = dot
    L = [[0 for j in range(W + 2)] for i in range(H + 2)]


    def line(MAP):
        for i in range(1, H + 2):
            before = 0
            for j in range(1, W + 2):
                if MAP[i][j] == '#':
                    for x in range(before + 1, j):
                        L[i][x] = j - before - 1
                    before = j


    def column(MAP2):
        ans = 0
        for j in range(1, W + 2):
            before = 0
            for i in range(1, H + 2):
                if MAP2[i][j] == '#':
                    for y in range(before + 1, i):
                        ans = max(ans, i - before - 1 + L[y][j])
                    before = i
        return ans - 1

    line(MAP)
    column(MAP)
    print(column(MAP))

if __name__ == '__main__':
    main()

Measured memory_bytes: 217096
#include<vector>
#include<iostream>
using namespace std;
#define REP(p,q) for(p=0;p<q;p++)
vector<int> c,t;
int n,i,j;
void cut(int k) {t.clear();REP(j,k)t.push_back(c[j]);REP(j,2*n-k)c[j]=c[k+j];for(j=2*n-k;j<2*n;j++)c[j]=t[j-2*n+k];}
void riffle(){t.clear();REP(j,n)t.push_back(c[j]);REP(j,2*n)if(j%2)c[j]=c[n+(j-1)/2];else c[j]=t[j/2];}
int main(){int m,k;cin>>n>>m;REP(i,n*2)c.push_back(i+1);REP(i,m){cin>>k;if(!k) riffle();else cut(k);}REP(i,n*2)cout<<c[i]<<endl;}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int h, w, n;
    cin >> h >> w >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int idx = 0;
    vector<vi> v(h, vi(w));
    for (int i = 0; i < h; ++i) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; ++j) {
                v[i][j] = idx + 1;
                a[idx]--;
                if (a[idx] == 0) idx++;
            }
        } else {
            for (int j = w - 1; j >= 0; j--) {
                v[i][j] = idx + 1;
                a[idx]--;
                if (a[idx] == 0) idx++;
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << v[i][j] << ' '; 
        }
        cout << endl;
    } 
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 384
using System;

namespace abc165
{
    class Program
    {
        static void Main()
        {
            var x = long.Parse(Console.ReadLine());
            var c = 100L;
            var y = 0L;
            while (c < x)
            {
                c = (long)(c * 1.01);
                ++y;
            }
            Console.WriteLine(y);
        }
    }
}


Measured memory_bytes: 27532
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int H, W, now[1005][1005];
const int di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1};
char A[1005][1005];
queue <Pii> que;

int main(){
  scanf("%d%d", &H, &W);
  for (int i = 0; i < H; i++){
    scanf("%s", A[i]);
    for (int j = 0; j < W; j++){
      if (A[i][j] == '#') que.push(make_pair(i, j));
      else now[i][j] = -1;
    }
  }
  
  int ans = 0;
  while (!que.empty()){
    Pii Q = que.front(); que.pop();
    ans = max(ans, now[Q.first][Q.second]);

    for (int k = 0; k < 4; k++){
      int I = Q.first + di[k], J = Q.second + dj[k];

      if (0 <= I && I < H && 0 <= J && J < W){
        if (now[I][J] == -1){
          now[I][J] = now[Q.first][Q.second] + 1;
          que.push(make_pair(I, J));
        }
      }
    }
  }
  
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

const double EPS = 1e-8;

double dp[51][5001];
int x, y, z, v[4], e[51], a[51];

main(){
  while(cin >> x >> y >> z && (x|y|z)){
    fill(dp[0], dp[51], 0.0);
    fill(e, e+51, 2);
    fill(a, a+51, 0);
    for(int i=0;i<x;i++) cin >> v[i];
    for(int i=0;i<z;i++){
      int in;
      cin >> in;
      cin >> e[in] >> a[in];
    }
    dp[0][0] = 1.0;
    for(int i=0;i<y;i++){
      for(int j=0;j<5001;j++){
        if(abs(dp[i][j]) < EPS) continue;
        for(int k=0;k<x;k++){
          int next = min(i + v[k], y);
          int money = j;
          if(e[next] == 1) next = min(next + a[next], y);
          else if(e[next] == 2) money += a[next];
          else if(e[next] == 3) money = max(money - a[next], 0);
          dp[next][money] += dp[i][j] / (double)x;
        }
      }
    }
    double ans = 0.0;
    for(int i=0;i<5001;i++){
      ans += i * dp[y][i];
    }
    cout << (int)ans << endl;
  }
}

Measured memory_bytes: 3152
// https://atcoder.jp/contests/abc018/tasks/abc018_4

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e18;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

class UnionFind {
  public:

  vector<ll> Parent;
  vector<ll> Size;

  //Constructor
  UnionFind( ll InitSize ) : Parent( InitSize ), Size( InitSize, 1LL ) {
    for( ll i = 0; i < InitSize; i++ ) Parent[i] = i; //myself
  } 

  void Init( ll InitSize ){
    Parent.resize( InitSize );
    Size.assign( InitSize, 1LL );
    for( ll i = 0; i < InitSize; i++ ) Parent[i] = i; //myself   
  }

  //Member Function
  //FindRoot
  ll FindRoot( ll x ){
    while( Parent[x] != x ){
      x = Parent[x] = Parent[Parent[x]];
    }
    return x;
  }

  //Merge
  void Merge( ll x, ll y ){
    x = FindRoot(x);
    y = FindRoot(y);
    if (x == y) return;
    if (Size[x] < Size[y]) swap(x, y);
    Size[x] += Size[y];
    Parent[y] = x;
    return;
  }

  bool IsSame(ll x, ll y) { 
      return FindRoot(x) == FindRoot(y);
  }

  ll CalcSize(ll x) { 
      return Size[FindRoot(x)];
  }
};

int main() {

  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(M), B(M), C(K), D(K);
  REP(i, M){
    int _a, _b;
    cin >> _a >> _b;
    _a--; _b--;
    A[i] = _a; B[i] = _b;
  }
  REP(i, K){
    int _a, _b;
    cin >> _a >> _b;
    _a--; _b--;
    C[i] = _a; D[i] = _b;
  }

  UnionFind UF_friend(N);
  REP(i, M){
      UF_friend.Merge(A[i], B[i]);
  }

  vector<int> ans(N, 0);

  REP(i, N){
    ans[i] = UF_friend.CalcSize(i) - 1;
  }

  REP(i, M){
    if(UF_friend.IsSame(A[i], B[i])){
      ans[A[i]]--; ans[B[i]]--;
    }
  }

  REP(i, K){
    if(UF_friend.IsSame(C[i], D[i])){
      ans[C[i]]--; ans[D[i]]--;
    }
  }

  REP(i, N){
    cout << ans[i] << " ";
  }cout << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n, s[1000], i;
	double SD, sum1, sum2, avr;
	while(scanf("%d", &n), n != 0){
		sum1=sum2=0;
		for(i=0; i<n; i++){
			scanf("%d", &s[i]);
			sum1 += s[i];
		}
		avr = sum1 / n;
		for(i=0; i<n; i++){
			sum2 += (s[i]-avr)*(s[i]-avr);
		}
		SD = sqrt(sum2 / n);
		printf("%f\n", SD);
	}
	return 0;
}

Measured memory_bytes: 636
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        d: i64, t: i64, s: i64,
    }

    println!("{}", if d <= t * s { "Yes" } else { "No" });
}


Measured memory_bytes: 2200
#include <iostream>
using namespace std;
typedef long long ll;

ll sum(ll x) {
  if (x == 0)
    return 0;
  else if (x == 1)
    return 1;
  else
    return x + sum(x - 1);
}

int main() {
  int x;
  cin >> x;
  int t = 0;
  while (sum(t) < x) t++;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

ans = ''
if sy < ty:
  v = 'U' * (ty-sy)
  if sx < tx:
    h = 'R' * (tx-sx)
    ans += v + h
    v = 'D' * (ty-sy)
    h = 'L' * (tx-sx)
    ans += v + h
  else:
    h = 'L' * (tx-sx)
    ans += v + h
    v = 'D' * (ty-sy)
    h = 'R' * (tx-sx)
    ans += v + h
else:
  v = 'D' * (sy-ty)
  if sx < tx:
    h = 'R' * (tx-sx)
    ans += v + h
    v = 'U' * (ty-sy)
    h = 'L' * (tx-sx)
    ans += v + h
  else:
    h = 'L' * (tx-sx)
    ans += v + h
    v = 'U' * (ty-sy)
    h = 'R' * (tx-sx)
    ans += v + h
  
if sy < ty:
  v = 'U' * (ty-sy+1)
  if sx < tx:
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'D'
    v = 'D' * (ty-sy+1)
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'U'
  else:
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'D'
    v = 'D' * (ty-sy+1)
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'U'
else:
  v = 'D' * (sy-ty+1)
  if sx < tx:
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'U'
    v = 'U' * (ty-sy+1)
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'D'
  else:
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'U'
    v = 'U' * (ty-sy+1)
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'D'
print(ans)

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

int main() {
    ll N;
    cin >> N;

    ll ans = 1e12;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ll move = i + N / i - 2;
            if (move < ans) ans = move;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <math>

using namespace std;

std::vector<long> get_devisors(const int n) {
    std::vector<long> v;

    for (long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (n != i*i) v.push_back(n/i);
        }
    }

    return v;
}

int main(int argc, char* argv[]) {
    int N, M;

    std::cin >> N >> M;

    auto devisors = get_devisors(M);

    long ans = 1;
    for (auto d : devisors) {
        if (M >= d * N) {
            ans = std::max(ans, d);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        if (N == 0) {
            System.out.println(2);
            return;
        }
        if (N == 1){
            System.out.println(1);
            return;
        }
        long l0 = 2;
        long l1 = 1;
        for (int i = 1; i < N; i++) {
            long l2 = l0 + l1;
            l0 = l1;
            l1 = l2;
        }
        System.out.println(l1);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

const Int MOD = 2019;

//---------- べき乗 ----------
Int power(Int a, Int n){
    if(a == 0) return 0;
    if(n == 0) return 1;
    
    Int res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD; n /= 2;
    }
    return res;
}

int main(){
    string S; cin >> S;
    Int N = S.length();
    reverse(S.begin(), S.end());

    vector<Int> R(2019, 0);
    R[0]++;

    Int cur = 0; 
    for(int i=0; i<N; i++){
        Int c = S[i] - '0';
        cur = (c * power(10, i) % MOD + cur) % MOD;
        //cout << cur << endl;

        R[cur]++;
    }

    Int ans = 0;
    rep(i,2019){
        ans += R[i] * (R[i]-1) /2;
    }
    cout << ans << endl;   
}

Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_3_D {
    class Program {
        static void Main(string[] args) {
            Dictionary<int, Stack<int>> dic = new Dictionary<int, Stack<int>>();
            Stack<KeyValuePair<int, int>> stk = new Stack<KeyValuePair<int, int>>();

            string input = Console.ReadLine();
            int h = 0;
            for (int i = 0; i < input.Length; i++) {
                if (input[i] == '\\') {
                    if (!dic.ContainsKey(h))
                        dic[h] = new Stack<int>();
                    dic[h].Push(i);
                    h--;
                }
                else if (input[i] == '/') {
                    h++;
                    stk.Push(new KeyValuePair<int, int>(h, i));
                }
            }

            List<int> areaList = new List<int>();
            int total = 0;
            int area = 0;
            int index = input.Length;
            while (stk.Count > 0) {
                KeyValuePair<int, int> cur = stk.Pop();
                int upH = cur.Key;
                int upW = cur.Value;

                if (!dic.ContainsKey(upH))
                    continue;

                int downW = upW;
                while (dic[upH].Count > 0 && downW >= upW) {
                    downW = dic[upH].Pop();
                }

                if (downW >= upW)
                    continue;

                if (index > downW) {
                    index = downW;
                    areaList.Add(area);
                    area = 0;
                }

                int tempArea = upW - downW;
                total += tempArea;
                area += tempArea;
            }
            areaList.Add(area);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(total.ToString());
            sb.Append(areaList.Count - 1);
            if (areaList.Count != 1)
                for (int i = areaList.Count - 1; i > 0; i--)
                    sb.AppendFormat(" {0}", areaList[i]);
            Console.WriteLine(sb);
        }
    }
}

Measured memory_bytes: 14100
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

vector<int> dfs(vector< vector<int> > &G, vector<bool> &visited, int v){
  vector<int> ret;
  for(int i = 0; i < G[v].size(); ++i){
    int v_ = G[v][i];
    if(visited[v_]) continue;
    visited[v_] = true;
    ret = dfs(G, visited, v_);
	break;
  }
  ret.push_back(v);
  return ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector< vector<int> > G(N);
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<bool> visited(N, false);
  int s = 0, t = G[0][0];
    visited[s] = true;
  visited[t] = true;
  vector<int> S = dfs(G, visited, s), T = dfs(G, visited, t);
  reverse(T.begin(), T.end());
  cout << S.size() + T.size() << endl;
  for(int i = 0; i < S.size(); ++i) cout << S[i]+1 << " ";
  for(int i = 0; i < T.size()-1; ++i) cout << T[i]+1 << " ";
  cout << T.back()+1 << endl;
  return 0;
}


Measured memory_bytes: 14012
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1

print(ans)


Measured memory_bytes: 9068
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    int N = sc.nextInt();
    int num = 0;
    if (D == 0) {
      num = 1;
    } else if (D == 1) {
      num = 100;
    } else if (D == 2) {
      num = 10000;
    }
    if (N == 100) {
      if (D== 0) {
        System.out.println(num * N + 1);  
      } else if (D == 1) {
        System.out.println(num * N + 100); 
      } else if (D == 2) {
        System.out.println(num * N + 10000); 
      }
    } else {
      System.out.println(num * N);
    }
  }
}

Measured memory_bytes: 23124
#include "atcoder/dsu"
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,q;
    cin >> n >> q;
    atcoder::dsu uf(n);
    while(q--){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            uf.merge(u,v);
        }else{
            if(uf.same(u,v)){
                print(1);
            }else{
                print(0);
            }
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3820
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class ADoubleHelix {
public:
	void solve(std::istream& in, std::ostream& out) {
	    char b;in>>b;
        switch (b) {
            case 'A':
                out<<'T'<<endl;
                break;
            case 'C':
                out<<'G'<<endl;
                break;
            case 'G':
                out<<'C'<<endl;
                break;
            case 'T':
                out<<'A'<<endl;
                break;


        }

	}
};


int main() {
	ADoubleHelix solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n,ans=0;
    cin>>n;
    auto f=[&](int a){
        int ans=0;
        while(a){
            a/=10;
            ans++;
        }
        return ans;
    };
    rep(i,n){
        if(f(i+1)%2==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\n'
int main()
{
    const ll MOD= 1000000007;
    ll s;
    cin >> s;
    ll x[s+10];
    x[0]=1;
    for(ll i=1;i<s+1;i++){
        if(i<3){
            x[i]=0;
        }else{
            x[i]=(x[i-3]+x[i-1])%MOD;
        }
    }


    cout << x[s] << endl;
}

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

int main(int argc, char *argv[]) {
  string S;
  unsigned long long K;
  cin >> S;
  cin >> K;
  int c;
  for(int i = 0; i < 100; i++) {
    if(S[i] != '1') {
      c = i+1;
      break;
    }
  }
  if(K < c) {
    cout << S[0] << endl;
  } else {
    cout << S[c-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
ans = 100000000
for i in range(L,R + 1):
    if ans == 0:
        break
    for j in range(i + 1,R + 1):
        if i*j % 2019 < ans:
            ans = i*j % 2019
            if ans == 0:
                break
print(ans)

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

typedef pair<ll,int> pli;

int n;
ll x;
int a[2000];
int b[2000];
ll ans = 0;

int main(){
  cin >> n >> x;
  REP(i,n){
   cin >> a[i];
   b[i] = a[i];
  }
  REP(k,n){
    ll tmp = k*x;
    REP(i,n){
      tmp += b[i];
      b[i] = min(b[i],a[(n+i-(k+1))%n]);
    }
    if(ans == 0) ans = tmp;
    ans = min(ans,tmp);
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;

using namespace std;

int main()
{
    double l;
    cin >> l;
    double cubic;
    cubic = l * l * l / 27;
    printf("%.12f", cubic);
    return 0;
}

Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun, 19th Jan 2020                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

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

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n;
	cin >> n;

	vii m(10, vi(10,0));

	rep(i,1,n+1){
		int a = i%10;
		// int b = i;
		// while(b >= 10) b /= 10;
		int b = to_string(i)[0] - '0';
		m[a][b]++;
	}

	ll tot = 0;
	rep(i,0,10) rep(j,0,10) tot += (ll)m[i][j] * m[j][i];
	ret(tot);
}


Measured memory_bytes: 256
def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

    

ans = 0

k = int(input())
for ai in range(1,k+1):
    for bi in range(ai,k+1):
        for ci in range(bi,k+1):
            count = len(set({ai,bi,ci}))
            if count == 1:
                comb = 1
            elif count ==2:
                comb =  3
            else:
                comb = 6
            ans += gcd(gcd(ai,bi),ci) * comb
print(ans)

Measured memory_bytes: 9212
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    ll now = 0;
    int l = (int)s.size();
    for(int i=0;i<l;++i){
        if(s[i]=='W'){
            ans += (ll)i-now;
            now++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool era[10000001]={false};


void makeERA(){
    for(int i=2;i<1000001;i++){
        if(era[i]!=true)continue;
            for(int j=2;i*j<=10000000;j++){
                    era[i*j]=false;
            }

    }
    era[2]=true;
}




int main(){
    for(int i=0;i<10000001;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    int n;
    while(cin>>n){
        if(n==0)break;
        
        if(n%2==0)n--;
        for(int i=n;i>=8;i-=2){
            if(era[i-8]&&era[i-6]&&!era[i-4]&&era[i-2]&&era[i]){
                cout<<i<<endl;
                goto next;
            }
        }
        next:;
    }
    
    
    return 0;
}

Measured memory_bytes: 10928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const long long MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    if(i%2==0 && a%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long ans=0;
    for(long long i=1; i<n+1; i++){
        if(i%3!=0 && i%5!=0) ans += i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

ll power( ll a, int b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

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

	vector<int> a(n);
	for( auto &k : a ) cin >> k;

	const int a_bound = 1000010;
	vector<int> l(a_bound, 0);
	
	int p_bound = 1;
	for( auto k : a ){
		if( k == 1 ) continue;
		int t = k;
		for( int p = 2; p*p <= k; ++p ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			if( cnt > 0 ){
				p_bound = max(p_bound, p);
				l[p] = max(l[p], cnt);
			}
		}
		if( t != 1 ){
			p_bound = max(p_bound, t);
			l[t] = max(l[t], 1);
		}
	}
	
	vector<int> pset;
	for( int p = 2; p < a_bound; ++p ){
		if( l[p] > 0 ) pset.emplace_back(p);
	}

	ll ans = 0;
	
	for( auto &t : a ){
		ll pro = 1;
		for( auto p : pset ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			pro *= pow((ll)p, l[p]-cnt);
			pro %= mod;
		}
		ans += pro;
		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4352
n, m = map(int, input().split())
ac=0
wa=0
ques_list = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p)-1
    if ques_list[p] != "AC":
        if s == "AC":
                ac += 1
                wa += ques_list[p]
                ques_list[p] = "AC"
        else:
            ques_list[p] += 1
print(str(ac)+" "+str(wa))



Measured memory_bytes: 3956
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
    static void solve(){//Here is the main function
      int N = nextInt();
      long output = 1;
      int mod = 1000000007;
      for(int i = 1; i <= N; i++){
        output *= i;
        output %= mod;
      }
      myout(output);
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 32780