akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    ul a=1,b=2,c,n;
    cin>>n;
    rep(i,n)c=a,a=a+b,b=c;
    cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){

  int temp, min;
  int n;
  int i, j, k;
  int A[N];
  int count;

  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);    
  }
  
  /* selection_sort */
  count=0; 
  for(i=0; i<n; i++){
    // i 番目の要素を暫定的に最小値とし添字を保存
    k=i;
    for(j=i; j<n; j++){
      // より小さい値が現れたら最小値の入れ替え
      if(A[j] < A[k]){
	k=j; // 添字を保存
      }
    }
    // このループを抜けるとk に最小値の添字が入っている
    // i 番目の要素と最小値の交換
    if (k > i)
    {
      temp = A[i]; 
      A[i] = A[k];
      A[k] = temp;
      ++count;
    }
  }
  
  for(i=0; i<n; i++){
    if(i == n - 1) printf("%d", A[i]);
    else printf("%d ", A[i]);
  }
  
  printf("\n");
  printf("%d", count);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int ans = a[0];
    for(int i = 1; i < N; i++) ans = __gcd(ans, a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}



int main()
{
   string S;cin>>S;
   int x=S.length();
   string print=string(x,'x');
   cout<<print<<"\n";
    
}

Measured memory_bytes: 27036
N,M = map(int,input().split())
shops = []
for i in range(N):
    price,B = map(int,input().split())
    shops.append([price,B])
shops.sort()
i = 0
money = 0
while M > 0:
    if shops[i][1] > M:
        money += M*shops[i][0]
        break
    else:
        money += shops[i][1] * shops[i][0]
        M -= shops[i][1]
    i += 1
print(money)

Measured memory_bytes: 20056
# coding: utf-8
from collections import Counter
import copy

n = int(input())

d_str = []
for __ in range(n):
    l_char = list(input())
    d_count = Counter(l_char)
    d_str.append(dict(d_count))

now_dict = d_str[0]

for i in range(1, n):
    dif_dict = d_str[i]
    next_dict = dict()
    for key, item in now_dict.items():
        if key in dif_dict:
            next_dict[key] = min(item, dif_dict[key])
        else:
            pass

    now_dict = copy.deepcopy(next_dict)

print_str = []
for tup in sorted(now_dict.items()):
    for item in range(tup[1]):
        print_str.append(tup[0])

print("".join(print_str))


Measured memory_bytes: 3692
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;

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

int main () {
  int n;
  cin>>n;
  vector<int> val(n);
  vector<int> cost(n);
  REP(i, n){
    cin >> val[i];
  }
  REP(i, n){
    cin >> cost[i];
  }
  int ans=0;
  REP(i, n){
    if(val[i]>cost[i])
      ans+=val[i]-cost[i];
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int r, g, b, n;
  readf("%d %d %d %d\n", &r, &g, &b, &n);
  
  int res;
  foreach (x; iota(0, n+1, r)) {
    foreach (y; iota(0, n+1, g)) {
      immutable t = n - (x + y);
      if (t < 0) {
        break;
      }
      if (t % b == 0) {
        res++;
      }
    }
  }
  res.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,b[21][100001]={};
int memo[1<<20];
int dp(int k,int bit){
  if(k == n) return 0;
  if(memo[bit] != -1) return memo[bit];
  int ret = INT_MAX;
  for(int i=1;i<=m;i++){
    if( (bit&1<<i-1) == 0){
      int isum = n-b[i][n];
      int rui = b[i][k+isum]-b[i][k];
      ret = min(ret,dp(k+isum,bit|1<<i-1)+rui);
    }
  }
  return memo[bit] = ret;
}
int main(){
  scanf("%d %d",&n,&m);
  int a;
  for(int i=1;i<=n;i++){
    scanf("%d",&a);
    for(int j=1;j<=m;j++){
      if(j != a) b[j][i]++;
      b[j][i] += b[j][i-1];
    }
  }
  fill(memo,memo+(1<<20),-1);
  printf("%d\n",dp(0,0));
  return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.14159265359;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int n;
    cin >> n;
    
    v_int a(n);
    ll suma = 0, sumb = 0, diff = 0;
    irep(i, n) { cin >> a[i]; suma += a[i]; }

    v_int q;
    int ans = 0;

    irep(i, n) { 
        int b; cin >> b;
        sumb += b;
        if(b > a[i]) {
            diff += b-a[i];            
            ans++;
        } else {
            if(b != a[i]) {
                q.push_back(a[i]-b);
            }
        }
    }
    
    if(suma < sumb) { 
        cout << -1 << endl;
        return 0;
    }
    
    sort(q.rbegin(), q.rend());
    irep(i, q.size()) {
        if(diff <= 0) { continue; }
        diff -= q[i];
        ans++;
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define rep(i,n) for(u64 i = 0; i < (u64) n; ++i)

typedef signed int s32;
typedef unsigned int u32;
typedef float f32;
typedef signed long long s64;
typedef unsigned long long u64;
typedef double f64;

using namespace std;
using str = string;
template<typename T>
using vec = vector<T>;
template<typename T>
using uset = unordered_set<T>;
template<typename T, typename S>
using umap = unordered_map<T, S>;

const u64 mod = 1000000007;
const f64 pi = 3.14159265359;

void solve()
{
        u32 k;
        str s;
        cin>>k>>s;
        if(s.size()>k) s=s.substr(0,k)+"...";
        cout<<s;
}

int main()
{
        ios::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        cout.precision(10);
        cout<<fixed;
        //for(cin>>t; t>0; --t)
        solve();
        return 0;
}

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

int N,K;
int a[100000];
int main (){
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    int sum = K;
    int cnt = 1;
    while( sum < N ){
        sum += K-1;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
// 2020-09-01 21:46:26
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int V = 10010;
vector<int> G[V];
void answer() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> c(n), ans(n, -1);
  int tot = 0;
  rep(i, n) {
    cin >> c[i];
    tot += c[i];
  }
  sort(RALL(c));
  tot -= c[0];
  queue<int> que;
  que.push(0);
  int ci = 0;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    ans[u] = c[ci++];
    for (int v : G[u]) {
      if (ans[v] == -1) {
        que.push(v);
      }
    }
  }
  cout << tot << '\n';
  rep(i, ans.size()) {
    if (i) cout << ' ';
    cout << ans[i];
  }
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4276
n = int(input())

A = []

for i in range(n):
    s = input()
    if i == 0:
        A.append(s)
    else:
        if A[-1][-1] == s[0] and A.count(s) == 0:
            A.append(s)
        else:
            break
if len(A) == n:
    print("Yes")
else:
    print("No")

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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = n/(a+b)*a;
	ans += min(n%(a+b), a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
int n,K,ans,e,lnk[maxn],nxt[maxn],son[maxn],dep[maxn];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
inline void add_e(int x,int y){son[++e]=y;nxt[e]=lnk[x];lnk[x]=e;}
void DFS(int x,int fa){
	for (int i=lnk[x];i;i=nxt[i])
	DFS(son[i],x),dep[x]=max(dep[x],dep[son[i]]);
	if(++dep[x]==K) ans+=x!=1&&fa!=1,dep[x]=0;
}
int main(){
	n=read(),K=read();
	if(read()^1) ans++;
	for (int i=2;i<=n;i++) add_e(read(),i);
	DFS(1,-1);printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6528
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	a := make(map[int]int)
	for i := 0; i < N; i++ {
		x := getInt()
		a[x]++
	}

	sum := 0
	for _, v := range a {
		sum += v - 1
	}
	if sum%2 == 1 {
		sum++
	}
	out(N - sum)
}


Measured memory_bytes: 6784
hoge=input()
key=input()
ans=[]
for i in range(len(hoge)-len(key)+1):
  flag=0
  for j in range(len(key)):
    if(hoge[i+j]==key[j] or hoge[i+j]=="?"):
      flag+=1
  if(flag==len(key)):
    kari=hoge[:i]+key+hoge[i+len(key):]
    ans.append(kari.replace("?","a"))
    
if(len(ans)>0):
  ans.sort()
  print(ans[0])
else:
  print("UNRESTORABLE")

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


struct Z{
    vi a;
    Z() {}
    Z(string& s) : a(s.size()) {
        int n = s.size();
        a[0] = n;

        int i = 1, j = 0;
        while(i < n) {
            while(i + j < n && s[i + j] == s[j]) ++j;
            a[i] = j;
            if (j == 0) {++i; continue;}
            int k = 1;
            while(i + k < s.size() && k + a[k] < j) a[i+k] = a[k], ++k;
            i += k; j -= k;
        }
    }

    inline int operator[](int i) {return a[i];}
};


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

    int N;
    string S;

    cin >> N >> S;

    int ans = 0;
    REP(i, N) {
        string t(S.begin() + i, S.end());

        Z z(t);

        REP(j, t.size()) {
            if (j >= z[j]) ans = max(ans, z[j]);
        }
    }

    print(ans);

}


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

int main(){
  string S,T,U;
  cin >> S >> T;
  int A,B;
  cin >> A >> B >> U;
  if(U == S)
    cout << A-1 << " " << B;
  else
    cout << A << " " << B-1;
}

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 998244353;
const ll INF = 1e18L + 9;


template<typename T>
unsigned int index_of_max(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] > arr[idx])
			idx = i;
	}
	return idx;
}

template<typename T>
unsigned int index_of_min(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] < arr[idx])
			idx = i;
	}
	return idx;
}

bool isPalindrome(string s, int l, int r) {
	for (; l <= r; ++l, --r) {
		if (s[l] != s[r])
			return false;
	}
	return true;
}

const int MAXN = 3005;
ll dp[MAXN][MAXN];

ll sum(int L, int R, vector<int>& a) {
	ll s = 0;
	for (int i = L; i <= R; ++i)
		s += a[i];
	return s;
};

int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif	
	FAST_IO;
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& x : a)
		cin >> x;
	// do[i][j] the total cost of interval [i,j]
	for (int L = n - 1; L >= 0; --L) {
		for (int R = L; R < n; ++R) {
			if (L == R)
				dp[L][R] = 0;
			else {
				dp[L][R] = INF;
				ll s = sum(L, R, a);
				for (int i = L; i <= R - 1; ++i)
					dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + s);
			}
		}
	}
	cout << dp[0][n - 1];
	return 0;
}




Measured memory_bytes: 9088
# 1 "i.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "i.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "i.cpp" 2

long long n;
vd p;
long double dp[(long long)3e3][(long long)3e3+1];

long double solve(long long idx, long long acc){
    if(idx == n)
        return acc > n/2;
    if(dp[idx][acc] + 1e-9 > 0)
        return dp[idx][acc];
    return dp[idx][acc] = (1-p[idx])*solve(idx+1, acc) + p[idx]*solve(idx+1, acc+1);
}

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    cin >> n;
    p.resize(n);
    for(long double &i:p)
        cin >> i;
    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision(15) << solve(0, 0) << "\n";
    return 0;
}


Measured memory_bytes: 141184
numbers = [int(_) for _ in input()]
n = len(numbers) - 1

for i in range(2 ** n):
    ans = numbers[0]
    ops = []
    for j in range(n):
        if i >> j & 1:
            ans += numbers[j+1]
            ops.append("+")
        else:
            ans -= numbers[j+1]
            ops.append("-")
    if ans == 7:
        break

print("{0}{4}{1}{5}{2}{6}{3}=7".format(numbers[0], numbers[1], numbers[2], numbers[3], ops[0], ops[1], ops[2]))

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

int main()
{
  int H,W;
  cin >> H >> W;
  char s[H][W];
  
  for (int i = 0; i < H; i++) {
    string str="";
    cin >> str;
    for (int j = 0; j < W; j++) {
      s[i][j] = str[j];
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(s[i][j] == '.'){
        //まわりの#を数える
        int cnt = 0;
        for(int di=-1; di<=1; di++){
          for(int dj=-1; dj<=1; dj++){
            if(0<=i+di && i+di<H && 0<=j+dj && j+dj<W){
              if(s[i+di][j+dj] == '#'){
                cnt++;
              }
            }
          }
        }
        s[i][j] = (char)(cnt+48);
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
input=lambda :sys.stdin.readline().rstrip()

N=int(input())
A=list(map(int,input().split()))
C=Counter(A)
num=sum([C[i]*(C[i]-1)//2 for i in C])
for a in A:
    c=num-C[a]*(C[a]-1)//2
    n=C[a]-1
    if n>=2:
        c+=n*(n-1)//2
    print(c)


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

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

	int transNum = 5;
	long long minC = 9223372036854775807LL;

	vector<long long > c(transNum); for (int i = 0; i < transNum; i++) { cin >> c[i];
		minC = min(minC, c[i]);
	}

	long long ans = (n + minC - 1) / minC + 4;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b;
    for(int i = 0; i < n; i++)  cin >> a[i];
    while(b.size() != n){
        int sel = -1;
        for(int i = 0; i < a.size(); i++){
            if(i+1 == a[i] && (sel == -1 || a[i] > a[sel])) sel = i;
        }
        if(sel == -1)   break;
        b.push_back(a[sel]);
        a.erase(a.begin()+sel);
    }
    if(b.size() != n){
        cout << -1 << endl;
    }else{
        for(int i = 0; i < n; i++)  cout << b[n-1-i] << endl;
    }
    return 0;
}

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

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] ds = new int[n];
        for (int i = 0; i < n; i++) {
            ds[i] = sc.nextInt();
        }

        Arrays.sort(ds);
        int ans = 0;
        int tmp = 0;
        for (int d : ds) {
            if (d != tmp) {
                ans++;
                tmp = d;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
    string S;
    cin >> S;
    
    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        cout << "Bad"; return 0;
    }

    cout << "Good";
    return 0;
}

Measured memory_bytes: 256
import sys
alphabet = "abcdefghijklmnopqrstuvwxyz"
dictionary = {}
for character in alphabet:
    dictionary[character] = 0

for line in sys.stdin:
    for character in line.strip():
        if character.lower() in dictionary:
            dictionary[character.lower()] += 1

for character in alphabet:
    print(character + ' : ' + str(dictionary[character]))

Measured memory_bytes: 6296
N = int(input())
A = list(map(int, input().split()))
A.sort()


total_value = 0
for i in range(1,N):
    if i != 1:
        total_value += A[i]/pow(2, N-i)
    else:
        total_value += (A[0]+A[1])/pow(2, N-1)
    
print(total_value)

Measured memory_bytes: 3064
#include<cstdio> 
#include <iostream>
#include <algorithm>
#include<string.h>
#include<memory.h>
using namespace std;
int m[300000000];
int main()
{
	int n,a,b,t[4]={0};
	scanf("%d",&n);
	scanf("%d%d",&a,&b);
	for(int i=0;i<n;i++)
		scanf("%d",&m[i]);
	sort(m,m+n);
	for(int i=0;i<n;i++){
		if(m[i]<=a)
			t[0]++;
		else if(m[i]<=b)
			t[1]++;
		else 
			t[2]++;
			}
	sort(t,t+3);
		printf("%d\n",t[0]);
		return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
void count(int N, int M){
    if(!(N+M)) return;
    int i, j, k;
    int h[1500];
    int w[1500];
    long long s_cnt = 0;
    int *h_cnt;
    int *w_cnt;
    for(i = 0; i < N; i++) scanf("%d", &h[i]);
    for(i = 0; i < M; i++) scanf("%d", &w[i]);
    h_cnt = (int *)calloc(1000 * N, sizeof(int));
    w_cnt = (int *)calloc(1000 * M, sizeof(int));
    //????????????
    for(i = 0; i < N; i++){
        int size = 0;
        for(j = i; j < N; j++){
            size += h[j];
            (*(h_cnt+size))++;
        }
    }
    //?¨?
    for(i = 0; i < M; i++){
        int size = 0;
        for(j = i; j < M; j++){
            size += w[j];
            (*(w_cnt+size))++;
        }
    }
    int min = (N > M) ? M : N;
    for(i = 0; i < min * 1000; i++){
        s_cnt += ((long long)(*(h_cnt + i)) * (*(w_cnt + i)));
    }
    printf("%d\n", s_cnt);
    free(h_cnt);
    free(w_cnt);
}

int main(){
    int N, M;
    while(scanf("%d %d", &N, &M) != EOF) count(N, M);
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,s = 0,ans;
    double ave,min = 100;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
        s += a[i];
    }
    ave = (double)s / n;
    for(int i = 0;i < n;i ++){
        if(abs(ave-a[i])<min){
            min = abs(ave-a[i]);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int> L(n);
  int p=0;
  int ans=1;
  for(int i=0;i<n;i++){
    cin>>L[i];
  }
  for(int i=0;i<n;i++){
    p+=L[i];
    if(p<=x) ans++;
    else break;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    // X以上のものだけを使ったときの個数がM以下か
    auto check = [&](ll X){
        ll cnt = 0;
        rep(i,N){
            int add = A.end() - lower_bound(all(A), X - A[i]);
            cnt += add;
        }
        return cnt < M;
    };
    ll ng = 0;
    ll ok = INFLL;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    cerr << ng << " " << ok << endl;
    //累積和で高速化パート
    vec<ll> cum(N+1, 0);
    rep(i, N)cum[i+1] = cum[i] + A[i];
    //ok以上のものだけ使えばM個以内に収まる
    //ngを何個か入れることを考える
    //ngが入る余地があるときがある
    //ok以上でM以下だが、Mピッタリとは限らない
    //ngにすると超えるということである。
    //余りがあるはずなので、それを加えよう。
    ll ans = 0;
    rep(i,N){
        int idx = lower_bound(all(A), ok - A[i]) - A.begin();
        int cnt = N - idx;
        ans += cum[N] - cum[idx] + A[i] * cnt;
        M -= cnt;
    }
    ans += M * (ok - 1);
    cout << ans << endl;
}

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

int main(void){
    int a, b;
    cin>>a>>b;
    float min1=(float)a/0.08;
    float min2=(float)b/0.10;
    float max1=(float)(a+1)/0.08;
    float max2=(float)(b+1)/0.10;

    float max_integral = 0;
    float min_integral = 0;
    float max_fractional = modf(min(max1, max2), &max_integral);
    float min_fractional = modf(max(min1, min2), &min_integral);

    if(max_integral<=min_integral) {
        cout<<-1<<endl;
        return 0;
    }
    int ans=0;
    if(min_fractional==0) ans=min_integral;
    else ans=min_integral+1;
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
s=input().split()

a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])


if(abs(a-c)<=d):
    print("Yes")
elif(abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
  ll n,a,b;
  cin >> n >> a >> b;
  if((abs(a-b))%2 ==0) cout << (abs(a-b))/2;
  else
  {
    if(a>b) swap(a,b);
    cout << min( (a+b-1)/2 , ((n-a)+(n-b)+1 )/2 );
    
  }
  
}


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

using namespace std;

int main(){
  int N; cin >> N; 
  string S; cin >> S; int max_cnt = 0;
  for(int i = 0; i < N - 1; i++){//i番目までは前半部に含む
       vector<char> T; int cnt = 0;
    
    //XとY の初期化を初めに行うこと
    for(int j = 0; j <= i ; j++){
      char X  = S[j]; 
     if( count(T.begin(),T.end(),X) == 0 ){ T.push_back(X); }//ダブらないように
                                  }
    
    for(int k = i + 1; k < N ; k++){
      char Y = S[k];
      if( count(T.begin(),T.end(),Y) == 1){ cnt++; T.push_back(Y);} } 
                                                               
            max_cnt = max(max_cnt,cnt);   }
  // 0 で存在しない、1で検知、2回目以降はすでにカウントし終えたものを意味
                                                               
                                 cout << max_cnt << endl;
                                                               return 0;}
                                                               
                                                               
                                                               //i固定化で前半と後半に切り分けた
    //Xに含まれる種類を全列挙し、そのうちYにも含まれるものをcnt2で検出する
    
    


Measured memory_bytes: 256
from collections import deque

n,m,s,t = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    e[u].append((v,a,b))
    e[v].append((u,a,b))
S = [float("INF")]*(n+1)
S[s] = 0
q = deque([])
q.append([s,-1])
while q:
    now,bef = q.popleft()
    for nex,a,b in e[now]:
        if nex == bef:
            continue
        if S[now]+a < S[nex]:
            S[nex] = S[now]+a
            q.append([nex,now])
T = [float("INF")]*(n+1)
T[t] = 0
q = deque([])
q.append([t,-1])
while q:
    now,bef = q.popleft()
    for nex,a,b in e[now]:
        if nex == bef:
            continue
        if T[now]+b < T[nex]:
            T[nex] = T[now]+b
            q.append([nex,now])

ans = [0]*(n+1)
cost = 10**15
now = 0
for i in range(n,0,-1):
    now = max(now,cost-S[i]-T[i])
    ans[i] = now
for i in ans[1:]:
    print(i)

Measured memory_bytes: 60612
A, B = map(int, input().split())

m = len(format(B, "b"))

a = A
b = B
AA = 0
BB = 0

if A % 2 == 1:
    a = A + 1
    AA = A
if B % 2 == 0:
    b = B - 1
    BB = B
b += 1

t = (b - a) // 2
#print(AA, b, t)
if t % 2 == 0:
    print(AA ^ BB)
else:
    print(AA ^ BB ^ 1)


Measured memory_bytes: 9212
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
* * WRITER:kakitamasziru/OxOmisosiru * *
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1001001001001001;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

long long A,B;
bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    sort(retu.begin(),retu.end());
    int ans = 0;

    //i→j→kの順で大きくなる
    for(int i = 0;i<N;i++){
        for(int j = i+1;j<N;j++){
            for(int k = j+1;k<N;k++){
                if(retu.at(k) < retu.at(j) + retu.at(i)){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 2e5 + 5;
int n, k, a[M], vis[M];
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int cur = 1, cnt = 0, not_cy = 0;
	while(!vis[cur])
	{
		cnt++;
		vis[cur] = 1;
		cur = a[cur];
	}
	int st = cur;
	cur = 1;
	while(cur != st)
	{
		not_cy++;
		cur = a[cur];
		if(not_cy == k)
			return cout << cur, 0;
	}
	cnt -= not_cy, k = (k - not_cy) % cnt;
	cur = st;
	while(k--)
		cur = a[cur];
	cout << cur;
    	return 0;
}

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

inf = 10 ** 20
d = [list(map(int, input().split())) for _ in range(10)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0
for _ in range(h):
    row = list(map(int, input().split()))
    for num in row:
        if num == -1:
            continue
        ans += d[num][1]

print(ans)

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

int main()
{
    int a[3][3],N;
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++) cin>>a[i][j];
    }
    cin>>N;
    int b[N];
    for (int i=0; i<N; i++) {
        cin>>b[i];
        //ビンゴカード埋める
        for (int j=0; j<3; j++){
            for (int k=0; k<3; k++) {
                if (b[i]==a[j][k]) a[j][k]=0;
            }
        }
    }

    bool bingo=false;
    for (int i=0; i<3; i++){
        if ((a[i][0]==0&&a[i][1]==0&&a[i][2]==0)||
            (a[0][i]==0&&a[1][i]==0&&a[2][i]==0)) bingo=true;
    }
    if ((a[0][0]==0&&a[1][1]==0&&a[2][2]==0)||
        (a[0][2]==0&&a[1][1]==0&&a[2][0]==0)) bingo=true;
    if (bingo) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
/*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
stack push pop top
queue push pop front
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////
double x[4], y[4];
bool solve()
{
  return (fabs((x[1]-x[0])*(y[3]-y[2])-(x[3]-x[2])*(y[1]-y[0]))<1e-10);
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  int n; cin >> n;
  REP(i,n)
  {
    REP(i,4) cin >> x[i] >> y[i];
    printf("%s\n",(solve()?"YES":"NO"));
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
using namespace std;
using ll = long long;

const int N = 2 * (int)1e5;
ll as[N];
ll bs[N];
ll cou = 0;

void check(int i, int n) {
	int pi = (i + (n-1)) % n;
	int ni = (i + 1) % n;
	ll d = bs[i] - as[i];
	if (d > 0) {
		ll add = bs[pi] + bs[ni];
		ll r = d / add;
		cou += r;
		bs[i] -= r * add;

		if (r > 0) {
			check(pi, n);
			check(ni, n);
		}
	}
}

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

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) cin >> as[i];
	for (int i = 0; i < n; ++i) cin >> bs[i];
	for (int i = 0; i < n; ++i) check(i, n);

	bool fail = false;
	for (int i = 0; i < n; ++i) fail |= (as[i] != bs[i]);

	if (fail) cout << "-1\n";
	else cout << cou << '\n';
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    int n,m,b;
    cin>>n>>m;
    
    b=(n-1)*(m-1);

    cout<<b;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();

        int[] hArray = new int[N];
        for(int i = 0; i < N; i++){

            hArray[i] = scan.nextInt();
        }

        int ans = 1;
        int count =0;
        for(int i = 0; i < N; i++) {

            count = 0;

            for (int j = 0; j < i; j++){

                if(hArray[i] >= hArray[j]){
                    count++;
                    if(count == i) ans++;
                }
            }

        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    int x = N*800, y = 200*(N/15);
    cout << x - y << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<int>();
        for (int i = 0; i < inp[0]; i++)
        {
            list.Add(int.Parse(Console.ReadLine()));
        }
        int MP = int.MaxValue;
        for (int i = 0; i < Math.Pow(4, inp[0]); i++)
        {
            int a = 0, b = 0, c = 0;
            int comb = 0;
            for (int j = 0; j < inp[0]; j++)
            {
                if ((i >> 2*j & 1) == 0 && (i >> (2 * j + 1) & 1) == 0)
                {
                    if (a != 0) comb++;
                    a += list[j];
                }
                else if ((i >> 2 * j & 1) == 0 && (i >> (2 * j + 1) & 1) == 1)
                {
                    if (b != 0) comb++;
                    b += list[j];
                }
                else if ((i >> 2 * j & 1) == 1 && (i >> (2 * j + 1) & 1) == 0)
                {
                    if (c != 0) comb++;
                    c += list[j];
                }
            }
            if (a * b * c == 0) continue;
            var abc = new int[3] { a, b, c };
            abc = abc.OrderByDescending(f => f).ToArray();
            MP = Math.Min(MP, Math.Abs(inp[1] - abc[0]) + Math.Abs(inp[2] - abc[1]) + Math.Abs(inp[3] - abc[2]) + comb * 10);
        }
        Console.WriteLine(MP);
    }
}

Measured memory_bytes: 17472
#include <stdio.h>

int main(void){
	int a,b,c;
	int x;
	int i;
	int y;
	scanf("%d %d %d", &a ,&b ,&c);
	for(i=a;i<=b;i++){
		y=c%i;
		if(y==0){
			x++;
		}
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 596
///age yekam bekeshi beham is no problem ._.
#include<bits/stdc++.h>
#define size(a) (int)a.size()
#define ld long double
#define int long long
#define F first
#define S second
#define pb push_back
using namespace std;
void null(){return ;}
const int maxn=1e5+7,INF=3e18+9237,mod=1e9+7;
int a[maxn];

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,l;cin>>n>>l;
	for(int i=1;i<=n;i++)cin>>a[i];
	
	int ind=-1;
	for(int i=1;i<n;i++)if(a[i]+a[i+1]>=l){ind=i;break;}
	if(ind==-1)return cout<<"Impossible\n",0;
	cout<<"Possible\n";
	for(int i=1;i<ind;i++)cout<<i<<'\n';
	for(int i=n-1;i>ind;i--)cout<<i<<'\n';
	cout<<ind;
	
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string>vec(H);
  for(int i=0;i<H;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<H;i++){
    bool frag1=true;
    for(int j=0;j<W;j++){
      if(vec.at(i).at(j)=='#'){
        frag1=false;
      }
      else{
      }
    }
    if(frag1==true){
      for(int k=0;k<W;k++){
        vec.at(i).at(k)='0';
      }
    }
    else{
    }
  }
  for(int i=0;i<W;i++){
    bool flag=true;
    for(int j=0;j<H;j++){
      if(vec.at(j).at(i)=='#'){
        flag=false;
      }
      else{
      }
    }
    if(flag==true){
      for(int k=0;k<H;k++){
        vec.at(k).at(i)='0';
      }
    }
    else{
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(vec.at(i).at(j)=='0'){
      }
      else{
        cout<<vec.at(i).at(j);
      }
    }
    cout<<' '<<endl;
  }
}


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

using namespace std;

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

	if (s.size() <= k) {
		cout << s;
	}
	else {
		cout << s.substr(0, k) << "...";
	}
	return 0;
}

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

struct Card {
  char suit;
  char value;
  int i;
};

void bubble(struct Card A[], int N){
  for(int i=0; i<N; i++){
    for(int j=N-1; j>=i+1; j--){
      if( A[j].value < A[j-1].value ){
        Card temp = A[j];
        A[j] = A[j-1];
        A[j-1] = temp;
      }
    }
  }
}

void selection(struct Card A[], int N){
  for(int i=0; i<N; i++){
    int minj = i;
    for(int j=i; j<N; j++){
      if( A[j].value < A[minj].value )minj = j;
    }
    Card temp = A[i];
    A[i] = A[minj];
    A[minj] = temp;
  }
}

bool isStable(struct Card C1[], struct Card C2[], int N){
  for(int i=0; i<N; i++){
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

void print(struct Card A[], int N){
  for(int i=0; i<N; i++){
    if( i>0 ) std::cout << " ";
    std::cout << A[i].suit << A[i].value;
  }
  std::cout << std::endl;
}

int main(){
  int N;
  Card C1[100], C2[100];
  char ch;
  
  std::cin >> N;
  for(int i=0; i<N; i++){
    std::cin >> C1[i].suit >>C1[i].value;
  }

  for(int i=0; i<N; i++){
    C2[i] = C1[i];
  }

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  std::cout << "Stable" << std::endl;
  print(C2, N);
  if(isStable(C1, C2, N)){
    std:: cout << "Stable" << std::endl;
  }else{
  std::cout << "Not stable" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m; long long int ans;
  scanf("%d %d", &n, &m);

  if(n >= 2 && m >= 2) ans = ((long long)n - 2) * ((long long)m - 2);
  if(n == 1 && m >= 2) ans = (long long)m - 2;
  if(m == 1 && n >= 2) ans = (long long)n - 2;
  if(n == 1 && m == 1) ans = 1;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long a=sc.nextLong(), b=sc.nextLong();
        sc.close();
        long r=euclidean_gcd(a, b);
        HashSet<Long> primes=new HashSet<>();
        add(primes,r);
        primes.add(1l);
        System.out.println(primes.size());
    }
    public static void add(HashSet<Long> set, long k){
        for(long i=2;i*i<=k;i++){
            if(k%i==0) set.add(i);
            while(k%i==0) k/=i;
        }
        set.add(k);
    }
    public static long euclidean_gcd(long a, long b) {
        if(a < b) return euclidean_gcd(b, a);
        long r=a%b;
        while (r!=0) {
          a = b;
          b = r;
          r=a%b;
        }
        return b;
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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 MAX_WS=2e4+10;

struct block{ll w,s,v;};
bool cmp(const block &a,const block &b){
    return a.w+a.s!=b.w+b.s?a.w+a.s<b.w+b.s:a.s<b.s;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<block> bs(N);
    rep(i,N){
        ll w,s,v; cin >> w >> s >> v;
        bs[i]=block{w,s,v};
    }
    sort(all(bs),cmp);
    vector<vector<ll>> dp(N+1,vector<ll>(MAX_WS,0));
    rep(i,N) rep(j,MAX_WS){
        chmax(dp[i+1][j],dp[i][j]);
        if (j<=bs[i].s) chmax(dp[i+1][j+bs[i].w],dp[i][j]+bs[i].v);
    }
    ll ans=0;
    rep(j,MAX_WS) chmax(ans,dp[N][j]);
    cout << ans << endl;
}

Measured memory_bytes: 160640
n = int(input())
nums = [int(input()) for _ in range(n)]
mem = [0] * (n + 1)
a, b = 1, 1
s = 0
for i in range(n):
    mem[nums[i]] += i

p, q = mem[1], mem[n]

for i in range(2, n+1):
    if  p < mem[i]:
        a += 1
    else:
        s = max(s, a)
        a = 1
    p = mem[i]
s = max(s, a)
for j in range(n, 0, -1):
    if  q > mem[j]:
        b += 1
    else:
        s = max(s, b)
        b = 1
    q = mem[j]
s = max(s, b)
print(n - s)

Measured memory_bytes: 18860
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int money[4] = {10,50,100,500}; 
int data[4],pay[4],ans[4],use[4];
int cost;
int minans;
int n,I=0;
bool check(int cst){
	for(int i=3;i>=0;i--){
		pay[i] = 0;
		while(cst >= money[i]){
			pay[i]++;
			cst -= money[i];
		}
	}
	rep(i,4)if(pay[i] && use[i]) return false;
	
	return true;
}
void dfs(int pos){
	if(pos == -1){	
		if(cost >= n && check(cost-n)){
			int kans=0;
			rep(i,4)kans += pay[i] + data[i]-use[i];
			if(kans < minans){
				rep(i,4)ans[i] = use[i];
				minans = kans;
			}
		}
		return;
	}
	for(int i=data[pos];i>=0;i--){
		use[pos] = i;
		cost += i * money[pos];
		dfs(pos-1);
		cost -= i * money[pos];
	}
}
int main(){
	check(100);
	while(cin >> n,n){
		if(I++)cout << endl;
		minans = 10000;
		cost = 0;
		cin >> data[0] >> data[1] >> data[2] >> data[3];
		dfs(3);
		rep(i,4){
			if(ans[i])cout << money[i] << " " << ans[i] << endl;
		}
	}
}

Measured memory_bytes: 868