akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int x,y;
    cin>>x>>y;
    if(x<y)swap(x,y);
    
    if(x-y<=1)cout<<"Brown";
    else cout<<"Alice";




     return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

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

  if(a < b && b < c) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3088
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=15;
int n,m;
int tb[N][N];
int sum[1<<N];
int tmp[1<<N][N],dp[1<<N][N];
void prt_bitmsk(int x){
	for(int i=0;i<n;i++)cout<<!!(x&1<<i);
}
int main(){
	cin>>n>>m;
	int tot=0;
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		tb[x][y]=tb[y][x]=z;
		tot+=z;
	}
	for(int i=0;i<1<<n;i++){
		for(int j=0;j<n;j++)if(i&1<<j)for(int k=j+1;k<n;k++)if(i&1<<k)
			sum[i]+=tb[j][k];
//		printf("sum[");prt_bitmsk(i);printf("]=%d\n",sum[i]);
	}
	for(int i=0;i<1<<n;i++)for(int j=0;j<n;j++)dp[i][j]=tmp[i][j]=-inf;
	for(int i=0;i<1<<n;i++)if(i&1)for(int j=0;j<n;j++)if(i&1<<j){
		if(j)
			for(int k=i^1<<j^1;;k=k-1&(i^1<<j^1)){
				dp[i][j]=max(dp[i][j],sum[k|1<<j]+tmp[i^k^1<<j][j]);
				if(!k)break;
			}
		else
			dp[i][j]=sum[i];
//		printf("dp[");prt_bitmsk(i);printf("][%d]=%d\n",j,dp[i][j]);
		for(int k=0;k<n;k++)if(!(i&1<<k))
			if(tb[j][k])
				tmp[i][k]=max(tmp[i][k],dp[i][j]+tb[j][k]);
	}
	cout<<tot-dp[(1<<n)-1][n-1];
	return 0;
}
/*1
4 6
1 2 100
3 1 100
2 4 100
4 3 100
1 4 100
3 2 100
*/
/*2
2 1
1 2 1
*/
/*3
15 22
8 13 33418
14 15 55849
7 10 15207
4 6 64328
6 9 86902
15 7 46978
8 14 53526
1 2 8720
14 12 37748
8 3 61543
6 5 32425
4 11 20932
3 12 55123
8 2 45333
9 12 77796
3 9 71922
12 15 70793
2 4 25485
11 6 1436
2 7 81563
7 11 97843
3 1 40491
*/

Measured memory_bytes: 4224
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

def min(a, b)
  return a < b ? a : b
end

def max(a, b)
  return a > b ? a : b
end

N, h_list = gets_n_and_i_list      
INF = Float::INFINITY

dp = Array.new(N, INF)
dp[0] = 0
dp[1] = (h_list[1] - h_list[0]).abs

1.upto(N-2) do |i|
  n1 = (h_list[i + 1] - h_list[i]).abs + dp[i]
  n2 = (h_list[i + 1] - h_list[i - 1]).abs + dp[i - 1]
  dp[i + 1] = min(n1, n2)
end

puts dp.last

Measured memory_bytes: 21980
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);

    System.out.println(b / a * a == b ? a + b : b - a);
  }

}

Measured memory_bytes: 24916
#include <iostream>

using namespace std;

int calc_ds(int n) {
    int sum=0;
    while(10*n/10) {
        sum += n%10;
        n /= 10;
    }
    return sum;
}

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

    int i, sum, min=100001;
    for(i=N-1; i>0; i--) {
        sum = calc_ds(i) + calc_ds(N-i);
        if(min>sum) {
            min = sum;
        }
    }

    cout << min << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const int INF = 2e9 + 1;
int x[4] = {-1, 0, 1, 0};
int y[4] = {0, 1, 0, -1};
int dp[1010][1010];
void Main(){
    int h, w;
    cin >> h >> w;
    h += 2;
    w += 2;
    int sh, sw, gh, gw;
    cin >> sh >> sw >> gh >> gw;
    vector<string> s(h);
    string str = "";
    For(i,0,w) str += '#';
    s[0] = str;
    s[h-1] = str;
    For(i,1,h-1){
        cin >> s[i];
        s[i] = '#' + s[i] + '#';
    }
    For(i,0,h) For(j,0,w) dp[i][j] = INF;
    dp[sh][sw] = 0;
    priority_queue<pair<int,pair<int,int>>, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int>>>> que;
    que.push({0, {sh, sw}});
    while(!que.empty()){
        pair<int,int> now;
        int dist;
        tie(dist,now) = que.top();
        que.pop();
        if(now.first == gh && now.second == gw) break;
        bool flag = true;
        For(i,0,4){
            if(s[now.first + x[i]][now.second + y[i]] == '#'){
                flag = true;
                continue;
            }
            if(dp[now.first + x[i]][now.second + y[i]] > dist){
                dp[now.first + x[i]][now.second + y[i]] = dist;
                que.push({dist, {now.first + x[i], now.second + y[i]}});
            }
        }
        if(flag){
            For(i, -2, 3){
                if(clamp(now.first + i, 0, h-1) != now.first + i) continue;
                For(j, -2, 3){
                    if(clamp(now.second + j, 0, w-1) != now.second + j) continue;
                    if(s[now.first + i][now.second + j] == '#') continue;
                    if(dp[now.first + i][now.second + j] > dist + 1){
                        dp[now.first + i][now.second + j] = dist + 1;
                        que.push({dist + 1, {now.first + i, now.second + j}});
                    }               
                }
            }
        }
    }
    /*For(i,0,h){
        For(j,0,w){
            cout << dp[i][j] << " \n"[j==w-1];
        }
    }*/
    if(dp[gh][gw] == INF) cout << -1 << endl;
    else cout << dp[gh][gw] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


Measured memory_bytes: 9692
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());

  int ans = 0;
  int pos = 0;
  while (pos < n) {
    int cnt = 0;
    int now = a[pos];
    while (pos < n && now == a[pos]) {
      cnt++;
      pos++;
    }
    ans += cnt%2;
  }

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

Measured memory_bytes: 640
while 1:
	n=input()
	if n==0:break
	hmax=7500
	block=[map(int,raw_input().split()) for i in range(n)]
	field=[[0]*5 for i in range(hmax)]
	top=[0]*5
	for d,p,q in block:
		if d==1:
			h=max(top[q-1:q-1+p])
			field[h][q-1:q-1+p]=[1]*p
			top[q-1:q-1+p]=[max(top)+1]*p
		else:
			h=top[q-1]
			for i in range(p):
				field[h+i][q-1]=1
			top[q-1]=h+p
		h=0
		while 1:
			if field[h]==[1]*5:
				del field[h]
				top=[x-1 for x in top]
			elif field[h]==[0]*5:
				break
			else:
				h+=1
		for w in range(5):
			for h in range(top[w]-1,-2,-1):
				if field[h][w]==1 or h==-1:
					top[w]=h+1
					break
	print sum([sum(field[h]) for h in range(max(top))])

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (auto& e : A) {
    cin >> e;
  }
  for (int i = K; i < N; i++) {
    if (A[i] > A[i - K]) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 3968
function main()
	N,K=map(x->parse(Int,x),split(readline()))
	A=map(x->parse(Int,x),split(readline()))
	X=Int[]
	for i=1:N
		sum=0
		for j=i:N
			sum+=A[j]
			push!(X,sum)
		end
	end
	ans=0
	take=1<<45
	while take>0
		Y=Int[]
		for x=X
			if (x&take)==take
				push!(Y,x)
			end
		end
		if length(Y)>=K
			ans+=take
			X=Y
		end
		take>>=1
	end
	println(ans)
end
main()


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

int main() {
    long long X,N;
    
    cin >> X >> N;
    
    long long p[N+1],A[101],ans=101,ans2=101;
    p[0]=0;
    A[0]=0;
    for(long long i=1;i<=100;i++){
        A[i]=0;
    }
    if(N==0){
        cout << X << endl;
        return 0;
    }
    
    for(long long i=1;i<=N;i++){
        cin >> p[i];
        A[p[i]]=1;
    }
    
    if(A[X]==0){
        cout << X << endl;
        return 0;
    }
    
    for(long long i=-110;i<=110;i++){
        if(i<0 && ans>abs(X-i)){
            ans = i;
            ans2 = abs(X-i);
        }
        if(i>=0 && A[i]==0 && ans2 >abs(X-i)){
            ans = i;
            ans2 = abs(X-i);
        }else if(i>=0 && A[i] == 0 && ans2 == abs(X-i) && ans>i){
            ans = i;
            ans2 = abs(X-i);
        }else if(i>100 && ans2 >abs(X-i)){
            ans = i;
            ans2 = abs(X-i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(N)]
R = [0 for i in range(N)]
T = [0 for i in range(N)]

for i in range(N):
    if i == 0:
        L[i] = 0
    else:
        L[i] = gcd(L[i-1], A[i-1])
for i in reversed(range(0, N)):
    if i == N-1:
        R[i] = 0
    else:
        R[i] = gcd(R[i+1], A[i+1])
for i in range(N):
    T[i] = gcd(L[i], R[i])

print(max(T))

Measured memory_bytes: 14488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){
    int kame, turu;
    int X, Y;

    cin >> X >>Y;
    //turu = Y-kame;
    if((Y-2*X)>=0 && (Y-2*X)%2 == 0){
        if((Y-2*X)/2 <= X){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3604
h, w = map(int, input().split())

s = [input() for i in range(h)]

board_w = [[0 for _ in range(w)] for _ in range(h)]
board_h = [[0 for _ in range(w)] for _ in range(h)]

# 右、左、上、下の順に走査
for i in range(h):
    cnt_continue = 0
    for j in range(w):
        if s[i][j] == "#":
            cnt_continue = 0
        else:
            cnt_continue += 1
            board_w[i][j] = cnt_continue

    for j in reversed(range(w-1)):
        if board_w[i][j] == 0:
            continue
        board_w[i][j] = max(board_w[i][j], board_w[i][j+1])

for i in range(w):
    cnt_continue = 0
    for j in range(h):
        if s[j][i] == "#":
            cnt_continue = 0
        else:
            cnt_continue += 1
            board_h[j][i] = cnt_continue

    for j in reversed(range(h-1)):
        if board_h[j][i] == 0:
            continue
        board_h[j][i] = max(board_h[j][i], board_h[j+1][i])


ans = 0

for i in range(h):
    for j in range(w):
        v = board_w[i][j] + board_h[i][j] - 1
        ans = max(ans, v)

print(ans)


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

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

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

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

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

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

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

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

// use std::io::{stdout, Write, BufWriter};
use std::cmp::min;

fn main() {
    input! {
        _n: i32,
        m: usize,
        x: i32,
        a: [i32; m],
    }
    let to_zero = (0..x).filter(|i| a.contains(i)).count();
    println!("{}", min(to_zero, m - to_zero))
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>

using namespace std;

typedef pair<int, int> P;

int main()
{
	while(1) {
		int N, M, r, q;
		int t[1001], n[1001], m[1001], s[1001];
		cin >> N >> M;
		if(!N && !M) break;
		cin >> r;
		for(int i = 0; i < r; ++i) {
			cin >> t[i] >> n[i] >> m[i] >> s[i];
		}
		cin >> q;
		while(q--) {
			int start, end, target, count = 0, ans = 0;
			int beg;
			cin >> start >> end >> target;
			beg = -1;
			for(int i = 0; i < r; ++i) {
				if(m[i] != target) continue;
				// endを越えたら集計終了
				if(t[i] >= end) {
					if(count > 0) { ans += end - beg; }
					break;
				}
				// start以前のカウンタをセット
				if(s[i] == 1)      { ++count; }
				else if(s[i] == 0) { --count; }
				if(t[i] < start) {
					if(count > 0) beg = start;
					else          beg = -1;
					continue;
				}
				// カウンタが0になったら連続起動終了
				if(count == 0) {
					ans += t[i] - beg;
					beg = -1;
					continue;
				}
				// ガウンタが0から1になったら連続起動開始
				if(count == 1 && beg == -1) { beg = t[i]; continue; }
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1172
n=int(input())
xy=[[0]*2 for ii in range(n)]
d=[[0]*n for ii in range(n)]
for ii in range(n):
  xy[ii][:]=map(int,input().split())
r=0
c=0
for ii in range(n):
  for jj in range(n):
    if ii!=jj:
      r+=((xy[ii][0]-xy[jj][0])**2+(xy[ii][1]-xy[jj][1])**2)**0.5
      c+=1
print((r/c)*(n-1))


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
#include<map>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const int big=1e8+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	string str;cin>>str;
	if(str[0]=='9'||str[1]=='9'){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
struct MyIo{

}

impl MyIo{
    fn readline()->Vec<String>{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let ret:Vec<String> = buf.split_whitespace().map(|c|c.to_string()).collect();
        ret
    }
}


fn main() {

    let N = MyIo::readline().into_iter();
    let mut count = 0;
    for item in MyIo::readline().iter(){
        let mut value = item.parse::<u64>().unwrap();
        while true{
            if value%2 == 0{
                count+=1;
                value=value/2;
            }else{
                break;
            }
        }
    }
    println!("{:?}",count);
}


Measured memory_bytes: 4352
N,W=[int(i) for i in input().split(" ")]
v=[]
w=[]
for i in range(N):
	vw=input().split(" ")
	v.append(int(vw[0]))
	w.append(int(vw[1]))



array=[[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
	array[i+1]=array[i].copy()
	for j in range(W):
		try:
			array[i+1][w[i]+j]=max(array[i+1][w[i]+j],array[i][j]+v[i],array[i][w[i]+j])
		except:
			pass


print (array[-1][-1])

Measured memory_bytes: 28112
import itertools
from collections import defaultdict
import collections
import math
import sys
import queue
sys.setrecursionlimit(200000)
mod = 1000000007

n, m = map(int, input().split())

graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

tf = [False] * (n + 1)
sirube = [0] * (n + 1)
def bfs(v):
    q = queue.Queue()
    q.put([v,0])
    tf[v] = True
    while not q.empty():
        sub = q.get()
        now = sub[0]
        before = sub[1]
        for next in graph[now]:
            if tf[next]:
                continue
            tf[next] = True
            if sirube[next] == 0:
                sirube[next] = now
            q.put([next, now])

bfs(1)
for i in range(2, n + 1):
    if sirube[i] == 0:
        print("No")
        exit()

print("Yes")
for i in range(2, n + 1):
    print(sirube[i])

Measured memory_bytes: 48372
/*ABC174-F*/
#include<stdio.h>
#include<math.h>
#include<algorithm> 
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void read(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void read(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void read(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void push(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void write(T x) {
    	if(x < 0) {
			x = -x;
			push('-');
		}
    	static T sta[35];
    	T top = 0;
    	do{
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			push(sta[--top] + '0');
	}
	template <class T>
	inline void write(T x, char lastChar) {
    	write(x);
		push(lastChar);
	}
} io;
int aa[1000010], cnt[1000010], belong[1000010];
int n, m, size, bnum, now, ans[1000010];
struct query { /*询问*/
	int l, r, id;
} q[1000010];

int cmp(query a, query b) {
	return (belong[a.l] ^ belong[b.l]) ? belong[a.l] < belong[b.l] : ((belong[a.l] & 1) ? a.r < b.r : a.r > b.r); /*奇偶优化后的排序*/
}
int main() {
	io.read(n), io.read(m);
	size = sqrt(n);
	bnum = ceil((double)n / size);
	rep(i, 1, bnum) 
		rep(j, (i - 1) * size + 1, i * size) {
			belong[j] = i; /*依旧不知道所以然的离散化*/
		}
	rep(i, 1, n) io.read(aa[i]); 
	rep(i, 1, m) {
		io.read(q[i].l), io.read(q[i].r);
		q[i].id = i; /*读入每一个询问*/
	}
	std::sort(q + 1, q + m + 1, cmp);
	int l = 1, r = 0;
	rep(i, 1, m) {
		int ql = q[i].l, qr = q[i].r; /*莫队主体*/
		while(l < ql) now -= !--cnt[aa[l++]]; /*需要移动就移,在移的过程中更新答案*/
		while(l > ql) now += !cnt[aa[--l]]++;
		while(r < qr) now += !cnt[aa[++r]]++;
		while(r > qr) now -= !--cnt[aa[r--]];
		ans[q[i].id] = now;
	}
	rep(i, 1, m) io.write(ans[i], '\n');
}

Measured memory_bytes: 17344
n = gets.to_i
a = gets.split.map &:to_i

min = 1000000
max = -1000000
sum = 0

for i in 0...n do

    if a[i] < min
        min = a[i]
    end

    if a[i] > max
        max = a[i]
    end

    sum += a[i]

end

print "#{min}", " ", "#{max}", " ", "#{sum}", "\n"



Measured memory_bytes: 8896
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Maybe

readInteger = fst . fromJust . BS.readInteger

getInteger = readInteger <$> BS.getLine

calc :: Integer -> String -> String
calc n s
  | n <= 26 = (chr (ord 'a' + (fromIntegral n - 1))) : s
  | otherwise = calc d' ((chr (ord 'a' + m' - 1)) : s)
  where
    m = fromIntegral (n `mod` 26)
    d = n `div` 26
    m' = if m == 0 then 26 else m
    d' = if m == 0 then (d - 1)  else d


main = do
  n <- getInteger
  putStrLn $ calc n ""


Measured memory_bytes: 3836
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
a = factorization(n)
ans = 0
for i in a:
    t = i[1]
    b = 1
    while (b*(b+1))//2  <= t:
        b += 1
    ans += b-1
if n==1:
    print(0)
    exit()
print(ans)

Measured memory_bytes: 63372
//By Don4ick
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int a, b, c;

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	cin >> a >> b >> c;
	if (a == b)
		cout << c << endl;
	else if (b == c)
		cout << a << endl;
	else
		cout << b << endl;	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
ll power(ll x, ll y, ll m) { 
    if (y == 0) return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
ll modInverse(ll a, ll m){ 
    return power(a, m-2, m);  
}


int main(){
  
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
       ll m = 1e9+7 , i , j  ;
       
       ll r1 , c1 , r2 , c2  , a[4] , fac[4] , b[4] , c[4] ;
       cin >> r1 >> c1 >> r2 >> c2 ;
       ll rmin = min(r1, r2) ; ll rmax = max(r1 , r2) ;
       ll cmin = min(c1, c2) ; ll cmax = max(c1 , c2) ;

       a[0] = rmax+cmax+2 , a[1] = rmax+cmin+1 , a[2] = rmin+cmax+1 , a[3] = rmin+cmin ;
       for(j=0 ; j<4 ; j++){
              fac[j]=1 ;
         for(i=2 ; i<=a[j] ; i++){
               fac[j] = (fac[j]*i)%m ;
         }
       }
      b[0] = rmax+1 , b[1] = rmin , b[2] = cmax+1 , b[3] = cmin  ;
      for(i=0 ; i<4 ; i++){
               c[i]=1 ;
           for(j=2 ; j<=b[i] ; j++){
                 c[i] = (c[i]*j)%m ;
           }
      }

      ll ans1 = ( ( ( fac[0]*modInverse(c[0] , m) )%m )*modInverse(c[2] , m) )%m ;
      ll ans2 = ( ( ( fac[1]*modInverse(c[0] , m) )%m )*modInverse(c[3] , m) )%m ;
      ll ans3 = ( ( ( fac[2]*modInverse(c[1] , m) )%m )*modInverse(c[2] , m) )%m ;
      ll ans4 = ( ( ( fac[3]*modInverse(c[1] , m) )%m )*modInverse(c[3] , m) )%m ;

      cout << ((ans1+ans4-ans2-ans3)>0 ?(ans1+ans4-ans2-ans3) :(ans1+ans4-ans2-ans3)+m)%m ;

    return 0 ;
}

Measured memory_bytes: 256
import numpy as np

N,M = list(map(int, input().split()))
A = [0] * N
B = [0] * N

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

sum = 0
ans = 0

idx = np.argsort(A)

for i in range(N):
	if(sum+B[idx[i]] >= M):
		for j in range(B[idx[i]]):
			ans += A[idx[i]]
			sum += 1
			if(sum >= M):
				break
		break
	ans += A[idx[i]]*B[idx[i]]
	sum += B[idx[i]]
print(ans)


Measured memory_bytes: 21432
import java.util.Scanner;
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if(S.length()%2!=0){
      System.out.println("No");
      return;
    }
    for(int i = 0; i < S.length(); i=i+2){
      if(S.charAt(i)!='h'){
        System.out.println("No");
        return;
      }
      if(S.charAt(i+1)!='i'){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}

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

bool isPrime(int x){

  if(x==2)
    return true;

  else if(x<2 || x%2==0)
    return false;

  for(int i=3; i<=sqrt(x); i+=2){
    if(x%i==0)
      return false;
  }

  return true;

}

int main(){

  int n,x;
  int sum=0;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> x;
    sum += isPrime(x);
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1160
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n,m;cin>>n>>m;
    vvl x(n,vl(3));
    rep(i,n)rep(j,3)cin>>x[i][j];

    ll ans=-LINF;
    rep(i,1<<3){
        vl a;
        rep(j,n){
            ll tmp=0;
            rep(k,3)tmp+=((i>>k&1)*2-1)*x[j][k];
            a.push_back(tmp);
        }
        sort(rbegin(a),rend(a));
        ll sum=0;
        rep(j,m)sum+=a[j];
        chmax(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


string to_string(string s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(char ch) {
	return string("'")+ch+string("'");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <class InputIterator>
string to_string (InputIterator first, InputIterator last) {
	bool start = true;
	string res = "{";
	while (first!=last) {
		if (!start) {
			res += ", ";
		}
		start = false;
		res += to_string(*first);
		++first;
	}
	res += "}";
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
	return res;
	}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=300005;

void solve()
{  
int n;
cin>>n;
vi a(n);
vi b(n);
cin>>a>>b;
int ans=0;
for(int i=0;i<n;i++)if(a[i]-b[i]>0)ans+=a[i]-b[i];
cout<<ans;

} 
	
	
   
	
	

signed main()
{   
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//cin>>tc;
    for(int i=0;i<tc;i++)
	{
		//cout<<"Case #"<<i+1<<": "; 
        solve();
		}
	
	}


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

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

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(x) x.begin(), x.end()
#define lp(i, n) for (int i = 0; i < n; i++)
#define mem(a, v) memset(a, v, sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y, a.X))
#define vec(a, b) ((b) - (a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a) / length(a)
#define dotP(a, b) ((conj(a) * b).X)
#define crossP(a, b) ((conj(a) * b).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(a) dotP(a, a)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(v, m) conj(v / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll n, ll x) {
  if (!x)
    return 1;
  if (x % 2)
    return n * fastpow(n, x - 1);
  ll p = fastpow(n, x / 2);
  p %= mod;
  p *= p;
  p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll ret = num % mod;
  while (ret < 0)
    ret += mod;
  return ret;
}

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
long double dist(pair<ll, ll> &a, pair<ll, ll> &b) {
  return sqrt(
      ((a.f - b.f) * (a.f - b.f) * 1.0 + (a.se - b.se) * (a.se - b.se)));
}
/*vector<int> ap;
bool np[MX];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <MX; j+=i) np[j] = 0;
        }
    }
    for(ll i = 2 ; i< MX ; i++) if(np[i]) ap.pb(i);
}*/
const ll MX = 1e5+5;
void add(int &a, int b){
	a +=b;
	if(a>=mod) a-=mod;
}
void sub(int &a, int b){
	a -=b;
	if(a<0) a+=mod;
}
bool inMask(int mask , int idx){
	return (mask & (1<<idx));
}
int adjustMask(int mask, int idx){
	return mask | (1<<idx);
}
bool mat[22][22];
int n;
int dp[22][(1<<21)];
int solve(int idx , int mask){
	if(idx == n)return (mask == (1<<n) - 1);
	int &ret = dp[idx][mask];
	if(~ret)return ret;
	ret = 0;
	for(int i = 0 ; i< n ; i++){
		if(mat[idx][i] &&  !inMask(mask,i))
			add(ret,solve(idx+1,adjustMask(mask,i)));
	}
	return ret;
	

}
int main()
{
    IO;
    cin>>n;
    for(int i = 0; i< n ; i++) for(int j = 0 ; j< n ;j++) cin>>mat[i][j];
    mem(dp,-1);
    cout<<solve(0,0);
    
    return 0;
}



Measured memory_bytes: 180480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n;
    cin >> n;
    vll hm(10, vl(10, 0));
    for(int i=1; i<=n; i++)
    {
        string snum = to_string(i);
        int f = snum.at(0) - '0';
        int e = snum.back() - '0';
        hm.at(f).at(e)++;
    }

    ll sun = 0;
    for(int i=1; i<10; i++)
    for(int j=i; j<10; j++)
    {
        if(i==j) sun += hm.at(i).at(j) * hm.at(j).at(i);
        else sun += hm.at(i).at(j) * hm.at(j).at(i) * 2;
    }
    cout << sun << endl;
    return 0;
}


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

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

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, std::vector<long long> C) {
    sort(rall(C));
    ll ans = 1LL;
    rep(i, N - 1) {
        ans = (ans << 2LL);
        ans %= mod;
    }
    ll sum = 0;
    rep(i, N) {
        sum += C[i] * (i + 2);
        sum %= mod;
    }
    cout << (ans * sum) % mod << endl;
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> C(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &C[i]);
    }
    solve(N, std::move(C));
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, H: int, M: int):
    m = H * 60 + M
    a = 6 * m
    b = 0.5 * m

    print (math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(a - b))))
    return


# Generated by 1.1.7.1 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(A, B, H, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9524
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
31 10
)");
#define cin input
#endif

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

	cout << (k * 2 - 1 <= n ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
let prim a n =
  let d = Array.make n max_int in
  d.(0) <- 0;
  let b = Array.make n false in
  let z = Array.make n (-1) in
  let rec get_u i m u =
    if i = n then u
    else if b.(i) = false && m > d.(i) then get_u (i + 1) d.(i) i
    else get_u (i + 1) m u
  in
  let rec doit () =
    let u = get_u 0 max_int (-1) in
    if u <> (-1) then (b.(u) <- true; duduwa 0 u)
  and duduwa j u =
    if j = n then doit ()
    else if b.(j) = true || a.(u).(j) = max_int || d.(j) <= a.(u).(j) then duduwa (j + 1) u
    else begin
      d.(j) <- a.(u).(j);
      z.(j) <- u;
      duduwa (j + 1) u
    end in
  doit ();
  let rec sum i acc =
    if i = n then acc
    else sum (i + 1) (acc + (if z.(i) <> (-1) then a.(i).(z.(i)) else 0))
  in sum 0 0

let () =
  let n = read_int () in
  let a = Array.make_matrix n n max_int in
  let rec read = function
    | (i, _) when i = n -> ()
    | (i, j) when j = n -> read (i + 1, 0)
    | (i, j) ->
      let x = Scanf.scanf " %d " (fun x -> x) in
      if x <> (-1) then a.(i).(j) <- x;
      read (i, j + 1)
  in read (0, 0);
  Printf.printf "%d\n" (prim a n)

Measured memory_bytes: 4424
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.*;
public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a=scan.nextInt();
        List<String> listA = new ArrayList<String>();
        for(int i=0;i<a;i++){
            String n=scan.next();
            //System.out.println(n);
            listA.add(n);
            //System.out.println("ListA = " + listA);
        }
        List<String> listB = listA.stream().distinct().collect(Collectors.toList());

       // System.out.println("ListA = " + listA);
        //System.out.println("ListB = " + listB);
        System.out.println(listB.size());
            }
        }



Measured memory_bytes: 72456
n, x = map(int, input().split())
L = list(map(int,input().split()))
D = [0]*(n+1)
ans = 1
for i in range(n):
  D[i+1] = D[i] + L[i]
  if D[i+1] <= x:
    ans += 1
   
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    cin >> n;
    ll ans = 0;
    for(ll k = 1;k * k < n;k++){
        if(n % k != 0)continue;
        ll m = n / k - 1;
        if(n % m == 0)continue;
        ans += m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b;
  cin >> a >> b;
  int c, d;
  cin >> c >> d;
  string e;
  cin >> e;
  
	if(a == e){
    cout << c-1 << " " << d << endl;
	}
	else{
    cout << c << " " << d-1 << endl;
	}

}

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

int main(){

    int N,K;
    cin>>N>>K;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
    }
    int ans=400000000;
    for(int i=0;i<=N-K;i++){
        int x=abs(S.at(i+K-1)-S.at(i))+min((abs(S.at(i+K-1))),abs(S.at(i)));
        ans=min(ans,x);
    }
    cout<<ans<<endl;
}
    


Measured memory_bytes: 640
N,M=map(int,input().split())
md=10**9+7
def P(m):
  ret=1
  for i in range(1,m+1):
    ret = (ret*i)%md
  return ret

if N<M:
  N,M=M,N
MK = P(M)
if N==M:
  ans=(2*(MK**2))%md
elif N==M+1:
  ans=(MK**2)%md
  ans=(ans*N)%md
else:
  ans=0
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#define maxn 200009
using namespace std;
int a[maxn];
int main(){
	int n, t;
	scanf("%d%d", &n, &t);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		if(i < n){
			if(a[i + 1] - a[i] >= t)
				ans += t;
			else
				ans += a[i + 1] - a[i];
		}
		else{
			ans += t;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],ans,x[200005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	for(int i=n;i;i--){
		int s=0;
		for(int o=i+i;o<=n;o+=i){
			s+=x[o];
		}
		s&=1;
		x[i]=(a[i]-s+2)&1;
		if(x[i])ans++;
	}
	printf("%d\n",ans);
	for(int i=1;i<=n;++i)if(x[i])printf("%d ",i);
}

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

int main(){
  char s[3];
  int a=700,i,j=0;
  cin>>s;
  for(i=0;i<3;i++)
  {
      if(s[i]=='o')a=a+100;
  }
  cout<<a;
  return 0;
}

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

int main()
{
  int N; cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i++)
  {
    int p; cin >> p;
    if (p != i) cnt++;
  }
  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for((i)=(l);(i)<=(r);(i)++)
#define drep(i,l,r) for((i)=(l);(i)>=(r);(i)--)
#define MOD 1000000007
#define ll long long
#define MAX(a,b) ((a)>(b)?(a):(b))
using namespace std;
int main(){
    ll n;
    cin>>n;
    cout<<n*(n+1)/2-n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[200001];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}

long long nCr(long long n, long long r) {
    if (r > n) return 0;
    return (fac[n] * modInverse(fac[r]) % MOD * modInverse(fac[n - r]) % MOD) % MOD;
}

long long bfs(vector<int> g, queue<int> q) {
    return 1ll;
}

int main() {

    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long common = lcm(c, d);
    long long x = b / d - (a-1) / d;
    long long y = b / c - (a-1) / c;
    long long z = b / common - (a - 1) / common;
    long long ans = b - a - x - y + z;

    cout << ans+1;

    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int m,n,i,j,k=0,check,store,res;
    scanf("%d%d",&n,&m);
    long long int a[n],b[n],c[m],d[m];
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
    }
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&c[i],&d[i]);
    }
    for(i=0;i<n;i++)
    {
        res=abs(abs(a[i]-c[k])+abs(b[i]-d[k]));
        check=1;
        for(j=1;j<m;j++)
        {
            store=abs(abs(a[i]-c[j])+abs(b[i]-d[j]));
            if(res>store)
            {
                res=store;
                check=j+1;
            }
        }
        printf("%d\n",check);
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main
{

	public static void main(String[] args)
	{
		 Scanner scan = new Scanner(System.in);
		 int first = scan.nextInt();
		 String op = scan.next();
		 int second = scan.nextInt();
		 if(op.equals("+")) {
			 System.out.println(first + second);
		 } else {
			 System.out.println(first - second);
		 }
	}

}

Measured memory_bytes: 21844
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	ans := int(1e12)
	for i := 0; i <= len(s)-3; i++ {
		a, _ := strconv.Atoi(s[i : i+3])
		ans = min(ans, abs(753-a))
	}
	fmt.Println(ans)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1772
#include<stdio.h>
#define N 100
#define INF 99999
#define WHITE 0
#define BLACK 2
#define GRAY 1
int prim(int n,int A[N][N]){
  
  int i,p[N],mincost,cost[N],color[N],sum=0,k,ver;

  for(i=0;i<n;i++){
    cost[i] = INF;
    color[i] = WHITE;
  } //初期化
  cost[0] = 0;
 
 p[0] = -1;
  while(1){
   
    mincost = INF;
    for(i=0;i<n;i++){
        if(color[i] != BLACK && cost[i] < mincost){
      
      mincost = cost[i];
   
      ver = i; 
      }
    }

  
    
  
    if(mincost == INF)break; 
  sum += mincost;
  
  color[ver] = BLACK;

  for(k=0;k<n;k++){
    if(color[k] != BLACK && A[ver][k]!=-1){
      if(A[ver][k] < cost[k]){
          cost[k] = A[ver][k];
          p[k] = ver;
          color[k] = GRAY;
      }
        
    }
      
  }
  }
    
    return sum;
}




int main(){

  int i,j,answer,n,A[N][N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
         A[i][j] = -1; //ここで全て辺無しにしておく
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);//ここで編の番号を入力。ないなら－１を入力
    
    }
  }

   answer = prim(n,A);

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


  return 0;
}



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

using namespace std;

#define pb push_back
#define mem(a) memset(a,-1,sizeof(a))

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

const int mn=2e5+5;

int n;
int a[mn];
set<int> s;

int main() {
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	ll ans=0;
	for(int i=n;i;i--){
		int u=i-a[i];
		s.insert(u);
		if (s.count(i)) s.erase(i);
		if (u<0||!s.empty()&&(*s.begin()<u||*s.begin()<=0)) {
			puts("-1");
			return 0;
		}
		ans+=s.size();
		//printf("%d %d %d\n",i,u,ans);
		//for(auto i:s) printf("%d\n",i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5760