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

#define MOD 1000000007;

using namespace std;

typedef long long ll;

int main() {
    ll n;
    char c;
    vector<ll> d(26, 1);
    scanf("%lld\n", &n);
    for (ll i = 0; i < n; ++i) {
        scanf("%c", &c);
        ++d.at(c - 'a');
    }
    printf("%lld\n", accumulate(d.begin(), d.end(), 1LL, [](ll init, ll i) { return init = init * i % MOD; }) - 1);
    return 0;
}


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

ll gcd(ll a, ll b) {
    return (!b ? a : gcd(b, a % b));
}

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll a, b; cin >> a >> b;
    ll g = gcd(a, b);

    ll ans = 0;
    for (ll i = 2; i * i <= g; i++) {
        if (g % i == 0) {
            ans++;
            while (g % i == 0) {
                g /= i;
            }
        }
    }
    if (g > 1) ans++;

    cout << ans + 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String S = sc.next();
		int N = S.length();
		int ans = 0;
		int count0 = 0;
		int count1 = 0;

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				if ('0' != S.charAt(i))
					count0++;
			}
			if (i % 2 == 1) {
				if ('1' != S.charAt(i))
					count0++;
			}
		}

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				if ('1' != S.charAt(i))
					count1++;
			}
			if (i % 2 == 1) {
				if ('0' != S.charAt(i))
					count1++;
			}
		}

		ans = Math.min(count0, count1);
		System.out.println(ans);

	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main()
{
    int h,a;

    cin>>h;
    cin>>a;
    if(h>a){
        if(h%a!=0)
        cout<<h/a+1;
        else
        cout<<h/a;
    }else
    {
        cout<<1;
    }
    
    return 0;
    
}

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

struct data {
  long long x, y;
};

long long n, m, t;
vector<data> v;
set<long long> st;
vector<bitset<50000>> bv;

string solve();

int main() {
  cin >> n >> m >> t;
  v.resize(m);
  for(int i = 0; i < m; ++i) {
    cin >> v[i].x >> v[i].y;
    --v[i].x, --v[i].y;
  }
  cout << solve() << endl;
  return 0;
}

string solve() {
  if(t == 1) {
    bitset<50000> bs;
    for(int i = n; i < 50000; ++i) bs[i] = 1;
    bv.assign(n, bs);
    for(int i = 0; i < n; ++i) bv[i][i] = 1;
    for(int i = 0; i < m; ++i) {
      bv[v[i].x] |= bv[v[i].y];
      bv[v[i].y] = bv[v[i].x];
    }
    int id = -1;
    for(int i = 0; i < n; ++i)
      if(bv[i].all()) id = i;
    if(id == -1) return "-1";
    string res;
    bs[id] = 1;
    reverse(v.begin(), v.end());
    for(int i = 0; i < m; ++i) {
      if(bs[v[i].x] && !bs[v[i].y])
        res += '^';
      else
        res += 'v';
      bs[v[i].x] = bs[v[i].x] | bs[v[i].y];
      bs[v[i].y] = bs[v[i].x];
    }
    reverse(res.begin(), res.end());
    return res;
  }
  if(n == 2) return "-1";
  vector<long long> bs;
  map<long long, long long> mp;
  bs.resize(n);
  for(int i = 0; i < n; ++i) bs[i] = i, mp[i] = 1;
  reverse(v.begin(), v.end());
  string res;
  for(int i = 0; i < m; ++i) {
    if(mp[bs[v[i].x]] > 1) {
      --mp[bs[v[i].x]];
      ++mp[bs[v[i].y]];
      bs[v[i].x] = bs[v[i].y];
      res += 'v';
    }
    else {
      --mp[bs[v[i].y]];
      ++mp[bs[v[i].x]];
      bs[v[i].y] = bs[v[i].x];
      res += '^';
    }
  }
  reverse(res.begin(), res.end());
  return res;
}


Measured memory_bytes: 307584
#include<bits/stdc++.h>
#define LL  long long int
using namespace std;
LL a[100000];

int main()
{
    LL k,i;
    k = 10;
    for(i=0;i<k;i++)
        cin>>a[i];
    sort(a,a+k);
    for(i=k-1;i>=k-3;i--)
        cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    string s,r,l;
    cin>>s;
    int q;
    cin>>q;
    bool flag=true;
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        if(t==1){
            flag=(!flag);
        }else{
            int f; char c;
            cin>>f>>c;
            if((flag==true && f==1) || (flag==false && f==2)){
                l+=c;
            }else{
                r+=c;
            }
        }        
    }
    if(flag){
        reverse(l.begin(), l.end());
        s=l+s+r;
    }else{
        reverse(s.begin(), s.end());
        reverse(r.begin(), r.end());
        s=r+s+l;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 1348
import java.util.*

val sc = Scanner(System.`in`)
var S: String = sc.next()
val T: String = sc.next()

fun main(args: Array<String>) {
    var flg = false
    repeat(T.length + 1) {
        if (S == T) {
            flg = true
            return@repeat
        }
        S = S.substring(1) + S[0]
    }
    println(if (flg) "Yes" else "No")
}


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

int main(){
	string s,t;
	while(getline(cin,s),s!="END OF INPUT"){
		while(~s.find("  "))s.replace(s.find("  "),2," 9=_=9 ");
		stringstream ss(s);
		while(ss>>t)cout << (t=="9=_=9"?0:t.length());
		cout << endl;
	}
}

Measured memory_bytes: 0
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, r = map(int, input().split())
    if n >= 10:
        print(r)
    else:
        print(r + 100 * (10 - n))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
x, y = map(int , input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

if ((x in A) & (y in A)) or ((x in B) & (y in B)) or ((x in C) & (y in C)):
    print("Yes")
else:
    print("No")

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a >= k) {
        cout << a - k << " " << b << EOL;
    } else {
        cout << 0 << " " << max(0LL, b - (k - a)) << EOL;
    }
}


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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int Snack[101];

int main() {

  int n, k, d, kelp, ans = 0;
  cin >> n >> k;
  for(int i = 1;i <= k;i++){
    cin >> d;
    for(int j = 1;j <= d;j++){
      cin >> kelp;
      Snack[kelp]++;
    }
  }
  for(int i = 1;i <= n;i++){
    if(Snack[i] == 0){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>

using namespace std;

int main() {
	int coin[6]={500,100,50,10,5,1};
	int money,ans;
	while(scanf("%d",&money),money) {
		money=1000-money;
		ans=0;
		for(int i=0;i<6;i++) {
			ans+=money/coin[i];
			if(!(money%=coin[i])) break;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1028
#include <stdio.h>
int main()
{
  int s,ama,h,m;
  scanf("%d",&s);
  h=s/3600;
  s=s%3600;
  m=s/60;
  s=s%60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 1020
x = [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]
print(x[int(input())-1])

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }else if(b > a){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }
return 0;
}
    

Measured memory_bytes: 3096
import math
 
num = int(input())
value = input().split()
value = [int(x) for x in value]
 
res = 0
two = 0
for i in value:
    if i % 4 == 0:
        res += 1
    elif i % 2 == 0:
        two += 1
 
if two > 0:
    print("Yes" if res >= math.ceil((len(value)-two)/2) else "No")
else:
    print("Yes" if res >= math.floor(len(value)/2) else "No")

Measured memory_bytes: 14252
def prime_decomposition(n):
  i = 2
  table = [1]
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A,B = map(int, input().split())

As = list(set(map(int, prime_decomposition(A))))
Bs = list(set(map(int, prime_decomposition(B))))
print(len([a for a in As if a in Bs]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    vector<int> sh[26];
    for (int i = 0; s[i]; ++ i) {
        sh[s[i] - 'a'].emplace_back(i + 1);
    }
    for (int i = 0; t[i]; ++ i) {
        if (sh[t[i] - 'a'].empty()) {
            cout << "-1";
            return 0;
        }
    }
    ll ans = 0;
    int pos = 0;
    for (int i = 0; t[i]; ++ i) {
        auto x = upper_bound(sh[t[i] - 'a'].begin(), sh[t[i] - 'a'].end(), pos);
        if (x == sh[t[i] - 'a'].end()) {
            ans += (int)s.size() - pos;
            pos = 0;
            -- i;
        }
        else {
            ans += (*x - pos);
            pos = *x;
        }
    }
    cout << ans;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll,ll> P;
const ll INF = 1e10;
const ll MOD = 1e9+7;
vector<ll> number;
vector<P> k;
queue<ll> stock;
int main(){
    ll n,m,a;
    cin >> n >> m;
    rep(i,n){
        cin >> a;
        number.push_back(a);
    }
    SORT(number);
    ll b,c;
    rep(i,m){
        cin >> b >> c;
        k.push_back(P(c,b));
    }
    RSORT(k);
    int cnt = 0;
    rep(i,m){
        if (cnt > 200000) break;
        rep(j,k[i].second){
            stock.push(k[i].first);
            cnt++;
        }
    }
    rep(i,n){
        if (stock.empty() || stock.front() <= number[i]) break;
        number[i] = stock.front();
        stock.pop();
    }
    ll ans = 0;
    rep(i,n) ans += number[i];
    PRINT(ans);
}


Measured memory_bytes: 5104
#include<bits/stdc++.h> 
using namespace std; 
  
// Function to find that number divisible by 9 or not 
int check(string str) 
{ 
    // Compute sum of digits 
    int n = str.length(); 
    int digitSum = 0; 
    for (int i=0; i<n; i++) 
        digitSum += (str[i]-'0'); 
  
    // Check if sum of digits is divisible by 9. 
    return (digitSum % 9 == 0); 
} 
  
// Driver code 
int main() 
{ 
    string str;
    cin>>str;
    check(str)?  cout << "Yes" : cout << "No "; 
    return 0; 
} 

Measured memory_bytes: 3848
N = int(input())
As = list(map(int, input().split()))
 
dico = {}
dice = {}
for i in range(N):
  if i % 2 == 0:
    if As[i] not in dice:
      dice[As[i]] = 1
    else:
      dice[As[i]] += 1
  else:
    if As[i] not in dico:
      dico[As[i]] = 1
    else:
      dico[As[i]] += 1
    
cnto = [0,0]
cnte = [0,0]
 
o = -1
e = -1
for k in dico:
  if dico[k] > cnto[0]:
    cnto[1] = cnto[0]
    cnto[0] = dico[k]
    o = k
  elif dico[k] > cnto[1]:
    cnto[1] = dico[k]
    
for k in dice:
  if dice[k] > cnte[0]:
    cnte[1] = cnte[0]
    cnte[0] = dice[k]
    e = k
  elif dice[k] > cnte[1]:
    cnte[1] = dice[k]
  
if o == e:
  print(N-max(cnto[0]+cnte[1],cnte[0]+cnto[1]))
else:  
  print(N-cnto[0]-cnte[0])

Measured memory_bytes: 98348
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int keta(long long int a){
	if (a == 0)
		return 0;
	else
		return 1 + keta(a/10);
}

int main(void){
	int min = 1000;

	long long int n;
	cin >> n;


	for (int i = 1; i <= sqrt(n); i++){
		if (n % i == 0){
			min = keta(n/i);
		}
	}

	cout << min << endl;
}

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

using namespace std;

int main(){
	int N, K, ans = 1000000000; cin >> N >> K;
	vector<int> h(N);
	for(int i = 0; i < N; ++i) cin >> h[i];
	sort(h.begin(), h.end());
	for(int i = 0; i < N - K + 1; ++i){
		ans = min(ans, abs(h[i] - h[i + K - 1]));
	}
	cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n, m;
int d, p;

int main()
{
  while(cin >> n >> m, n){
    priority_queue<pii> que;
    rep(i, n){
      cin >> d >> p;
      que.push(mp(p, d));
    }

    while(m > 0 && !que.empty()){
      p = que.top().first;
      d = que.top().second;
      if(d <= m){
        m -= d;
        que.pop();
      }
      else{
        que.pop();
        que.push(mp(p, d - m));
        m = 0;
     }
    }

    int res = 0;
    while(!que.empty()){
      res += que.top().first * que.top().second;
      que.pop();
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int N;
int main() {
  cin >> N;
  double ans = 0;
  rep(i,N) {
    double x; string u;
    cin >> x >> u;
    if (u == "JPY") ans += x;
    else {
      ans += 380000.0 * x;
    }
  }
  printf("%.12f\n", ans);
  return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[100000];
int colors[100000];

int main()
{
	int N;
	int head = 99999, tail = 100000;

	cin >> N;
	rep(i, N) cin >> A[i];

	rep(i, N) {
		if (i == 0) {
			colors[head] = A[i];
			continue;
		}
		else if (A[i] <= colors[head]) {
			head--;
			colors[head] = A[i];
		}
		else {
			int* it = lower_bound(colors + head, colors + tail, A[i]);
			it--;
			*it = A[i];
		}
	}

	cout << tail - head << endl;

	return 0;
}


Measured memory_bytes: 1024
/*
				C++
				encoding: UTF-8
				Modified: <07/Sep/2019 05:55:53 PM>

				✪ H4WK3yE乡
				Mohd. Farhan Tahir
				Indian Institute Of Information Technology (IIIT), Gwalior
*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define         ll                     long long
#define         ve                     vector
#define         pb                     push_back
#define         endl                   "\n";
#define         ff                     first
#define         ss                     second
#define         pii                    pair<int, int>
#define         len(v)                 int(v.size())
#define         all(v)                 v.begin(), v.end()
#define         reset(a, b)            memset(a, b, sizeof(a));
#define         fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define         dfr(i, s, n)           for (int i = s ; i > n ; --i)

void pr () {
    cout << "\n";
}

template < typename T, typename... ARGS > void pr (const T& t, ARGS... args) {
    cout << t << " ";
    pr (args...);
}

// clang-format on

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	int b[n];
	b[0] = 0;
	fr (i, 1, n) cin >> b[i];
	int a[n + 1];
	a[1] = a[2] = b[1];
	int prv = a[2];
	fr (i, 3, n + 1) {
		a[i] = b[i - 1];
		if (prv > b[i - 1]) a[i - 1] = b[i - 1];
		prv = a[i];
	}

	int ans = 0;
	fr (i, 1, n + 1) ans += a[i];
	pr (ans);
	return 0;
}


Measured memory_bytes: 256
'''
問題文
	数列 a1,a2,...,an が以下の条件を満たすとき、 /\/\/\/ と呼ぶことにします。
	・各 i=1,2,..,n−2 について、ai=ai+2
	・数列に現れる数はちょうど 2 種類
	偶数長の数列 v1,v2,...,vn が与えられます。 
	要素をいくつか書き換えることでこの数列を /\/\/\/ にしたいです。 書き換える要素の数は最小でいくつになるか求めてください。

制約
2 ≤ n ≤ 10^5
n は偶数
1 ≤ vi ≤ 10^5
vi は整数

入力
入力は以下の形式で標準入力から与えられる。
n
v1 v2 ... vn

出力
書き換える要素数の最小値を出力してください。

入力例 1 
4
3 1 3 2
出力例 1 
1
数列 
3,1,3,2 は /\/\/\/ ではありませんが、
1 要素書き換えることで /\/\/\/ にすることができます。 例えば、4 要素目を書き換えて 3,1,3,1 とすればよいです。

入力例 2 
6
105 119 105 119 105 119
出力例 2 
0
数列 
105,119,105,119,105,119 は /\/\/\/ です。

入力例 3 
4
1 1 1 1
出力例 3 
Copy
2
数列 
1,1,1,1 は 1 種類の数からなる数列であるため、 /\/\/\/ ではありません。
'''

import collections

def calcChange(even_list, odd_list) :
	"""
	/\/\/\/にするために変更する要素数を算出

	Parameters
	----------
	even_list : list
			偶数番目の要素のリスト
	odd_list : list
			奇数番目の要素のリスト
	
	Returns
	-------
	change : int
			/\/\/\/にするために変更する要素数
			
	"""	

# 1:60   1:60
# 2:50   2:60
# 3:30   3:20
 
 
	# 変更回数を代入する変数
	change = 0

	# 各リストについて、要素名:要素数 の辞書を、Counterで作成
	even_counter = collections.Counter(even_list)
	odd_counter = collections.Counter(odd_list)
	
	# 最多要素を取得
	most_even = even_counter.most_common()
	most_odd = odd_counter.most_common()

	# 最多要素が被っていない
	if most_even[0][0] != most_odd[0][0] :
		even_change = len(even_list) - most_even[0][1]
		odd_change  = len(odd_list)  - most_odd[0][1]
		change = even_change + odd_change
	# 被ってる
	else :
		if len(most_even)==1 and len(most_odd)==1 :# 全かぶり
			change = len(even_list)
		else : # even と odd のどちらの最多要素を残すかを、それぞれの場合で比較して少ない方を採用する。
			even_1 = (len(even_list) - most_even[0][1]) + (len(odd_list)  - most_odd[1][1])
			odd_1  = (len(even_list) - most_even[1][1]) + (len(odd_list)  - most_odd[0][1])
			change = min(even_1, odd_1)


	return change



def main():
	'''
	メイン関数
	'''
	# 数列の大きさ
	n = int(input())
	# 数列
	v = list(map(int, input().split()))

	# 偶数番目を抽出した配列
	v_e = [ v[i] for i in range(0,n) if i%2==0 ]

	# 奇数番目を抽出した配列
	v_o = [ v[i] for i in range(0,n) if i%2==1 ]

	print(calcChange(v_e, v_o))


if __name__ == '__main__':
	main()




Measured memory_bytes: 21944
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-11;
const int MOD = 1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

vector<int> G[200];
int n;

bool ques(int a,int b){
	cout << "? ";
	for(int i = 0;i < n;i++){
		if(i == a || i == b) printf("1");
		else printf("0");
	}
	cout << endl;
	int d;
	cin >> d;
	return d;
}

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			if(ques(i,j)) G[i].push_back(j);
		}
	}
	cout << "!";
	for(int i = 0;i < n;i++){
		for(int j = 0;j < G[i].size();j++){
			printf(" (%lld,%lld)",i,G[i][j]);
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, x;
	cin >> a >> b >> x;
	if (a + b >= x&&a <= x) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 256
function bomb(y,x,v){
var arr=[[y,x,v]];
while(true){
if(arr.length==0)break;
var yxv=arr.shift();
var y=yxv[0];
var x=yxv[1];
var v=yxv[2];
   var dy=[0,0,-1,1];
   var dx=[-1,1,0,0];
   for(var i=0;i<4;i++){
      var yy=y+dy[i];
      var xx=x+dx[i];
      if(yy<0 || yy>=n[0] || xx<0 || xx>=n[1])continue;
      if(v==yx[yy][xx]){yx[yy][xx]=0;arr.unshift([yy,xx,v])}
   }
}
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=(Arr.shift()).split(" ").map(Number);
   if(n[0]==0 && n[1]==0)break;
   var yx=[];
   for(var i=0;i<n[0];i++){
      var arr=(Arr.shift()).split("");
      yx.push(arr);
   }
   var cnt=0;
   for(var i=0;i<n[0];i++){
      for(var j=0;j<n[1];j++){
         var v=yx[i][j];
         if(v=="@" || v=="#" || v=="*"){cnt++;yx[i][j]=0;bomb(i,j,v);}
      }
   }
   console.log(cnt);
}

Measured memory_bytes: 11788
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include<algorithm>
#include <set>
#include <stdlib.h>

using namespace std;

int main()
{
    map<int,int>m;
    int n,r;
    cin>>n;
    for(int j=1;j<=100;j++)
    {
        for(int k=1;k<=100;k++)
        {
            for(int h=1;h<=100;h++)
            {
                r=(j*j)+(k*k)+(h*h)+(j*k)+(k*h)+(j*h);
                m[r]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<m[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 5372
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int n;
	std::cin >> n;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	for (int i = 0; i < n; i++)
	{
		std::string s;
		std::cin >> s;
		if (s == "AC")
			++ac;
		else if (s == "WA")
			++wa;
		else if (s == "TLE")
			++tle;
		else
			++re;
	}
	std::cout << "AC x " << ac << '\n';
	std::cout << "WA x " << wa << '\n';
	std::cout << "TLE x " << tle << '\n';
	std::cout << "RE x " << re << '\n';
	return (0);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

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

    int N;cin >> N;
    cout<<(N-2)*180<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;

		for (int i = a; i <= b ; i++) {
			String s = "" + i;
			if (s.charAt(0) == s.charAt(4) && s.charAt(1) == s.charAt(3)) {
				ans++;
//				System.out.println(i);
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 34640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;
    cin>>n;
    int h[n+2];
    h[0]=h[n+1]=0;
    rep(i,n)cin>>h[i+1];
    int ans=0;
    while(true){
        bool flag=0;
        rep(i,1,n+2){
            if(h[i]>0&&h[i-1]==0){
                flag=1;
            }
            if(h[i]==0){
                if(flag){
                    ans++;
                    break;
                }
                else{
                    if(i==n+1){
                        cout<<ans<<endl;
                        exit(0);
                    }
                    else continue;
                }
            }
            h[i]--;
        }
    }
}




Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define int ll

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
#define kill _kill

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll btc = 30;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(2e9 + 239);
const ll MOD = 1e9 + 7;

//random
#ifdef ONPC
mt19937_64 rnd(239);
#else
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 25;
const int T = (1 << 18) + 239;
const int B = 500;
const int X = 1e4 + 239;

int32_t main()
{
#ifdef ONPC
    freopen("input", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int k;
    cin >> k;
    cout << (360 / gcd(360, k)) << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll H,W,K,cnt=0;
    cin>>H>>W>>K;
    char c[H][W];
    vector<vector<ll>> ans(H,vector<ll> (W,INF));
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            cin>>c[i][j];
            if(c[i][j]=='#'){
                cnt++;
                ans[i][j]=cnt;
            }
        }
    }
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            if(c[i][j]=='#'){
                cnt=ans[i][j];
                ll k=1;
                while(j+k<W){
                    if(ans[i][j+k]!=INF) break;
                    ans[i][j+k]=cnt;
                    k++;
                }
                k=1;
                while(j-k>=0){
                    if(ans[i][j-k]!=INF) break;
                    ans[i][j-k]=cnt;
                    k++;
                }
            }
        }
    }
    for(ll i=1;i<H;i++){
        ll sp=0;
        for(ll j=0;j<W;j++){
            if(ans[i][j]==INF) sp++;
        }
        if(sp==W){
            for(ll k=0;k<W;k++){
                ans[i][k]=ans[i-1][k];
            }
        }
    }
    for(ll i=H-2;i>=0;i--){
        ll sp=0;
        for(ll j=0;j<W;j++){
            if(ans[i][j]==INF) sp++;
        }
        if(sp==W){
            for(ll k=0;k<W;k++){
                ans[i][k]=ans[i+1][k];
            }
        }
    }
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            cout<<ans[i][j];
            if(j!=W-1) cout<<" ";
        }
        cout<<endl;
    }
}

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

namespace ABC131_D___Megalomania
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var works = new Work[N];
            for (int i = 0; i < N; i++)
            {
                var read = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
                works[i] = new Work(read[0], read[1]);
            }

            works = works.OrderBy(w => w.limit).ToArray();
            bool canFinish = true;
            long workingTime = 0;

            foreach (Work w in works)
            {
                workingTime += w.time;
                if (workingTime > w.limit)
                {
                    canFinish = false;
                    break;
                }
            }

            Console.WriteLine(canFinish ? "Yes" : "No");
        }
    }
    class Work
    {
        public long time;
        public long limit;

        public Work(long _time, long _limit)
        {
            time = _time;
            limit = _limit;
        }
    }
}


Measured memory_bytes: 36124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#define fir first
#define sec second
using namespace std;

int n,m;

int main() {
    scanf("%d%d",&n,&m);
    printf("%d\n",n*(n-1)/2+m*(m-1)/2);

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<long long> X(N - 1);
    X[0] = A[0];
    vector<long long> Y(N - 1);
    Y[0] = A[0] * (-1);
    for (int i = 0; i < N; i++) {
        Y[0] += A[i];
    }
    for (int i = 1; i < N - 1; i++) {
        X[i] = X[i - 1] + A[i];
        Y[i] = Y[i - 1] - A[i];
    }

    long long ans = abs(X[0] - Y[0]);
    for (int i = 0; i < N - 1; i++) {
        ans = min(ans, abs(X[i] - Y[i]));
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.*;
     
    public class Main{
          public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();
                if(a >= b && a >= c){
                  System.out.println(a * 10 + b + c);
              } else if(b >= a && b >= c){
                    System.out.println(a + 10 * b + c);
                  } else {
                    System.out.println(a + b + c * 10);
                  }
                }
    }

Measured memory_bytes: 23764
def gcd(a,b):
	while(b):
		a,b = b,a%b
	return a
k = int(input())
ans=0
for a in range(1,k+1):
	for b in range(1,k+1):
		for c in range(1,k+1):
			ans+=gcd(a,gcd(b,c))

print(ans)

Measured memory_bytes: 68624
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int L;

int n,m;
vector< pair< int,pair<int,int> > > edges;

void solve(int ver,int R)
{
    n = ver;

    if (R <= 3)
    {
        int i;

        for (i=0;i<=R;i++)
        {
            edges.push_back(make_pair(ver,make_pair(ver+1, i)));
            n = ver+1;
        }

        return;
    }

    if (R % 2 == 1) ///Good
    {
        edges.push_back(make_pair(ver,make_pair(ver+1, 0)));
        edges.push_back(make_pair(ver,make_pair(ver+1, (R+1)/2)));

        solve(ver+1, R/2);
    }
    else ///Bad
    {
        edges.push_back(make_pair(ver,make_pair(-1, R)));
        solve(ver, R-1);
    }

    return;
}

int main()
{
    int i;

    scanf("%d",&L);

    solve(1,L-1);

    for (i=0;i<edges.size();i++)
    {
        if (edges[i].second.first == -1)
            edges[i].second.first = n;
    }

    m = edges.size();

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

    for (i=0;i<m;i++)
    {
        printf("%d %d %d\n",edges[i].first,edges[i].second.first,edges[i].second.second);
    }
}


Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	string s;
	cin>>s;
	rep(i,3)
		cout<<s[i];
	return 0;
}


Measured memory_bytes: 3612
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import qualified Data.IntMap as M

main = do
  BS.getLine
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  BS.getLine
  co <- BS.getContents
  let bcs = map (l2p . unfoldr (BS.readInt . BS.dropWhile isSpace)) $ BS.lines co
  let ans = compute as bcs
  mapM_ print ans

l2p [b,c] = (b,c)

compute :: [Int] -> [(Int,Int)] -> [Int]
compute as bcs = map snd $ tail $ scanl step (am, sum as) bcs
  where
    am = M.fromListWith (+) [ (a,1) | a <- as ]

step :: (M.IntMap Int, Int) -> (Int,Int) -> (M.IntMap Int, Int)
step (am, sum0) (b,c) = (am1, sum1)
  where
    numb = M.findWithDefault 0 b am
    numc = M.findWithDefault 0 c am
    am1 = M.insert c (numb+numc) $ M.delete b am
    sum1 = sum0 + numb * (c - b)


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


void solve(long long X){
    ll num=X/100;
    ll z=X-100*num;
    ll ans=0;
    rep(i,num){
        if(z<=num*1 and z%1==0) ans=1;
        else if(z<=num*2 and z%2==0) ans=1;
        else if(z<=num*3 and z%3==0) ans=1;
        else if(z<=num*4 and z%4==0) ans=1;
        else if(z<=num*5 and z%5==0) ans=1;
    }
    cout<<ans<<endl; 

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int A, B, C, D;
        A = Integer.parseInt (arr[0]);
        B = Integer.parseInt (arr[1]);
        C = Integer.parseInt (arr[2]);
        D = Integer.parseInt (arr[3]);
        System.out.println ((B + C - 1) / B <= (A + D - 1) / D ? "Yes" : "No");
        return;
    }
}

Measured memory_bytes: 32692
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  VEC<int> L(N);
  REP(i, 0, N) cin >> L[i];
  sort(ALL(L));
  LL cnt = 0;
  REP(a, 0, N - 2) {
    REP(b, a + 1, N - 1) {
      int la = L[a];
      int lb = L[b];
      auto lim = lower_bound(ALL(L), la + lb);
      int dist = distance(L.begin() + b+1, lim);
      cnt += dist;
      // DUMP(la, lb, *lim, dist, cnt);
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b - a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll inf = 30;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n; cin >> n;
    ll ans = inf;
    rep(i,1,sqrt(n)+1){
        if(n%i != 0) continue;
        ll iketa=0;
        ll tmp = i;
        while(tmp>0){
            tmp /=  10;
            iketa++;
        }
        ll rketa = 0;
        tmp = n/i;
        while(tmp>0){
            tmp /= 10;
            rketa++;
        }
        ans = min(ans,max(rketa,iketa));
    }
    cout << ans << endl;
}

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

int n, m;

int main() {
    cin >> n >> m;
    int a[n][m];
    int b[m];
    int ans;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    
    for (int i = 0; i < n; i++) {
        ans = 0;
        for (int j = 0; j < m; j++) {
            ans += (a[i][j] * b[j]);
        }
        cout << ans << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    // 整数の入力
    int AB, BC, CA;
    cin >> AB >> BC >> CA;
	cout << AB * BC / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int gcd(int a ,int b){
    if(b == 0)
        return a;
    return gcd(b,a%b);
}


int main(){
    FIO
    int a,b;
    cin>>a>>b;
    int ans=0;
    ans=a*b;
    if(a>=10 || b>=10){
        ans=-1;
    }
    
    cout<<ans;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,s[100],l[100],a,b,c,d,i,j,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		s[i]=0;
		l[i]=1;
	}
	x=n*(n-1)/2;
	for(i=1;i<=x;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d)	s[a]+=3;
		else if(c<d)	s[b]+=3;
		else{
			s[a]++; s[b]++;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(s[i]<s[j]){
				l[i]++;
			}
		}
	}
	for(i=1;i<=n;i++)	printf("%d\n",l[i]);
	return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int a,b,k;
    cin>>a>>b>>k;k--;
    if(a+k>=b-k)
    {
        for(int i=a;i<=b;i++)cout<<i<<endl;
        return;
    }
    else
    {
        for(int i=a;i<=a+k;i++)cout<<i<<endl;
        for(int i=b-k;i<=b;i++)cout<<i<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int gcd(int x, int y){
    if(x < y) swap(x, y);
    if(x % y == 0) return y;
    return gcd(y, x % y);
}
int main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    for(int i = 0; i < N; i++){
        if(A[i] == K){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if(K > A[N - 1]){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    set<int> s;
    for(int i = 0; i < N - 1; i++){
        s.insert(gcd(A[i], A[i + 1]));
    }
    for(int i = 0; i < N; i++){
        if(s.count(gcd(K, A[i]))){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 4392
n = int(input())
sa = [0]
ans = float("INF")
for i, ai in enumerate(list(map(int, input().split()))):
    sa.append(sa[i] + ai)
for i in range(n + 1):
    ans = min(ans, abs(sa[i] - (sa[-1] - sa[i])))
print(ans)


Measured memory_bytes: 31516
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	cin >> n;
	cout << (n - 30) / 2 << endl;
}


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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int fours = 0, twos = 0, nones = 0;
  while(n--) {
    int x;
    cin >> x;
    if(x%4 == 0) ++fours;
    else if(x%2 == 0) ++twos;
    else ++nones;
  }
  cout << (fours - nones >= (twos ? 0 : -1) ? "Yes" : "No") << endl;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    bool ok = false;
    int t = a;
    for(int i = 0; i < b; i++){
        if(a%b == c) ok = true;
        a += t;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define mod 1000000007
#define INF 1000000000000000


int main()
{

    int n;
    scanf("%d",&n);
    int ara[n+5];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
    }

    int ans=1;
    vector<int> vp;
    vp.pb(-ara[0]);

    for(int i=1;i<n;i++)
    {
        int y=upper_bound(vp.begin(),vp.end(),-ara[i])-vp.begin();
        if(y==vp.size())
        {
            ans++;
            vp.pb(-ara[i]);
        }
        else{
            vp[y]=-ara[i];
        }


    }
    printf("%d",ans);
}





Measured memory_bytes: 1276