akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

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

  vector<ll> A(N);
  loop(0, N, i) {
    cin >> A[i];
  }

  ll sum = 0;
  loop(1, N, i) {
    if (A[i] < A[i-1]) {
      ll res = A[i-1] - A[i];
      sum += res;
      A[i] += res;
    }
  }
  print(sum);
}

Measured memory_bytes: 4792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  string s;
  cin>>s;
  string t[16];
  REP(i, 16){
    t[i]="";
    if(i&1)t[i]+="A";
    t[i]+="KIH";
    if(i&2)t[i]+="A";
    t[i]+="B";
    if(i&4)t[i]+="A";
    t[i]+="R";
    if(i&8)t[i]+="A";
  }
  REP(i, 16){
    if(s==t[i]){
      ECHO("YES");
      return 0;
    }
  }


  ECHO("NO");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ff first
#define ss second
#define pb push_back
#define I insert
int main()
{
  
  ll N;
  cin>>N;
  ll i=1;
  vector<ll>A;
  vector<ll>B;
  vector<ll>C;
  for(i=0;i<N;i++)
    A.push_back(i+1);
  ll in;
  for(i=0;i<N;i++)
  {
    cin>>in;
    B.push_back(in);
  }
  for(i=0;i<N;i++)
  {
    cin>>in;
    C.push_back(in);
  }
  if(B==C)
    cout<<0;
  else
  {
    ll cnt1=0,cnt2=0;
    while(A!=B)
    {
      cnt1++;
     next_permutation(A.begin(),A.end());
    }
    A.clear();
    for(i=0;i<N;i++)
    {
    A.push_back(i+1);
    }
    while(C!=A)
    {
      cnt2++;
      next_permutation(A.begin(),A.end());
    }
    cout<<abs(cnt2-cnt1);
  }
    
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
  string a,b;
  std::cin >> a;
  rep(i,a.size())if(i%2==0)b.push_back(a[i]);
  std::cout << b << std::endl;
}

Measured memory_bytes: 512
#include <climits>
#include <cstring>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <fstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define f first
#define s second

#define MM INT_MAX/5
#define MIM INT_MIN/2

int di[] = { 1,-1,0,0 };
int dj[] = { 0,0,1,-1 };

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for  (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define v vector
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

int day[(int)1e5 + 10][3];
int dp[(int)1e5 + 10][3];

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < 3; j++) {
			cin >> day[i][j];
		}
	for (int i = 0; i < 3; i++)
		dp[0][i] = day[0][i];
	for (int i = 1; i < N; i++) {
		dp[i][0] = day[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = day[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = day[i][2] + max(dp[i - 1][0], dp[i - 1][1]);		
	}
	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,x,y;	cin>>n>>m>>x>>y;
	int i,j,a[n],b[m];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	sort(a,a+n);
	sort(b,b+m);

	if(a[n-1]<b[0] && a[n-1]<y && b[0]>x){
		cout<<"No War";
	}
	else	cout<<"War";

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim();
  var tate = parseInt(input.split("\n")[0].split(" ")[0]);
  for(var i = 1; i <= tate; i++){
    console.log(input.split("\n")[i]);
    console.log(input.split("\n")[i]);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  
  int n;
  cin >> n;
  vector<int> num(n);
  for(int i=0;i<n;i++)
    cin >> num.at(i);
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  int A=0;
  int B=0;
  for(int i=0;i<n;i++){
    if( i % 2 == 0 )
      A += num.at(i);
    else
      B += num.at(i);
  }
  
  cout << A - B << endl;
  
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

int X;
int main() {
  cin >> X;
  int i=1;
  int sum = 0;
  while(true) {
    sum += i;
    if (sum >= X) {
      break;
    }
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1e9+7;

using namespace std;

int main(){
    string s;
    cin>>s;
    int q;
    cin>>q;
    string st="",ed="";
    int count=0;
    for(int i=0;i<q;i++){
        int n;
        cin>>n;
        if(n==1){
            count++;
        }else{
            int a;
            string c;
            cin>>a>>c;
            if(count%2==0){
                if(a==1){
                    st=c+st;
                }else{
                    ed=ed+c;
                } 
            }else{
                if(a==1){
                    ed=ed+c;
                }else{
                    st=c+st;
                }

            }
        }
    }
    //cout<<st<<" "<<ed<<endl;
    if(count%2==0){
        cout<<st+s+ed<<endl;
    }else{
        reverse(st.begin(),st.end());
        reverse(s.begin(),s.end());
        reverse(ed.begin(),ed.end());
        cout<<ed+s+st<<endl;
    }
    return 0;

}


Measured memory_bytes: 1512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    vec<vec<pair<int,ll>>> G(N);
    rep(i, N-1){
        int a,b,c;
        cin >> a >> b >> c;
        --a,--b;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    
    int Q, K;
    cin >> Q >> K;
    --K;
    ll INF = 1e18+9;
    vec<ll> d(N,INF);
    queue<pair<int,ll>> q;
    q.push({K,0});
    d[K] = 0;

    while(!q.empty()){
        int now = q.front().first;
        ll nowd = q.front().second;
        q.pop();

        for(auto [f, dist]:G[now]){
            ll nextd = nowd+dist;
            if(d[f] < nextd) continue;
            d[f] = nextd;
            q.push({f,nextd});
        }
    }
    
    rep(i, Q) {
        int x,y;
        cin >> x >> y;
        --x,--y;
        ll ans = d[x] + d[y];
        cout << ans << endl;
    }

}


Measured memory_bytes: 12680
#include <stdio.h>
#define MAX 100000
int array[MAX];
int partition(int,int);

int main(){
  int i,p,k;

  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&array[i]);
  }

  p=partition(0,k-1);

  for(i=0;i<k;i++){
    if(i) printf(" ");
    if(i==p) printf("[");
    printf("%d",array[i]);
    if(i==p) printf("]");
  }
  printf("\n");

  return 0;
}

int partition(int p,int r){
  int x,i,j,t;
  x=array[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(array[j]<=x){
      i++;
      t=array[i];
      array[i]=array[j];
      array[j]=t;
    }
  }
  t=array[i+1];
  array[i+1]=array[r];
  array[r]=t;
  
  return i+1;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,X;
  cin >> K >> X;
  
  for(int i=X-K+1; i < X+K; i++){
    if(i >= -1000000 && i <= 1000000){
      cout << i << " ";
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>

using namespace std;

int check_num(int i) {
    if (i % 3 == 0) {
        cout << " " << i;
        return 1;
    } else return 0;
}

int include3(int i) {
    int x = i;
    do{
        if (x % 10 == 3) {
            cout << " " << i;
            return 1;
        }
    }while (x /= 10);
    return 0;
}

void call(int n) {
    for (int i=1; i <= n; i++) {
        if (!check_num(i)) include3(i);
    }
    cout << endl;
}

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


Measured memory_bytes: 3088
#include<stdio.h>

int main(){
  int i=1,x;

  while (1){
    scanf("%d\n", &x);
    if(x==0){
      break;
    }
    else{
      printf("Case %d: %d\n", i,x);
      i++;
    }
  }

  return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  
  int point = 0;
  
  point += max(A,B);
  
  if (A>B){
    A--;
  }
  else{
    B--;
  }
  
  point += max(A,B);
  
  cout << point << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cmath>

using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int N, M;
    cin >> N >> M;
    tuple<int, int, int> data[M];

    for (int i = 0; i < M; ++i) {
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }

    sort(data, data + M);

    int cnt[N + 1];
    fill(cnt, cnt + N + 1, 0);

    pair<int, int> id[M];

    for (int i = 0; i < M; ++i) {
        int y, p, idx;
        tie(y, p, idx) = data[i];
        ++cnt[p];
        id[idx] = make_pair(p, cnt[p]);
    }

    for (int i = 0; i < M; ++i) {
        cout << setw(6) << setfill('0') << id[i].first;
        cout << setw(6) << setfill('0') << id[i].second << endl;
    }
}

Measured memory_bytes: 3968
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	sort(x.begin(), x.end());
	int ans = 1 << 30 - 1;
	for (int i = x[0]; i <= x[n - 1]; i++) {
		int sum = 0;
		for (int j = 0; j <n; j++) {
			sum += (x[j] - i) * (x[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10 ** 4)
N, K = map(int, input().split())
R = N - K

if R == 0: #赤いボールが無い時
    print (1)
    for _ in range(1, K):
        print (0)
    exit()

if K == 1: #青いボールが1つのとき
    print (R+1)
    exit()

K_1 = math.factorial(K-1)
R_1 = math.factorial(R+1)
# print (K_1, R_1)
for i in range(1, K+1): #K回答えを出力
    # if i > R:
    #     print (0)
    #     continue
    if i == 1:
        print (R + 1)
        continue
    # print (K_1, R_1, math.factorial(i))
    if i == 2:
        position = R_1//(math.factorial(i) * math.factorial(R + 1- i))
        boal = K_1//(math.factorial(i-1) * math.factorial(K - i))
    if i > 2:
        position = (position * (R + 1 - (i-1))) // i
        boal = (boal * (K - (i-1)))// (i-1)
    print ((position * boal)%(7 + 10 ** 9))

Measured memory_bytes: 3316
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    vector<int> vec(N);
    vector<int> check(N, 0);
    int now = 1;
    int flag = 0;
    int next;
    int count = 0;

    rep(i, N)
    {
        cin >> vec.at(i);
    }

    while(true){
        count++;
        next = vec.at(now - 1);
        if(next == now){
            break;
        }
        if(check.at(next - 1) == 1){
            break;
        }

        if(next == 2){
            flag = 1;
            break;
        }

        now = next;
        check.at(next - 1) = 1;
    }

    if(flag == 1){
        cout << count << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3984
#include <stdio.h>

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

    scanf("%d %d %d", &a, &b, &c);

    int i = 0;
    for(; a <= b ;a++){
        if( (c % a) == 0){
            i++;
        }
    }

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

    return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  ll ans=0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      ans += vec[i]*vec[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    X, Y = LI()
    ans = 0
    if X == 1:
        ans += 300000
    elif X == 2:
        ans += 200000
    elif X == 3:
        ans += 100000

    if Y == 1:
        ans += 300000
    elif Y == 2:
        ans += 200000
    elif Y == 3:
        ans += 100000

    if X == 1 and Y == 1:
        ans += 400000

    print(ans)
    return


# B
def B():
    N = I()
    A = LI()
    A_sum = sum(A)
    cnt = 0
    ans = sum(A)
    for i in range(N):
        cnt += A[i]
        sa = abs(A_sum - cnt - cnt)
        ans = min(ans, sa)
    print(ans)
    return


# C
def C():
    H, W, K = LI()
    s = [S() for i in range(H)]
    ans = [[0] * W for i in range(H)]
    cnt = 1
    index = 0
    for i in range(H):
        if '#' in s[i]:
            index = i
            break

    for i in range(i, H):
        ichigo = 0
        for j in range(W):
            if s[i][j] == '#' and ichigo == 0:
                ichigo += 1
                ans[i][j] = cnt
            elif s[i][j] == '#' and ichigo != 0:
                cnt += 1
                ans[i][j] = cnt
            else:
                ans[i][j] = cnt
        if ichigo == 0:
            ans[i] = ans[i - 1]
        else:
            cnt+=1

    for i in range(0, index):
        ans[i] = ans[index]

    for i in range(H):
        print(' '.join([str(j) for j in ans[i]]))
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    C()
    return


# Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 45804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, i, j;
  int a, b;
  cin >> x;
  for (i=-118; i<120; i++) {
    for (j=-119; j<119; j++) {
      if (pow(i, 5)-pow(j, 5)==x) {
        a = i;
        b = j;
        break;
      }
    }
  }
  
  cout << a << " " << b << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> ar(n);
  for(int &x: ar) cin >> x;
  sort(ar.begin(), ar.end());
  int sum = 0;
  for(int i = 0; i < k; ++i) sum += ar[i];
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main() {
	int n; cin>>n;
	VL a(n);
	rep(i,n) cin>>a[i];
	sort(ALL(a));
	ll ans=1LL;
	if(a[0]==0LL) return cout<<0<<endl,0;
	rep(i,n){
		if((ll)1e18/ans<a[i]) return cout<<-1<<endl,0;
		ans*=a[i];
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
typedef long long LL;
#define rep(i,a,b) for(auto i=(a);i<=(b);++i)
#define per(i,a,b) for(auto i=(a);i>=(b);--i)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define root 1,cnum,1
#define Pr pair<int,int>
#define Prd pair<double,double>
#define Prl pair<LL,LL>
#define fi first
#define se second
#define Abs(x) (x>0?x:x*-1)
#define lowbit(x) (x&(-x))
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
const int INF = 0x7FFFFFFF;
const LL LINF = 0x7FFFFFFFFFFFFF;
void guan() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }

const LL mod = 1e9+7; 
const int maxn = 1010101;

int main() {
    guan();
    int d, h, k, p, q;
    LL n, m;
    while(cin >> n >> m) {
        string s, t;
        cin >> s >> t;
        if(s[0]!=t[0]) cout << -1 << endl;
        else {
            LL gcd=__gcd(n,m);
            n/=gcd, m/=gcd;
            int i = 0;
            LL ans = n*m*gcd;
            while(i*n+1<=n*gcd&&i*m+1<=m*gcd) {
                if(s[i*n]!=t[i*m]) {
                    ans = -1;
                    break;
                } ++i;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

int main(void) {
	int N,T[100],M,P[100],X[100];
	int i, j, sum;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &T[i]);
	}
	scanf("%d", &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &P[i],&X[i]);
	}
	sum = 0;
	for (i = 0; i < N; i++) {
		sum = sum + T[i];
	}
	for (i = 0; i < M; i++) {
		printf("%d\n", sum - T[P[i] - 1] + X[i]);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N, C, K; cin >> N >> C >> K;
    vec T(N); readv(T);
    SORT(T);

    int ans = 0;
    int s = 0;
    while(s < N){
        int e = min(N - 1, s + C - 1);
        if(T[e] > T[s] + K) e = Upper_bound(T, T[s] + K) - 1;
        ans++;
        s = e + 1;
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 1024
five_dish = [int(input()) for _ in range(5)]
idx = 0
maxdiff = 0
result = 0
for i in range(len(five_dish)):
    tmp = five_dish[i] % 10
    if tmp != 0:
        if 10 - tmp > maxdiff:
            maxdiff = 10 - tmp
            idx = i
for j in range(len(five_dish)):
    if j == idx:
        continue
    else:
        if five_dish[j] % 10 == 0:
            result += five_dish[j]
        else:
            result += five_dish[j] + (10 - (five_dish[j] % 10))
result += five_dish[idx]
print(result)


Measured memory_bytes: 3064
N = int(input())

A = [int(x) for x in input().split()]

nega_count = [1 for x in A if x < 0]
nega_count = sum(nega_count)

B = [abs(x) for x in A]
if nega_count % 2 == 0:
  print(sum(B))
else:
  b = B.pop(B.index(min(B)))
  print(sum(B) - b)

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

int main(void){
  int a, b, c;
  int cnt = 3;
  cin >> a >> b >> c;
  if(a == b && b == c)
    cnt = 1;
  else if(a == b || b == c || a == c)
    cnt = 2;
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 3492
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long m = long.Parse(input[1]);
    long[] usedCount = new long[n];
    bool answer = true;

    long[,] vertexes = new long[n,2];//ここに受け取る
    for(long i = 0; i < m; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      usedCount[nums[0]-1]++;
      usedCount[nums[1]-1]++;
    }

    for(int i = 0; i < n; i++)
    {
      if(usedCount[i] % 2 == 1) answer = false;
    }

		Console.WriteLine((answer) ? "YES" : "NO");
	}
}

Measured memory_bytes: 17304
#include <iostream>
#include <cstdio>

int main()
{
	char a,b;
	int ma,mb;
	scanf("%c %c",&a,&b);
	ma=a=='H'?1:-1;
	mb=b=='H'?1:-1;
	printf("%c\n",ma*mb==1?'H':'D');
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int W = 0, H = 0, C = 0, l = 1, ku = 0, hiyou = 0, GCM = 0;
    int yaku[1000] = {};
    scanf("%d %d %d", &W, &H, &C);
    for(int i = 2; i <= W; i++){
        if( W % i == 0 ){ 
            yaku[l] = i;
            l++;
        }
    }
    for(int i = 2; i <= H; i++){
        for(int m = 1; m <= l; m++){
            if( H % i == 0 ){
                if(yaku[m] == i)    GCM = i;
            }
        }
    }
    if( GCM == 0 ){
        ku = W * H;
    } else {
        ku = (W / GCM) * (H / GCM);
    }
    hiyou = ku * C;
    printf("%d\n", hiyou);
    return 0;
}


Measured memory_bytes: 2148
import collections

N, C, K = map(int, input().split())
T = collections.deque()
for _ in range(N):
    T.append(int(input()))
T = sorted(T)
T = collections.deque(T)
#print(T)
ans = 0

while T:
    time = T[0] + K
    cnt = 0
    while T[0] <= time:
        T.popleft()
        cnt += 1
        if cnt >= C:
            break
        if not T:
            break
    ans += 1
print(ans)


Measured memory_bytes: 50776
// AOJ Volume 0 Problem 0033

#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int no;
	int right, left;
	int flg;

	scanf("%d", &n);
	for (; n > 0; n--){
		flg = 0;
		right = left = -1;
		for (i = 0; i < 10; i++){
			scanf("%d", &no);
			if (left >= no && right >= no){
				flg = 1;
				for (; i < 10; i++){
					scanf("%d", &no);
				}
				break;
			}
			if (left < no && right >= no){
				left = no;
			}
			else if (left >= no && right < no){
				right = no;
			}
			else {
				if (left < right){
					right = no;
				}
				else {
					left = no;
				}
			}
		}
		
		if (flg == 1){
			printf("NO\n");
		}
		else {
			printf("YES\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize ("O3,unroll-loops")
#define f first
#define s second
#define ri register int
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
#define MAXN 2999
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	double p[MAXN];
	ld **dp;
	cin >> n;
	for(ri i = 0; i < n; ++i) cin >> p[i];
	dp = new ld*[n + 1];
	for(ri k = 0; k <= n; ++k) {
		dp[k] = new ld[n + 1];
		for(ri i = 0; i <= n; ++i)
			dp[k][i] = 0;
	}
	dp[0][0] = 1.0L;
	for(ri k = 0; k < n; ++k) {
		for(ri i = 0; i < n; ++i) {
			dp[k + 1][i + 1] += dp[k][i] * p[k];
			dp[k + 1][i] += dp[k][i] * (1.0L - p[k]);
		}
	}
	ld ans = 0;
	for(ri k = (n + 2) / 2; k <= n; ++k)
		ans += dp[n][k];
	cout << fixed << setprecision(15) << ans << '\n';
    return 0;
}

Measured memory_bytes: 140928
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    float sum = 0;
    for (int j = 0; j < n; j++){
        sum += 1 / float(arr[j]);
    }
    cout << 1/sum;

}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

/////////////////////////////////////////////////////////////
class ModuloOperator {
public:
  ll mo_modulo;

  ModuloOperator(ll modulo) {
    mo_modulo = modulo;
  }

  ll add(ll a, ll b) {
    ll ret = a + b;
    ret %= mo_modulo;
    return ret;
  }

  ll sub(ll a, ll b) {
    ll ret = a - b;
    if (ret < 0) ret += mo_modulo;
    else ret %= mo_modulo;
    return ret;
  }

  ll mul(ll a, ll b) {
    ll ret = a * b;
    ret %= mo_modulo;
    return ret;
  }

  ll div(ll a, ll b) {
    return mul(a, pow(b, mo_modulo - 2));
  }

  ll pow(ll x, ll y) {
    ll res = 1LL;

    x %= mo_modulo;

    while (y > 0) {
      if (y & 1) {
        res = mul(res, x);
      }

      y = y >> 1;
      x = mul(x, x);
    }

    return res;
  }
};
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
class CombinationModulo {
 public:
  static const ll MOD = (ll)(1e9 + 7);

  vector<ll> fact;
  vector<ll> inv;
  vector<ll> fact_inv;

  CombinationModulo(int n) {
    this->fact = vector<ll>(n + 1, 0LL);
    this->inv = vector<ll>(n + 1, 0LL);
    this->fact_inv = vector<ll>(n + 1, 0LL);
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1LL;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0LL;
    return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

int n;
ll a, b, c;

ll a_div_apb_arr[MAX_N];
ll b_div_apb_arr[MAX_N];

ll ans;

ModuloOperator mo(MOD);

int main(void) {
  // Here your code !
  scanf("%d %lld %lld %lld", &n, &a, &b, &c);

  CombinationModulo cm(n + n + 3);

  ll a_div_apb = mo.div(a, mo.add(a, b));
  ll b_div_apb = mo.div(b, mo.add(a, b));

  ll hund_div_hund_sub_c = mo.div(100LL, mo.sub(100LL, c));

  a_div_apb_arr[0] = 1LL;
  b_div_apb_arr[0] = 1LL;

  for (int i = 1; i <= n; ++i) {
    a_div_apb_arr[i] = mo.mul(a_div_apb_arr[i - 1], a_div_apb);
    b_div_apb_arr[i] = mo.mul(b_div_apb_arr[i - 1], b_div_apb);
  }

  ans = 0;

  for (int i = 0; i <= n - 1; ++i) {
    ll combination = cm.comb(n - 1 + i, n - 1);

    ll after_fst = mo.mul(a_div_apb_arr[n], b_div_apb_arr[i]);
    ll after_snd = mo.mul(b_div_apb_arr[n], a_div_apb_arr[i]);
    ll after = mo.add(after_fst, after_snd);

    ll expect_fst = mo.mul(n + i, mo.mul(combination, after));

    ans = mo.add(ans, expect_fst);
  }

  ans = mo.mul(ans, hund_div_hund_sub_c);

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

  return 0;
}


Measured memory_bytes: 6528
n = int(input())
A = list(map(int,input().split()))

print(" ".join([str(A[(-1) ** int(i < (n+1)//2) * (2*(i%((n+1)//2))+1) - int(i >= (n+1)//2) * ((n+1)%2)]) for i in range(n)]))

Measured memory_bytes: 118100
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin>> N;
VI A(N); rep(i, 0, N) cin >> A[i];
VI a(N, 0);
rep(i, 0, N){
    if (i & 1) a[0] -= A[i];
    else a[0] += A[i];
}
cout << a[0] << ' ';
rep(i, 0, N-1){
    a[i+1] = 2 * A[i] - a[i];
    cout << a[i+1] << ' ';
}
cout << endl;

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 2944
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

void main() {
  long a, b, c, k;
  readf("%d %d %d %d\n", &a, &b, &c, &k);
  if(k-a<=0) writeln(k);
  else if(k-a-b<=0) writeln(a);
  else writeln(a-(k-a-b));
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  cout << N/3 << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

inline
int getint(){
	re int num;
	re char c;
	while(!isdigit(c=gc()));num=c^48;
	while(isdigit(c=gc()))num=(num<<1)+(num<<3)+(c^48);
	return num;
}

cs ll mod=1000000007;

ll fac[8003],inv[8003],ifac[8003];

ll C(int n,int m){
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

cs int N=200005;
int a[N],b[N];
int n;
ll f[4003][4003];

ll ans=0;

signed main(){
	fac[0]=fac[1]=inv[0]=inv[1]=ifac[0]=ifac[1]=1;
	for(int re i=2;i<=8000;++i)
	fac[i]=fac[i-1]*i%mod,
	inv[i]=(mod-mod/i)*inv[mod%i]%mod,
	ifac[i]=ifac[i-1]*inv[i]%mod;
	
	n=getint();
	for(int re i=1;i<=n;++i)a[i]=getint(),b[i]=getint(),++f[2001-a[i]][2001-b[i]];
	
	for(int re i=1;i<=4002;++i)
	for(int re j=1;j<=4002;++j)
	f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	
	for(int re i=1;i<=n;++i)
	ans=(ans+f[2001+a[i]][2001+b[i]])%mod,
	ans=(ans-C((a[i]+b[i])<<1,b[i]<<1)+mod)%mod;
	
	ans=ans*inv[2]%mod;
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 127104
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, k, A[N], M[N];
int main()
{
    scanf("%d%d", &n, &k);
    if (k == 1 || k == n + n - 1)
        return !printf("No\n");
    if (n == 2)
        return !printf("Yes\n1\n2\n3\n");
    int md = n;
    A[md] = k; M[k] = 1;
    if (k == 2)
        A[md + 1] = 1, M[1] = 1;
    else
    {
        A[md - 1] = k - 1; M[k - 1] = 1;
        A[md + 1] = k + 1; M[k + 1] = 1;
        A[md + 2] = k - 2; M[k - 2] = 1;
    }
    printf("Yes\n");
    for (int i = 1, r = 1; i <= n + n - 1; i++)
    {
        if (!A[i])
        {
            while (M[r]) r ++;
            A[i] = r ++;
        }
        printf("%d\n", A[i]);
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int D, G;
	cin >> D >> G;
	vector<int> A(D);
	vector<int> B(D);
	int res = (int)1 << 60;
	for (int i = 0; i < D; i++) {
		cin >> A[i] >> B[i];
	}
	vector<int> X(D, 0);
	for (int i = 0; i < (1 << D); i++) {
		int z = 0;
		int ans = 0;
		for (int j = 0; j < D; j++) {
			X[j] = A[j];
			if (i & (1 << j)) {
				ans += A[j];
				z += B[j];
				z += A[j] * 100 * (j + 1);
			}
		}
		for (int j = D - 1; j >= 0; j--) {

			if (z >= G)break;
			if ((i & (1 << j)) == 0) {
				if (X[j] > 0) {
					ans++;
					z += 100 * (j + 1);
					X[j]--;
					j++;
				}
			}
		}
		res = min(res, ans);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int l = sc.nextInt();
        int taste[] = new int[n];
        int min = Integer.MAX_VALUE;
        int ans = 0;
        for(int i = 0; i < n; i++){
        	taste[i] = l + i;
            ans += taste[i];
            int a = Math.abs(taste[i]);
            min = Math.min(min, a);
        }
        if(l + n - 1 < 0){
        	System.out.println(ans + min);
        }else{
        	System.out.println(ans - min);
        }
    }
}

Measured memory_bytes: 35748
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n, m;cin >> n >> m;
	vector<ll> v(n);
	ll sum = 0;
	REP(i, n){
		cin >> v[i];
		sum += v[i];
	}

	sort(ALL(v), greater<ll>());
	if(4*m*v[m-1] >= sum)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const ll G = 2000005;
ll a,k,mod = 1e9+7;
ll fac[G], inv_fac[G];

ll binpow(ll x, ll K){
    x%=mod;
    if(K<2) return K ? x : 1;
    return (binpow(x*x, K/2)*(K&1 ? x : 1))%mod;
}

ll modinv(ll c){
    return binpow(c, mod-2);
}

ll CizNpoK(ll N, ll K){
    ll o = fac[N]*inv_fac[K];
    o %= mod;
    return (o*inv_fac[N-K])%mod;
}

int main() {
    fast;
    fac[0] = 1;
    inv_fac[0] = modinv(fac[0]);
    for(ll q=1; q<G; q++){
        fac[q] = (fac[q-1]*q)%mod;
        inv_fac[q] = modinv(fac[q]);
    }
    cin>>k;
    str t; cin>>t; a = t.size();
    k += a;
    ll all = binpow(26, k), pidori = 0;
    for(ll q=0; q<a; q++){
        pidori += CizNpoK(k, q)*binpow(25, k-q);
        pidori %= mod;
    }
    cout<<(all-pidori+mod)%mod;
}

Measured memory_bytes: 35524
import sys
import numpy as np

def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(Ss())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])

s = S()[0]
t = S()[0]

ans = 0
for i, j in zip([c for c in s], [c for c in t]):
  if i != j:
    ans += 1
print(ans)

Measured memory_bytes: 30396
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 10*9+7

int main(){
  int a,b,k;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<< "OK" <<endl;
      return 0;
    }
  }
  cout<< "NG" <<endl;
}

Measured memory_bytes: 3604
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL A;
string B;

LL ans = 0;

void solve(){
	LL u,p1,p2;
	u = B[0] - '0';
	p1 = B[2] - '0';
	p2 = B[3] - '0';

	u = u*A;
	p1 = p1*A;
	p2 = p2*A;

	p2 = p2/10LL;
	p1 = p1 + p2;
	p1 = p1/10LL;

	ans = u + p1;
}

int main(){
    cin >> A >> B;

    solve();
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ll long long
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'a'||__c>'z') __c=getc();
        while(__c>='a'&&__c<='z') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(long double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            long double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y+1e-9);if(__c==10) __c--;
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
struct nod{ll num,dis;}a[100010];
ll ans,n,sz[100010],fa[100010],d[100010],dep[100010];vector<ll>son[100010];
bool cmp(nod l,nod r){return l.dis<r.dis;}
void dfs(ll u,ll f){ll i;dep[u]=dep[f]+1;for(auto v:son[u]){if(v!=f) dfs(v,u);}}
int main()
{
	read(n);ll i;for(i=1;i<=n;i++) read(a[i].dis),a[i].num=i;sort(a+1,a+n+1,cmp);for(i=1;i<=n;i++) d[i]=a[i].dis;
	for(i=n;i>=2;i--)
	{
		sz[a[i].num]++;ll tmp=d[i]-(n-2*sz[a[i].num]),pos=lower_bound(d+1,d+i,tmp)-d;
		if(pos>=i||d[pos]!=tmp){puts("-1");return 0;}
		sz[a[pos].num]+=sz[a[i].num];fa[a[i].num]=a[pos].num;
	}
	for(i=1;i<=n;i++) if(fa[i]) son[fa[i]].push_back(i);
	dep[0]=-1;dfs(a[1].num,0);for(i=1;i<=n;i++) ans+=dep[i];
	if(ans!=d[1]){puts("-1");return 0;}
	for(i=1;i<=n;i++) if(fa[i]) cout<<i<<' '<<fa[i]<<'\n';
	flush();
}

Measured memory_bytes: 16000
import bisect
from collections import deque
N, K = map(int, input().split())
D = list(map(int, input().split()))

ans = 0
for pull_num in range(K+1):
    if pull_num > N:
        continue
    push_num = K - pull_num
    for left_num in range(pull_num+1):
        right_num = pull_num - left_num
        left_D = D[:left_num];  right_D = D[N-right_num:]
        temochi = left_D + right_D
        temochi.sort()
        index = bisect.bisect_left(temochi, 0)
        if push_num >= index:
            ans = max(ans, sum(temochi[index:]))
        else:
            ans = max(ans, sum(temochi[push_num:]))
print(ans)

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

int main(){
	int N,K;cin>>N>>K;
    int Arr[N];
    for(int i=0;i<N;i++) cin>>Arr[i];
    sort(Arr,Arr+N);
    int res=0;
    for(int i=0;i<K;i++) {
       res+=Arr[i];
    }
  cout<<res<<endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

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

  ll N;
  std::cin >> N;

  ld tmp = (N + 1) / 2;

  std::cout << std::setprecision(6);
  print(tmp/N);

  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    ll u = stol(s);
    vector <int> a(s.size());
    for(int i=0;i<s.size();i++)
    {
        a[i]=u%10;
        u=u/10;
    }
    reverse(a.begin(),a.end());
    
    int minV = 1000;
    for(int i=0;i<s.size()-2;i++)
    {
        minV = min(minV,abs(753-(a[i]*100+a[i+1]*10+a[i+2])));
    }

    cout<<minV<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    double n,m,d;
    scanf("%lf%lf%lf",&n,&m,&d);
    double ans;
    if (d!=0){
        ans=((n-d)*2)*(m-1)/(n*n);
    }   else {
        ans=(n-d)*(m-1)/(n*n);
    }
    
    printf("%f\n",ans);
	return 0 ;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 1e9
#define infll 1e15


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int n;

int main(){
    string s;
    cin>>s;
    int ans=inf;
    rep(i,s.length()-2){
        ans=min(ans,abs(753-stoi(s.substr(i,3))));
    }
    cout<<ans<<endl;
}

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

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

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

    return arr

n=int(input())
arr=factorization(n)
ans=0
if n==1:
    print(0)
else:
    for i in arr:
        tmp=i[1]
        cnt=1
        while tmp>=0:
            tmp-=cnt
            cnt+=1
            #print(tmp,cnt)
        ans+=cnt-2
    print(ans)


Measured memory_bytes: 63252
#include<iostream>

using namespace std;

int main(){
    long N, M;
    cin >> N >> M;

    if(N == 1 && M == 1)cout << 1 << endl;
    else if(N == 1 || M == 1)cout << N*M - 2 << endl;
    else cout << (N-2)*(M-2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  char a[4] = {'A','T','C','G'};
  char b[1];
  
  scanf("%c",&b[0]);
  
  if(b[0]==a[0])
    printf("%c",a[1]);
  else if(b[0]==a[1])
    printf("%c",a[0]);
  else if(b[0]==a[2])
    printf("%c",a[3]);
  else
    printf("%c",a[2]);
  
  

  return 0;

}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC128A
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] n = Console.ReadLine().Split(' ');
			int a = int.Parse(n[0]);
			int b = int.Parse(n[1]);
			int c,d = 0;
			c = a * 3;
			d = c + b;
 
			Console.WriteLine(d / 2);
		}		
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
   int N;
   cin>>N;
   vector<string>S(N);
   rep(i,N){
       cin>>S[i];
   }
   int M;
   cin>>M;
   vector<string>T(M);
   rep(i,M){
       cin>>T[i];
   }
   int ans=0;
   bool h=false;
   rep(i,N){
       int cnt=0;
       rep(j,M){
           if(S[i]==T[j]){
               cnt--;
           }
       }
       rep(j,N){
               if(S[i]==S[j]){
                   cnt++;
               }
           }
       
       if(ans<cnt){
           ans=cnt;
           h=true;
       }
   }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596