akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int N, M;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


signed main(signed argc, char **argv) {
  cin >> N >> M;
  vector<vector<int>> e(M, vector<int>(2));
  for (size_t i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    e[i][0] = a - 1;
    e[i][1] = b - 1;
  }
  UnionFind uf(N);
  int ans = N * (N-1) / 2;
  VI anss(M);
  for (size_t i = M - 1; i >= 0; i--) {
    anss[i] = ans;
    // debug(ans);
    // debug(M - i - 1);
    bool con = uf.findSet(e[i][0], e[i][1]);
    if (!con) {
      ans = ans - uf.size(e[i][0]) * uf.size(e[i][1]);
    }
    uf.unionSet(e[i][0], e[i][1]);
    // debug(uf.size(e[i][0]));
    // debug(uf.size(e[i][1]));
  }
  for (size_t i = 0; i < M; i++) {
    cout << anss[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8320
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

//最大公約数
int gcd(int a, int b){
    //a>bになるように入れ替え
    if(a<b){
        int tmp=a;
        a=b;
        b=tmp;
    }

    //ユークリッドの互除法
    if(a%b==0) return b;
    return gcd(b,a%b);
}

int main(void){
    int N,X;
    scanf("%d%d",&N,&X);

    //A[0]~A[N-1]に,x_i-X間の距離を格納する
    int* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        A[i]=abs(A[i]-X);
    }

    int ans;
    if(N==1){
        ans=A[0];
    }
    else{
        ans=gcd(A[0],A[1]);
        for(int i=2;i<N;i++) ans=gcd(ans,A[i]);
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0;
  cin >>a>>b;
  for(int n=0;n<a;n++) cin >>c,i[c]++;
  sort(i,i+a+1,greater<long long>());
  c=0;
  while(1){
    if(i[c]==0) break;
    c++;
  }
  for(int n=c-1;n>=b;n--){
    d+=i[n];
  }
  cout <<d<<'\n';
  return (0);
}


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;

ll a[N], b[N];

int main() {
  int n; scanf("%d", &n);
  priority_queue < pair <ll, ll> > pq;
  for(int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for(int i = 0; i < n; i++) {
    scanf("%lld", &b[i]);
    if(b[i] > a[i]) pq.push({b[i], i});
  }
  ll moves = 0;
  while(not pq.empty()) {
    auto cur = pq.top(); pq.pop();
    ll have = cur.first;
    int idx = cur.second;
    if(b[idx] != have) continue;
    ll d = b[(idx + n - 1) % n] + b[(idx + 1) % n];
    if(d >= b[idx]) break;
    if((b[idx] - a[idx]) % d == 0) {
      moves += (b[idx] - a[idx]) / d;
      b[idx] = a[idx];
    } else {
      moves += b[idx] / d;
      b[idx] %= d;
    }
    if(b[idx] > a[idx]) pq.push({b[idx], idx});
  }
  for(int i = 0; i < n; i++) {
    if(a[i] != b[i]) moves = -1;
  }
  printf("%lld\n", moves);
}

Measured memory_bytes: 8688
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.IArrayI32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI32(), i|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.IArrayI64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI64(), i|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.IArrayF32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF32(), i|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public this.IArrayF64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF64(), i|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let a = scanner.NextI32()
    let b = scanner.NextI32()
    let rec f c = function
        | 0 | -1 -> c
        | x -> f (c + x) (x - 1)
    (f 0 (a - 1)) + (f 0 (b - 1))
    |> printfn "%i"

    0


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;

lli n,m;
lli a[e3][e3];

bool solve(lli x){
  set<lli> s;
  queue<lli> b[e3];
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < m;j++){
      b[i].push(a[i][j]);
    }
  }

  for(lli i = 0;i < m;i++){
    lli cnt[e3];
    for(lli j = 0;j < m;j++){
      cnt[j] = 0;
    }
    for(lli j = 0;j < n;j++){
      cnt[b[j].front()]++;
    }
    lli flag = 0;
    for(lli j = 0;j < m;j++){
      if(cnt[j] > x){
        s.insert(j);
        for(lli k = 0;k < n;k++){
          while(!b[k].empty() && s.count(b[k].front())) b[k].pop();
        }
        flag = 1;
        break;
      }
    }
    if(flag == 0) return true;
  }
  return false;
}

int main(){
  cin >> n >> m;
  for(lli i = 0;i < n;i++)
    for(lli j = 0;j < m;j++) cin >> a[i][j];
  for(lli i = 0;i < n;i++)
    for(lli j = 0;j < m;j++) a[i][j]--;
  lli top = n;
  lli bottom = 0;
  while(top-bottom > 1){
    lli middle = (top+bottom)/2;
    if(!solve(middle)) bottom = middle;
    else top = middle;
  }
  cout << top << endl;
}


Measured memory_bytes: 12128
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>

#define true 1
#define false 0

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)


int judge(int L, int M, int N);

int main(){
  char buf[1024];
  int L,M,N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d/%d/%d", &L, &M, &N);

  int a=judge(L, M, N);

  if(a==true){
    printf("Heisei\n");
  }
  else{
    printf("TBD\n");
  }

  return 0;
}


int judge(int L, int M, int N){
  int a=false;

  if(L<=2019){
    if(M<=4){
      a=true;
    }
  }

  return a;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	string s;cin>>s;
	ll n;cin>>n;
	bool ok=1;
	char d=s[0];
	rep(i,1,sz(s))if(s[i]!=d)ok=0;
	ll ans=0,i=1;
	while(i<sz(s)){
		if(s[i]!=s[i-1])i++;
		else ans++,i+=2;
	}
	char c=s[sz(s)-1];
	ll cnt=0,cnt1=0,i1=0,j1=0;
	for(ll i=sz(s)-1;i>=0;--i){
		if(s[i]==c)cnt++;
		else {j1=i;break;}
	}
	rep(i,0,sz(s)){
		if(s[i]==c)cnt1++;
		else {i1=i;break;}
	}
	ll ans1=0;i=i1+1;
	while(i<=j1){
		if(s[i]!=s[i-1])i++;
		else ans1++,i+=2;
	}
	if(ok)cout<<(n*sz(s))/2;
	else if(s[0]!=c)cout<<ans*n;
	else cout<<((cnt+cnt1)/2)*(n-1)+ans1*n+(cnt1)/2+(cnt)/2;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

	char bef;

	int ans=1;

	bef=s[0];

	for(int i=1;i<s.size();i++)
	{
		if(bef=='0')
		{
			ans++;
			bef='1';
		}
		else if(bef==s[i])
		{
			bef='0';
		}
		else
		{
			ans++;
			bef=s[i];
		}
	}

	if(bef=='0')
		ans=ans;

		

	int ansan=ans;

	ans=2;

	bef=s[2];

	for(int i=3;i<s.size();i++)
	{
		if(bef=='0')
		{
			ans++;
			bef='1';
		}
		else if(bef==s[i])
		{
			bef='0';
		}
		else
		{
			ans++;
			bef=s[i];
		}
	}
		

	cout << max(ans,ansan) << endl;
//	cout << ans << ":" << ansan << endl;



}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>
#include <cassert>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int ret = 0; char c = getchar(); while (c < '0' || c > '9') { c = getchar(); }
    while ('0' <= c && c <= '9') { ret = ret * 10 + c - '0'; c = getchar(); } return ret;
}
void write(int x) { if (x >= 10) { write(x / 10); } putchar(x % 10 + '0'); }

const int INF = 0x7fffffff;
const int maxn = 100 + 10;
int N, W;
ll ans = 0;
int w[maxn], v[maxn];
ll dp[maxn][maxn * 3];
int offset[maxn];

int main() {
#ifdef __AiR_H
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%d %d", &N, &W);
    for (int i = 1; i <= N; ++i) {
        scanf("%d %d", &w[i], &v[i]);
    }
    memset(dp, -1, sizeof(dp)); dp[0][0] = 0;
    for (int i = 1; i <= N; ++i) { offset[i] = w[i] - w[1]; }
    for (int i = 1; i <= N; ++i) {
        for (int j = i; j >=1; --j) {
            for (int k = 3 * N; k >= offset[i]; --k) {
                if (1ll * j * w[1] + k > 1ll * W) { continue; }
                if (dp[j - 1][k - offset[i]] == -1) { continue; }
                dp[j][k] = max(dp[j][k], dp[j - 1][k - offset[i]] + v[i]); ans = max(ans, dp[j][k]);
//                printf("j = %d, dp = %I64d, ans = %I64d\n", j, dp[j][k], ans);
            }
        }
//        printf("\n");
    }
    cout << ans << endl;
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;
typedef unsigned int UINT;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {
	
	int ans = 0;
	int a, b;
	cin >> a >> b;
	ans = a - b + 1;


	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

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

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const long long MAXN =1001000;

int n,r,c;
int val[ MAXN ];

struct Po{
int x,y;
int val;
    void get_val(){
    val=-1;
    if (x==0)
        val=y;
    if (y==c)
        val=c+x;
    if (x==r)
        val=c+r+(c-y);
    if (y==0)
        if ( x!=0 )
            val=c+r+c+(r-x);
    }
};

struct kt{
Po p1,p2;
}a[ MAXN ];

struct ene{
int pos,val;
}b[ MAXN ];

bool cmp_pos(ene A, ene B){
return A.pos<B.pos;
}

int d[ MAXN ],top;

int get_op(int x){
if ( x<0 )
    return -1;
if ( x>0 )
    return 1;
if (x==0 )
    return 0;
}

int main(){
    read(r);read(c);    read(n);
    int cnt=0;
    for (int i=1;i<=n;i++)
        {
            read(a[i].p1.x);
            read(a[i].p1.y);
            read(a[i].p2.x);
            read(a[i].p2.y);
            a[i].p1.get_val();
            a[i].p2.get_val();
            if( ( a[i].p1.val !=-1) && (a[i].p2.val!=-1) )
                {
                    int x=a[i].p1.val;
                    int y=a[i].p2.val;
                    if ( x>y )
                        swap(x,y);
                    ++cnt;  b[cnt].pos=x;   b[cnt].val=i;
                    ++cnt;  b[cnt].pos=y;   b[cnt].val=-i;
                }
        }
    sort(b+1,b+cnt+1,cmp_pos);

    top=0;
    for (int i=1;i<=cnt;i++)
        if ( top==0 )
            d[++top]=b[i].val;
        else
            {
                if ( get_op( d[top] )!=get_op(b[i].val) )
                    if ( -d[top]!=b[i].val )
                        {
                            puts("NO");
                            return 0;
                        }
                    else
                        top--;
                else
                    d[++top]=b[i].val;
            }
    puts("YES");
    return 0;
}


Measured memory_bytes: 9084
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());


    int g = (n-1)*(m-1);
    System.out.println(g);

  }
}


Measured memory_bytes: 21844
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
using namespace std;

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

	map<long long, long long> table;
	for(int i=0; i<N; i++)
	{
		long long A;
		cin >> A;

		table[A]++;
	}

	for(auto it=table.begin(); it!=table.end(); it++)
		it->second /= 2;

	vector<long long> edge(2, 0);
	for(int i=0; i<2; i++)
	{
		for(auto it=table.rbegin(); it!=table.rend(); it++)
		{
			if(it->second > 0)
			{
				edge[i] = it->first;
				(it->second)--;
				break;
			}
		}
	}

	cout << edge[0] * edge[1] << endl;

	return 0;
}


Measured memory_bytes: 6528
import sys
n = int(input())
a_list = list(map(int,input().split()))
if 0 in a_list:
  print(0)
  sys.exit(0)
ans = 1
for i in range(n):
  ans = ans * a_list[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)

Measured memory_bytes: 21576
n,k = (int(x) for x in input().split())
s = input()

temp = s[0]
flag = False
count = 0

for i in range(1,len(s)):
    this = s[i]
    if flag == False:
        if not(temp == this):
            flag = True
        else:
            count += 1
    else:
        if not(temp == this):
            if k>0:
                count += 2
                k -= 1
                flag = False
        else:
            count += 1
    
    #print(flag,count,temp,this)
    temp = this
    
    
else:
    if flag == True and k>0:
        count += 1
            
print(count)



Measured memory_bytes: 39792
# d, t, s = map(int, input().split())
s = input()
t = input()


def diff(a, b, minCount):
    count = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            count += 1
    return min(minCount, count)


minc = 1001
for i in range(0, 1 + len(s) - len(t)):
    minc = diff(s[i: i + len(t)], t, minc)
print(minc)


Measured memory_bytes: 9112
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N =	sc.nextInt();
        int x =	N;
	int sum = 0;

	while(x>0) {
            sum	+= x%10;
            x /= 10;
        }
	if(N%sum == 0) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      if(i<n/i-1)ans+=n/i-1;
      if(n/i<i-1)ans+=i-1;
    }
  }
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 3656
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)


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

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	h := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		h[i], _ = strconv.Atoi(sc.Text())
	}

	ans := 1
	max := h[0]
	for i := 1; i < n;i++ {
		if h[i] < max {
			continue
		}
		ans++
		if max < h[i] {
			max = h[i]
		}
	}

	fmt.Println(ans)

}



Measured memory_bytes: 1844
#include<cstdio>
#include<cstring>

int Check(int x){
    char s[10];
    sprintf(s+1,"%d",x);
    int len=strlen(s+1);
    for(int i=1;i<=len/2;i++)
        if(s[i]!=s[len-i+1])
            return 0;
    return 1;
}

int main(){
    int A,B,Ans=0;
    scanf("%d%d",&A,&B);
    for(int i=A;i<=B;i++)
        Ans+=Check(i);
    printf("%d",Ans);
    return 0;
}


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

int main ()
{
  char b;
  cin>>b;
  switch (b){
    case 'A' : cout<< 'T' <<endl;
      break;
    case 'T' : cout <<"A\n";
      break;
    case 'G' : cout<<"C\n";
      break;
    default: cout<<"G\n";
  break;}
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args) {
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine(Q3(a) );
        }
        private static int Q3(int a) {
            int cnt8 = 0;
            // cnt8 = Q3_cntDivisor(a);

            for (int i = 1; i <= a; i += 2) {

                if (Q3_cntDivisor(i) == 8) { cnt8++; }

            }
            return cnt8;
        }
        private static int Q3_cntDivisor(int a) {
            int cnt = 0;
            int b = (int)Math.Floor(Math.Sqrt(a));
            for (int i = 1; i <= b; i++) {
                if (a % i == 0) {
                    cnt++;
                }
            }
            return cnt*2;
        }
        private static string Q1() {
            //          a
            //          b c（bとcの間はスペース）
            //          s
            //          という入力値（改行されている）　abcは数値　sは文字列
            //　　これを　a+b+c sの形で出力せよ
            // 　　a=3.b=12,c=20 s="miho" なら　出力は　"35 miho"
            int a = int.Parse(Console.ReadLine());
            string[] bc = Console.ReadLine().Split(' ');

            int b = int.Parse(bc[0]);
            int c = int.Parse(bc[1]);
            string s = Console.ReadLine();
            return ((a + b + c) + " " + s);
        }
        private static int Q2() {
            string[] ab = Console.ReadLine().Split(' ');
            int a = int.Parse(ab[0]);
            int b = int.Parse(ab[1]);
            return ((a - 1) * (b - 1));
        }
       

        //private static bool Q3() {
        //    int a = int.Parse(Console.ReadLine());
        //    int cnt = 0;
        //    for (int i = 1; i < a; i++) {
        //        if (Q3_primenum(i) == false) {
        //            //約数があるから約数が8こあるかどうか判断
        //        }
        //    }
        //}
        //private static bool  Q3_primenum(int a) {
        //    if (a == 1) {
        //        return true;
        //    }else if (a == 2) {
        //        return true;
        //    }
        //    else {
        //        for(int i=2;i< a; i++) {
        //            if ((a % i) == 0) {
        //                return false;
        //            }
        //        }
        //        return true;
        //    }
        //}
        //private static bool Q3_divisorCnt8(int a) {
        //    int[] pn = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 89, 97, 101 };
        //    //int odd1 = 0;
        //    //int i = 0;
        //    //while (odd1 >= odd) {
        //}
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
#include <iomanip>
using namespace std;
const int mod = 1e+9 + 7;

int main()
{
	int N,K;
	cin>>N>>K;
	vector<long long> a(N);
	for(int i=0; i<N; i++)
	{
		cin>>a[i];
	}
	vector<long long> b = a;
	vector<long long> c(N,0);
	long long count = 0;

	for(int i=0; i<N; i++)
	{
		for(int j=0; j<N; j++)
		{
			if(b[i]>b[j] && i<j)
			{
				count++;
				count %= mod;
			}
			if(b[i]>b[j])
			{
				c[i]++;
			}
		}
	}
	count *= K;
	count %= mod;
	for(int i=0; i<N; i++)
	{
		long long add;
		if(K % 2 == 0)
		{
			add = K / 2;
			add *= K-1;
		}
		else
		{
			add = K / 2;
			add *= K;
		}
		add %= mod;
		add *= c[i];
		add %= mod;
		count += add;
		count %= mod;
	}
	
	cout<<count<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    if(n==1)    cout << "0";
    else if(n==2)   cout << "1";
    else
    {
        long long sum=(n*1LL);
        long long sm=((n-1)*1LL);
        if(n%2==0)  sum/=2;
        else    sm/=2;
        sum*=sm;
        cout << sum;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static long C(long n, long k)
        {
            long bunbo = 1;
            long bunsi = 1;
            for (long i = n - k; i <= n; i++)
                bunsi *= i;
            for (long i = 1; i <= n - k; i++)
                bunbo *= i;
            return bunsi / bunbo;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var input = Reads();
            var n = input[0];
            var a = input[1];
            var b = input[2];
            var c = input[3];
            var d = input[4];
            var s = Console.ReadLine().ToCharArray();
            var f = true;
            var ff = false;
            for (int i = 0; i < s.Length-1; i++)
            {
                if (a-1<=i&&i<=d-1&&s[i] == s[i + 1] && s[i] == '#')
                    f = false;
                if (i>0&&b - 1<= i && i <= d-1 && s[i - 1] == s[i] && s[i] == s[i + 1] && s[i] == '.')
                    ff = true;
            }
            if ((c < d && f) || (c > d && ff))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

      


            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 14176
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DTriangles {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> L(N);
        for(auto& l : L) in>>l;
        sort(ALL(L));
        lint ans = 0;
        REP(i, N) FOR(j, i+1, N){
            int id = lower_bound(ALL(L), L[i]+L[j]) - L.begin();
            ans += max(0, id-j-1);
        }
        out<<ans<<'\n';
    }
};


int main() {
	DTriangles solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        while (true) {
            UL H, W; scanf("%d%d", &H, &W);
            if (H == 0) return;
            rep(y, H) {
                rep(x, W) {
                    if (y == 0 || y == H - 1 || x == 0 || x == W - 1) printf("#");
                    else  printf(".");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3088
/*        ~ABC 171~
 *    code by kazalika   */
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, allx = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    allx ^= a[i];
  }
  for (int i = 0; i < n; ++i)
    cout << (allx ^ a[i]) << ' ';
}

Measured memory_bytes: 3956
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean[] f;

	static int rec(int n) {
		if (f[n]) return -1;
		f[n] = true;
		String s = String.valueOf(n);
		long max = 0;
		int ln = s.length();
		if (ln == 1) return 0;
		for (int i=1; i<ln; i++) {
			long t = Long.parseLong(s.substring(0, i))*Long.parseLong(s.substring(i, ln));
			if (max < t) {
				max = t;
			}
		}

		int res = rec((int)max);
		return res == -1 ? -1 : (res + 1);
	}

	static void solve() {
		int q = in.nextInt();

		while (q-- > 0) {
			int n = in.nextInt();
			f = new boolean[1000001];

			out.println(rec(n));
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 68824
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n, t;
	cin >> n >> t;
	int minl = INF, ans = 0, maxl = 0;
	int a[100001];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		minl = min(minl, a[i]);
		maxl = max(a[i] - minl, maxl);
	}
	minl = INF;
	for (int i = 0; i < n; i++) {
		minl = min(minl, a[i]);
		if (a[i] - minl == maxl) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int n,m,maxn;
	cin >> n >> m;
	maxn=max(n-m,n+m);
	cout << max(m*n,maxn);
}

Measured memory_bytes: 256
//
// Created by karth on 8/2/2020.
//
// BDTSL
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define INF 1e18
#define MOD 1e9+7

//void setIO(string s) {
//    ios_base::sync_with_stdio(0); cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".out").c_str(),"w",stdout);
//}
int factorial(int n) {
    if (n == 1)
        return 1;
    return n * factorial(n - 1);
}

int nCr(int n, int r) {
    return factorial(n) / (factorial(r) * factorial(n - r));
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    vector<int> vi;
    int ret = 0;
    for(int i = 0; i < n; ++i){
        long double x, y;
        cin >> x >> y;
        long double ans = sqrt(((x)*(x)) + ((y)*(y)));
        //cout << ans << " ";
        if(ans <= d){
            ret++;
        }
    }
   // cout << endl;
    cout << ret << "\n";
    return 0;
}



Measured memory_bytes: 3848
#include <iostream>
#include <set>

int main() {
    int q;
    std::cin >> q;

    std::set<int> my_set{};
    for (int i = 0; i < q; ++i) {
        int kind, x;
        std::cin >> kind >> x;

        decltype(my_set)::iterator iter;
        switch (kind) {
            case 0:
                my_set.insert(x);
                std::cout << my_set.size() << std::endl;
                break;
            case 1:
                iter = my_set.find(x);
                std::cout << ((iter != my_set.end()) ? 1 : 0) << std::endl;
                break;
            default:
                std::cerr << "kind: ?" << std::endl;
        }
    }
}


Measured memory_bytes: 12444
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,r,d;
	cin>>l>>r>>d;
	if(l%d==0)
	{
		cout<<((r/d)-(l/d)+1)<<endl;
	}
	else
	{
		cout<<((r/d)-(l/d))<<endl;
	}
	return 0;
}

Measured memory_bytes: 3508
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
using ll = long long;
using IR = pair<int, int>;

int A, B;

int main() {
	S2(A, B);
	for(int i = 1; i <= 1000; i++) {
		if (floor((double)i * 0.08) == A && floor((double)i * 0.1) == B) {
			P(i);
			return 0;
		}
	}
	P(-1);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<unordered_map>
#define int long long

using namespace std;

inline int read()
{
   int x=0,f=1;char ch=getchar();
   while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
   while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
   return x*f;
}

const int maxn = 2e5+1e2;

unordered_map<int,int> mp;
int n,m;
int a[maxn];
int ans;

void count(int x)
{
	int cnt=-1;
	for (int i=1;i<=2e9;i*=2)
	{
		if (i<x) continue;
		if (mp[i-x]) cnt=i-x;
		//if (mp[i-x]) cout<<i<<" "<<i-x<<endl;
	}
	if (cnt!=-1)
	{
		mp[cnt]--;
		ans++;
	}
}

signed main()
{
  n=read();
  for (int i=1;i<=n;i++) a[i]=read();
  sort(a+1,a+1+n);
  for (int i=n;i>=1;i--)
  {
      int pre=ans;
  	  count(a[i]);
  	  if (ans==pre)
  	    mp[a[i]]++;
  	  //cout<<ans<<endl;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 31760
#include<iostream>

int main()
{
    int N=0;
    int joyo,otsuri=0;

    std::cin >> N;

    joyo=N%1000;

    if(0 != joyo)
    {
        otsuri=1000-joyo;
        std::cout << otsuri;
        return 0;
    }
    std::cout << joyo;

    return 0;
}

Measured memory_bytes: 3572
score = int(input())

atcoder_class = 1

if 400 <= score < 600:
    atcoder_class = 8
elif 600 <= score < 800:
    atcoder_class = 7
elif 800 <= score < 1000:
    atcoder_class = 6
elif 1000 <= score < 1200:
    atcoder_class = 5
elif 1200 <= score < 1400:
    atcoder_class = 4
elif 1400 <= score < 1600:
    atcoder_class = 3
elif 1600 <= score < 1800:
    atcoder_class = 2
elif 1800 <= score < 2000:
    atcoder_class = 1

print(atcoder_class)

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

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    cin >> p[i];
  }
  
  int ans = 0;
  for (int i = 1; i < N - 1; i++){
    if (p[i - 1] < p[i] && p[i] < p[i + 1]){
      ans++;
    }
    else if (p[i - 1] > p[i] && p[i] > p[i + 1]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(j%2==1)
	    {
	      if(i%2==1)printf("#");
	      else printf(".");
	    }
	  else 
	    {
              if(i%2==1)printf(".");
	      else printf("#");
	    }
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}


Measured memory_bytes: 2032
n, m, k = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0

a = [0]
b = [0]

for i in range(n):
    a.append(a[i] + A[i])

for i in range(m):
    b.append(b[i] + B[i])

j = m

for i in range(n + 1):
    if a[i] > k:
        break
    while a[i] + b[j] > k:
        j -= 1
    else:
        ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47332
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int n, m;
    while (readf("%d %d\n", &n, &m), n || m) {
        int[] z = new int[m];
        foreach (i; 0 .. n) {
            int[] x = readln.chomp.split(" ").map!(to!int).array;
            foreach (j; 0 .. m) {
                z[j] += x[j];
            }
        }
        alias Tuple!(int, int) P;
        P[] p;
        foreach (i; 0 .. m) {
            p ~= P(i + 1, z[i]);
        }
        p.sort!"a[1] == b[1] ? a[0] < b[0] : a[1] > b[1]";
        writefln("%(%s %)", p.map!("a[0]"));
    }
}

Measured memory_bytes: 2068
k = gets.chomp.to_i
ar = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts ar[k - 1]

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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    
    int K,X;

    cin>>K>>X;

    if(K * 500 >= X)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

int main(){
    long int n, W;
    int i,j;
    long int dp[110][100010] = {0};
    long int w[110],v[110];

    scanf("%ld %ld",&n, &W);

    for(i = 1; i <= n ; i++){
        scanf("%ld %ld",&w[i],&v[i]);
    }
    
    for(i = 1; i <= n ;i++){
        for(j = 0; j <= W; j++ ){
            if(j-w[i] >= 0){
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }

        }
    }
    printf("%ld\n",dp[n][W]);
    return 0;


}

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

int main() {
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);
	
	if (b - a <= x) {
		if (b <= a) printf("delicious");
		else printf("safe");
	} else printf("dangerous");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    int n,m;
    cin >> n >> m;
    if(n < m)
        swap(n,m);
    if(n-1 > m){
        puts("0");
        return 0;
    }
    ll ans = 1;
    for(int i = 1; i <= n; ++i)
        ans = (ans * i)%MOD;
    for(int i = 1; i <= m; ++i)
        ans = (ans * i)%MOD;
    if(n == m)
        ans = (ans*2)%MOD;
    cout << ans << '\n';
}


Measured memory_bytes: 256
import itertools
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
    dum = input()
    if dum[0] == "M":
        m += 1
    elif dum[0] == "A":
        a += 1
    elif dum[0] == "R":
        r += 1
    elif dum[0] == "C":
        c += 1
    elif dum[0] == "H":
        h += 1
march = [m,a,r,c,h]
ans = 0
for i in itertools.combinations(march,3):
    if i.count(0) == 0:
        ans += i[0]*i[1]*i[2]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[110];
int main()
{
     cin>>n;
     for(int i=0;i<n;i++) cin>>a[i];
     int minx=a[0],maxx=a[0];
     for(int i=0;i<n;i++)
     {
            minx=min(minx,a[i]);
            maxx=max(maxx,a[i]);
     }
    cout<<maxx-minx<<endl;
    return 0;
}

Measured memory_bytes: 256
// 2014/08/30 Tazoe

#include <iostream>
using namespace std;

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

		if(N==0)
			break;

		int cnt0 = 0;		// 0個残っている景品の数
		int cnt1 = 0;		// 1個残っている景品の数

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

			if(k==0){
				cnt0++;
			}
			else if(k==1){
				cnt1++;
			}
		}

		if(cnt0+cnt1==N){
			cout << "NA" << endl;
		}
		else{
			cout << N-cnt0+1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
  
const int N = 16777217;
  
int n;
char data[16777217];
  
int conv(char c){
  switch(c){
  case 'A':
    return 1;
    break;
  case 'C':
    return 2;
    break;
  case 'G':
    return 3;
    break;
  case 'T':
    return 4;
    break;
  }
}
  
int hash(char str[10]){
  int res = 0, size = strlen(str), r = 1, i;
  for(i=size-1;i>=0;i--){
    res += r * conv(str[i]);
    r *= 4;
  }
  return res;
}
  
void insertElm(int d){
  data[d] = 1;
}
  
char findElm(int d){
  return data[d];
}
  
main(){
  char ope[13], str[13];
  int i;
  memset(data, 0, 16777217);
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s", ope);
    scanf("%s", str);
    if(!strcmp(ope, "insert")) insertElm(hash(str));
    else printf("%s\n", (findElm(hash(str)) ? "yes" : "no"));
  }
  return 0;
}


Measured memory_bytes: 18124
#include <bits/stdc++.h> 
using namespace std ;
int main () {
	int a , b , c , k ;
	cin >> a >> b >> c >> k ;
	if (k <= a) {
		cout << k ;
	}
	else if (k > a && k <= (a+b)) {
		cout << a ;
	}
	else {
		cout << a - (k-(a+b)) ;
	}
	return 0 ;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.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; }


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

    ll ans = 0;
    REP(i, 1, N+1)ans += i;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<math.h>
#include <cassert>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAXN 1200
struct node
{
	int t, n;
}a[110000];
int b[110000];
bool cmp(node a, node b)
{
	return a.n > b.n;
}
int main()
{
	int n, m,t=1;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &b[i]);
	}
	for (int i = 1; i <= m; i++)
	{
		scanf("%d %d", &a[i].t, &a[i].n);
	}
	sort(b + 1, b + n + 1);
	sort(a + 1, a + 1 + m, cmp);
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= a[i].t; j++)
		{
			if (a[i].n > b[t])
			{
				b[t] = a[i].n;
				t++;
			}
			else goto p;
		}
	}
p:
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ans += b[i];
	}
	printf("%lld", ans);
}


Measured memory_bytes: 1408
<?php
/**
 * Created by PhpStorm.
 * User: wahho
 * Date: 2017/01/07
 * Time: 20:44
 */

fscanf(STDIN, "%d %d", $in_k, $in_s);

$ans_kumi = 0;

for($x = 0; $x <= $in_k; $x++) {
    for($y = 0; $y <= $in_k; $y++) {
        if(($in_s - $x - $y >= 0) && ($in_s - $x - $y <= $in_k)){
            $ans_kumi++;
        }
    }
}

echo "$ans_kumi\n";

?>

Measured memory_bytes: 3704
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()

N = d_in()
S = s_in()

np_s = np.zeros(N+1, dtype=int)
for i in range(N):
    if S[i] == '#':
        np_s[i+1] = 1

cum_s = np.cumsum(np_s)

tot = cum_s[-1]
ans = N
for i in range(N+1):
    r_white = (N-i) - (tot - cum_s[i])
    l_black = cum_s[i]
    ans = min(ans, r_white + l_black)

print(ans)


Measured memory_bytes: 25008
N, L = map(int, input().split())
 
if L > 0: print(sum([i for i in range(L+1, L+N)]))
elif L+N-1 < 0: print(sum([i for i in range(L, L+N-1)]))
else: print(sum([i for i in range(L, L+N)]))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
   long a, b, S = 0;
	long m = 10;

	cin >> a;
   b = a;
	while(a/m != 0){
		S += a%10;
		a/=10;
	}
	S += a%10;

	if(b%S == 0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
   return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInt()
    val h = readIntList()

    var max = 0
    var cnt = 0
    var before = h[n - 1]
    for (i in n - 2 downTo 0) {
        if (h[i] < before) {
            max = kotlin.math.max(max, cnt)
            cnt = 0
        } else {
            cnt++
        }
        before = h[i]
    }
    max = kotlin.math.max(max, cnt)
    println(max)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


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

int main() {
  int n, m;
  cin >> n >> m;
  double a[n], b[n], c[m], d[m];

  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }

  for (int i = 0; i < n; i++) {
    int cp = 1000;
    double md = 1e9;
    for (int j = 0; j < m; j++) {
      if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < md) {
        cp = j + 1;
        md = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      }
    }
    cout << cp << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int que(int N,string S){
    int x=0,m=0;
    for (int i=0;i<N;i++){
        if (S[i]=='I') x++;
        else x--;
        m=max(x,m);
    }
    return m;
}
int main(){
    int N;
    string S;
    cin >> N >> S;
    cout << que(N,S)<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
L = len(S)

while L:
  f = True
  if L >= 7:
    if S[L-7:L] == "dreamer":
      L -= 7
      f = False
  if L >= 6:
    if S[L-6:L] == "eraser":
      L -= 6
      f = False
  if L >= 5:
    if S[L-5:L] == "dream" or S[L-5:L] == "erase":
      L -= 5
      f = False
  if f:
    break

if L:
  print("NO")
else:
  print("YES")

Measured memory_bytes: 3188