akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

MOD = 998244353  # type: int


MAX = 600000
fac = [0] * MAX
ifac = [0] * MAX
fac[0] = 1
for i in range(1,MAX):
    fac[i] = (fac[i-1] * i) % MOD
ifac[MAX-1] = pow(fac[MAX-1],MOD-2,MOD)
for i in reversed(range(1,MAX)):
    ifac[i-1] = (ifac[i] * i) % MOD
 
def combination(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return (fac[n] * ifac[k] * ifac[n-k]) % MOD

def solve(N: int, M: int, K: int):
    ans = 0
    for k in range(K+1): 
        ans += combination(N-1,N-k-1) * M * pow(M-1, N-k-1, MOD) % MOD
        ans %= MOD
    
    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)

if __name__ == '__main__':
    main()


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

int dp[501][501];

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

	for(int i = 0; i < m; i++){
		int x,y;cin>>x>>y;
		dp[x][y]++;
	}

	for(int i = 1; i <= n; i++){
		for(int j = i; j <= n; j++){
			dp[i][j] += dp[i][j-1]; 
		}
	}

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			dp[i][j]+=dp[i-1][j];
		}
	}

	for(int i = 0; i < q; i++){
		int x,y;cin>>x>>y;
		cout<<dp[y][y] - dp[x-1][y]<<endl;
	}
}

Measured memory_bytes: 1920
import heapq
n,q = map(int,input().split())

S = [[] for i in range(n)]
for i in range(q):
    query = tuple(map(int,input().split()))

    if query[0] == 0:
        heapq.heappush(S[query[1]],-1*query[2])
    elif query[0] == 1:
        if len(S[query[1]]) != 0:
            a = heapq.heappop(S[query[1]])
            print(-1*a)
            heapq.heappush(S[query[1]],a)
    else:
        if len(S[query[1]]) != 0:
            heapq.heappop(S[query[1]])


Measured memory_bytes: 13576
#define TEST_SNO	1
#define TEST_ENO	1
#define ll			long long

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int a;
	int b;
} data;

FILE *in, *ans;
int tno;

char s[100010];
int dp[100010][2];

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	int i;

	getstr(s);

	if (s[0] == '0') {
		dp[0][0] = 0;
		dp[0][1] = 1;
	}
	else {
		dp[0][0] = 1;
		dp[0][1] = 0;
	}

	for (i = 1;; i++) {
		if (s[i] == '0') {
			dp[i][0] = dp[i - 1][1];
			dp[i][1] = dp[i - 1][0] + 1;
		}
		else if (s[i] == '1') {
			dp[i][0] = dp[i - 1][1] + 1;
			dp[i][1] = dp[i - 1][0];
		}
		else {
			break;
		}
	}

	if (dp[i - 1][0] < dp[i - 1][1]) {
		outi(dp[i - 1][0]);
	}
	else {
		outi(dp[i - 1][1]);
	}

	return 0;
}

int main() {
#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


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

int64_t getF(int64_t A, int64_t B){
  int64_t num = max(A, B);
  int64_t count = 0;
  while(num != 0){
    num = num / 10;
    count ++;
  }
  return count;
}

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());
  int64_t N;
  cin >> N;

  int64_t minF = 20;
  for(int64_t i=1; i<sqrt(N)+1; i++){
    if(N%i==0){
      int64_t A = i;
      int64_t B = N / i;
      minF = min(getF(A, B), minF);
    }
  }
  cout << minF << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int buf=0;
		int max=-1;
		for(int i=0;i<n;i++)
		{
			int a=sc.nextInt(),b=sc.nextInt();
			if(a>max){
				max=a;
				buf=a+b;
			}
		}
		System.out.println(buf);

	}

}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> a(n+1);
  for(int i = 1;i<=n;i++) cin >> a[i];

  int cnt = 0;
  for(int i = 1;i<=n;i+=2){
    if(a[i]%2==1) cnt++;
  }

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


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

int main(){
  int h,w;
  cin >> h >> w;
  const int INF = 100000000;
  vector<string> field;
  string pad(w+2,'#');
  field.push_back(pad);
  int kabe=0;
  string tmp;
  for (int i=0; i<h; i++){
    cin >> tmp;
    for (int j=0; j<w; j++){if(tmp.at(j)=='#')kabe++;}
    field.push_back("#" + tmp + "#");
  }
  field.push_back(pad);
  vector<int> ofst = {0,0,1,-1};
  vector<vector<int>> d(h+2,vector<int>(w+2,INF));
  int s_p=0;
  d[1][1] = 0;
  queue<pair<int,int>> que;
  que.push(make_pair(1,1));
  while(que.size()){
    pair<int,int> p = que.front(); que.pop();
    //cout << p.first << ' ' << p.second << endl;
    for(int i=0; i<4; i++){
      int ny=p.first+ofst[i],nx=p.second+ofst[3-i];
      if(ny==h&&nx==w){s_p = d[p.first][p.second]+1;goto END;}
      else if(field[ny].at(nx)=='.'&&d[ny][nx]==INF){
        que.push(make_pair(ny,nx));
        d[ny][nx] = d[p.first][p.second] + 1;
      }
    }
  }
END :
  if(s_p){
   // cout << kabe << ' ' << s_p << endl;
    cout << h*w - kabe - (s_p+1) << endl;
  }else{
    cout << -1 << endl;
  }
}

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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<"."
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int H,W,N;
int a[10000];

int m[100][100];
void solve(){
	int c=1;
	int v=1;
	int x=0;
	rep(y,H){
		rep(j,W){
			m[y][x]=c;
			x+=v;
			if(--a[c-1]==0) c++;
		}
		v*=-1;
		x+=v;
	}
	rep(i,H)
		rep(j,W)
			cout<<m[i][j]<<(j==W-1?"\n":" ");
}

int main(){
	cin>>H>>W>>N;
	rep(i,N) {
		cin>>a[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 384
N = int(input())
HList = list(map(int,input().split()))
dp = [0]*(N)
dp[0]=0
dp[1]=abs(HList[0]-HList[1])

for i in range(2,N):
    c1 = dp[i-2]+abs(HList[i-2]-HList[i])
    c2 = dp[i-1]+abs(HList[i-1]-HList[i])
    dp[i]= min(c1,c2)

print(dp[N-1])

Measured memory_bytes: 13928
import java.util.*;
public class Main {
	double EPS = 1.0e-02;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			double [] compDis = new double[3];
			for(int i = 0; i < 3; i++){
				compDis[i] = sc.nextDouble();
			}
			int m = sc.nextInt();
			double [][] inputDis = new double[m][3];
			for(int i = 0; i < m; i++){
				for(int j = 0; j < 3; j++){
					inputDis[i][j] = sc.nextDouble();
				}
			}
			
			calc(compDis, inputDis);
			
		}
	}
	
	private void calc(double [] compDis, double [][] inputDis){
		int m = inputDis.length;
		for(int i = 0 ; i < m; i++){
			for(int j = 0; j < m; j++){
				for(int k = 0; k < m; k++){
					if(i == j || i == k || j == k) continue;
					double a = getDis(inputDis[i], inputDis[j]);
					double b = getDis(inputDis[j], inputDis[k]);
					double c = getDis(inputDis[k], inputDis[i]);
					double rate = compDis[0] / a;
					double value1 = rate * b;
					double value2 = rate * c;
					//System.out.println(isSimilar(compDis[1],value1) +" "+ isSimilar(compDis[2], value2));
					if(isSimilar(compDis[1],value1) && isSimilar(compDis[2], value2)){
						System.out.println((k+1) + " "+ (i+1) + " " + (j+1));
						return;
					}
				}
			}
		}
	}
	
	

	private boolean isSimilar(double comp, double value1) {
		if(value1 - EPS <= comp && comp <= value1 + EPS){
			return true;
		}
		return false;
	}

	private double getDis(double [] a, double [] b) {
		double x = a[0] - b[0];
		double y = a[1] - b[1];
		double z = a[2] - b[2];
		double res = x * x + y * y + z * z;
		return Math.sqrt(res);
	}

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

Measured memory_bytes: 13000
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M)]
l = sorted(l, key = lambda l:(l[1]))

p_num = -1
ans = 0

for i in range(M):
	if not l[i][0] <= p_num:
		p_num = l[i][1] - 1
		ans += 1

print(ans)

Measured memory_bytes: 29852
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var a = arr[0];
    var b = arr[1];
    Console.WriteLine(a <= 8 && b <= 8 ? "Yay!" : ":(");
  }
}

Measured memory_bytes: 13268
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (r, g, b, n) = (v[0], v[1], v[2], v[3]);
    let mut ans = 0;
    for ri in 0..n + 1 {
        for bi in 0..n + 1 {
            if (n - (r * ri + b * bi)) % g == 0 && r * ri + b * bi <= n {
                ans += 1;
            }
        }
    }
    println!("{:?}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <vector>
const long long INF=1LL<<50;
using namespace std;
int N,M;
typedef struct{
    long long from,to,cost;
}EDGE;
int main(void){
    const int NMAX=1000;
    const int MMAX=2000;
    int a,b;
    long long  dist[NMAX];
    vector<EDGE>edges;
    cin>>N>>M;
    long long c;
    for(int i=0;i<M;i++){
        EDGE e;
        cin>>a>>b>>c;
        a--;
        b--;
        c=-c;
        e.from=a;
        e.to=b;
        e.cost=c;
        edges.push_back(e);
            }
    for(int i=0;i<N;i++){
        dist[i]=INF;
    }
    dist[0]=0;
    for(int i=0;i<N-1;i++){
        for(int j=0;j<edges.size();j++){
            EDGE e=edges[j];
            if(e.from==INF)continue;
            if(dist[e.to]>dist[e.from]+e.cost){
                dist[e.to]=dist[e.from]+e.cost;}
        }
    }
    bool negative[NMAX];
    for(int i=0;i<N;i++)negative[i]=false;
    for(int i=0;i<N;i++){
        for(int j=0;j<edges.size();j++){
            EDGE e=edges[j];
            if(dist[e.from]==INF)continue;
            if(dist[e.to]>dist[e.from]+e.cost){
                dist[e.to]=dist[e.from]+e.cost;
                negative[e.to]=true;
            }
            if(negative[e.from]==true){
                negative[e.to]=true;
            }
        }
    }
    if(negative[N-1])printf("inf\n");
    else printf("%lld\n",-dist[N-1]);
}


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

int main() {
	int N ,X, L;
	cin >> N >> X;
	int total = 0;
	int count = 0;
	for (int i = 0; i < N + 1; i++) {
		cin >> L;
		total += L;
		count += 1;
		if (total <= X) {
			continue;
		}
		else {
			break;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3484
import itertools
n,m,x=map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
ca.sort(key=lambda x:x[0])

ans=[0]*(m+1)
for i in range(n):
    for j in itertools.combinations(ca, i+1):
        p=[0]*(m+1)
        for k in range(m+1):
            for value in range(len(j)):
                p[k] += j[value][k]
        kari_ans = [i for i in p[1:] if i >= x]
        if len(kari_ans) >= m and (ans[0] == 0 or ans[0] > p[0]):
            ans = p
if ans[0] != 0:
    print(ans[0])
else:
    print("-1")


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

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    REP(i, N) cin >> T[i];
    sort(T.begin(), T.end());
    int i = 0;
    int ans = 0;
    while(i < N) {
        LL t = T[i] + K;
        int rest = C;
        while(rest > 0 && i < N && T[i] <= t) {
            i++;
            rest--;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
    int a, b;
    cin >> a >> b;
    int sa = b - a;
    int real = sa*(sa+1)/2;
    cout << real - b << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    def gcd(x, y):
        while y:
            x, y = y, x % y
        return x

    def soin(x):
        res = []
        cnt = 0
        while x % 2 == 0:
            x //= 2
            cnt += 1
        if cnt: res.append(cnt)
        d = 3
        while d ** 2 <= x:
            cnt = 0
            while x % d == 0:
                x //= d
                cnt += 1
            if cnt: res.append(cnt)
            d += 2
        if x != 1: res.append(1)
        return res

    a, b = map(int, input().split())
    g = gcd(a, b)
    e = soin(g)
    print(len(e) + 1)

main()


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int N;
    cin >> N;
    vll As(N);
    vll Bs(N);
    ll asum = 0;
    ll bsum = 0;
    rep(i, N) {
        cin >> As[i];
        asum += As[i];
    }
    rep(i, N) {
        cin >> Bs[i];
        bsum += Bs[i];
    }

    ll count = 0;
    rep(i, N) {
        if (As[i] < Bs[i]) count += std::ceil((Bs[i] - As[i])/2.0);
    }
    cout << ((count <= bsum - asum) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;

    vector<pair<int,int>> query(q);
    for(auto& i : query){
        cin >> i.first >> i.second;
    }

    vector<int> dp(n+1, 0);
    bool flag = false;
    REP(i, n){
        dp[i+1] = dp[i];
        if(s[i] == 'A'){
            flag = true;
        }else if(flag && s[i] == 'C'){
            dp[i+1]++;
            flag = false;
        }else{
            flag = false;
        }
    }

    for(auto i : query){
        cout << dp[i.second] - dp[i.first] << '\n';
    }

    return 0;
}

Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>

int n, w;
int W[100];
int V[100];

long long int dp[100001];

int main(){
  scanf("%d%d", &n, &w);
  for(int i = 0; i < n; i++) scanf("%d%d", W+i, V+i);

  for(int i = 1; i <= n; i++){
    for(int j = w; j >= W[i-1]; j--){
      dp[j] = std::max(dp[j], dp[j-W[i-1]] + V[i-1]);
    }
  }
  printf("%lld\n", dp[w]);

  return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    ll N; cin >> N;
    ll K; cin >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    ll ans = 0;
    //(S[j]-S[i]) % K = j-i
    //(S[j]-j) % K = (S[i]-i) % K, 0 < j-i < Kをみたす(i,j)の組の数
    // i = 0 -> j = min(N-1, i+K-1)
    ll S[N+1]; S[0] = 0;
    rep(i, N){
        S[i+1] = S[i] + A[i];
    }
    map<ll, ll> mp;
    ll l = 0, r = 0;
    while(r < min(N+1, K)){
        ll val = (S[r]-r) % K;
        if(val < 0) val += K;
        if(mp.count(val) == 0) mp[val] = 1;
        else mp[val] += 1;
        r++;
    }
    while(l < N){
        ll val = (S[l]-l) % K;
        if(val < 0) val += K;
        mp[val] -= 1;
        ans += mp[val];

        if(r <= N){
            val = (S[r]-r) % K;
            if(val < 0) val += K;
            if(mp.count(val) == 0) mp[val] = 1;
            else mp[val] += 1;
            r++;
        }
        l++;
    }
    cout << ans << endl;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

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

  int a; cin >> a;
  cout << a + a * a + a * a * a << endl;

}








Measured memory_bytes: 3644
/*///////////////////////////////////////////*/
/*/ root@NULLCT$(´・ω・｀)<<"Be accept!!"  /*/
/*///////////////////////////////////////////*/
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  int x;
  cin >> x;
  int ans = 0;
  ans += (x / 500) * 1000;
  ans += ((x % 500) / 5) * 5;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int x,h500=0,h5=0,total=0;
    scanf("%d",&x);

    h500 = x/500;
    x = x%500;
    h5 = x/5;

    total = h500*1000 + h5*5;

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

    return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {

	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}

		out << "\n";
	}
		
    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long n;
	cin >> n;

	long long min_moves = 1e15;
	for (long long i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			long long j = n / i;
			long long curr_min = i - 1 + j - 1;
			min_moves = min(min_moves, curr_min);
		}
	}

	cout << min_moves << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int a;
  string s;
  cin>>a>>s;

  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
char grid[12][1002];
int val[1002],curr[1002];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int h,w,k;
	cin>>h>>w>>k;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>grid[i][j];
	int ans=h+w-2;
	for(int mask=0;mask<(1<<(h-1));mask++)
	{
		std::vector<int> v;
		v.pb(-1);
		for(int i=0;i<(h-1);i++)
		{
			if((mask&(1<<i)))
				v.pb(i);
		}
		v.pb(h-1);
		int res = 0;
		for(int j=1;j<sz(v);j++)
			val[j] = 0;
		bool flag=0;
		for(int i=0;i<w;i++)
		{
			bool cng = 0;
			for(int j=1;j<sz(v);j++)
			{
				curr[j] = 0;
				int x=v[j-1]+1,y=v[j];
				for(int p=x;p<=y;p++)
					if(grid[p][i]=='1')
						curr[j]++;
				if(curr[j]>k)
					flag=1;
				if(val[j]+curr[j]>k)
				{
					cng = 1;
				}
			}
			if(cng)
			{
				res++;
				for(int j=1;j<sz(v);j++)
					val[j]=0;
			}
			for(int j=1;j<sz(v);j++)
				val[j]+=curr[j];
		}
		if(flag)
			continue;
		ans=min(ans,res+(int)sz(v)-2);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int S;
    int a;
    int m;
    int h;
    scanf("%d",&S);

    h=S/3600;
    S%=3600;
    m=S/60;
    S%=60;
    a=S;
    printf("%d:%d:%d\n", h,m,a);

    return 0;
}


Measured memory_bytes: 2104
#N,K = map(str,input().split())
N = int(input())
K = int(input())
X = list(map(int,input().split()))
c=0
for i in range(len(X)):
    if abs(X[i]-0) < abs(X[i]-K):
        c += X[i]*2
    else:
        c += (K-X[i])*2
print(c)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
    int A,B,K,tmp;
    scanf("%d %d %d",&A,&B,&K);

    if(B - A + 1 < K){
        for(int i=A; i<=B; i++){
            printf("%d\n",i);
        }
        return 0;
    }

    for(int i=0; i<K; i++){
        printf("%d\n",A+i);
        tmp = A+i;
    }

    int j = B + 1 - K;
    
    if(tmp >= j){
        j = tmp + 1;
    }


    for(int i=j; i<B+1; i++){
        printf("%d\n",i);
    }



    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#include <functional>
#include <unordered_map>

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::list<unsigned> l;

  std::unordered_map<std::string,std::function<void(void)>> funcs{
    {
      "insert",
      [&l](){
        unsigned i;
        std::cin >> i;
        l.push_front(i);
      }
    },
    {
      "delete",
      [&l](){
        unsigned i;
        std::cin >> i;
        auto it = std::find(l.begin(),l.end(),i);
        if(it != l.end()) l.erase(it);
      }
    },
    {
      "deleteFirst",
      [&l](){
        l.erase(l.begin());
      }
    },
    {
      "deleteLast",
      [&l](){
        l.erase(--(l.end()));
      }
    }
  };

  unsigned n;
  std::string buf;
  std::cin >> n;
  for(;n;n--){
    std::cin >> buf;
    funcs[buf]();
  }

  std::cout << *(l.begin());
  for(auto it = ++l.begin(); it != l.end(); ++it){
    std::cout << ' ' << *it;
  }
  std::cout << '\n';

}

Measured memory_bytes: 32480
def main():
    from fractions import gcd
    def build() :
        for k in range(N0-2,-1,-1) :
            data[k]=gcd(data[2*k+1],data[2*k+2]) 
            
    def update(k,x):
        k+=N0-1
        data[k]=x
        while k+1:
            k=~-k//2
            data[k]=gcd(data[2*k+1],data[2*k+2])
    def query(l,r):
        L,R=l+N0,r+N0
        s=0
        while L<R:
            if R&1:
                R-=1
                s=gcd(s,data[R-1])
            if L&1:
                s=gcd(s,data[L-1])
                L+=1
            L>>=1
            R>>=1
        return s
    n,*a=map(int,open(0).read().split())
    N0=2**(n-1).bit_length()
    data=[0]*2*N0
    for i in range(n):
        data[i + N0 - 1] = a[i]
    build()
    print(max(gcd(query(0,i),query(i+1,n))for i in range(n)))
if __name__=='__main__':
    main()



Measured memory_bytes: 16140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int H, W, K;
char t[1000][1000];
int d[1000][1000];
int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };

int main() {
	cin >> H >> W >> K;
	int si, sj;
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			cin >> t[i][j];
			if (t[i][j] == 'S') si = i, sj = j;
		}
	}
	for (int i = 0; i <= H; ++i) t[i][0] = t[i][W + 1] = 'E';
	for (int i = 0; i <= W; ++i) t[0][i] = t[H + 1][i] = 'E';
	for (int i = 0; i <= H + 1; ++i) {
		for (int j = 0; j <= W + 1; ++j) {
			d[i][j] = -1;
		}
	}
	priority_queue<pair<int, pair<int, int>>> que;
	que.push({ K, {si, sj} });
	while (!que.empty()) {
		int res = que.top().first, posi = que.top().second.first, posj = que.top().second.second;
		que.pop();
		if (d[posi][posj] >= 0) continue;
		d[posi][posj] = 0;
		if (res == 0) continue;
		for (int i = 0; i < 4; ++i) {
			if (t[posi + di[i]][posj + dj[i]] == '.') {
				que.push({ res - 1, {posi + di[i], posj + dj[i]} });
			}
		}
	}

	int ans = 1e9;
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (d[i][j] != 0) continue;
			ans = min({ ans, (i + K - 2) / K, (H - i + K - 1) / K, (j + K - 2) / K, (W - j + K - 1) / K });
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 4992
import std.stdio, std.string, std.conv, std.algorithm, std.numeric, std.array, std.range;

void main() {
  long a, b, c;
  readf("%d %d %d", &a, &b, &c);

  if (a == b && b == c) {
    writeln("Yes");
  }
  else {
    writeln("No");
  }
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll S, W;
    cin >> S >> W;

    if(S<=W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

const int dif = 'A' - 'a';

int main(){
	int count = 0;
	string w, str;
	getline(cin, w);
	for(int i = 0; i < static_cast<int>(w.size()); i++){
		if('A' <= w[i] && w[i] <= 'Z'){
			w[i] -= dif;
		}
	}

	for(;;){
		cin >> str;
		if(str == "END_OF_TEXT") break;
		for(int i = 0; i < static_cast<int>(str.size()); i++){
			if('A' <= str[i] && str[i] <= 'Z'){
				str[i] -= dif;
			}
		}
		if(str == w) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main() {
  int N;
  cin >> N;
  vector<ll> ju(N);
  vector<vector<int>> D(N, vector<int>(2));
  
  for(ll i=0; i< N; i++){
    cin >> D[i][0] >> D[i][1];
    if(D[i][0] == D[i][1]) ju[i] = 1;
  } 

  for(ll i=0; i< N-2; i++){
    if (ju[i]==1 && ju[i+1]==1 && ju[i+2]==1){
      cout << "Yes" << endl;
      return 0;
    }
  }






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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <atcoder/all>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;

    
    
    int N, Q;
    cin >> N >> Q;
    atcoder::dsu dsu(N);
    vector<int> t(Q), u(Q), v(Q);
    REP (i, Q) {
        cin >> t[i] >> u[i] >> v[i];
        if (t[i] == 0) dsu.merge(u[i], v[i]);
        else cout << dsu.same(u[i], v[i]) << endl;
    }


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_a && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 8136
/* winners never quit and quitters never win.
      #swap                                 */
      
#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;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

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

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt(),x=nxt(),t=nxt();
    cout<<((n+x-1)/x)*t<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3776
#include <stdio.h>
#include <set>

int main(void) {
  int i, j, n, m, d, t;
  std::multiset<int> s;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", &d), s.insert(d);
  scanf("%d", &m);
  for(i = 0; i < m; ++i) {
    scanf("%d", &t);
    if(s.find(t) == s.end()) {
      printf("NO");
      return 0;
    }
    s.erase(s.find(t));
  }
  printf("YES");
  return 0;
}

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

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int X, D, N, A, suma=0;
  cin >> N;
  cin >> D >> X;
  int arr[D];
  memset(arr, 0, sizeof(arr));
  arr[0] = N;
  while(N--){
    cin >> A;
    for(int i=1; A*i<D; ++i){
      arr[A*i]++;
    }
  }
  for(int i=0; i<D; ++i){
    suma+=arr[i];
  }
  cout << suma+X;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

const int INF = 1e9 + 7;


int main(){



	ios::sync_with_stdio(false);
	cin.tie(0);

	set<string> st;

	cout << "?a" << endl;
	st.insert("a");

	while (1)
	{
		string s;
		cin >> s;
		if (s[0] != 'a' || st.count(s) > 0)
		{
			cout << "!OUT" << endl;
			return 0;
		}
		else
		{
			st.insert(s);
			cout << "?" << s.back() << "aa" << endl;
		}

	}
	return 0;
}



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

int main(void){
  int x,y;
  cin>>x>>y;
  
  /*group1={1,3,5,7,8,10,12}
  	group2={4,6,9,11}
    group3={2}
  */
  int group[12]={1,3,1,2,1,2,1,1,2,1,2,1};
  (group[x-1]==group[y-1])?cout<<"Yes":cout<<"No";
  
  return 0;
}

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

int main() {

	int N;
	int H[210];

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

	int max = 0;
	int count = 0;
	for (int i = 0; i < N; ++i) {
		if (max <= H[i]) {
			max = H[i];
			count += 1;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a, b, d, r;
    double f;

    scanf("%d %d", &a, &b);
    d = a/b;
    r = a%b;
    f = (double)a/b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
using namespace std;
 //Compiler version g++ 4.9

 int main()
 {
 	int n;
 	cin >> n;	
 	vector<int> v(n);
 	for(int i = 0;i < n;i++){
 		cin >> v[i];
 		
 	}
 	int mi = v[0];
 	int ma = v[0];
 	for(int i = 1;i < n;i++){
 		ma = max(ma,v[i]);
 		mi = min(mi,v[i]);  
 	}
 		
 	cout << ma - mi << endl;
 }

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll 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;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//////////////////////////////////////////////////

int main(){
  ll N,M,K,ans=0;
  cin>>N>>M>>K;
  COMinit();
  
  RREP(i,N){
    ans+=M*M*(N-i)*i;
    ans%=MOD;
  }
  RREP(i,M){
    ans+=N*N*(M-i)*i;
    ans%=MOD;
  }
  ans*=COM(N*M-2,K-2);
  ans%=MOD;
  
  if(ans<0) ans+=MOD;
  co(ans);
  return 0;
}

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

class Program
{
  /// <summary>
  ///   The main entry point for the application
  /// </summary>
  [STAThread]
  public static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    long[] a = new long[n];
    long[] b = new long[n];
    long[] c = new long[n];
    for (int i = 0; i < n; i ++)
    {
      string[] s = Console.ReadLine().Split(' ');
      a[i] = int.Parse(s[0]);
      b[i] = int.Parse(s[1]);
    }
    for (int i = 0; i < n; i ++)
    {
      c[i] = a[i] + b[i];
    }
    Array.Sort(c);
    Array.Reverse(c);
    long ans = c.Where((value, index) => index % 2 == 0).Sum() - b.Sum();
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 17600
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll k;
		string s;
		cin >> k >> s;
		ll n = s.size();
		if (n <= k)
			cout << s << endl;
		else
		{
			cout << s.substr(0, k) << "..." << endl;
		}

	}
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define inff 100000


ll modo=1e9+7;



int main()
{
   faf;
   int a;
   string s;
   cin>>a>>s;
   if(a<3200)cout<<"red";
   else  cout<<s;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll a[n]; zep(i, 0, n)cin >> a[i];

    ll sm = 0;
    zep(i, 0, n){
        sm += a[i];
        sm %= MOD;
    }

    ll ans = sm * sm % MOD;
    zep(i, 0, n){
        ans += MOD - (a[i] * a[i] % MOD);
        ans %= MOD;
    }

    ans *= (MOD + 1) / 2;
    ans %= MOD;
    print(ans)
    
    return 0;
}

Measured memory_bytes: 5176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
          
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int tate = int.Parse(str[0]);
                int yoko = int.Parse(str[1]);

                if ((tate == 0) && (yoko == 0))
                {
                    break;
                }
                for (int i = 1; i <= tate; ++i)
                {
                    if ((i == 1) || (i == tate))
                    {
                        for (int j = 1; j <= yoko; ++j)
                        {
                            Console.Write("#");
                        }
                    }
                    else
                    {
                        for (int jj = 1; jj <= yoko; ++jj)
                        {
                            if ((jj == 1) || (jj == yoko))
                            {
                                Console.Write("#");
                            }
                            else
                            {
                                Console.Write(".");
                            }
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
                
            }
        }
    }
}

Measured memory_bytes: 5288
n=int(input())
a,b,c=[],[],[]
for _ in range(n):
  A,B,C=map(int,input().split())
  a.append(A)
  b.append(B)
  c.append(C)
#print(a,b,c)
dp=[[[0] for _ in range(3)] for _ in range(n)]
dp[0][0]=a[0]
dp[0][1]=b[0]
dp[0][2]=c[0]
#print(dp)
for i in range(1,n):
  dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i])
  #print("dp[i][0]",dp[i][0],"dp[i-1][1]",dp[i-1][1],"dp[i-1][2]",dp[i-1][2],"a[i]",a[i])
  dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i])
  #print("dp[i][1]",dp[i][1],"dp[i-1][0]",dp[i-1][0],"dp[i-1][2]",dp[i-1][2],"b[i]",b[i])
  dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i])
  #print("dp[i][2]",dp[i][2],"dp[i-1][0]",dp[i-1][0],"dp[i-1][1]",dp[i-1][1],"c[i]",c[i])
  #print(i,dp)
#print(dp)
print(max(dp[-1][0],dp[-1][1],dp[-1][2]))



Measured memory_bytes: 127916