akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	//ll a[200] = {};
	//ll b[200] = {};
	//ll v[3] = {};
	//ll *a, *b, *x;
	string S,T,U[52];
	ll count = 0;
	ll count2 = 0;
	ll sum = 0;
	ll min = 100000000000000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	
	
	//char p;


	

	

	//cin >> S;
	
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	
	cin >> N;
	//a = (ll *)malloc(A * sizeof(ll));
	vector<ll> a(N);
	rep(i,0,N){
		cin >> a[i];
		sum += a[i];
	}



		rep(i, 0, N-1) {
			max += a[i];

			if (llabs(sum - 2 * max) < min)
				min = llabs(sum - 2 * max);

			//max = 0;
		}

		

		//cout << max << "," << smax << endl;

	
		



	cout << min << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	

	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	return 0;

}

ll gcd(ll a, ll b) {
	ll x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return x/b;
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.nextLine());

        long max = 0;
        for (long i = 1; i <= N; i++) {
            max += i;
        }
        System.out.println(max - N);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
using namespace std;

int a[MAX], n;
long long f1[MAX], f2[MAX], y;

void setf(){
  f1[0] = f1[1] = 1;
  for(int i = 1; i <= n; i++) f1[i+1] = f1[i]*(i+1) % MOD;
  y = f1[n+1]; f2[n+1] = 1;
  for(int i = MOD-2; i; i/=2){
    if(i&1) f2[n+1] = f2[n+1] * y % MOD;
    y = y*y % MOD;
  }
  for(int i = n; i >= 0; i--) f2[i] = f2[i+1]*(i+1)%MOD;
}

int main(){
  int x, t, i;
  long long ans;
  scanf("%d", &n);
  for(i = 1; i <= n+1; i++){
    scanf("%d", &t);
    if(a[t]) break;
    a[t] = i;
  }
  x = i - a[t] - 1;
  
  setf();
  
  for(i = 1; i <= n+1; i++){
    ans = f1[n+1]*f2[n+1-i]%MOD*f2[i]%MOD;
    if(i <= n-x) ans = (ans + MOD - f1[n-x-1]*f2[n-x-i]%MOD*f2[i-1]%MOD)%MOD;
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 3200
# 全縦線と全横線を全探索するとO(N^5)
# 50 ** 5 = 312500000
# 縦線の選び方は50 C 2だから2分の1になるのを考慮しても、78125000
# いや無理だろ……と思ったら公式がこの解法だった。衝撃。
# 二次元累積和を使うと各回の計算がO(1)になるので、O(N^4)となる。

# まず O(N^5)解法を作ってみよう。通るのかこれ?
# Python 3.8.2 ではTLE、PyPyではAC(1.2秒)

n, k = list(map(int, input().split()))
coords = [list(map(int, input().split())) for _ in range(n)]

ans = (3 * 10 ** 9) ** 2
for ix1, x1 in enumerate(coords):
    for x2 in coords[ix1+1:]:
        for iy1, y1 in enumerate(coords):
            for y2 in coords[iy1+1:]:
                point_in_rect = 0
                for c in coords:
                    # ソートしてない。
                    if (c[0] - x1[0]) * (c[0] - x2[0]) <= 0 and (c[1] - y1[1]) * (c[1] - y2[1]) <= 0:
                        point_in_rect += 1
                if point_in_rect >= k:
                    ans = min(ans, abs((x1[0] - x2[0]) * (y1[1] - y2[1])))

print(ans)


Measured memory_bytes: 69200
# import sys
# sys.setrecursionlimit(10 ** 6)


def cmb2(n, r, mod):
    if n < r:
        return 0
    re = 1
    for i in range(n - r + 1, n + 1):
        re = (re * i) % mod
    for i in range(1, r + 1):
        re = (re * inverse(i, mod)) % mod
    return re % mod


def inverse(a, p):
    a_, p_ = a, p
    x, y = 1, 0
    while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
    x %= p
    return x


# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(n, a, b):
    mod = 10 ** 9 + 7
    ans = pow(2, n, mod)
    ans = (ans - cmb2(n, a, mod)) % mod
    ans = (ans - cmb2(n, b, mod)) % mod
    ans -= 1  # remove zero flower pattern
    print(ans)


if __name__ == '__main__':
    n, a, b = map(int, input().split())
    solve(n, a, b)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vll s(60, 1);
void init(){rep(i, 1, 60) s[i] = s[i-1] * 2;}
int main(int argc, char const *argv[]) {
  ll m, k;std::cin >> m >> k;
  init();
  if(k>=s[m]){
    std::cout << -1 << '\n';
    return 0;
  }
  if(m==1){
    std::cout << (k==0?"0 0 1 1":"-1") << '\n';
    return 0;
  }
  if(k==0){
    re(i, s[m]){
      std::cout << i << " ";
      std::cout << i << (i==s[m]-1?"\n":" ");
    }
    return 0;
  }
  set<ll> B;
  re(i, s[m]) if(i!=k) B.insert(i);
  vll A;
  if(k==1) A = vll{2, 3};
  else A = vll{1, k^1};
  B.erase(A[0]);B.erase(A[1]);
  vll ans;
  ans.push_back(k);
  for(auto itr = B.begin();itr!=B.end();itr++) ans.push_back((*itr));
  ans.push_back(A[0]), ans.push_back(A[1]);
  for(auto itr = B.end();B.size()!=0;){
    itr--;
    ans.push_back((*itr));
    if(itr==B.begin()) break;
  }
  ans.push_back(k);
  ans.push_back(A[1]), ans.push_back(A[0]);
  re(i, ans.size()) std::cout << ans[i] << (i==ans.size()-1?"\n":" ");
  return 0;
}


Measured memory_bytes: 10096
N, K = map(int, input().split())
A = list(map(int, input().split()))
end = max(A)
start = 0

def calc(n):
    num = K
    for a in A:
        s = max(a // n, 1)
        for cnt in range(s, a):
            if a / cnt <= n:
                num -= cnt - 1
                break
        if num < 0:
            return False
    return True


while end - start > 1:
    mid = (end + start) // 2
    if calc(mid):
        end = mid
    else:
        start = mid

print(end)


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

public class P
{
    public int area { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var n = s.Length;
        var a = new int[n];
        for (int i = 0; i < n; i++)
            if (s[i] == '\\') a[i] = -1;
            else if (s[i] == '/') a[i] = 1;
        var st1 = new Stack<int>();
        var st2 = new Stack<P>();
        getAns(a, st1, st2);
        print(st2);
    }
    public static void print (Stack <P> st)
    {
        var n = st.Count();
        if (n == 0) { Console.WriteLine(0); Console.WriteLine(0);  return; }
        var a = new int[n];
        for (int i =    0; i < n; i++)
        {
            var w = st.Pop();
            a[i] = w.area;
        }
        Array.Reverse(a);
        Console.WriteLine(a.Sum());
        Console.Write("{0} ", n);
        for (int i = 0; i < n; i++)
            if (i == n - 1) Console.WriteLine(a[i]);
            else Console.Write("{0} ", a[i]);

    }
    public static void getAns(int[] a, Stack<int> st1, Stack<P> st2)
    {
        var n = a.Length;
        for (int i = 0; i < n; i++)
            if (a[i] == -1) st1.Push(i);
            else if (a[i] == 1 && st1.Count() > 0)
            {
                var id = st1.Pop();
                var area = i - id;
                getSum(id, area, st2);
            }
    }
    public static void getSum(int id, int area, Stack<P> st2)
    {
        while (true)
        {
            if (st2.Count() == 0) { st2.Push(new P { id = id, area = area }); return; }
            var w = st2.Peek();
            if (id > w.id) { st2.Push(new P { id = id, area = area }); return; }
            else { area += w.area; st2.Pop(); }
        }
    }
}



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

using namespace std;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  vector<int> a(n+1);
  vector<long long> b(n);
  a[0]=1;
  a[1]=1;
  b[0]=1;
  for(int i=2;i<n+1;i++){
    a[i]=a[i-1]*2;
  }
  for(int i=1;i<n;i++){
    b[i]=b[i-1]*10;
  }
  long long sum=0;
  for(int i=0;i<n;i++){
    long long m=0;
    for(int j=n-i-1;j>=0;j--){
      m+=a[j]*b[n-i-1-j];
    }
    int number=s[i]-'0';
    sum+=number*m*a[i+1];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int in[20][20];

int s[20];
int main()
  {
  int n, m, x;
  cin >> n >> m >> x;

  REP(i, n)
    {
    REP(j, m+1)
      cin >> in[i][j];
    }
  int res = 1e9;
  REP(mask, 1 << n)
    {
    int cost = 0;
    REP(i, n)
      {
      if(mask & (1 << i))
        {
        REP(j, m+1)s[j] += in[i][j];
        }
      }
    
    bool ok = 1;
    REP(j, m)
      {
      if(s[j + 1] < x)ok = 0;
      }
    if(ok)mini(res, s[0]);
    REP(j, m+1)s[j] = 0;
    }
  if(res > 9e8)cout << -1 << endl;
  else cout << res << endl;
  }


Measured memory_bytes: 3636
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int a, b;
	while (cin >> a>> b)
	{
		int x = a + b;
		int count = 1;
		while (x >= 10)
		{
			x = x/10;
			count++;
		}
		COUT(count);
	}
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

const int MAX = 1e5 * 3 + 10;
int N;
long long a[MAX];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N * 3; ++i) {
		scanf("%lld", a + i);
	}
	sort(a, a + 3 * N);
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += a[3 * N - (i + 1) * 2];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 2560
// Problem : B - Papers, Please
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin >> n;
	//vector<int> v(n);
	int f=0;
	for(int i=0;i<n;i++)
	{
		int u;
		cin >> u;
		if(u%2);
		else
		{
			if(u%3==0 || u%5==0);
			else
			f=1;
		}
	}
	if(f)
	cout << "DENIED" << endl;
	else
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int[] n = new int[3];
    n[0] = Integer.parseInt(scan.next());
    n[1] = Integer.parseInt(scan.next());
    n[2] = Integer.parseInt(scan.next());
    scan.close();
    Arrays.sort(n);
        if(n[0] + n[1] == n[2]){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
}
}


Measured memory_bytes: 8916
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = (1..n).map { sc.nextInt() }
    val sum = Array(n) {0}
    for (i in (n-1) downTo 0) {
        sum[i] += d[i]
        if (i != n - 1) {
            sum[i] += sum[i + 1]
        }
    }
    var ans = 0
    for (i in 0..(n-2)) {
        ans += d[i] * sum[i + 1]
    }
    println(ans)
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    ll z,w;cin>>z>>w;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(n==1){
        cout<<abs(a[0]-w)<<endl;
    }
    else{
        cout<<max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, 0, n) cin >> a[i];
    int ans = a[0];
    rep (i, 0, n) {
        int sum = gcd (a[i], ans);
        ans = ans * a[i] / sum;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3088
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,M,P;
  cin>>N>>M>>P;
  // vector<pair<int,int> > c[N];
  // REP(i,M){
  //   int A,B,C;
  //   cin>>A>>B>>C;
  //   A--;
  //   B--;
  //   C-=P;
  //   c[A].push_back(make_pair(B,C));
  // }
  int A[M],B[M],C[M];
  REP(i,M){
    cin>>A[i]>>B[i]>>C[i];
    A[i]--;
    B[i]--;
    C[i]-=P;
  }
  lint d[N];
  REP(i,N)d[i]=-1e12;
  d[0]=0;
  REP(i,N+1){
    REP(m,M){
      if(d[B[m]]<d[A[m]]+C[m]){
        d[B[m]]=d[A[m]]+C[m];
      }
    }
  }
  lint temp=d[N-1];
  REP(i,N+1){
    REP(m,M){
      if(d[B[m]]<d[A[m]]+C[m]){
        d[B[m]]=d[A[m]]+C[m];
      }
    }
  }
  if(d[N-1]>temp){
    cout<<-1<<endl;
    return 0;
  }
  cout<<max((lint)0,d[N-1])<<endl;
  return 0;
}


Measured memory_bytes: 384
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{s:String, t:String, a:i64, b:i64, u:String};
    println!("{} {}", if s==u {a-1} else {a}, if s==u {b} else {b-1});
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n,m;
  while(scanf("%d ",&n), n){
    scanf("%d ",&m);

    int am = 0;
    int nn = 2*n + 1;
    int ans = 0;

    REP(i,m){
      int c = getchar();
      if(am % 2 == 0){
	if(c == 'I')
	  am++;
	else
	  am = 0;
      }else{
	if(c == 'O')
	  am++;
	else
	  am = 1;
      }
      if(am == nn){
	ans++;
	am -= 2;
      }
    }

    printf("%d\n",ans);
  }
  return 0;
}

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

Measured memory_bytes: 3060
n, k, c = map(int, input().split())
s = input()
L = [-1]*k
R = [-1]*k
now = 0
cnt = 0
while now < n and cnt < k:
  if s[now] == "o":
    L[cnt] = now
    cnt += 1
    now += c+1
  else:
    now += 1
now = n-1
cnt = k-1
while now >= 0 and cnt >= 0:
  if s[now] == "o":
    R[cnt] = now
    cnt -= 1
    now -= c+1
  else:
    now -= 1
A = []
for i in range(k):
  if L[i] == R[i]:
    A.append(L[i]+1)
print(*A, sep="\n")

Measured memory_bytes: 31716
from collections import OrderedDict
import sys


def is_alphabet(s):
    if (0x41 <= ord(s) and ord(s) <= 0x5A) or (0x61 <= ord(s) and ord(s) <= 0x7A):
        return True
    else:
        return False


d = OrderedDict()
for i in range(0x61, 0x7B):
    d[chr(i)] = 0

S = sys.stdin.read().strip()
for s in S:
    if is_alphabet(s):
        d[s.lower()] += 1

for k, v in d.items():
    print("{} : {}".format(k, v))


Measured memory_bytes: 5964
// https://atcoder.jp/contests/abc064/tasks/abc064_d

package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	var s []byte
	fmt.Scanf("%s", &s)

	nest := 0
	for i := 0; i < len(s); i++ {
		if s[i] == '(' {
			nest++
		} else if s[i] == ')' {
			nest--
			if nest == -1 {
				s = append([]byte{'('}, s...)
				nest = 0
				i++
			}
		}
	}
	for i := 0; i < nest; i++ {
		s = append(s, ')')
	}
	fmt.Println(string(s))
}


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

using namespace std;

#define sp(x) cout << setprecision(x);
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define inf 200000000

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<vector<ll>> f(n), p(n);
	ll in1;
	REP(i, n){
		REP(k, 10){
			cin >> in1;
			f[i].push_back(in1);
		}
	}
	ll in2;
	REP(i, n){
		REP(k, 11){
			cin >> in2;
			p[i].push_back(in2);
		}
	}

	//1 << 32 をintでやっちゃだめlong long でやりましょう
	//あとlong long に代入するときは(1LL) をかけるのもおすすめ
	//j: 0b0000000101 だとしたら、時間帯0と2に空いている
	// dight9876543210
	// 1 =0b0000000001
	//2^10 - 1 =0b1111111111 右からkbit目は時間帯kにおいてjoisinoお姉さんの店が空いているかどうかを表している
	//  1<<k =0b1000000000 (k = 9)
    ll ans = -INT64_MAX*0.99;
	for (ll j = 1; j < 1024 /* = (2^10)*/; j++){ //joisinoの店のかいへい
        ll temp = 0;
		for (ll i = 0; i < n; ++i){ //ｎこの店
			ll c = 0;
			/*
            // 店iとjoisinoお姉さんの開く店の両方が営業している時間帯の個数をciとする
            
			//時間帯ｋにおいてjoisinoお姉さんの店が空いている=> j(2)の右からk桁目で１
            // j:=時間帯kにおいてjoisinoお姉さんの店が空いているかどうかを表している
            //     9876543210
            // j:= 1010101011
            // AND 0000100000 = 1<<k
            //     0000100000
            */
           // 
           // p[i][c] := ???
			for (ll k = 0; k < 10; ++k){
				if (f[i][k] && (j & (1 << k))) ++c;
				
			}
            temp += p[i][c]; 
		}
        if(temp>ans) ans = temp;
	}
	cout << ans << endl;
	return 0;
}

// bit全探索


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  long long X, Y;
  scanf("%lld", &X);
  scanf("%lld", &Y);
  long long temp = X;
  int ans = 0;
  while(temp<=Y){
    temp *= 2;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define modulo 998244353



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d,a;
    cin>>n>>d>>a;
    vi x(n),h(n);
    vii q(n);
    for(ll i=0;i<n;i++)
        cin>>q[i].F>>q[i].S;
    sort(q.begin(),q.end());
    for(ll i=0;i<n;i++)
    {
        x[i]=q[i].F;
        h[i]=q[i].S;
    }
    set <ii> s;
    ll sum=0;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        while(!s.empty() && (s.begin()->F)<x[i])
        {
            sum-=s.begin()->S;
            s.erase(s.begin());
        }
        if(sum<h[i])
        {
            ll extra=h[i]-sum;
            ll bombs=(extra+a-1)/a;//i.e    ceil(extra)/a
            sum+=bombs*a;
            ans+=bombs;
            s.insert(mp(x[i]+2*d,bombs*a));
        }
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 12800
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int[] ary =new int[2];
    	for(;;){
    		ary[0]=sc.nextInt();
    		ary[1]=sc.nextInt();
    		if(ary[0]==0&&ary[1]==0){
    			break;
    		}
    		Arrays.sort(ary);
    		System.out.println(ary[0]+" "+ary[1]);
    	}
    	
    }
}


Measured memory_bytes: 34660
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n - 1];
        for(int i = 0 ; i < n - 1 ; i++ ){
            b[i] = sc.nextInt();
        }
        for(int i = 1 ; i < n - 1 ; i++ ){
            b[0] += Math.min(b[i - 1] , b[i]);
        }
        sc.close();
        System.out.println(b[0] + b[n - 2]);
    }
}

Measured memory_bytes: 35904
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MX=2e5+9;
int n,x,ans,a[MX];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        a[x]++;
    }
    for(int i=1;i<MX-1;i++){
        ans=max(ans,a[i]+a[i-1]+a[i+1]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

#define EPS (1e-10)
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
        int R0,W0,C,R; cin >> R0 >> W0 >> C >> R;
        if (R0+W0+C+R==0) break;
        int ans = 0;
        while (1) {
            if (double(R0+ans*R)/W0 > double(C) - EPS ) {
                cout << ans << ln;
                break;
            }
            ans++;
        }
    }
}



Measured memory_bytes: 3212
#include <stdio.h>
typedef long long LL;
LL n,x;
LL gcd(LL a,LL b){
	if(a<b)a^=b,b^=a,a^=b;
	if(a%b==0) return b;
	return gcd(a%b,b);
}
int main(){
	scanf("%lld%lld",&n,&x);
	printf("%lld",(n-gcd(n,x))*3);
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
h,w=list(map(int,input().split()))

b=['.'*(w+2)]
for _ in range(h):
    b.append('.'+input()+'.')
b.append('.'*(w+2))

#print(b)
ok = 1
for i in range(1,h+1):
    for j in range(1,w+1):
#        print(i,j)
        if b[i][j] == '#' and b[i-1][j] == '.' and b[i+1][j] == '.' and b[i][j-1] == '.' and b[i][j+1] == '.':
            ok=0
            break
    if ok==0:
        break

if ok==1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string A, B;
    cin >> A >> B;
    string C = A + B;
    reverse( ALL( C ) );
    cout << ( C == A + B ? "YES" : "NO" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 5003
#define ll long long

using namespace std;

int n, m, a, b;
int pos[N];
ll f[N][N << 1];

int main(){
	cin >> n >> a >> b; m = n * 2 + 1;
	for(int i = 1; i <= n; ++i){
		int x; scanf("%d", &x);
		pos[x] = i * 2;
	}
	memset(f, 127, sizeof f);
	for(int j = 1; j <= m; ++j) f[0][j] = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j){
			ll tmp = (j != pos[i]) * (j < pos[i] ? b : a);
			tmp += f[i - 1][j - !(j & 1)]; 
			f[i][j] = min(f[i][j - 1], tmp);
		}
	cout << f[n][m] << endl;
	return 0;
}

Measured memory_bytes: 391424
#include <iostream>
using namespace std;
pair <char, int> A[4005];
bool X[4005][4005];
int CostW[2005][2005];
int CostB[2005][2005], N, DP[2005][2005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= 2 * N; i++)
    {
        cin >> A[i].first >> A[i].second;
    }
}
void precalccostW()
{
    int cnt = 0;
    for(int i = 1; i <= N * 2; i++)
    {
        if(A[i].first == 'B')
            continue;
        int val = 0;
        for(int j = 1; j < i; j++)
            if(A[j].first == 'W' && A[i].second < A[j].second)
                val++;
        CostW[A[i].second][N + 1] = val;
        for(int j = 1; j < i; j++)
            if(A[j].first == 'B')
                CostW[A[i].second][A[j].second] = 1;
        for(int j = N; j >= 0; j--)
            CostW[A[i].second][j] += CostW[A[i].second][j + 1];
    }
}
void precalccostB()
{
    int cnt = 0;
    for(int i = 1; i <= N * 2; i++)
    {
        if(A[i].first == 'W')
            continue;
        int val = 0;
        for(int j = 1; j < i; j++)
            if(A[j].first == 'B' && A[i].second < A[j].second)
                val++;
        CostB[A[i].second][N + 1] = val;
        for(int j = 1; j < i; j++)
            if(A[j].first == 'W')
                CostB[A[i].second][A[j].second] = 1;
        for(int j = N; j >= 0; j--)
            CostB[A[i].second][j] += CostB[A[i].second][j + 1];
    }
}
void precalcDP()
{
    DP[0][0] = 0;
    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= N; j++)
        {
            if(i == 0 && j == 0)
                continue;
            DP[i][j] = 2000000005;
            if(i > 0)
            {
                DP[i][j] = min(DP[i][j], DP[i - 1][j] + CostW[i][j + 1]);
            }
            if(j > 0)
            {
                DP[i][j] = min(DP[i][j], DP[i][j - 1] + CostB[j][i + 1]);
            }
        }
    }
    cout << DP[N][N] << "\n";
}
int main()
{
    Read();
    precalccostB();
    precalccostW();
    precalcDP();
    return 0;
}


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c/b+min((c%b),1)<=a/d+min(a%d,1)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main(){
	int n, m, l;
	int A[100][100], B[100][100];
	long C[100][100]={0};
	int i, j, k;
	
	cin >> n >> m >>l;
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	
	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			for(k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			cout << C[i][j];
			if(j != l -1){
				cout << " ";
			}
		}
		cout << endl;
	}
	
	return 0;	
}

Measured memory_bytes: 3228
N = gets.to_i
a = gets.chomp.split.map(&:to_i)
rate_optional_color = 0

rate = a.each_with_object(Hash.new(0)){|i, hash|
    case i
    when 1..399 then
        hash[:grey] += 1
    when 400..799 then
        hash[:brown] += 1
    when 800..1199 then
        hash[:green] += 1
    when 1200..1599 then
        hash[:light_blue] += 1
    when 1600..1999 then
        hash[:blue] += 1
    when 2000..2399 then
        hash[:yellow] += 1
    when 2400..2799 then
        hash[:orange] += 1
    when 2800..3199 then
        hash[:red] += 1
    else
        rate_optional_color += 1
    end
}

puts [rate.size, 1].max
puts [rate.size + rate_optional_color, N].min

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int a,b,sum=0;
    cin>>a>>b;
    sum=a+b;
    if((a%3==0)||(b%3==0)||(sum%3==0)){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a[2001]={},b[4001]={};
	for(int i=0;i<=1000;i++)
		for(int j=0;j<=1000;j++)
			a[i+j]++;
	for(int i=0;i<=2000;i++)
		for(int j=0;j<=2000;j++)
			b[i+j]+=a[i]*a[j];
	
	for(int n;cin>>n;)
		cout<<b[n]<<endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

const int N = 2019;

void solve() {
  ll l, r;
  cin >>l >> r;
  ll m = min(r, l + N);
  ll ans = N;
  for (ll i = l; i <= m; i++) {
    for(ll j = i + 1; j <= m; j++) {
      ans = min(ans, (i * j) % N);
    }
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

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

using namespace std;

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

  vector<int> a(n);
  rep(i,n){
    int t;cin>>a[i];
  }
  sort(a.begin(), a.end());
  cout<<a[a.size()-1]-a[0];

  return 0;
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMinimum(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMaximum(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

    int A,B;
    cin >>A>>B;



    cout << A*B << endl;
}

Measured memory_bytes: 3636
/*
power and fast-scan code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 100001
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

// void fastscan(int &number) 
// { 
//     //variable to indicate sign of input number 
//     bool negative = false; 
//     register int c; 
  
//     number = 0; 
  
//     // extract current character from buffer 
//     c = getchar(); 
//     if (c=='-') 
//     { 
//         // number is negative 
//         negative = true; 
  
//         // extract the next character from the buffer 
//         c = getchar(); 
//     } 
  
//     // Keep on extracting characters if they are integers 
//     // i.e ASCII Value lies from '0'(48) to '9' (57) 
//     for (; (c>47 && c<58); c=getchar()) 
//         number = number *10 + c - 48; 
  
//     // if scanned input has a negative sign, negate the 
//     // value of the input number 
//     if (negative) 
//         number *= -1; 
// } 

bool comp(ll &a, ll &b){
    return a>b;
}

int main(){


    // #ifndef ONLINE_JUDGE 

    // // For getting input from input.txt file 
    // freopen("input.txt", "r", stdin); 

    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout); 
    // #endif 


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,m;
    cin>>n>>m;
    ll ans=(n*(n-1LL))/2LL;
    ans+=(m*(m-1LL))/2LL;
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod1e7(ll a){
  return (a % 1000000007);
}

ll mod1e9(ll a){
  return (a % 1000000009);
}

ll mod998(ll a){
  return (a % 998244353);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

vector<ll> fac(200001);
void factorial(){
  fac[0] = 1; 
  for(ll i=1; i < 200001; i++){
    fac[i] = mod998(fac[i-1]*i);
  }
}
    
ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return mod998(fac[n]/fac[r]/fac[n-r]);
}

int main(){
  string s; cin >> s; ll cnt1 = 0; 
  
  rep(i,(long long)(s.size())){
    if(s[i] == '1') cnt1++;
  }
  
  cout << min(cnt1,(long long)(s.size()) - cnt1)*2 << endl;
  
  
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll ans = 0;
  FOR(i,1,N){
    if(!(i % 3 == 0) && !(i % 5 == 0)) {
      ans += i;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3656
n = int(input())
v = list(map(int, input().split()))
c = [0] * 9
for i in range(0, n):
  if v[i] >= 3200:
    c[8] += 1
  else:
    c[v[i]//400] += 1
a = 0
for i in range(0, 8):
  if c[i] > 0:
    a += 1
print(max(a, 1), a+c[8])

Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll long long
# define ln cout<<'\n'
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
 
ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int factorial(int n)
{
    int x = 1; // 0! = 1

    for (int i = 1; i <= n; ++i)
        x *= i;

    return x;
}

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


using namespace std;

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(){
    ll N;
    cin >> N;
    vector<int> A(N+1);
    A[0] = 0;
    int tmp,Sum=0;
    for(int i = 1;i<N+1;i++){
        cin >>A[i];
    }
    A.pb(0);
    for(int i=0;i<N+1;i++){
        Sum += abs(A[i]-A[i+1]);
        
    }
    
    
    for(int i=1;i<N+1;i++){
        tmp = Sum-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]);
        cout << tmp << endl;
    }
}

Measured memory_bytes: 1656
# -*- coding: utf-8 -*-

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]
 
    tokens = lines[0].split(" ")
    a = int(tokens[0])
    b = int(tokens[1])
    c = int(tokens[2])

    return (a, b, c)


def solve(a, b, c):

    tmp = b
    count = 0
    while True:
        tmp = tmp - a
        if tmp >= 0:
            count += 1
        else:
            break

        if count >= c:
            break

    return count

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
n,m,x = map(int, input().split())

A = []
C = []
for i in range(n):
    Z = list(map(int, input().split()))
    C.append(Z[0])
    A.append(Z[1:])

ans = 10**12
for i in range(1<<n):
    rikai  = [0] * m
    cost = 0
    for j in range(n):
        if i&(1<<j):
            # 本を購入
            cost += C[j]
            for k in range(m):
                rikai[k] += A[j][k]            
    a = sum([1 for r in rikai if r >= x])
    if a == m:
        ans = min(ans,cost)
print(ans if ans != 10**12 else -1)

Measured memory_bytes: 9236
def main():
    """ ????????? """
    num = int(input().strip())
    F = []
    for n in range(num+1):
        if n < 2:
            F.append(1)
        else:
            F.append(F[n-1] + F[n-2])
    print (F[num])
if __name__ == '__main__':
    main()

Measured memory_bytes: 7724
#include <iostream>
#include <string>

using namespace std;

int main(){
	string str1, str2;
	char tmp;
	int i, length;

	getline(cin, str1);
	length = str1.size();
	//cout << length << endl;
	str2.reserve(length+1);
	for(i=0;i<length;i++){
		tmp = str1.at(length - i - 1);
		//cout << tmp << endl;
		str2 += tmp;
	}
	//str2 += '\0';
	cout << str2 << endl;
	//getline(cin, str1);

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[333][333];

signed main(){
    cin>>N;
    rep(i,N)rep(j,N)cin>>A[i][j];

    int ans=0;
    rep(i,N)for(int j=i+1;j<N;j++){
        bool flag=false;
        rep(k,N){
            if(A[i][k]+A[k][j]<A[i][j]){
                cout<<-1<<endl;
                return 0;
            }
            if(A[i][k]+A[k][j]>A[i][j])continue;
            if(i!=k&&j!=k)flag=true;
        }
        if(!flag)ans+=A[i][j];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forp(a,b,c) for(int (a)=(b); (a)<(c); (a++))
#define form(a,b,c) for(int (a)=(b); (a)>(c); (a--))
#define fori(a,b) for(auto (a):(b))
#define pb(a) push_back(a)
#define INF ((unsigned) ~0)
#define endl "\n"
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
 
int main()
{
    fastIO
    int n,k;
    cin>>n>>k;
    vi vec(n);
    forp(i,0,n) cin>>vec[i];
    sort(vec.begin(), vec.end());
    int sum=0;
    forp(i,0,k) sum+=vec[i];
    cout<<sum;
}

Measured memory_bytes: 3628