akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        x:usize,
        y:usize,
    }
    let ans = gcd(x, y);
    println!("{}",ans);
}

fn gcd(a:usize,b:usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b,a%b)
    }
}


#[test]
fn gcd_test(){
    assert_eq!(gcd(147, 105),21);
}


Measured memory_bytes: 5028
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  bool ok = true;
  REP(i, n / 2) {
    if (s[i] != s[n - i - 1]) ok = false;
  }
  n /= 2;
  REP(i, n / 2) {
    if (s[i] != s[n - i - 1]) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

#define x first
#define y second

using namespace std;

int f[200010], fi[200010];
const int MOD = 1e9 + 7;

int add(long long a, long long b){
    return (a + b) % MOD;
}

int mul(long long a, long long b){
    return (a * b) % MOD;
}

int fp(long long a, int b){
    if(b == 0) return 1;
    int tp = fp(a, b >> 1);
    tp = mul(tp, tp);

    if(b & 1) return mul(tp, a);
    else return tp;
}

int comb(int n, int k){
    if(k > n) return 0;

    return mul(f[n], mul(fi[n - k], fi[k]));
}

int h, w, n, dp[3010];
vector<pair<int, int> > v;

int main(){
    f[0] = fi[0] = 1;
    for(int i = 1; i <= 200002; i++){
        f[i] = mul(i, f[i - 1]);
        fi[i] = fp(f[i], MOD - 2);
    }
    
    scanf("%d%d%d", &h, &w, &n);

    v.resize(n);
    for(int i = 0; i < n; i++){
        scanf("%d%d", &v[i].x, &v[i].y);
    }
    sort(v.begin(), v.end());
    v.emplace_back(h, w);

    for(int i = 0; i <= n; i++){
        dp[i] = comb(v[i].x + v[i].y - 2, v[i].x - 1);
        
        for(int j = 0; j < i; j++){
            if(v[j].x <= v[i].x && v[j].y <= v[i].y){
                dp[i] = add(dp[i], -mul(comb(v[i].x + v[i].y - (v[j].x + v[j].y), v[i].x - v[j].x), dp[j]));
                if(dp[i] < 0) dp[i] += MOD;
            }
        }
    }

    printf("%d\n", dp[n]);

    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
using P = pair< int,int>;
using node = tuple<string,int,int>;
const int MAX_N = (1 << 21) - 1;
const int inf = numeric_limits<int>::max();

int n,m;
vector<vector<int>> sw;
vector<int> p;

bool ok(int i){
  for(int j = 0;j < m;++j){
    int cnt = 0;
    for(int k : sw[j]){
      if((i >> k) & 1) ++cnt;
    }
    if(cnt % 2 != p[j])return false;
  }
  return true;                      
}

int main(void){
  cin >> n >> m;
  sw.clear();sw.resize(m);
  for(int i = 0;i < m;++i){
    int k;
    cin >> k;
    for(int j = 0;j < k;++j){
      int s;
      cin >> s;
      --s;
      sw[i].push_back(s);
    }
  }

  p.clear();p.resize(m);
  for(int i = 0;i < m;++i){
    cin >> p[i];
  }
  
  int res = 0;
  for(int i = 0;i < (1 << n);++i){
    if(ok(i))++res;
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/

    int n,k;cin>>n>>k;
    cout<<n-k+1;

    
    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> sc(m);
  for (int i = 0; i < m; i++) {
    cin >> sc[i].first >> sc[i].second;
  }
  vector<int> ans(n, 0);
  if (n >= 2) {
    ans[0] = 1;
  }
  vector<bool> flag(n, 1);
  for (auto [si, ci] : sc) {
    if (n != 1 && si == 1 && ci == 0) {
      cout << -1 << '\n';
      return 0;
    } else if (flag[si - 1]) {
      ans[si - 1] = ci;
      flag[si - 1] = 0;
    } else {
      if (ans[si - 1] != ci) {
        cout << -1 << '\n';
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3660
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from heapq import heappop, heappush
def resolve():
    n, m = map(int, input().split())
    N = 1 << (n - 1).bit_length()
    N2, now = N * 2, N * 3
    E = [[] for _ in range(N * 3 + m)]
    ref = lambda v : v if v < 3 * N else v - N2

    # build range-edge graph
    for i in range(N - 1, 0, -1):
        cl, cr = i << 1, i << 1 | 1
        E[i].append((cl, 0))
        E[i].append((cr, 0))
        E[ref(cl + N2)].append((ref(i + N2), 0))
        E[ref(cr + N2)].append((ref(i + N2), 0))

    # add range-edge
    for _ in range(m):
        u, v, w = map(int, input().split())
        u -= 1
        # lower
        l, r = u + N, v + N
        while l < r:
            if l & 1:
                E[ref(l + N2)].append((now, w))
                l += 1
            if r & 1:
                r -= 1
                E[ref(r + N2)].append((now, w))
            l >>= 1
            r >>= 1
        # upper
        l, r = u + N, v + N
        while l < r:
            if l & 1:
                E[now].append((l, 0))
                l += 1
            if r & 1:
                r -= 1
                E[now].append((r, 0))
            l >>= 1
            r >>= 1
        now += 1

    # Dijkstra (source : N, termination : N + n - 1)
    dist = [INF] * now
    dist[N] = 0
    heap = [(0, N)]
    while heap:
        d, v = heappop(heap)
        if dist[v] != d:
            continue
        for nv, w in E[v]:
            if dist[nv] > d + w:
                dist[nv] = d + w
                heappush(heap, (d + w, nv))

    ans = dist[N + n - 1]
    if ans == INF:
        ans = -1
    print(ans)
resolve()

Measured memory_bytes: 263108
import java.util.*;
import java.awt.geom.*;
import java.io.*;
public class Main{
	//0108 cording start
	//0115 cording end
	int [] die;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			char [] data = new char[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.next().charAt(0);
			}
			
			die = new int[7];
			for(int i = 0; i <= 6; i++){
				die [i] = i;
			}
			
			for(int i = 0; i < n; i++){
				switch(data[i]){
				case 'n':
					swap(1,2,6,5);
					break;
				case 's':
					swap(1,5,6,2);
					break;
				case 'e':
					swap(1,4,6,3);
					break;
				case 'w':
					swap(1,3,6,4);
					break;
				}
			}
			System.out.println(die[1]);
		}
	}

	private void swap(int i, int j, int k, int l) {
		int temp = die[l];
		die[l] = die[k];
		die[k] = die[j];
		die[j] = die[i];
		die[i] = temp;
	}

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

Measured memory_bytes: 12000
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
posx = 0
posy = 0
mod = 10**9+7
ans = 1
flgx = 0
flgy = 0
if len(set(a)) != len(a) or len(set(b)) != len(b):
  print(0)
  exit()
if max(a) != n*m or max(b) != n*m:
  print(0)
  exit()
for i in range(n*m,0,-1):
  while posx<n-1 and a[posx+1] >= i:
    posx += 1
  if a[posx] == i:
    flgx = 1
  while posy<m-1 and b[posy+1] >= i:
    posy += 1
  if b[posy] == i:
    flgy = 1
  if flgx and flgy:
    flgx = 0
    flgy = 0
    continue
  elif flgx:
    ans = (ans*(posy+1))%mod
  elif flgy:
    ans = (ans*(posx+1))%mod
  else:
    ans = (ans*((posx+1)*(posy+1)-(n*m-i)))%mod
  flgx = 0
  flgy = 0
print(ans)

Measured memory_bytes: 3316
n = int(input())
p = list(map(int, input().split()))
c = 0
for i in range(2,n):
  p1 = p[i-2]
  p2 = p[i-1]
  p3 = p[i]
  if p1 < p2 < p3 or p3 < p2 < p1:
    c += 1
print(c)

Measured memory_bytes: 9120
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n, p[16], t[16], ans;

	while(cin >> n, n){
		for(int i = 0;i < n; i++)
			cin >> p[i];

		for(ans = 0; ; ans++){
			for(int i = 0;i < n; i++){
				int cnt = 0;
				for(int j = 0;j < n; j++){
					//if(i == j) continue;
					if(p[i] == p[j]) cnt++;
				}
				//cout << cnt << endl;
				t[i] = cnt;
			}
			bool f = false;
			for(int i = 0;i < n; i++)
				if(p[i] != t[i]) f = true;
			if(!f) break;
			memcpy(p, t, sizeof(p));
		}
		cout << ans << endl;
		cout << p[0];
		for(int i = 1;i < n; i++) cout << ' ' << p[i];
		cout << '\n';
	}
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a, b, c, ans=0;
    cin >> n;
    for(a=1;a<n;a++){
        for(b=1;b<n;b++){
            if(n-a*b>=1) ans++;
            if(a*b>n) break;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3624
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin >> n;
	vector<ll> cnt(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		cnt[a - 1]++;
	}

	sort(cnt.rbegin(), cnt.rend());
	int cur = 0;
	cnt.insert(cnt.begin(), n);
	vector<ll> pref(n + 1);
	for (int i = 0; i <= n; i++) {
		pref[i] = (i ? pref[i - 1] : 0) + cnt[i];
	}

	for (int i = 1; i <= n; i++) {
		cur += cnt[i];
		int rem = n - cur;
		int l = 0, r = i;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			ll need = cnt[i - mid] * (mid + 1) - pref[i] + pref[i - mid - 1];
			if (rem < need) {
				r = mid;
			} else {
				l = mid;
			}
		}
		ll need = cnt[i - l] * (l + 1) - pref[i] + pref[i - l - 1];
		cout << cnt[i - l] + (rem - need) / (l + 1) << " \n"[i == n];
	}
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

ll a, b, c;

int main () {
    cin >> a >> b >> c;

    cout << min(c, a+b+1) + b;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=2e5+50;
const int inf=0x3f3f3f3f;
const int M=5000*4;
char ch[MAXN];
int cnt[MAXN];
int main()
{
 int n;
 cin>>n;
 cout<<(n/2)+n%2;
    
    
 return 0;
 
}

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

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double s = x/a;
    double rad;
    if (s >= a*b/2){
        double h = (a*b-s)*2/a;
        rad = atan2(h,a);
    } else {
        double w = s*2/b;
        rad = atan2(b,w);
    }
    double deg = rad/(2*M_PI)*360;
    cout << setprecision(10) << deg << endl;
    return 0;
}

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

public static partial class Program
{
    public static void Main()
    {
        var inp = CRL().ArrayInts();
        var r = inp[0];
        var d = inp[1];
        var x = inp[2];
        for (int i = 0; i < 10; i++)
        {
            x = r * x - d;
            CWL(x);
        }
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = new[] {0, -1, 0, 1};
    public static readonly int[] Dy = new[] {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    }
}

class Deck{
    private String str;
    Deck(){
    }
    void setDeck(String s){
        this.str=s;
    }
    void shuffle(int h){
        this.str=this.str.substring(h,this.str.length())+this.str.substring(0,h);
    }
    void printDeck(){
        System.out.println(this.str);
    }
}


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

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


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BLucasNumber solver = new BLucasNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class BLucasNumber {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long[] r = new long[87];
            r[0] = 2;
            r[1] = 1;
            for (int i = 2; i < 87; i++) {
                r[i] = r[i - 2] + r[i - 1];
            }
            out.println(r[in.nextInt()]);
        }

    }
}



Measured memory_bytes: 23764
package main

import "fmt"

func main() {
	var n, u, v int
	fmt.Scan(&n, &u, &v)

	g := make([][]int, n+1)
	var a, b int
	for i := 0; i < n-1; i++ {
		fmt.Scan(&a, &b)
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	us := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		us[i] = -1
	}

	us[u] = 0
	q := make([]int, 0)
	q = append(q, u)
	for len(q) > 0 {
		cur := q[0]
		q = q[1:]
		for _, next := range g[cur] {
			if us[next] != -1 {
				continue
			}
			us[next] = us[cur] + 1
			q = append(q, next)
		}
	}

	vs := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		vs[i] = -1
	}
	vs[v] = 0
	q = make([]int, 0)
	q = append(q, v)
	for len(q) > 0 {
		cur := q[0]
		q = q[1:]
		for _, next := range g[cur] {
			if vs[next] != -1 {
				continue
			}
			vs[next] = vs[cur] + 1
			q = append(q, next)
		}
	}

	ans := 0
	for i := 0; i < n+1; i++ {
		if us[i] < vs[i] {
			ans = max(ans, vs[i]-1)
		}
	}

	fmt.Println(ans)
}

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


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

signed main(){
  string S;
  cin>>S;
  int N=S.size(),ans=0;
  rep(i,N){
    if(i%2==0){
      if(S[i]=='0')ans++;
    }else{
      if(S[i]=='1')ans++;
    }
  }
  cout<<min(ans,N-ans)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
const int M=1000000;
ll f[M+1],g[M+1],inv[M+1];
void precalc(){
	f[0]=1;
	rep1(i,M) f[i]=f[i-1]*i%mod;
	inv[1]=1;
	for(int i=2;i<=M;i++) inv[i]=mod-mod/i*inv[mod%i]%mod;
	g[0]=1;
	rep1(i,M) g[i]=g[i-1]*inv[i]%mod;
}
ll Comb(int x,int y){
	return f[x]*g[y]%mod*g[x-y]%mod;
}


int A,B,C;
ll p3[M+1];
int main(){
	precalc();
	p3[0]=1;
	rep1(i,M) p3[i]=p3[i-1]*3%mod;
	cin>>A>>B>>C;
	ll ans=0;
	int pL,pR;
	ll sum=0;
	for(int last=A;last<=A+B+C;last++){
		int N=last-A;
		int L=max(0,N-C),R=min(B,N);
		if(L<=R){
			if(last==A){
				sum=1;
			}else{
				sum=sum*2+Comb(N-1,pL-1)+Comb(N-1,pR+1);
				if(pL+1==L) sum-=Comb(N,pL);
				if(pR==R) sum-=Comb(N,R+1);
				sum%=mod;
			}
			ll c=Comb(last-1,A-1)*sum%mod*p3[A+B+C-last]%mod;
			add(ans,c);
		}
		pL=L,pR=R;
	}
	if(ans<0) ans+=mod;
	cout<<ans<<endl;
}


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

double p = 1.0 / 6.0;

int main(){


    while(1){

        int N, T, L, B; cin >> N >> T >> L >> B;
        if(!N) break;

        vector<int> a(N + 1, 0);
        for(int i = 0; i < L; i++){
            int l; cin >> l;
            a[l] = 1;
        }


        for(int i = 0; i < B; i++){
            int b; cin >> b;
            a[b] = 2;
        }
        
        vector<vector<double> > dp(T + 2, vector<double> (N + 1, 0.0));
        dp[0][0] = 1.0;
        for(int i = 0; i < T; i++){
            for(int j = 0; j < N; j++){

                for(int h = 1; h <= 6; h++){
                    int next = j + h;
                    if(next > N) next = 2*N - next;

                    //cout << i << " " << j << " " << next << " " << dp[i][j] << endl;

                    if(a[next] == 0) dp[i + 1][next] += dp[i][j] * p;
                    else if(a[next] == 1) dp[i + 2][next] += dp[i][j] * p;
                    else dp[i + 1][0] += dp[i][j] * p;
                    //cout << i + 1 << " " << next << " " << dp[i + 1][next] << endl;

                }
            }
        }

        double ans = 0.0;
        for(int i = 0; i <= T; i++){
             //cout << dp[i][N] << endl;
             ans += dp[i][N];
        }
        //cout << dp[1][6] << endl;
        printf("%f\n", ans);

    }

    return 0;
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc075.contest.atcoder.jp/tasks/arc075_c>
問題文============================================================
 長さ N の整数列 a= {a1,a2,…,aN} と、整数 K が与えられます。
 
 a の空でない連続する部分列 {al,al+1,…,ar} (1≤l≤r≤N) は N(N+1)⁄2 個存在します。
 これらのうち、算術平均が K 以上であるものは何個あるでしょうか？
 
 入力値はすべて整数である。
 1≤N≤2×10^5
 1≤K≤10^9
 1≤ai≤10^9
=================================================================

解説=============================================================

 そのままやると O(N^2) で、まぁ間に合わない。
 ここで、a の累積和を cusum とすると,
 目的は (cusum[r] - cusum[l])/(r-l) >= K となるものを探すことである
 この条件について,あらかじめ全てのaをKで減じておくと K => 0 となるため
 
 (cusum[r] - (cusum[l])/(r-l) >= 0
 
 cusum[r] - cusum[l] >= 0
 
 となり、目的は cusum[r] が cusum[l] (1 <= l < r) 以上であるという条件に置き換えることができる
 これは indexとともにソートされたcusumをBITなどで管理すれば O(NlogN)で解くことができる
================================================================
*/


struct BIT {
    int N;
    vector<ll> bit;
    BIT(int N):N(N) {
        /* BITは[1..N]で扱う */
        bit.resize(N + 1, 0);
    }
    
    void add(int x, int val)
    {
        while (x <= N) {
            bit[x] += val;
            x += x & -x;
        }
    }
    
    int sum(int x)
    {
        int ret = 0;
        while (x) {
            ret += bit[x];
            x &= (x - 1);
        }
        
        return (ret);
    }
};

ll solve(){
    ll res = 0;
    ll N,K; cin >> N >> K;
    vector<ll> a(N); for(auto &in:a){ cin >> in; in -= K; }
    vector<pll> cusum(N);
    for(int i = 0; i < N;i++){
        if(i == 0){
            cusum[i] = {a[i],i+1};
        }else{
            cusum[i] = {cusum[i-1].first + a[i],i+1};
        }
    }
    sort(cusum.begin(),cusum.end());
    reverse(cusum.begin(),cusum.end());
    BIT bit(N);
    for(int i = 0; i < N;i++){
        if(cusum[i].first >= 0){
            res += bit.sum(cusum[i].second);
            bit.add(cusum[i].second,1);
        }else{
            bit.add(cusum[i].second,1);
            res += bit.sum(cusum[i].second);
        }
    }
    return N*(N+1)/2 - res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 2000005;
const int MOD = 998244353 ;

int b[N];

int fun(int n){
    ff(i,sqrt(n)){
        if(n%i == 0){
            if(i != n){
                if(b[i] >= 1)return 0;
            }
            else{
                if(b[i] > 1)return 0;
            }
            int k = (n/i);
            if(k != n){
                if(b[k] >= 1)return 0;
            }
            else{
                if(b[k] > 1)return 0;
            }
        }
    }
    return 1;
}

void solve(){
    int n, ans = 0;
    cin>>n;
    int a[n+10];
    f(i,n)cin>>a[i],b[a[i]]++;
    f(i,n)if(fun(a[i]))ans++;
    cout<<ans;
}

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


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

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

  vector<int> roadNums(N);
  fill(roadNums.begin(), roadNums.end(), 0);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;

    roadNums[a - 1]++;
    roadNums[b - 1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << roadNums[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
"""
i が 3 でも 5 でも割り切れるなら、ai=FizzBuzz
そうではなく i
が 3 で割り切れるなら、ai=Fizz
そうではなく i
が 5 で割り切れるなら、ai=Buzz
そうではないなら、ai=i
"""
n=int(input())
r=0
for ii in range(n):
  if (ii+1)%3!=0 and (ii+1)%5!=0:
    r+=(ii+1)
print(r)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y-= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    ll x,y;
    cin >> x >> y;

    if (x % y == 0) {
        cout << -1 << endl;
    }else{
        cout << x << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
def resolve():
    import copy
    D = int(input())
    cost = list(map(int, input().split()))
    sat = [list((map(int, input().split()))) for _ in range(D)]
    last = [0]*26

    for i in range(D):
        if i % 3 != 0:
            print(i%26 + 1)
        else:
            maxcost = -float("INF")
            ans = 0
            for j in range(26):
                nowlast = copy.deepcopy(last)
                nowlast[j] = i+1
                plussat = sat[i][j]
                minussat = 0
                for k in range(26):
                    minussat += (i + 1 - nowlast[k]) * (cost[k])
                cum = plussat-minussat

                if maxcost < cum:
                    ans = j
                    maxcost = cum
            last[j] = i+1
            print(ans+1)
resolve()

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

int main(){
	int a,b,c;
	int min,max,mid;

	cin>>a>>b>>c;
		if(b<a&&b<c){
			min=b;
		}else if(c<a){
			min=c;
		}else{
			min= a;
		}

		if(b>a&&b>c){
			max=b;
			
		}else if(c>a){
			max=c;
		}else{
			max= a;
		}
		mid=a+b+c-max-min;
		cout<<min<<" "<<mid<<" "<<max<<endl;
return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;
    return 0;
}

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

int main() {
    int X;
    cin >> X;
    int ans = 0;
    ans += 1000*(X/500);
    X = X%500;
    ans += (X/5)*5;
    cout << ans << endl;
    
    
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	string A[3];

	cin >> N;
	rep(i,3) cin >> A[i];

	rep(i,N){
		map<char,int> cnt;
		rep(j,3) cnt[ A[j][i] ]++;
		if( cnt.size() == 2 ){
			ans++;
		}else if( cnt.size() == 3 ){
			ans += 2;
		}
	}

	cout << ans << endl;

	return 0;
}

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

const int N = 3;
int main() {
    vector<int> A(N);

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

    sort(A.begin(), A.begin() + N);

    int sum = 0;
    for (int i=0;i<N - 1;i++)
    {
        sum += abs(A[i] - A[i + 1]);
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=10**9+7
if len(set(a))!=len(a) or len(set(b))!=len(b):
  print(0)
else:
  a.sort()
  b.sort()
  L=[]
  for i in range(n):
    l=[]
    for j in range(m):
      l.append(0)
    L.append(l)
  ct=1;ctn=0;ctm=0
  A=set(a);B=set(b)
  for k in range(m*n,0,-1):
    if k in A and k in B:
      L[bisect.bisect_left(a,k)][bisect.bisect_left(b,k)]=k
      ctn+=1;ctm+=1
    elif k in A:
        ct*=ctm
        ctn+=1
    elif k in B:
        ct*=ctn
        ctm+=1
    else:
      ct*=(ctm*ctn-m*n+k)
    if ct==0:
      break
    ct=ct%x
  print(ct)

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

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

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

    long long S;
    if (N % 2 == 0){
        int c = N / 2;
        S = -2 * accumulate(A.begin(), A.begin() + c, 0LL) + 2 * accumulate(A.begin() + c, A.end(), 0LL) + A[c-1] - A[c];
    }
    else{
        int c = (N - 1) / 2;
        long long tmp1 = -2 * accumulate(A.begin(), A.begin() + c, 0LL) + 2 * accumulate(A.begin() + c + 2, A.end(), 0LL) + A[c] + A[c+1];
        long long tmp2 = -2 * accumulate(A.begin(), A.begin() + c-1, 0LL) + 2 * accumulate(A.begin() + c + 1, A.end(), 0LL) - A[c-1] - A[c];
        S = max(tmp1, tmp2);
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 640
def cmb(n):
    if n < 2:
        return 0
    else:
        return (n*(n-1)/2)

N = int(input())
A = list(map(int,input().split()))

num_dict = {i:0 for i in range(1,N+1)}
for i in range(N):
    num_dict[A[i]] += 1

S = 0
for i in range(1,N+1):
    S += cmb(num_dict[i])

for i in range(N):
    tmp = 0
    S_dif = cmb(num_dict[A[i]]-1) - cmb(num_dict[A[i]])
    tmp = S + S_dif
    print(int(tmp))

Measured memory_bytes: 40972
import java.util.*;

public class Main {
    List<String> list = new ArrayList<String>();
    Map<Integer,Integer> map = new HashMap<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
        int H2 = sc.nextInt();
        int M2 = sc.nextInt();
        int K = sc.nextInt();
        sc.close();
        if(M2 >= M1){
            System.out.println(60 * (H2 - H1) + M2 - M1 - K);
        }else{
            System.out.println(60 * (H2 - H1) - (M1 - M2) - K);
        }
    }
}


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

int main(){
int n;cin >> n;
string s[n+1];

int ac=0;
int wa=0;
int tle=0;
int re=0;

for(int i=0;i<n;i++){
  cin >> s[i];
  if(s[i]=="AC") ac ++;
  if(s[i]=="WA") wa ++;
  if(s[i]=="TLE") tle ++;
  if(s[i]=="RE") re ++;
}

cout << "AC"<< " " << "x" << " "<<ac <<endl;
cout << "WA"<<  " "  "x" << " "<<wa <<endl;
cout << "TLE"<< " "<<  "x" << " "<<tle <<endl;
cout << "RE"<< " "<<"x" << " "<<re <<endl;

}

Measured memory_bytes: 6752
N = int(input())
li = [["M",0],["A",0],["R",0],["C",0],["H",0]]
ans = 0
for i in range(N):
    tmp = str(input())
    if tmp[0]=="M" or tmp[0]=="A" or tmp[0]=="R" or tmp[0]=="C" or tmp[0]=="H":
        for j in range(5):
            if tmp[0]==li[j][0]:
                li[j][1] += 1
                break

for i in range(3):
    for j in range(i+1,5,1):
        for k in range(j+1,5,1):
            ans += li[i][1]*li[j][1]*li[k][1]
            
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,t,x,y;
    multimap<ll,ll>m;
    cin>>n>>t;
    for(ll i=0;i<n;++i)
    {
        cin>>x>>y;
        m.insert(make_pair(x,y));
    }
    multimap<ll,ll> :: iterator it;
    for(it = m.begin();it!=m.end();++it)
    {
        if(it->second <= t){
            cout<<it->first<<endl;
            return 0;
        }
    }
    cout<<"TLE"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		if (s.charAt(0) != 'A') {
			System.out.println("WA");
			return;
		}
		int count = 0;

		for (int i = 2; i < s.length() - 1; i++) {
			if (s.charAt(i) == 'C') {
				count++;
			}
		}
		if (count != 1) {
			System.out.println("WA");
			return;
		}
		for (int i = 1; i < s.length(); i++) {

			if (Character.isUpperCase(s.charAt(i))
					&& s.charAt(i) != 'C') {
				System.out.println("WA");
				return;
			}
		}
		System.out.println("AC");

	}
}

Measured memory_bytes: 23764
///答え見ました
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  
  h[0]--;
  for(int i=1; i<n; i++){
    if(h[i]>h[i-1]){
     h[i]--; 
    }
    else if(h[i]<h[i-1]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
  
}
  

Measured memory_bytes: 640
(let* ((n (read))
       (x (make-hash-table :size 100000 :test 'equal))
       (ans 0))
  (loop :for i :from 0 :to (1- n)
        :for r := (sort (read-line) #'char<)
        :if (gethash r x)
        :do (incf (gethash r x))
        :else
        :do (setf (gethash r x) 0))
  (maphash (lambda (k v) k (incf ans (/ (* v (1+ v)) 2))) x)
  (format t "~A~%" ans))


Measured memory_bytes: 61864
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define MOD 1000000007

int gcd(int a, int b){
    if( a < b){
        swap(a,b);
    }
    return (a % b == 0)? b:gcd(a, a%b);
}

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


int main(){
    ll dp[10001];
    rep(i,10001){
        dp[i] = INT32_MAX;
    }

    dp[0] = 0;
    ll h,n;
    cin >> h >> n;
    unordered_map<ll, ll> spells;
    rep(i,n){
        ll cost, power;
        cin >> power >> cost;
        spells.insert(make_pair(cost, power));
    }

    for(pair<ll, ll> spell : spells){
        rep(i,h){
            if(dp[i] != INT32_MAX ){
                ll target = min(h, i + spell.second);
                dp[target] = min(dp[i] + spell.first, dp[target]);
            }
        }
    }

    cout << dp[h] << endl;
}

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

void chmax(int &a, int b){
    a = max(a,b);
}

bool solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    vector<vector<int> > dp(n, vector<int>(3, 1));
    int ans = 1;
    for(int i=1;i<n;i++){
        if(a[i-1]!=a[i]){
            dp[i][0] = dp[i-1][0]+1;
            chmax(dp[i][1], dp[i-1][1]+1);
            chmax(dp[i][2], dp[i-1][2]+1);
        }else{
            chmax(dp[i][1], dp[i-1][0]+1);
            chmax(dp[i][2], dp[i-1][1]+1);
        }
        for(int j=0;j<3;j++){
            chmax(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return true;
}

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



Measured memory_bytes: 8616
#include <stdio.h>

main() {
  int a, b, ascore=0, bscore=0, n, i; 
  
  while(1) {
    scanf("%d", &n);
    if(n == 0) break;
    for(i=0 ; i<n ; i++) {
      scanf("%d%d", &a, &b);
      if(a > b) ascore += a+b;
      else if(a < b) bscore += a+b;
      else {
	ascore += a;
	bscore += b;
      }
    }
      printf("%d %d\n", ascore, bscore);
      ascore = bscore = 0;
  }
return 0;
} 

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

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

	vector<int> cnt(10000005, 1);

	for (int i = 2; i <= n; ++i) {
		for (int j = i; j <= n; j += i) {
			cnt[j]++;
			if (i + j > n) break;
		}
	}


	long long ans = 0;
	for (int i = 1; i <= n; ++i) ans += (long long)cnt[i] * i;

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

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  
  int ans=0;
  char stk='S';
  for(int i=0;i<n;++i){
    if(stk!=s.at(i)){
      stk=s.at(i);
      ++ans;
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;

	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0,a=1;
    cin>>n;
    for(int i=1;i<=n;i++){
    	if(a%2!=0){
    	    ans++;	
		}
		if(i==9||i==99||i==999||i==9999){
			a++;
		}
		if(n==100000){
			cout<<90909;
			return 0;
		}
	}
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}


signed main() {
  ios::sync_with_stdio(false);
  ll n, t;
  cin >> n >> t;
  vector<ll> a(n);
  REP(i, n)  cin >> a[i];
  ll c = a[0];
  ll b = 0;
  REP(i, n) {
    c = min(a[i], c);
    b = max(b, a[i] - c);
  }
  ll ans = 0;
  c = a[0];
  REP(i, n) {
    c = min(a[i], c);
    if(a[i] - c == b) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

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

    int N, d;
    cin >> N >> d;
    vector<int> p(N);
    rep(i, N) cin >> p[i];

    int smdiff = 0;
    rep(i, N) {
        smdiff += max(0, p[i] - d);
    }

    int ans = 0;
    rep(g, N) {
        int t = -d + smdiff;
        if (p[g] - d > 0) {
            t += d;
        }
        ans = max(ans, t);
    }

    if (ans == 0) {
        cout << "kusoge" << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int c[10][1005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w,k,ans = 1e9;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h)cin >> s[i];
    rep(div, 1<<(h-1)){
        int g = 0;
        vector<int> id(h);
        rep(i,h){
            id[i] = g;
            if(div>>i&1)++g;

        }
        ++g;
        rep(i,g)rep(j,w)c[i][j]=0;
        rep(i,h)rep(j,w)c[id[i]][j] += (s[i][j]=='1');
        int num = g-1;
        vector<int> now(g);

        auto add = [&](int j){
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if(now[i] > k) return false;
            return true;
        };

        rep(j,w){
            if (!add(j)) {
                num++;
                now = vector<int>(g);
                if(!add(j)){
                    num = 1e9;
                    break;
                }
            }
        }
        chmin(ans,num);
    }
    cout << ans << endl;
}

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

int main(void){
    int x,a,b = 0;
    cin >> x >> a >> b;
    int absa = abs(x-a);
    int absb = abs(x-b);
    if(absa <= absb){
        cout << "A";
    }else
    {
        cout << "B";
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans = 0;
    bool ok = false;
    while(true){
        if(b <= ans * (a-1) + 1){break;}
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
inf = 10**10
V = 0
for a in range(N):
	V += A[a][1]
dp = [inf for v in range(V+1)]
dp[0] = 0
for p in range(N):
	for q in range(V - A[p][1], -1, -1):
		dp[q + A[p][1]] = min(dp[q + A[p][1]], dp[q] + A[p][0])
# print(dp)
ans = 0
for b in range(V+1):
	if (dp[b] <= W):
		ans = b
print(ans)


Measured memory_bytes: 45040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int a,b;
int main()
{
	int c;
	cin>>a>>b;
	if (a%2==0 || b%2==0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256