akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int p[101], N;

int num(int m){
    int ret = 0;
    for(int i=2; i<=N; i++){
        if(p[i] >= m) ret++;
    }
    return ret;
}

int main(void){
    cin >> N;

    // N!に含まれる素因数を全て列挙する
    for(int i=2; i<=N; i++){
        int cur = i;
        for(int j=2; j*j<=i; j++){
            while(cur%j == 0){
                p[j]++;
                cur /= j;
            }
        }
        if(cur != 1) p[cur]++;
    }

    cout << num(74) + num(14)*(num(4)-1) + num(24)*(num(2)-1) + (num(4)*(num(4)-1)/2)*(num(2)-2) << endl;

}

Measured memory_bytes: 256
n = int(input())
t0,x0,y0 = 0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    if abs(t0-t)%2 != (abs(x0-x)+abs(y0-y))%2 or (abs(x0-x)+abs(y0-y)) > abs(t0-t):
        print("No")
        exit()
    t0,x0,y0, = t,x,y
else:
    print("Yes")

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        s: usize,
    }

    for _ in 0..k {
        print!("{} ", s);
    }
    for _ in 0..(n - k) {
        if s == 1_000_000_000 {
            print!("{} ", 1);
        } else {
            print!("{} ", s + 1);
        }
    }
    println!();
}


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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, e;
  cin >> n >> m >> e;
  vector<string> g(n);
  for (int i = 0; i < n; i++) {
    cin >> g[i];
  }
  int all = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      all += g[i][j] == '#';
    }
  }
  int ans = 0;
  for (int mask_r = 0; mask_r < (1 << n); mask_r++) {
    for (int mask_c = 0; mask_c < (1 << m); mask_c++) {
      int d = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if ((mask_r & (1 << i)) && (mask_c & (1 << j)) && g[i][j] == '#') {
            d -= 1;
          }
          if (mask_r & (1 << i) && g[i][j] == '#') {
            d += 1;
          }
          if (mask_c & (1 << j) && g[i][j] == '#') {
            d += 1;
          }
        }
      }
      if (all - d == e) {
        ans += 1;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3656
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True) + [0, 0, 0, 0]
l = []
for i in range(len(a) - 1):
  if a[i] == a[i + 1] and (len(l) == 0 or l[-1] != i - 1):
    l.append(i)
    if len(l) >= 2:
      break
print(a[l[0]] * a[l[1]])


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  if(n%2==0){
    co(n/2*(n-1))
  }
  else{
    co((n-1)/2*n)
  }
}
  

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;

class Main{
        public static void main(String args[]){
                Scanner sc = new Scanner(System.in);
                int X = sc.nextInt();
                int A = sc.nextInt();
                int B = sc.nextInt();
                int C = (X - A) % B ;
                System.out.print(C);
        }
}


Measured memory_bytes: 21716
import java.util.Arrays;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    }

    public static ArrayList<Integer> toList(int[] arr){
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    }
}


Measured memory_bytes: 36052
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: usize,
        xs: [(chars, usize); n],
    }
    // let s = "hoge".chars().collect::<Vec<char>>();
    // let t = "hoge".chars().collect::<Vec<char>>();

    // debug!(xs);

    // xs.iter().map(|&(ref mut s, p)| s.push(char::from_digit(p, 10).unwrap()));

    let mut ys = xs.into_iter().enumerate().vec();

    // ys.sort_by(|&(_, (s1, p1)), &(_, (s2, p2))| s1.cmp(&s2));// && p1.cmp(p2));
    // ys.sort_by(|a, b| (a.1).0.cmp(&(b.1).0));
    // ys.sort_by(|a, b| (a.1).0.cmp(&(b.1).0).then((a.1).1.cmp(&(b.1).1)));

    ys.sort_by(|a, b|
               match (a.1).0.cmp(&(b.1).0) {
                   Ordering::Less => Ordering::Less,
                   Ordering::Equal => (b.1).1.cmp(&(a.1).1),
                   Ordering::Greater => Ordering::Greater,
               }
    );

    for (i, _) in ys {
        println!("{}", i+1);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void) {
  char b = getchar();

  if (b == 'A') {
    putchar('T');
  }
  if (b == 'T') {
    putchar('A');
  }
  if (b == 'G') {
    putchar('C');
  }
  if (b == 'C') {
    putchar('G');
  }

  putchar('\n');

  return 0;
}


Measured memory_bytes: 128
import           Control.Arrow         (second)
import           Data.Char             (isSpace)
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BSC8
import           Data.List             (sort, unfoldr)
import           Data.Vector.Unboxed   (Vector)
import qualified Data.Vector.Unboxed   as UV

getI :: ByteString -> Maybe (Int, ByteString)
getI = fmap (second BSC8.tail) . BSC8.readInt
getAB :: IO (Int, Int)
getAB = (\vec -> (vec UV.! 0, vec UV.! 1)) . UV.unfoldrN 2 getI <$> BSC8.getLine

getIL :: IO [Int]
getIL = unfoldr f <$> BSC8.getLine
  where
    -- f :: ByteString -> Maybe (Int, ByteString)
    f s = do
      (n, s') <- BSC8.readInt s
      return (n, BSC8.dropWhile isSpace s')

main :: IO ()
main = do
  (_, k) <- getAB
  ps <- getIL
  print $ sum . take k . sort $ ps


Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

ll N;
vector<ll> A(200010);
ll eval(ll b){
    ll sum = 0;
    rep(i,N){
        sum += abs(A[i] - b);
    }
    return sum;
}

int main(){
    cin >> N;
    ll ans = 1e18;
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        A[i] -= (i+1);
        //A[i] = abs(A[i]);
    }
    sort(A.begin(),A.begin()+N);
    //PR(A,N);
    ans = min(eval(A[N/2]), eval(A[N/2 + 1]));
    if(N>1){
        cmin(ans, eval(A[N/2-1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
A,B,H,M = map(int,input().split())
import math

a_theta = 30*H+0.5*M
a_sin_theta = math.sin(math.radians(a_theta))
a_cos_theta = math.cos(math.radians(a_theta))

b_theta = 6*M
b_sin_theta = math.sin(math.radians(b_theta))
b_cos_theta = math.cos(math.radians(b_theta))

ax = A*a_cos_theta
ay = A*a_sin_theta

bx = B*b_cos_theta
by = B*b_sin_theta

distance = math.sqrt((ax-bx)**2+(ay-by)**2)
print(distance)

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

int main(void) {
    vector<int> xs;
    int n, X; cin >> n >> X;

    int xi; cin >> xi;
    int minx = abs(xi - X);
    xs.push_back(abs(xi - X));

    for (int i = 1; i < n; i++) {
        cin >> xi;
        minx = min(minx, abs(xi - X));
        xs.push_back(abs(xi - X));    
    }

    vector<int> divx;
    for (int i = 1; i * i <= minx; i++)
    {
        if (minx % i == 0){
            divx.push_back(i);
            if (i * i != minx) divx.push_back(minx / i);
        }
    }

    int maxd = 1;
    for (int i = 0; i < divx.size(); i++) {
        bool flag = true;
        for (int j = 0; j < xs.size(); j++) {
            if (xs[j] % divx[i] != 0) {
                flag = false;
                break;
            }
        }
        if (flag)
            maxd = max(divx[i], maxd);
    }

    cout << maxd << endl;

    return 0;
}

Measured memory_bytes: 892
import sys
import math
import fractions
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()

mod = 10**9 + 7


def factorize(n):
    b = 2
    fct = defaultdict(lambda: 0)
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct[b] += 1
        b = b + 1
    if n > 1:
        fct[n] += 1
    return fct


def divmod(x, mod=10**9 + 7):
    return pow(x, mod - 2, mod)


def solve():

    N = int(input())
    A = list(map(int, input().split()))
    B = [[1] for _ in range(N)]

    fac_list = defaultdict(lambda: 0)
    for i in range(N):
        d = factorize(A[i])
        for k, v in d.items():
            fac_list[k] = max(fac_list[k], v)

    lcm = 1
    for k, v in fac_list.items():
        lcm *= (k**v)
        lcm %= mod

    ans = 0
    for i in range(N):
        ans += divmod(A[i])
        ans %= mod

    ans *= lcm
    ans %= mod
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 75480
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt(),a = sc.nextInt(),b = sc.nextInt();
        int bigger = Math.max(a,b);
        int smaller = Math.min(a,b);
        if(bigger - smaller - W > 0){
            System.out.println(bigger - smaller - W);
        }else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;

void preParse(int u){
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}
void inParse(int u){
  if ( u == NIL ) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}
void postParse(int u){
  if ( u == NIL ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



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

int main(void){
    int S;
    cin >> S;
    int h,m,s;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3100
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  ll ans=-1;
  for(ll i=1;i*i<=m;i++){
    if(m/i>=n && m%i==0)
      ans = max(ans,i);
    if(i>=n && m%i==0)
      ans = max(ans,m/i);
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    st s ;
    getline (cin , s) ;

    for (int i = 0 ; i < s.size() ; i ++)
    {
        s[i] = 'x' ;

    }
    cout << s ;


    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
    char a[100], b[100], c[100];
    scanf("%s %s %s", a, b, c);

    if(a[strlen(a) - 1] == b[0] && b[strlen(b) - 1] == c[0]) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>> a >> b >> c ;
    if(b-a==c-b)
    {
        cout <<"YES" << endl;


    }
    else
    {
        printf("NO\n");

    }
return 0;
}


Measured memory_bytes: 256
#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() {
  double l;
  cin >> l;
  double a,b;
  a=l/3.0;
  b=l/3.0+(l-a*3);
  double ans=a*a*a;
  cout << std::fixed << std::setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0; i<n; i++)
#define reps(i,s,n) for (int i=s, i<n; i++)
#define rep1(i,n) for (int i=1; i<=n; i++)
#define print(a) cout << a << endl;


const ll mod = 1e9+7;
struct mint {
  ll x;
  mint(ll x=0) : x((x%mod+mod)%mod) {}
  mint &operator+=(const mint &p) { if((x += p.x) >= mod) x -= mod; return *this; }
  mint &operator-=(const mint &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
  mint &operator*=(const mint &p) { x = x * p.x % mod; return *this; }
  mint &operator/=(const mint &p) { *this *= p.inverse(); return *this; }
  mint operator-() const { return mint(-x); }
  mint operator+(const mint &p) const { return mint(*this) += p; }
  mint operator-(const mint &p) const { return mint(*this) -= p; }
  mint operator*(const mint &p) const { return mint(*this) *= p; }
  mint operator/(const mint &p) const { return mint(*this) /= p; }
  bool operator==(const mint &p) const { return x == p.x; }
  bool operator!=(const mint &p) const { return x != p.x; }
  mint inverse() const {
    ll a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return mint(u);
  }
  mint pow(ll n) const {
    mint ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const mint &p) { return os << p.x; }
  friend istream &operator>>(istream &is, mint &a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};

template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;
  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i=1; i<=sz; i++) _fact[i] = _fact[i-1]*i;
    _rfact[sz] /= _fact[sz];
    for(int i=sz-1; i>=0; i--) _rfact[i] = _rfact[i+1]*(i+1);
    for(int i=1; i<=sz; i++) _inv[i] = _rfact[i]*_fact[i-1];
  }
  inline T fact(int k) const { return _fact[k]; }
  inline T rfact(int k) const { return _rfact[k]; }
  inline T inv(int k) const { return _inv[k]; }
  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n-r);
  }
  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p-q);
  }
  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n+r-1, r);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  mint ans = 0;
  Combination<mint> c(1000001);
  for (int i=0; i<=N; i++) {
    mint tmp = 0;
    tmp = c.C(N,i) * c.P(M, i) * c.P(M-i, N-i) * c.P(M-i, N-i);
    if (i%2)
      ans -= tmp;
    else
      ans += tmp;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 26756
#include<stdio.h>

int main(){
        int i,n,k,p,win;
        scanf("%d",&n);

        for(i=0;i<n;i++){
                scanf("%d %d",&k,&p);
                win=k%p;
                if(win==0){
                        win=p;
                }
                printf("%d\n",win);
        }
        return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;

int main()
{
	sync;
	ll n,k,q,cq;
	cin>>n>>k>>q;cq=q;
	ll tot[n+1]={0};
	while(cq--)
	{
		ll x;cin>>x;
		tot[x]++;
	}
	for(ll i=1;i<=n;i++)
	{
		if(k+tot[i]-q>0)
		cout<<"Yes\n";
		else
		cout<<"No\n";
	}
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
int main() 
{
    io();
    li n,k;
    cin>>n;
    li a[n],c=0,i;map<li,li>m;
    F {cin>>a[i];m[a[i]]++;c+=a[i];}
    cin>>k;
    while(k--)
    {
    	li x,y;
    	cin>>x>>y;
    	li z=m[x];
    	c-=z*x;
    	c+=z*y;
    	m[x]=0;
    	m[y]+=z;
    	cout<<c;
    	ne;
	}
}

Measured memory_bytes: 10300
#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;
	vector<int> A(N);
	rep(i, N) cin >> A.at(i);
	int i = 0;
	int answer = 0;
	while (i <= N - 1) {
		if (A.at(i) % 2 == 1) answer++;
		i += 2;
	}
	cout << answer << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int n;
		while(sc.hasNextInt()) {
			n = sc.nextInt();
			System.out.println(combinationOf4Integers(n));
		}
		sc.close();
	}

	static int sumOf4Integers(int a, int b, int c, int d) {
		return a + b + c + d;
	}
	
	static int combinationOf4Integers(int n) {
		int result = 0;
		for(int i = 0; i <= 9; i++) {
			for(int j = 0; j <= 9; j++) {
				for(int k = 0; k <= 9; k++) {
					for(int l = 0; l <= 9; l++) {
						if(sumOf4Integers(i, j, k, l) == n) result++;
					}
				}
			}
		}
		return result;
	}
}

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

int main()
{
    int A, B;
    cin >> A >> B;

    int answer;
    for (int i = 0; i < 100; ++i) {
        if ((A - 1) * (i - 1) + A >= B) {
            answer = i;
            break;
        }
    }

    cout << answer << endl;
}


Measured memory_bytes: 256
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#main
n=int(input())
C=[0,0,0]
S=[input() for _ in range(n)]
for a in S:
    if a[0]=="B" and a[-1]=="A":
        C[0]+=1
    elif a[0]=="B":
       C[1]+=1
    elif a[-1]=="A":
        C[2]+=1
count=0
if C[0]==0:
    count+=(min(C[1],C[2]))
elif C[0]>0 and C[1]==0 and C[2]==0:
    count+=C[0]-1
else:
    count+=C[0]+min(C[1],C[2])
for a in S:
    count+=a.count("AB")
print(count)



Measured memory_bytes: 6892
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 100001

using namespace std;

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

int main() {
    ll N, C, x[MAX_N], v[MAX_N];
    cin >> N >> C;
    for (int i = 1; i <= N; ++i) {
        cin >> x[i] >> v[i];
    }
    
    ll v_l[MAX_N], v_r[MAX_N];
    v_l[0] = 0; v_r[0] = 0;
    for (int i = 1; i <= N; ++i) {
        v_l[i] = v_l[i - 1] + v[i];
        v_r[i] = v_r[i - 1] + v[(N+1) - i];
    }
    
    ll l_0[MAX_N], l_1[MAX_N], r_0[MAX_N], r_1[MAX_N];
    l_0[0] = 0; l_1[0] = 0; r_0[0] = 0; r_1[0] = 0;
    for (int i = 1; i <= N; ++i) {
        l_0[i] = max(l_0[i - 1], v_l[i] - x[i]);
        l_1[i] = max(l_1[i - 1], v_l[i] - 2 * x[i]);
        r_0[i] = max(r_0[i - 1], v_r[i] - (C - x[(N+1) - i]));
        r_1[i] = max(r_1[i - 1], v_r[i] - 2 * (C - x[(N+1) - i]));
    }
    
    ll l_max0 = l_0[N], r_max0 = r_0[N];
    
    ll l_max1 = -INF, r_max1 = -INF;
    for (int i = 0; i <= N; ++i) {
        l_max1 = max(l_max1, l_1[i] + r_0[N - i]);
        r_max1 = max(r_max1, l_0[i] + r_1[N - i]);
    }
    
    ll ans = -INF;
    ans = max(ans, l_max0);
    ans = max(ans, r_max0);
    ans = max(ans, l_max1);
    ans = max(ans, r_max1);
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int d[40];
int x[maxn],y[maxn],n,tag;
int num;
char ch[40];

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d %d",&x[i],&y[i]);
	tag = (x[1] + y[1]) & 1;
	rep(i,1,n) if ( ((x[i] + y[i]) & 1) != tag ) return printf("-1\n"),0;
	if ( !tag ){
		num = 31;
		d[31] = 1;
		rep(i,1,n) x[i]--;
		ch[31] = 'R';
	}
	else num = 30;
	rep(i,0,30) d[i] = 1 << i;
	printf("%d\n",num + 1);
	rep(i,0,num) printf("%d ",d[i]);
	puts("");
	rep(i,1,n){
		repd(j,30,0){
			int lim = d[j] - 1;
			if ( (ll)abs(x[i] + d[j]) + abs(y[i]) <= lim ){
				ch[j] = 'L';
				x[i] += d[j];
			}
			else if ( (ll)abs(x[i] - d[j]) + abs(y[i]) <= lim ){
				ch[j] = 'R';
				x[i] -= d[j];
			}
			else if ( (ll)abs(y[i] + d[j]) + abs(x[i]) <= lim ){
				ch[j] = 'D';
				y[i] += d[j];
			}
			else if ( (ll)abs(y[i] - d[j]) + abs(x[i]) <= lim ){
				ch[j] = 'U';
				y[i] -= d[j];
			}
		}
	//	cout<<x[i]<<" "<<y[i]<<endl;
		rep(j,0,num) putchar(ch[j]);
		puts("");
	}
}


Measured memory_bytes: 384
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;


        public static void Main()
        {

            int days = int.Parse(Console.ReadLine());
            const int alphabets = 26;
            var sw = new Stopwatch();

            sw.Start();
            
            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var data = new KeyValuePair<int, int>[days][];
            var ans = new int[days];


            for (int i = 0; i < days; i++)
            {

                var buf = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                data[i] = new KeyValuePair<int, int>[alphabets];

                for (int j = 0; j < alphabets; j++)
                    data[i][j] = new KeyValuePair<int, int>(j + 1, buf[j]);

                Array.Sort(data[i], (left, right) => right.Value - left.Value);
                ans[i] = data[i][0].Key;

            }

            foreach (var answer in ans)
                Console.WriteLine(answer);

        }

    }

}

Measured memory_bytes: 29172
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n + 1.0);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n)
    {
        ans += a[i] / 2;
        a[i] %= 2;
        if (a[i] != 0 && a[i + 1] != 0)
            ans++, a[i + 1]--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
struct Node {
    int l, r;
}node[100005];
bool cmp(Node a, Node b) {
    if (a.l == b.l)
        return a.r < b.r;
    return a.l < b.l;
}
int main() {
    int N, M;
    scanf("%d%d",&N,&M);
    for (int i = 0; i < M; i++) {
        int l, r;
        scanf("%d%d",&l,&r);
        node[i].l = l;
        node[i].r = r;
    }
    sort(node, node+M, cmp);
    int curl, curr;
    curl = curr = 0;
    int ans = 0;
    curl = node[0].l;
    curr = node[0].r;
    for (int i = 1; i < M; i++) {
        if (node[i].l >= curl && node[i].r <= curr) {
            curl = node[i].l;
            curr = node[i].r;
        } else if (node[i].l >= curl && node[i].r > curr && node[i].l < curr) {
            curl = node[i].l;
            curr = curr;
        } else {
            if (i !=0 )
                ans++;
            curl = node[i].l;
            curr = node[i].r;
        }
    }
    ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 896
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Problem {
    private int N;
    private int M;
    private Long[][] shops;

    Problem() {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();

        shops = new Long[N][2];

        for (int i = 0; i < N; i++){
            shops[i][0] = sc.nextLong();
            shops[i][1] = sc.nextLong();
        }
    }

    long solve() {
        Arrays.sort(shops, new Comparator<Long[]>() {
            @Override
            public int compare(Long[] o1, Long[] o2) {
                return Long.compare(o1[0], o2[0]);
            }
        });

        long ans = 0;
        long m = M;
        int i = 0;
        while (m > 0) {
            long n = Math.min(shops[i][1], m);
            ans += shops[i][0] * n;
            m -= n;
            i++;
        }
        return ans;
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 98540
// 2分ヒープ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_H 500000
// 無効な値の定義
const int INV = -2147483645;

int parent(int i);
int leftNode(int i);
int rightNode(int i);

void buildMaxHeap(int heap[], int size);
void maxHeapify(int heap[], int size, int top);

int main(void)
{
    int H;
    int BinaryHeap[MAX_H];

    for(int i = 0; i < MAX_H; i++)
    {
        BinaryHeap[i] = INV;
    }

    cin >> H;

    for(int i = 1; i <= H; i++)
    {
        cin >> BinaryHeap[i];
    }

    // maxヒープを作成する
    buildMaxHeap(&BinaryHeap[0], H);

    for(int i = 1; i <= H; i++)
    {
        printf(" %d", BinaryHeap[i]);
    }

    printf("\n");

    return 0;
}

// 節点の親のNo.を返す関数
int parent(int i)
{
    return i / 2;
}

// 節点の左の子のNo.を返す関数
int leftNode(int i)
{
    return 2 * i;
}

// 節点の右の子のNo.を返す関数
int rightNode(int i)
{
    return ( 2 * i ) + 1;
}

// maxヒープを構成するための関数
void buildMaxHeap(int heap[], int size)
{
    for(int i = size / 2; i > 0; i--)
    {
        // 節点 i を頂点とするmaxヒープを作成する
        maxHeapify(&heap[0], size, i);
    }

    return;
}

// 節点 node を根とする部分木が max-ヒープになるように A[i] の値を
// max-ヒープの葉へ向かって下降させる関数
// heap[] : ヒープの値を保持する配列
// size : ヒープサイズ
// top : maxヒープの頂点
void maxHeapify(int heap[], int size, int top)
{
    int largest = top;
    int left = leftNode(top);
    int right = rightNode(top);

    // 部分木の中の最大値を検索する
    if( left <= size && heap[left] > heap[top] )
    {
        largest = left;
    }

    if( right <= size && heap[right] > heap[largest] )
    {
        // 左側の要素が範囲外なら右側の要素も範囲外のため,
        // else の処理は不要
        largest = right;
    }

    if( largest != top )
    {
        // 新しい最大値が見つかったら, 値を交換する
        swap(heap[top], heap[largest]);
        // 再帰的にCallする
        maxHeapify(&heap[0], size, largest);
    }

    return;
}



Measured memory_bytes: 5164
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
ll dp[1000001][4];
ll solve(ll a[][4], ll i, ll n, ll set)
{
	if (i == n)
		return 0;
	ll ans = 0;
	if (dp[i][set] != -1)
		return dp[i][set];
	if (set == 0)
	{
		ans = max(ans, a[i][1] + solve(a, i + 1, n, 1));
		ans = max(ans, a[i][2] + solve(a, i + 1, n, 2));
		ans = max(ans, a[i][3] + solve(a, i + 1, n, 3));
	}
	else if (set == 1)
	{
		ans = max(ans, a[i][2] + solve(a, i + 1, n, 2));
		ans = max(ans, a[i][3] + solve(a, i + 1, n, 3));
	}
	else if (set == 2)
	{
		ans = max(ans, a[i][1] + solve(a, i + 1, n, 1));
		ans = max(ans, a[i][3] + solve(a, i + 1, n, 3));
	}
	else
	{
		ans = max(ans, a[i][1] + solve(a, i + 1, n, 1));
		ans = max(ans, a[i][2] + solve(a, i + 1, n, 2));
	}
	// deba(ans);
	return dp[i][set] = ans;

}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll a[n + 1][4];
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 3; j++) {
			cin >> a[i][j];
		}
	}
	// ll i = 0, set = -1;
	mems(dp, -1);
	cout << solve(a, 0, n, 0);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

bool u[1010];
int n, m;
bool check() {
  int tmp = 0;
  REP(i, n) if(u[i]) tmp++;
  if(tmp == n) return false;
  else return true;
}

signed main(void)
{
  while(true) {
    cin >> n >> m;
    if(!n && !m) break;
    int a = n-1;
    memset(u, false, sizeof(u));
    while(check()) {
      REP(i, m) {
        a++;
        if(a >= n) a = 0;
        while(u[a]) {
          a++;
          if(a >= n) a = 0;
        }
      }
      u[a] = true;
      //cout << a << " ";
    }
    //cout << endl;
    cout << a+1 << endl;
  }

  return 0;
}

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

int main(){
  string s;
  cin >> s;
  vector<char> vec;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A')
      vec.push_back('A');
    else if(s[i]=='B'){
      if(s[i+1]=='C'){
        i++;
        vec.push_back('a');
      }
      else
        vec.push_back('d');
    }
    else
      vec.push_back('d');
  }
  long long ans=0,k,cnt=0;
  for(int j=0;j<vec.size();j++){
    if(vec[j]=='A'){
      cnt++;
    }
    else if(vec[j]=='a')
      ans+=cnt;
    else
      cnt=0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(), x.end()
using namespace std;
ll power(ll x, ll y,ll  m) 
{ 
    if (y == 0) 
        return 1; 
    ll  p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
ll modInverse(ll a, ll m) 
{ 
    ll g = __gcd(a, m); 
    if (g != 1) 
        cout << "Inverse doesn't exist"; 
    
    
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
        
              return power(a, m-2, m); 
    
} 

ll fact[1000];
void fac(ll m)
{
	ll i;
	fact[0]=1;
	for(i=1;i<1000;i++)
	{
		fact[i]=(i*fact[i-1])%m;
	}
}

ll comb(ll n,ll k,ll m)
{
	return(fact[n]*modInverse(fact[k],m)%m *modInverse(fact[n-k],m)%m)%m;
}
bool cmp(pair<ll,ll> a,pair<ll,ll>b)
{
	if(a.second==b.second)
	return a.first<b.first;
	return a.second>b.second;
}
void SieveOfEratosthenes(ll n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
     bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ll s,i;
	cin>>s;
	vector<ll> dp(s+1,0);
	dp[0]=1;ll j,mod=1000000007;
	for(i=3;i<=s;++i){
		for(j=i-3;j>=0;--j)
			(dp[i]+=dp[j])%=mod;
	}
	cout<<dp[s];
return 0;
}


Measured memory_bytes: 3644
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
cm=max(ct)
for i in ct:
    if i==cm:
        print(s[u])
    u+=i


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    string s;
    LL k;
    cin >> s;
    cin >> k;

    int L = s.size();

    for(int i = 0; i < min(1ll * L, k); i++){
        if(s[i] != '1'){
            return cout << s[i] << '\n', 0;
        }
    }

    cout << 1 << '\n';
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, sum;
  cin >> a >> b;
  sum = a + b;
  if(sum % 2 == 1)	//2で割り切れる場合は1を加える
  {
    sum += 1;
  }
  cout << sum / 2 << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
if __name__ == '__main__':
    S = raw_input()
    flg = True
    for index in range(len(S) - 1):
        if S[index]+S[index+1] == 'AC':
            print 'Yes'
            flg = False
            break
    if flg:
        print 'No'


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

int main() {

    for(int i = 1; i <= 10000; i++){
        int x;
        cin >> x;
        if(x != 0){
            cout << "Case " << i << ": " << x << endl;
        }
    }
}


Measured memory_bytes: 3096
#include<stdio.h>

int main(void)
{
	int a,b,c,ans=0,max;
	scanf("%d%d%d",&a,&b,&c);
	if((a%2 != b%2)&&(a%2 != c%2)){
		b++;
		c++;
		ans++;
	}
	else if((b%2 != a%2)&&(b%2 != c%2)){
		a++;
		c++;
		ans++;
	}
	else if((c%2 != a%2)&&(c%2 != b%2)){
		a++;
		b++;
		ans++;
	}
	max=a;
	if(b>max)
		max=b;
	if(c>max)
		max=c;
	ans+=(3*max-a-b-c)/2;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, v) = [int(e) for e in lines[0].split(' ')]
    (b, w) = [int(e) for e in lines[1].split(' ')]
    (t, ) = [int(e) for e in lines[2].split(' ')]

    return (a, v, b, w, t)


def solve(a, v, b, w, t):
    

    x = v - w
    if a < b and x > 0 and t * x >= b - a:
        result = 'YES'
    elif b < a and x > 0 and t * x >= a - b:
        result = 'YES'
    else:
        result = 'NO'

    return result    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62188
N = int(input())
h = list(map(int, input().split()))

tmp = [int(1e9)] * (N+10)
tmp[0] = 0
tmp[1] = abs(h[1] - h[0])
for i in range(2, N):
    tmp[i] = min(tmp[i-2]+abs(h[i]-h[i-2]), tmp[i-1]+abs(h[i]-h[i-1]))


print(tmp[N-1])

Measured memory_bytes: 52208