akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>

using namespace std;

class inverse {
    public:
    inverse(int n, int mod);
    ~inverse();
    long long get_inv(int x);
    long long get_fact(int x);
    long long get_invfact(int x);
    long long get_comb(int x, int y);
    
    private:
    int mod;
    long long* inv;
    long long* fact;
    long long* invfact;
};

inverse::inverse(int n, int mod) : mod(mod) {
    inv = (long long *)malloc(sizeof(long long) * (n + 1));
    fact = (long long *)malloc(sizeof(long long) * (n + 1));
    invfact = (long long *)malloc(sizeof(long long) * (n + 1));
    inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    fact[0] = invfact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invfact[i] = invfact[i - 1] * inv[i] % mod;
}

inverse::~inverse() {
    free(inv);
    free(fact);
    free(invfact);
}

long long inverse::get_inv(int x) {
    return inv[x];
}

long long inverse::get_fact(int x) {
    return fact[x];
}

long long inverse::get_invfact(int x) {
    return invfact[x];
}

long long inverse::get_comb(int x, int y) {
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod;
}

const int mod = 1000000007;
int x[100000];
long long a[100000];

int main() {
    int n, i;
    long long ans = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &x[i]);
    
    inverse inv(n, mod);
    
    a[0] = 1;
    
    for (i = 0; i < n - 1; i++) {
        long long p = inv.get_fact(n - 1) * inv.get_invfact(i + 1) % mod;
        
        if (i > 0) a[i] = (a[i - 1] * (i + 1) % mod + inv.get_fact(i)) % mod;
        
        ans += a[i] * p % mod * (x[i + 1] - x[i]) % mod;
    }
    
    printf("%lld\n", ans % mod);
    
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    long long x;
    cin >> x;
    
    long long sum = 100;
    int i = 0;
    for(i=0; i<1000000000; ++i){
        sum += 0.01*sum;
        if(sum >= x){
            break;
        }
    }

    cout << i+1 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a[4],t[4]={1,4,7,9},c=0;;
  rep(i,0,4) cin>>a[i];
  sort(a,a+4);
  rep(i,0,4) if(a[i]==t[i]) c++;
  if(c==4) co("YES");
  else co("NO");
  
  return 0;
}

Measured memory_bytes: 256
package main

import(
	"fmt"
)

func main(){
	var n,x int
	fmt.Scanln(&n,&x)
	l,d:=0,0
	for i:=0;i<n;i++{
		fmt.Scan(&l)
		d+=l
		if d>x{
			fmt.Println(i+1)
			return
		}
	}
	fmt.Println(n+1)
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 1;
    for (int i = 1; i <= N; i++) {
      ans *= i;
      ans = ans % 1000000007;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
// 整数論の知識が必要?
#include<iostream>
using namespace std;
int main() {
  int a,b,c; cin >> a >> b >> c;
  bool flag = false;
  for(int i=1;i<=b;i++){
    if(i*a%b==c){
      flag = true;
      break;
    }
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
(defun solver ()
  (let ((n (read)) (temp nil)
        (ai (make-array 100001 :fill-pointer 1)))
    (loop for i from 1 to n do
          (vector-push (read) ai))
    (setf temp (aref ai 1))
    (loop for i from 1 to 100002 do
          (when (= temp 2)
            (return (format t "~A~%" i)))
          (setf temp (aref ai temp))
          finally (format t "-1~%"))))

(solver)

Measured memory_bytes: 67304
# https://atcoder.jp/contests/abc103/tasks/abc103_d


N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(M)]

a.sort(key=lambda x: x[1])

# print(a)

count = 0

g = 0
for p in a:
    if g <= p[0]:
        count += 1
        g = p[1]
        # print(p)

print(count)


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

constexpr int mod = 1e9 + 7;

struct ModCombination {
  ModCombination(unsigned int n) : n(n), F(n + 1, 1), I(n + 1, 1) {
    for (int i = 1; i <= n; ++i) F[i] = 1ll * i * F[i - 1] % mod;
    for (int64_t i = mod - 2, j = F[n]; i; i >>= 1) {
      if (i & 1) I[n] = I[n] * j % mod;
      j = j * j % mod;
    }
    for (int i = n - 1; i; --i) I[i] = I[i + 1] * (i + 1ll) % mod;
  }

  unsigned int n;
  vector<int> F, I;

  int operator()(int p, int k) {
    if (k < 0 || k > p) return 0;
    return 1ll * F[p] * I[k] % mod * I[p - k] % mod;
  }
};

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  ModCombination mC(H + W);

  int ans = 0;
  for (int i = B + 1; i <= W; ++i) {
    (ans += (int64_t)mC(H - A + i - 2, i - 1) * mC(W - i + A - 1, A - 1) % mod) %= mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
//const ll mod=1000000007;
ll mod;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=210;
int dp[N][N];
int n,k;
void upd(int &a,int b) {
	a+=b; if (a>=mod) a-=mod;
}
int solve(int x,int y) {
	if (y<0) return 0;
	if (y==0) return x<=1;
	int ans=0;
	for (int a=2;a<=y+1;a++) {
		int b=x-a;
		if (b<1||b>y+1) continue;
		for (int i=0;i<a;i++) for (int j=0;j<=b;j++) {
			if (i==0&&j==0) { dp[i][j]=1; continue; }
			dp[i][j]=0;
			if (i==0&&j==b) continue;
			if (i>0&&b-j+i-1<=y) upd(dp[i][j],dp[i-1][j]);
			if (j>0&&a-i+j-1<=y) upd(dp[i][j],dp[i][j-1]);
		}
		upd(ans,dp[a-1][b]);
	}
	return ans;
}

int main() {
	scanf("%d%d%lld",&n,&k,&mod);
	int ans=0;
	for (int deg=0;deg<=n-2;deg++) {
		ans=(ans+(ll)solve(n-deg,k-deg)*powmod(n-deg,mod-2))%mod;
	}
	if (k>=n-1) {
		ans=(ans+1)%mod;
	}
	rep(i,1,n+1) ans=(ll)ans*i%mod;
	printf("%d\n",ans);
}

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

bool search(int A[], int n, int t)
{
    A[n] = t;
    int i = 0;
    while(A[i] != t)
        i += 1;
    return i != n;
}

int main()
{
    int N1, N2;
    int A[10000 + 1];
    int count = 0;
    int t;
    cin >> N1;
    for(int i = 0; i < N1; i++)
        cin >> A[i];
    cin >> N2;
    for(int j = 0; j < N2; j++)
    {
        cin >> t;
        if(search(A, N1, t))
            count += 1;
    }
    cout << count << endl;
}


Measured memory_bytes: 3124
import math
N,D=map(int,input().split())
X=[]
Y=[]
for i in range(N):
    Xi,Yi=map(int,input().split())
    X.append(Xi)
    Y.append(Yi)
ans=0
for i in range(N):
    if math.sqrt(X[i]**2+Y[i]**2)<=D:
        ans+=1
print(ans)


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

using namespace std;

const int mxn = 1e5;
unsigned long long a[mxn + 11];
const unsigned long long mm = 1e18;

int main(){
	int n;
	scanf("%d", &n);
	unsigned long long ans = 1;
	for (int i = 0; i < n; i++){
		scanf("%lld", a + i);
		if (a[i] == 0LL){
			ans = 0;
		}
	}
	if (ans == 0){
		puts("0");
		return 0;
	}
	for (int i = 0; i < n; i++){
		unsigned long long cur = ans;
		 ans *= a[i];
		 if (cur != ans / a[i]){
			puts("-1");
			return 0;
		 }
		 if (ans > mm){
			puts("-1");
			return 0;
		 }
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4604
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
  A=list(map(int,input().split()))
  D=[A[k]*B[k] for k in range(M)]
  if sum(D)+C>0 :
    ans+=1
print(ans)


Measured memory_bytes: 9156
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u64 = sc.read();
    let capacity: Vec<u64> = (0..5).map(|_| sc.read::<u64>()).collect();
    let res = capacity.iter().enumerate().min_by_key(|&(x, y)| (y, x)).unwrap();
    let (a, &b) = res;
    let mut result: u64 = 0;
    result += n / b;
    if n % b != 0 {
        result += 1;
    }
    result += 5u64 - (a + 1) as u64;
    result += a as u64;
    //result += a as u64;
    //println!("{:?}", res);
    println!("{}", result);

}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
const ll MAX = 1e15 + 1;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  ll ans = 0;
  rep(i,int(N/2)){
    ans += 2 * A.at(i);
  }
  ans -= A.at(0);
  if(N % 2 == 1){
    ans += A.at(N/2 + N%2 - 1);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4836
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#define BIG_NUM 2000000000
using namespace std;

int N;
int me[40000],enemy[40000];


void func(){

    for(int i = 0; i < N; i++)scanf("%d",&me[i]);
    for(int i = 0; i < N; i++)scanf("%d",&enemy[i]);

    sort(me,me+N,greater<int>() );
    sort(enemy,enemy+N,greater<int>());

    int me_index = 0,me_win = 0;
    int ans = BIG_NUM;


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

        while(me_index <= N-1){
            if(enemy[i] >= me[me_index]){
                me_index++;
                break;
            }else{
                me_win++;
                if(me_win >= (me_index+1)/2+1){
                    ans = me_index+1;
                    break;
                }
                me_index++;
            }
        }

        if(me_index >= N || ans != BIG_NUM)break;
    }

    if(ans == BIG_NUM || ans == N){
        printf("NA\n");
    }else{
        printf("%d\n",ans);
    }
}

int main(){

    while(true){
        scanf("%d",&N);
        if(N == 0)break;

        func();
    }

    return 0;
}

Measured memory_bytes: 3020
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("avx,avx2,fma,sse,sse2")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

#define N 200007

typedef tree<int, null_type, less<int>,rb_tree_tag,
tree_order_statistics_node_update> new_data;
int main()
{
    string s;
    ll sum=0;
    cin>>s;
    for(auto i:s)sum+=(i-'0');
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3764
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<vector<vector<int> > > ans(10,vector<vector<int> >(3,vector<int>(4,0)));
  for(int i=0;i<n;i++){
    int b,f,r,v;
    cin>>b>>f>>r>>v;
    b--;
    f--;
    r--;
    ans[r][f][b]+=v;
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        cout<<" "<<ans[k][j][i];
      }
      cout<<endl;
    }
    if(i!=3)cout<<"####################"<<endl;
  }
}



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

const ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  vector< ll > A(N);
  vector< ll > c(60,0);
  REP(i,N) {
    cin >> A[i];
    REP(j,60) if( ((A[i] >> j) & 1)==1 ) c[j]++;
  }
  ll ans = 0;
  REP(j,60) {
    ll mux = (c[j] * (N - c[j])) % MOD;
    ll addn = (mux * ((1LL << j) % MOD)) % MOD;
    ans = (ans + addn) % MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define INF 1e9
#define All(x) (x).begin(),(x).end()
#define F first
#define S second
#define Cout(x) cout << (x) << endl
typedef long long ll;
using namespace std;


int main(){
    int N,K;cin>>N>>K;
    int R,S,P;cin>>R>>S>>P;
    string t;cin>>t;
    string A;

    ll ans=0;
    REP(i,N){
        if(i<K){
            if(t[i]=='r'){ans+=P;A.push_back('p');}
            else if(t[i]=='s'){ans+=R;A.push_back('r');}
            else {ans+=S;A.push_back('s');}
        }else if(i<N-K){
            if(t[i]=='r'){
                if(A[i-K]=='p'){
                    ans+=0;
                    if(t[i+K]=='r')A.push_back('r');
                    else if(t[i+K]=='s')A.push_back('s');
                    else A.push_back('r');
                }
                else{
                    ans+=P;A.push_back('p');
                }
            }else if(t[i]=='s'){
                if(A[i-K]=='r'){
                    ans+=0;
                    if(t[i+K]=='r')A.push_back('s');
                    else if(t[i+K]=='s')A.push_back('s');
                    else A.push_back('p');
                }
                else{
                    ans+=R;A.push_back('r');
                }
            }else{
                if(A[i-K]=='s'){
                    ans+=0;
                    if(t[i+K]=='r')A.push_back('r');
                    else if(t[i+K]=='s')A.push_back('p');
                    else A.push_back('p');
                }
                else{
                    ans+=S;A.push_back('s');
                }
            }
        }else{
            if(t[i]=='p'&&A[i-K]!='s'){
                ans+=S;
            }else if(t[i]=='r'&&A[i-K]!='p'){
                ans+=P;
            }else if(t[i]=='s'&&A[i-K]!='r'){
                ans+=R;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        
        int [] A = {1,3,1,2,1,2,1,1,2,1,2,1};
        if(A[x-1] == A[y-1]){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

int32_t main()
{
    IOS;
    int a, b;
    cin>>a>>b;
    if(a+b==15)
    	cout<<"+";
    else if(a*b==15)
    	cout<<"*";
    else
    	cout<<"x";
    return 0;
}   

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = [0] * N
    for i in range(1, N):
        ans[A[i-1]-1] += 1
    for i in range(N):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 92416
fun main(args: Array<String>) {
    val (height, width) = readLine()!!.trim().split(' ').map {it.toInt()}

    val table: Array<Array<Boolean>> = Array(height) {
        Array(width) { false }
    }
    
    (0..(height - 1)).forEach { y ->

        readLine()!!.trim().forEachIndexed { x, s ->
            if (s == '#') {
                table[y][x] = true
            }
        }
    }

    // val openedTable: MutableList<MutableList<String>> = mutableListOf(mutableListOf())

    val openedTable = table.mapIndexed() { y, row ->
        row.mapIndexed { x, b ->
            if (b) {
                "#"
            } else {
                val count: Int = countNearBomb(y, x, table, height, width)
                "${count}"
            }
        }
    }

    openedTable.forEach {row ->
        row.forEach {str ->
            print(str)
        }
        println("")
    }
}

fun countNearBomb(y: Int, x: Int, table: Array<Array<Boolean>>, height: Int, width: Int): Int {
    var count: Int = 0
    (-1..1).forEach {yDiff ->
        (-1..1).forEach {xDiff ->
            val targetY = y + yDiff
            val targetX = x + xDiff
            if (targetY < 0 || targetY >= height ||
                    targetX < 0 || targetX >= width) {

            } else {
                if (table[targetY][targetX]) {
                    count += 1
                }
            }

        }
    }

    return count
}

Measured memory_bytes: 38216
# coding: utf-8
# Your code here!

while True:
    a = int(input())
    if a == 0 :
        break
    b = 1000 - a
    c = b //500
    d = b % 500
    e = d //100
    f = d % 100
    g = f //50
    h = f % 50
    i = h //10
    j = h %10
    k = j //5
    l = j %5
    print(c+e+g+i+k+l)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll A; 
    double B;
    cin >> A >> B;
    B *= 100.0;
    ll nB = round(B);
    //nB/=10;
    cout << setprecision(20) << (A*nB)/100<< endl;
}

Measured memory_bytes: 3736
from itertools import permutations

pas = [[0]*4 for i in range(4)]
for i in range(3):
        a, b = map(int, input().split())
        pas[a-1][b-1] = pas[b-1][a-1] = 1

ans = "NO"
for x in permutations(range(4)):
        cant = False
        for i in range(3):
                if pas[x[i]][x[i+1]]==0: cant = True
        if cant==False: ans = "YES"
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

int hist[6];

int main(){
  int i,j,n;
  double t;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf",&t);
    if(t<165.0){
      hist[0]++;
    }else if(t>=185.0){
      hist[5]++;
    }else{
      hist[(int)((t-165.0)/5.0)+1]++;
    }
  }
  for(i=0;i<6;i++){
    printf("%d:",i+1);
    for(j=0;j<hist[i];j++){
      printf("*");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int M = scan.nextInt();
			long K = scan.nextLong();

			long[]A = new long[N];
			long[]sA =new long[N+1];
			int a = 0;
			for(int i = 0;i<N;i++) {
				A[i] = scan.nextLong();
				sA[i+1] = sA[i]+A[i];
				if(sA[i+1]<=K)a=i+1;//常に更新し続ける
			}
			long[]B = new long[M];
			long[]sB =new long[M+1];
			for(int i = 0;i<M;i++) {
				B[i] = scan.nextLong();
				sB[i+1] = sB[i]+B[i];
			}


			int right = 0;
			int maxcount = 0;
			for(int i = a;i>=0;i--) {
				long valu = sA[i];
				int count = i;

				while(right+1<=M&&valu+sB[right+1]<=K) {
					right++;
				}
				//System.out.println(i+" "+right);
				if(maxcount<count+right)maxcount=count+right;
			}

			System.out.println(maxcount);




		}


	}


}


Measured memory_bytes: 66528
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {

  ll n;
  cin >> n;
  ll ans = 0;
  
  map<ll,ll> p;
  map<ll,ll> q;
  
  rep(i,n){
  ll x;
  cin >> x;
    if(i+1+x<200000) {
      if(p.count(i+1+x)) p.at(i+1+x)++;
      else p[i+1+x]=1;
    }
    if(0<i+1-x) {
      if(q.count(i+1-x)) q.at(i+1-x)++;
      else q[i+1-x]=1;
    }
  }
  
  rep(i,200000) {
    if(p.count(i) && q.count(i)) ans+=p.at(i)*q.at(i);
  }
  
  cout << ans << endl;

}


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

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=k*pow(k-1,n-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n);
	vector<ll> b(m);
	vector<ll> c(n+1, 0);
	vector<ll> d(m+1, 0);
	rep(i,n) cin >> a[i];
	loop(i, 1, n+1) c[i]+=(c[i-1]+a[i-1]);
	rep(i,m) cin >> b[i];
	loop(i, 1, m+1) d[i]+=(d[i-1]+b[i-1]);
	//rep(i, n+1) cout << c[i] << endl;
	//rep(i, m+1) cout << d[i] << endl;
	int ans = 0;
	rep(i,n+1){
		if(c[i]>k) break;
		int left = 0;
		int right = m;
		int mid;
		ll rim = k-c[i];
		while(1){
			if(left+1 == right){
				if(d[right]<= rim) mid = right;
				else mid = left;
				break;
			}
			mid = (left+right)/2;
			if(d[mid] > rim) right = mid;
			else if(d[mid] < rim) left = mid;
			else if(d[mid] == rim) break;
		}
		int subans = i+mid;
		if(ans < subans) ans = subans;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 9592
#include <iostream>

using namespace std;

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

	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);

	cout << a << " " << b << " " << c << endl;
	
}



Measured memory_bytes: 3088
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

const ll mod=1e9+7;

int main(){
    ll n,k;
    cin >> n >> k;
    ll val=1;
    rep(i,n){
        if(val<k) val*=2;
        else val+=k;
    }
    cout << val << endl;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    int n, m; cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}

Measured memory_bytes: 3544
/*
2
3 1

4
20 18 2 18
*/
fn main() {
    let n = read();
    let mut vec = read_line();
    vec.sort_by(|a, b| b.cmp(a));

    let mut alice = 0;
    let mut bob = 0;
    for i in 0..n as usize {
        if i % 2 == 0 {
            alice += vec[i];
        } else {
            bob += vec[i];
        }
    }

    println!("{}", alice - bob);
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_line() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    return v
}

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

using namespace std;

using ll = long long;

int main(void) {
	vector<int> arr(3);
	for (int i = 0; i < 3; i++)
		scanf("%d", &arr[i]);
	sort(arr.begin(), arr.end());
	if (arr[0] + arr[1] == arr[2])
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        sort(v.begin(),v.end());
        ll ans = 0, val = 0;
        for (int i = 0; i+1 < n; ++i) {
            val += v[i];
            ans += val;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3156
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
// #define MOD ll(1e9) + 7
#define ll long long
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int dx[4] = { -1, 0, 1, 0} ;
const int dy[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const ll INF = 1e9 ;
const ll MOD = 1e9 + 7 ;
const int N = 1e5 + 50 ;
vector<ll> cnt(N) ;


ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a % MOD ;
		a =  a * a % MOD ;
		e /= 2 ;
	}
	return res ;
}
vector<int> complement(const vector<int> &vec) {
	int n = vec.size() ;
	vector<bool> occur(n + 1 , true) ;
	vector<int> ans ;
	for (int i = 0 ; i < (int)vec.size() ; i++) {
		occur[vec[i]] = false ;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (occur[i]) ans.push_back(i) ;
	}
	return ans ;
}

ll intlog(double base, double x) {
	return (ll)(log(x) / log(base));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t ;
	// cin >> t;
	// while (t--) {
	int n ;
	cin >> n ;
	ll ans = 0 ;
	for (int i = 0 ; i < n ; i++) {
		int b ;
		cin >> b ;
		cnt[b]++ ;
		ans += b ;
	}
	int q ;
	cin >> q ;
	while (q--) {
		int b ,  c ;
		cin >> b >> c ;
		ans -= b * cnt[b] ;
		ans -= c * cnt[c] ;
		cnt[c] += cnt[b] ;
		cnt[b] = 0 ;
		ans += b * cnt[b] ;
		ans += c * cnt[c] ;
		cout << ans << "\n";
	}



	// }

	return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  ll x;
  cin >> N >> x;
  vector<int> a;
  int _a;
  REP(i, N) {
    cin >> _a;
    a.push_back(_a);
  }
  sort(a.begin(), a.end());
  if (accumulate(a.begin(), a.end(), 0ll) == x) {
    cout << N << endl;
    return 0;
  }

  int ans = 0;
  int sum = 0;
  REP(i, N) {
    sum += a.at(i);
    if (sum > x) {
      break;
    }
    ++ans;
  }

  cout << min(N - 1, ans) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

N=intput()
A=lint()
B=lint()
CA=dict()
for i in range(N):
    a=A[i]
    CA.setdefault(a,[i,i])
    CA[a][1]=i
CB=dict()
for i in range(N):
    a=B[i]
    CB.setdefault(a,[i,i])
    CB[a][1]=i
S=set()
for a in CA:
    if a not in CB:
        continue
    la,ra=CA[a]
    lb,rb=CB[a]
    for x in range(la-rb,ra-lb+1):
        S.add(x%N)
if len(S)==N:
    print('No')
    exit()
print('Yes')
for i in range(N):
    if i not in S:
        for j in range(N):
            print(B[(j-i)%N], end=' ')
        sys.exit()

Measured memory_bytes: 157776
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> V;

int main(){
    V.push_back("");
    V.push_back(".,!? ");
    V.push_back("abc");
    V.push_back("def");
    V.push_back("ghi");
    V.push_back("jkl");
    V.push_back("mno");
    V.push_back("pqrs");
    V.push_back("tuv");
    V.push_back("wxyz");

    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string out = "";
        string inp = "";
        cin >> inp;
        char now;
        int kai;
        now = '0';kai = 0;
        for(int j=0;j<inp.length();j++){
            if(inp[j] == '0'){
                if(kai != 0){
                    kai--;
                    out += V[now-'0'][kai%(V[now-'0'].length())];
                }
                now = inp[j];
                kai = 0;
                continue;
            }
            now = inp[j];
            kai++;
        }
        cout << out << endl;
    }
}

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

int gcd(int m, int n){
    if(m==0) return n;
    else if(n==0) return m;
    else{
        int m1 = m;
        int n1 = n;
        int tmp = 0;
        
        while(n1 != 0){
            tmp = n1;
            n1 = m1 % n1;
            m1 = tmp;
        }
        
        return m1;
    }
}

int main() {
    int N;
    cin >> N;
    int tmp;
    vector<int> As;

    for(int i = 0; i < N; i++){
        cin >> tmp;
        As.push_back(tmp); 
    }

    vector<int> L;
    L.push_back(0);
    vector<int> R;
    R.push_back(0);

    for(int i = 0; i < N; i++){
        L.push_back(gcd(As[i], L[i]));
        R.push_back(gcd(As[N-i], R[i]));
    }
    reverse(R.begin(), R.end());
    int ans = 0;

    for(int i = 0; i < N; i++){
        if(ans < gcd(L[i], R[i])) ans = gcd(L[i], R[i]);        
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    struct dice{int u,e,w,n,s,d;
    void rotate(char c){
        int temp=u;
        if(c=='E'){u=w;w=d;d=e;e=temp;}
        else if(c=='W'){u=e;e=d;d=w;w=temp;}
        else if(c=='N'){u=s;s=d;d=n;n=temp;}
        else if(c=='S'){u=n;n=d;d=s;s=temp;}
    }
    };
    dice a;
    in(a.u,a.s,a.e,a.w,a.n,a.d);
    string s;
    cin>>s;
    rep(i,s.length()){
        a.rotate(s[i]);
    }
    cout<<a.u<<endl;
}



Measured memory_bytes: 3236
n, m, q = map(int, input().split())

ans = [[0 for _ in range(n)] for __ in range(n)]

data = [list(map(int, input().split())) for _ in range(m)]

questions = [list(map(int, input().split())) for _ in range(q)]

for (l, r) in data:
    ans[l-1][r-1] += 1
for sub in ans:
    for i in range(n-1):
        sub[i+1] += sub[i]
for i in range(n-2, -1, -1):
    for j in range(n):
        ans[i][j] += ans[i+1][j]
for (l, r) in questions:
    print(ans[l-1][r-1])


Measured memory_bytes: 112688
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, H: "List[int]"):
    H.sort(reverse=True)
    if N > K:
        tot = sum(H[K:])
    else:
        tot = 0
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28932
# import math
# import bisect
# import heapq
# from collections import deque
import numpy as np

n, m = map(int, input().split())
s, c = [0] * m, [0] * m
for i in range(m):
    s[i], c[i] = map(int, input().split())

# replace = [False] * n
number = ['a'] * n
ans = 0
for i in range(m):

    if number[s[i]-1] != 'a' and str(c[i]) != number[s[i]-1]:
        ans = -1
        break

    number[s[i]-1] = str(c[i])

if not ans == -1:
    for i in range(n):
        if i == 0 and number[i] == 'a' and len(number) != 1:
            number[0] = '1'
        elif number[i] == 'a':
            number[i] = '0'
    ans = ''.join(number)

    if n != 1 and number[0] == '0':
        ans = -1
print(ans)




Measured memory_bytes: 20000
N, M = map(int, input().split())

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div
factors = divisors(M)
k = M//N
L = [x for x in factors if x <= k]
print(max(L))

Measured memory_bytes: 3064
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    int n, k, s;
    cin >> n >> k >> s;
    if (s == 1e9) {
        for (int i = 0; i < n; ++i) {
            if (k) {
                cout << s << " ";
                --k;
            } else {
                cout << 1 << " ";
            }
        }
    } else {
        for (int i = 0; i < n; ++i) {
            if (k) {
                cout << s << " ";
                --k;
            } else {
                cout << int(1e9) << " ";
            }
        }
    }
    cout << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
    return 0;
}


Measured memory_bytes: 3632
L,R = list(map(int,input().split()))

if R - L >= 2018:
  print(0)
else:
  min_mod = 2019
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      tmp = (i * j) % 2019
      if tmp < min_mod:
        min_mod = tmp
  print(min_mod)

Measured memory_bytes: 9176
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	int n;
    cin>>n;
    vi a(n+1),ans(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    int sum;
    for(int i=n/2+1;i<=n;i++){
        ans[i]=a[i];
    }
    // cout<<"AAAA"<<endl;
    for(int i=n/2;i>0;i--){
        //今いる位置
        sum=0;
        for(int j=i+i;j<=n;j+=i){
            sum+=ans[j];
        }
        // cout<<i<<" "<<a[i]<<" "<<sum<<endl;
        if(sum%2==a[i]){
            ans[i]=0;
        }
        else{
            ans[i]=1;
        }
    }
    // cout<<"BBBB"<<endl;
    int bef,count=0;
    for(int i=1;i<=n;i++){
        if(ans[i]==1){
            bef=i;
            count++;
        }
    }
    cout<<count<<endl;
    // for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
    // cout<<endl;
    for(int i=1;i<=n;i++){
        if(ans[i]==1&&i!=bef)cout<<i<<" ";
        else if(i==bef)cout<<i<<endl;
    }

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 2560
import sys
import bisect as bs
input = sys.stdin.readline

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

vL.sort()
#print(vL)

res = 0
for x in range(0, N-2):
	a = vL[x]
	for y in range(x+1, N-1):
		b = vL[y]
		# a+b<c in vL[y+1:N]
		cntC = bs.bisect_left(vL, a+b)
		res += cntC - (y+1)
		#print(res, a, b, a+b, cntC)

print(res)


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;

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

    Vi acf(n+1, 0);
    Vi wac(n+1, 0);
    int ac = 0;
    int wa = 0;
    REP(i, m) {
        int p; string s;
        cin >> p >> s;
        if (s == "AC" && acf[p] == 0) {
            ac++;
            acf[p]++;
            wa += wac[p];
        } else {
            wac[p]++;
        }
    }
    std::cout << ac << " " << wa << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int e,f,g,h;
    cin>>a>>b>>c>>d;
    cin>>e>>f>>g>>h;
    int x=a+b+c+d;
    int y=e+f+g+h;
    if(x>y){
        cout<<x<<endl;
    }
    else{
        cout<<y<<endl;
    }
    
}


Measured memory_bytes: 3100
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
ll dp[2005][2005];
char s[2005][2005];

int main(){
	cin >> n >> a;
	if(n%500 <= a){
		p("Yes");
	}else{
		p("No");
	}
	return 0;
}

Measured memory_bytes: 256