akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

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

    int q; cin >> q;
    ll total = 0;
    while (q--) {
        int p, n; char c;
        cin >> p >> c >> n;
        if (c == '(') total += n;
        if (c == ')') total -= n;
        cout << (total == 0 ? "Yes" : "No") << endl;
    }


    return 0;
}



Measured memory_bytes: 3224
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	M *= 1000;
	K *= 1000;
	int ans = 0;
	vector<int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		if (abs(M - v[ans] * 6 - K) > abs(M - v[i] * 6 - K))ans = i;
	}
	cout << ans + 1 << endl;
}

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

ab_list = []

for i in range(n):
    a, b = map(int, input().split())
    ab_list.append([a, b])

ab_list.sort(key=lambda x: x[1])

ct = 0

for item in ab_list:
    ct += item[0]
    if ct > item[1]:
        print('No')
        exit()

print('Yes')



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

personCount = int(input())
(days, remain) = [int(i) for i in input().rstrip().split(" ")]

eatList = [int(input()) for i in range(personCount)]

eatCount = [0 for i in range(days + 1)]

for i in eatList:
    current = 1
    while(current < len(eatCount)):
        eatCount[current] += 1
        current += i

print(sum(eatCount) + remain)

Measured memory_bytes: 3316
import math
import itertools

N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

distance = 0
total = 0
routes = itertools.permutations(range(N), N)

for v in routes:
    for i in range(0, N - 1):
        distance += math.sqrt((P[v[i]][0] - P[v[i + 1]][0]) ** 2 + (P[v[i]][1] - P[v[i + 1]][1]) ** 2)

    total += distance
    distance = 0

print(total / math.factorial(N))


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

int main(){
    int n,move=0,ans=0;cin>>n;
    long long h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            move++;
            ans=max(ans,move);
        }
        else move=0;
    }
    cout<<ans<<endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main(){
   int n;cin >>n;
   string s;cin >>s;
   int q;cin>>q;
   vector<int>k(q);
    for (int i = 0; i < q; ++i) {
        cin >>k[i];
    }
    for (int i = 0; i < q; ++i) {
        ll ans=0;
        ll m=0,c=0,mc=0;
        for (int j = 0; j <k[i]; ++j) {
            if(s[j]=='M')m++;
            if(s[j]=='C'){
                c++;
                mc+=m;
            }
        }
        for (int j = 0; j < n - k[i]; ++j) {
            if(s[j]=='D')ans+=mc;
            if(s[j]=='M'){
                m--;
                mc-=c;
            }
            if(s[j]=='C')c--;
            if(s[j+k[i]]=='M')m++;
            if(s[j+k[i]]=='C'){
                c++;
                mc+=m;
            }
        }
        for (int l =n-k[i]; l <n; ++l) {
            if(s[l]=='D')ans+=mc;
            if(s[l]=='M'){
                m--;
                mc-=c;
            }
            if(s[l]=='C')c--;
        }
        cout<<ans <<endl;
    }
}


Measured memory_bytes: 5336
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[]W = new String[n];
        ArrayList<String>ans  = new ArrayList<>();

    for(int i=0; i<n; i++) {
    	W[i] = sc.next();
    	if(!ans.contains(W[i])){		
    	      ans.add(W[i]);
    	}
    }
    int cou = 0;
    for(int i=0; i<n-1; i++) {
    	if(W[i].charAt(W[i].length()-1) != W[i+1].charAt(0)) {
    		cou++;
    	}
    }
    	if(ans.size() == n){
    		if(cou == 0) {
    		  	System.out.println("Yes");
    		}else {
    			System.out.println("No");
    		}
    	}else {
    			System.out.println("No");
    		}
}
}

Measured memory_bytes: 35792
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;

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

#define rep_reverse(i, init, n) for(int i = (init); i > n; --i)

void Main()
{
	string S;
	cin >> S;

	size_t k = S.size() / 2;
	rep_reverse(i, k-1, -1)
	{
		string S1 = S.substr(0, i);
		string S2 = S.substr(i, i);
		if (S1 == S2)
		{
			cout << S.substr(0, 2*i).size() << endl;
			break;
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

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

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

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

	bool result = false;
	for (int i = A; i <= B * A; i += A) {
		if (i % B == C) {
			result = true;
			break;
		}
	}

	cout << (result ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
# ABC131 C Anti-Division
from fractions import gcd
a,b,c,d = map(int,input().split())
n = b-a+1
cd = (c*d)//gcd(c,d)

a_c = (a-1)//c
a_d = (a-1)//d
a_cd = (a-1)//cd

b_c = b//c
b_d = b//d
b_cd = b//cd

print(n- ((b_c-a_c)+(b_d-a_d)-((b_cd-a_cd))))

Measured memory_bytes: 5076
#include <iostream>
using namespace std;
const double pi = 3.141592653589793238462643;
 
int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double angle_a = H * pi / 6 + pi / 360 * M;
  double angle_b = pi / 30 * M;
  
  double diff = abs(angle_a - angle_b) < pi? 
    abs(angle_a - angle_b)
    : 2 * pi - abs(angle_a - angle_b);
  double ans = sqrt(A * A + B * B - 2 * A * B * cos(diff));
  cout.precision(20);
  cout << fixed << ans << endl;
  return 0;   
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,k,s; cin>>n>>k>>s;

  
  if(k==0){
    int y=1e9;
    if(s==y) y--;
    rep(i,n){
      cout<<y<<endl;
    }
    return 0;
  }
  
  int tmp=1e9;
  if(s==tmp) tmp--;
  rep(i,n){
    if(i<k){
      cout<<s<<endl;
    }
    else{
      cout<<tmp<<endl;
    }
  }
  
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll dp[110][110][330];

int main() {
  ll N,W;
  cin>>N>>W;
  vector<vector<ll>> v(N,vector<ll>(2));
  for(ll i = 0; i < N; i++) cin>>v[i][0]>>v[i][1];
  ll T = v[0][0];
  for(ll i = 0; i < N; i++) v[i][0]-=T;
  for(ll i = 0; i < 110LL; i++){
    for(ll j = 0; j < 110LL; j++){
      for(ll k = 0; k < 330; k++){
        dp[i][j][k]=-1;
        if(j==0&&k==0) dp[i][j][k]=0;
      }
    }
  }
  dp[0][1][0]=v[0][1];
  for(ll i = 1; i < N; i++){
    for(ll j = 1; j <=i+1; j++){
      for(ll k = 0; k < 330; k++){
        if(k<v[i][0]) {
          dp[i][j][k]=dp[i-1][j][k];
          continue;
        }
        if(dp[i-1][j-1][k-v[i][0]]==-1) {
          dp[i][j][k]=dp[i-1][j][k];
          continue;
        }
        dp[i][j][k]=max(dp[i-1][j-1][k-v[i][0]]+v[i][1],dp[i-1][j][k]);
      }
    }
  }
  ll ans = 0;
  for(ll i = 0; i < 110; i++){
    for(ll j = 0; j < 330; j++){
      if(i*T+j<=W) chmax(ans,dp[N-1][i][j]);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,k;
    cin>>a>>b>>k;

    if(a>=k)
    {
        a=a-k;
    }
    else if(a<k && a+b>=k)
    {
      a=a-k;
      b=b+a;
      a=0;
    }
    else{a=0;b=0;}
    cout<<a<<" "<<b<<endl;

}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
c = 0
for i in range(N):
  if A[i] == K:
    c = 1
if c == 0:
  if K <= max(A):
    for i in range(N-1):
      p, r = A[N-i-2], A[N-i-1]
      while r != 0:
        p, r = r, p % r
      A[N-i-2] = p
      if p == 1:
        break
    if K % p != 0:
      c = -1
    else:
      c = 1
  else:
    c = -1
if c > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 14224
#include<stdio.h>
int main(void) {
	int x, y,temp,step;
	
	while (1) {
		scanf("%d %d",&x,&y);
		if (x == 0 && y == 0)break;
		step = 0;
		if (x < y) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y != 0) {
			x = x % y;
			temp = x;
			x = y;
			y = temp;
			step++;
		}
		printf("%d %d\n",x,step);
	}
	return 0;
}

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

int main(){
	int a[5];
	for(int i = 0; i < 5; i++){
	cin >> a[i];
	}
	sort(a, a + 5, greater<int>());
	for(int i = 0; i < 5; i++){
		if(i == 4){
			cout << a[i];
		}
		else cout << a[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3140
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

char buffer[1048576];

int main() {
  int h, w, K;
  scanf("%d%d%d", &h, &w, &K);
  vector<vector<int>> board(h);
  for (int i = 0; i < h; i++) {
    scanf("%s", buffer);
    for (int j = 0; j < w; j++) {
      if (buffer[j] == '#') {
        board[i].push_back(j);
      }
    }
  }
  vector<vector<int>> ans(h, vector<int>(w));
  int comp = 0;
  for (int i = 0; i < h; i++) {
    if (board[i].empty()) continue;
    int start = 0;
    for (int j = 0; j < board[i].size(); j++) {
      int end = board[i][j];
      if (j + 1 == board[i].size()) {
        end = w - 1;
      }
      comp++;
      for (int k = start; k <= end; k++) {
        ans[i][k] = comp;
      }
      start = end + 1;
    }
  }
  for (int i = 0; i < h; i++) {
    if (board[i].empty()) {
      if (i > 0 && ans[i - 1][0] != 0) {
        ans[i] = ans[i - 1];
      }
    }
  }
  for (int i = h - 1; i >= 0; i--) {
    if (ans[i][0] == 0 && i + 1 < h && ans[i+1][0] != 0) {
      ans[i] = ans[i + 1];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      printf("%d%c", ans[i][j], " \n"[j + 1 == w]);
    }
  }
  return 0;
}


Measured memory_bytes: 1792
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def debug(predicate, value):
    if predicate:
        print(value)
    return value


def solve():
    """
    OPT[i][j] : (count, all sum between i and j)
    OPT[i][j] = OPT[i][k]+S[k+1:j+1]
    """
    S = input().strip()
    N = len(S)
    OPT = [
        [0 for _ in range(N)] for _ in range(N)
    ]
    for length in range(N+1):
        for i in range(N-length):
            j = i+length
            OPT[i][j] = [1, int(S[i:j+1])]
            for l in range(i, j):
                OPT[i][j][0] += OPT[i][l][0]
                OPT[i][j][1] += OPT[i][l][1]+OPT[i][l][0]*int(S[l+1:j+1])
    return OPT[0][N-1][1]


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 62216
#include <bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i=1;i<=n;++i)

int main(void){
	int N,x;
	cin>>N>>x;
	if(x==1 || x==2*N-1)cout<<"No"<<endl;
	else{
		cout<<"Yes"<<endl;
		rep1(i,2*N-1)cout<<(x+N+i-2)%(2*N-1)+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 1536
//#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

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

    int cif = 0;
    long long aux = n;

    long long shp = 0;
    long long p10 = 1;

    while (aux > 10) {
        shp = shp * 10 + 9;
        p10 *= 10;

        aux /= 10;
        ++ cif;
    }

    long long ans = 9 * cif;

    for (int i = 1; i <= 9; ++ i) {
        if (p10 * i + shp <= n) {
            ++ ans;
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 764
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = input.trim().split("\n");
  const N = parseInt(input.shift());
  const permutation = input[0].split(" ").map(Number);

  let result = 0;
  let min = permutation[0];

  for (let i = 0; i < N; i++) {
    if (min >= permutation[i]) {
      result++;
      min = permutation[i];
    }
  }
  console.log(result);
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<pair<int, int>>> lesson(N * 5);
    rep(i, M) {
        int d, a, k, t;
        cin >> d >> a >> k >> t;
        a--;
        lesson[d * N + a].emplace_back(k, t);
    }

    vvi dp(N * 5 + 1, vi(L + 1));
    rep(i, N * 5) {
        rep(j, L + 1) {
            if (j < L) {
                for (auto p : lesson[i]) {
                    dp[i + p.first][j + 1] = max(dp[i + p.first][j + 1], dp[i][j] + p.second);
                }
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[N * 5][L] << endl;
}

Measured memory_bytes: 3236
def insertion_sort(num_list,gap):
    global cnt 

    for i in range(gap,len(num_list)):
        evc = num_list[i]
        j   = i-gap
        while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc

def shell_sort(num_list):
    global cnt
    cnt = 0
    m_list = []
    h = 1
    while h <= len(num_list):
        m_list.append(h)
        h = 3*h+1
    m_list.reverse()
    m = len(m_list)

    print(m)
    print(' '.join([str(i) for i in m_list]))
    for i in range(m):
        insertion_sort(num_list,m_list[i])

n = int(input())
num_list = [int(input()) for _ in range(n)]

shell_sort(num_list)
print(cnt)
for num in num_list:
    print(num)


Measured memory_bytes: 45508
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


string s;

int main(){
	cin >> s;
	
	if(s.size() < 4){
		cout << "No" << endl;
		return 0;
	}
	string t = "YAKI";
	for(int i = 0; i < 4; i++){
		if(s[i] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

const int maxn = 1e5 + 5;

int n, x[maxn], pref[maxn], suff[maxn];

ll calcgcd(ll a, ll b)
{
	if (!a)
		return b;

	return calcgcd(b % a, a);
}

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

	cin >> n;

	rep(i, 1, n + 1)
	cin >> x[i];

	rep(i, 1, n + 1)
	pref[i] = calcgcd(pref[i - 1], x[i]);

	revrep(i, 1, n + 1)
	suff[i] = calcgcd(suff[i + 1], x[i]);

	// rep(i, 1, n + 1)
	// cout << pref[i] << " ";
	// cout << endl;
	// rep(i, 1, n + 1)
	// cout << suff[i] << " ";

	cout << endl;

	ll ans = 1;

	rep(i, 1, n + 1)
	{
		// cout << ans << " " <<  calcgcd(pref[i - 1], suff[i + 1]) << endl;
		ans = max(ans, calcgcd(pref[i - 1], suff[i + 1]));
	}

	cout << ans << endl;

	return 0;
}








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

int main() {
	long long N, A[5], X;
	cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	sort(A, A + 5);
	if (N % A[0] == 0) X = N / A[0];
	else X = N / A[0] + 1;
	cout << X + 4;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
S=get_nsp
puts yn_judge(N/2<S.count("R"))

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    long long r,n,a,b;
    cin>>n>>a>>b;
    r=n%(a+b);
    if (r<=a)
        cout<<(a*(n/(a+b))+r);
    else
        cout<<(a*(n/(a+b))+a);
    return 0;
}


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

int main() {
    int n, win_cnt[2] = {}, m;
    cin >> n >> win_cnt[0] >> win_cnt[1] >> m;
    if(n == 1) {
        for(int i=0; i<2; ++i) {
            win_cnt[i] *= 4;
        }
    }
    vector<vector<int>> cntx(2, vector<int>(n)), cnty(2, vector<int>(n));
    vector<int> cntd(2), cntd2(2);
    vector<vector<vector<int>>> vv(2, vector<vector<int>>(n, vector<int>(n)));
    vector<map<int, pair<int, int>>> ma(2);
    for(int k=0; k<2; ++k) {
        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                cin >> vv[k][i][j];
                ma[k][vv[k][i][j]] = make_pair(i, j);
            }
        }
    }
    vector<int> M(m);
    for(int i=0; i<m; ++i) {
        cin >> M[i];
    }
    string win = "DRAW";
    int cnt[2] = {};
    for(int i=0; i<m; ++i) {
        bool finish = false;
        for(int k=0; k<2; ++k) {
            if(ma[k].count(M[i]) != 1) {
                continue;
            }
            pair<int, int> p = ma[k][M[i]];
            int y = p.first, x = p.second;
            cntx[k][x]++;
            cnty[k][y]++;
            if(y == x) {
                cntd[k]++;
                if(cntd[k] == n) {
                    cnt[k]++;
                }
            }
            if(y + x == n-1) {
                cntd2[k]++;
                if(cntd2[k] == n) {
                    cnt[k]++;
                }
            }

            if(cntx[k][x] == n) {
                cnt[k]++;
            }
            if(cnty[k][y] == n) {
                cnt[k]++;
            }
            if(cnt[k] >= win_cnt[k]) {
                finish = true;
                if(k == 1 && win != "DRAW") {
                    win = "DRAW";
                } else if(k == 0) {
                    win = "USAGI";
                } else {
                    win = "NEKO";
                }
            }
        }
        if(finish) {
            break;
        }
    }
    cout << win << endl;
}


Measured memory_bytes: 22080
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 998244353
#define INF 1000000009
typedef long long ll;
typedef pair<int,int> P;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
int BE(int b,int e){
    if(e==0){
        return 1;
    }else{
        int sum = BE(b,e/2);
        if(e%2==0){
            return (sum*sum)%MOD;
        }else{
            return (((sum*sum)%MOD)*b)%MOD;
        }
    }
}

const int N_MAX=300000;
int fac[N_MAX];
int facIE[N_MAX];
int comb_line[N_MAX];
void comb_lineup(int N){
    for(int i=0;i<=N;i++){
        if(i==0){fac[0]=1;continue;}
        fac[i]=(i*fac[i-1])%MOD;
    }
    for(int i=0;i<=N;i++){
        facIE[i]=BE(fac[i],MOD-2);
    }
    for(int i=0;i<=N;i++){
        comb_line[i]=(((fac[N]*facIE[i])%MOD)*facIE[N-i])%MOD;
    }
}

signed main(void){
    int N,A,B,K;
    int Ans=0;
    cin >> N>>A>>B>>K;
    comb_lineup(N);
    REP(i,N+1){//iは赤で塗る数
        int Bj=K-A*i;
        int j = Bj/B;
        if(B*j!=Bj)continue;
        if(0>j||j>N)continue;
        Ans+=(comb_line[i]*comb_line[j])%MOD;
        Ans=Ans%MOD;
    }
    cout << Ans%MOD << endl;
    
    
  return 0;
}


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

int main(){
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long ans=a*c;
	long long x=a*d;
	if(x>ans)ans=x;
	x=b*c;
	if(x>ans)ans=x;
	x=b*d;
	if(x>ans)ans=x;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
 
int main(){
    char a[202] = "";
    char b[202] = "";
    char c[202] = "";
    scanf("%s %s", a, b);
    strcpy(c, a);
    strcat(c, a);
    if ( strstr(c, b) == NULL ){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k) {
	  cout << ":(" << endl;
	}
  else {
	  cout << "Yay!" << endl;
	}
  return 0;
}


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

namespace Atc_0030
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            
            var As = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var Bs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var Cs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int result = 0;

            for (int i = 0; i < N; i++)
            {
                result += Bs[As[i] - 1];

                if (i != 0)
                {
                    if (As[i] == As[i - 1] + 1)
                    {
                        result += Cs[As[i - 1] - 1];
                    }
                }
            }
        
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28264
/*
[abc166] C - Peaks
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;

int N, M;
int H[MAX_N];
vector<int> g[MAX_N];

ll solve() {
    int ans = 0;
    for (int i = 0; i < N; i++) {
        bool ok = true;
        for (int to : g[i]) {
            if (H[to] >= H[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        }
    }

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e18;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      #ifndef ONLINE_JUDGE
      // freopen("input.txt", "r", stdin);
      // freopen("output.txt","w",stdout);
      #endif
      string s;
      cin>>s;
      int n=s.length();
      int ans[n];
      for(int i=0;i<n;i++) ans[i]=0;
      for(int i=0;i<n;i++)
      {
            char x=s[i];
            if(x=='R')
            {
                  int j=i;
                  int cnt=0;
                  while(j<n&&s[j]==x) cnt++,j++;
                  int k=j-1;
                  j=i;
                  while(j<=k){
                        // cout<<j<<" ";
                        if((k-j)&1) ans[k+1]++;
                        else ans[k]++;
                        j++;
                  }
                  i=k;
            }
            else{
                  int j=i;
                  int cnt=0;
                  while(j<n&&s[j]==x) cnt++,j++;
                  int k=j-1;
                  while(k>=i)
                  {
                        if((k-i)&1) ans[i-1]++;
                        else ans[i]++;
                        k--;
                  }
                  i=j-1;     
            }
      }
      for(int i=0;i<n;i++)
      {
            cout<<ans[i]<<" ";
      }
}
// I never lose. I either win or I learn


Measured memory_bytes: 1488
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 1)
  {
    cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)

template <class T = int>
T in() { T x; std::cin >> x; return x; }
#define output(e) std::cout << e << '\n'

#ifdef LOCAL
#define db std::cout << "L" << __LINE__
#define de << "\n"
#define dv(x) << " " << #x << "->" << x
#else
#define db
#define de
#define dv(x)
#endif

//
// Implementation
//

#define MAX_N 300000

int tp[MAX_N];

int main() {
  int N = in();
  rep(i, N) tp[i] = in();

  bool reach = false;
  int curr = 0;
  while (true) {
    if (curr == N-1) {
      reach = true;
    }
    int maxpos = -1;
    int nextmaxpos = 0;
    for (int i=curr+1; i<curr+1+(tp[curr]/10); i++) {
      if (i >= N) break;
      int can = i+(tp[i]/10);
      if (can > nextmaxpos) {
        nextmaxpos = can;
        maxpos = i;
      }
    }
    if (maxpos == -1) {
      break;
    }
    db dv(curr) de;
    curr = maxpos;
  }
  if (!reach) {
    output("no");
    return 0;
  }
  
  reach = false;
  curr = N-1;
  while (true) {
    if (curr == 0) {
      reach = true;
    }
    int maxpos = -1;
    int nextmaxpos = 9999999;
    for (int i=curr-1; i>curr-1-(tp[curr]/10); i--) {
      if (i < 0) break;
      int can = i-(tp[i]/10);
      if (can < nextmaxpos) {
        nextmaxpos = can;
        maxpos = i;
      }
    }
    if (maxpos == -1) {
      break;
    }
    curr = maxpos;
    db dv(curr) de;
  }
  if (!reach) {
    output("no");
    return 0;
  }

  output("yes");
}



Measured memory_bytes: 4260
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, A[201010];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
    int c2 = 0;
    int c4 = 0;
    int c = 0;

    rep(i, 0, N) {
        if (A[i] % 4 == 0) c4++;
        else if (A[i] % 2 == 0) c2++;
        else c++;
    }

    if (c4 + 1 == c && N == (c4 + c)) return yes;
    if (c4 < c) return no;

    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 640
#include "iostream"
#include "stdio.h"
#include "iomanip"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "string"
#include "utility"

using namespace std;

int K, X;
int ans;

int main() {
	cin >> K >> X;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			if (X - i - j >= 0 && X - i - j <= K)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    char a;
    cin >> a;
    int b = a - 'a';
    if (b >= 0 && b <= 25) {cout << 'a' << endl;}
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(){
  int p[3],j[2],minp,minj;
  int i;
  
  for(i=0; i<3; i++){
    scanf("%d",&p[i]);
  }

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

  minp = p[0];

  if(minp>=p[1] && p[1]<=p[2])
    minp = p[1];
  else if(minp>=p[2] && p[2]<=p[1])
    minp = p[2];

  minj = j[0];
  if(minj>=j[1])
    minj = j[1];

  printf("%d\n",minp+minj-50);
  return 0;
}


Measured memory_bytes: 2072
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

pub struct UnionFind(Vec<usize>);

#[allow(dead_code)]
impl UnionFind {
    pub fn new(len: usize) -> Self {
        Self((0..len).collect())
    }

    pub fn find(&mut self, i: usize) -> usize {
        if self.0[i] == i {
            i
        } else {
            let parent = self.0[i];
            self.0[i] = self.find(parent);
            self.0[i]
        }
    }

    pub fn union(&mut self, i: usize, j: usize) {
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.0[root_i] = root_j;
    }
}

fn main() {
    input! {
        n: usize,
        cs: [(usize, usize); n],
    }

    let mut cs = cs
        .into_iter()
        .enumerate()
        .map(|(idx, (x, y))| (idx, x, y))
        .collect::<Vec<_>>();
    let mut ans = 0;
    let mut q = std::collections::BinaryHeap::new();

    cs.sort_by_key(|&(_, x, _)| x);

    for i in 1..n {
        let cost = cs[i].1 - cs[i - 1].1;
        q.push(std::cmp::Reverse((cost, cs[i - 1].0, cs[i].0)));
    }

    cs.sort_by_key(|&(_, _, y)| y);

    for i in 1..n {
        let cost = cs[i].2 - cs[i - 1].2;
        q.push(std::cmp::Reverse((cost, cs[i - 1].0, cs[i].0)));
    }

    let mut uf = UnionFind::new(n);

    while let Some(std::cmp::Reverse((cost, from, to))) = q.pop() {
        if uf.find(from) == uf.find(to) {
            continue;
        }

        uf.union(from, to);
        ans += cost;
    }

    echo!(ans);
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int A,B,C;
signed main() {
    cin>>A>>B>>C;
    if(A%2==0||B%2==0||C%2==0)cout<<0<<endl;
    else cout<<min(min(A*B,A*C),B*C)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, x, c[15], a[15][15], f[1 << 15][15], level[15];

int main() {
#ifdef _0219nice
	freopen("1.in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	while (cin >> n >> m >> x) {
		int ans = INT32_MAX;
		for (int i = 0; i < n; i++) {
			cin >> c[i];
			for (int j = 0; j < m; j++) {
				cin >> a[i][j];
			}
		}
		for (int buy = 0; buy < (1 << n); buy++) {
			int cost = 0;
			memset(level, 0, sizeof(level));
			for (int i = 0; i < n; i++) {
				if (buy >> i & 1) {
					cost += c[i];
					for (int j = 0; j < m; j++) {
						level[j] += a[i][j];
					}
				}
			}
			if (*min_element(level, level + m) >= x) {
				ans = min(cost, ans);
			}
		}
		if (ans == INT32_MAX) ans = -1;
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ", a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
#define py puts("Yes")
#define pn puts("No")
#define pY puts("YES")
#define pN puts("NO")
#define re(i, a, b) for (int i = a; i <= b; ++i)
#define de(i, a, b) for (int i = a; i >= b; --i)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
const ll mode = 192600817;
template <class T>
inline void cmin(T &a, T b) { ((a > b) && (a = b)); }
template <class T>
inline void cmax(T &a, T b) { ((a < b) && (a = b)); }
ll a[100], b[100], c[100], d[100], A[100];
int n, m, q;
ll dfs(int i, int x)
{
  A[i] = x;
  if (i == n)
  {
    ll cnt = 0;
    for (int k = 1; k <= q; ++k)
    {
      int ak = a[k];
      int bk = b[k];
      if (A[bk] - A[ak] == c[k])
      {
        cnt += d[k];
      }
    }
    return cnt;
  }
  ll ma = 0;
  for (int j = x; j <= m; ++j)
  {
    ma = max(dfs(i + 1, j), ma);
  }
  return ma;
}
int main()
{
  siii(n, m, q);
  re(i, 1, q)
  {
    sll(a[i], b[i]);
    sll(c[i], d[i]);
  }
  ll ans = 0;
  for (int i = 1; i <= m; ++i)
    ans = max(ans, dfs(1, i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		BigInteger sum = BigInteger.ZERO;
		BigInteger[] nums = new BigInteger[100001];
		for (int i = 0; i < n; i++) {
			int num = sc.nextInt();
			if (nums[num] == null) {
				nums[num] = BigInteger.ONE;
			} else {
				nums[num] = nums[num].add(BigInteger.ONE);
			}
			sum = sum.add(BigInteger.valueOf(num));
		}
		sc.nextLine();
		int q = sc.nextInt();
		List<BigInteger> sumList = new ArrayList<BigInteger>();
		for (int i = 0; i < q; i++) {
			sc.nextLine();
			int b = sc.nextInt();
			int c = sc.nextInt();
			BigInteger bigB = BigInteger.valueOf(b);
			BigInteger bigC = BigInteger.valueOf(c);
			BigInteger cnt = nums[b] == null ? BigInteger.ZERO : nums[b];
			sum = sum.add(bigC.multiply(cnt));
			sum = sum.subtract(bigB.multiply(cnt));
			sumList.add(sum);
			
			if (nums[c] == null) {
				nums[c] = cnt;
			} else {
				nums[c] = nums[c].add(cnt);
			}
			nums[b] = BigInteger.ZERO;
		}
		
		for (BigInteger i : sumList) {
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 77268
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main() {
    string str;

    int m, r, f, sum;
    while (cin >> m >> r >> f) {
        sum = m + r;
        if (!(m == r && r == f && f == -1)) {
            if (m == -1 || r == -1) cout << "F";
            else if (sum >= 80) cout << "A";
            else if (sum >= 65) cout << "B";
            else if (sum >= 50) cout << "C";
            else if (f >= 50) cout << "C";
            else if (sum >= 30) cout << "D";
            else cout << "F";
        }
        else break;
        cout << endl;
    }
}



Measured memory_bytes: 3084
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		List<String> list_check=new ArrayList<String>();
		int n= sc.nextInt();
		for(int i=0;n>i;i++) {
			String s = sc.next();
			List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
			Collections.sort(list);
			String check ="";
			for(int j=0;list.size()>j;j++) {
				check=check+list.get(j);
			}
			list_check.add(check);
		}
		long answer=0;
		Collections.sort(list_check);
		//System.out.println(list_check);
		for(int i=0;list_check.size()>i;i++) {
			int count=0;
			for(int j=i+1;list_check.size()>j;j++) {
				if(list_check.get(i).equals(list_check.get(j))) {
					count++;
					answer=answer+count;
				}
				else
					break;
			}
			i=i+count;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 102388
import sys, re
def せいすう(): return int(input())
def たくさんのせいすう(): return map(int, input().split())
def せいすうのリスト(): return list(map(int, input().split()))

ようそすう = せいすう()
いま = せいすうのリスト()
もくひょう = せいすうのリスト()

def こうじゅんにならびかえ(リスト):
	return sorted(リスト, reverse=True)

def しゅつりょく(しゅつりょくしたいもじ):
	print(しゅつりょくしたいもじ)

def ごうけい(リスト):
	return sum(リスト)

def ながさ(リスト):
	return len(リスト)

def まとめる(リスト1, リスト2):
	return zip(リスト1, リスト2)

def おわり():
	exit()

def いちをたす(すうじ):
	return すうじ+1

def リストについか(リスト, あたい):
	リスト.append(あたい)

if ごうけい(いま) < ごうけい(もくひょう):
	しゅつりょく(-1)
	おわり()

ふそくリスト = []
よゆうリスト = []

for いまのじゅんびど, もくひょうのじゅんびど in まとめる(いま, もくひょう):
	if いまのじゅんびど < もくひょうのじゅんびど:
		リストについか(ふそくリスト, もくひょうのじゅんびど-いまのじゅんびど)
	else:
		リストについか(よゆうリスト, いまのじゅんびど-もくひょうのじゅんびど)

ふそくこすう = ながさ(ふそくリスト)
if ふそくこすう == 0:
	しゅつりょく(0)
	おわり()

ふそくぶん = ごうけい(ふそくリスト)
よゆうソート = こうじゅんにならびかえ(よゆうリスト)

こたえ = ふそくこすう
おぎなうぶん = 0
for よゆうぶん in よゆうソート:  # これはにぶたんでもできます
	おぎなうぶん += よゆうぶん
	こたえ = いちをたす(こたえ)
	if おぎなうぶん >= ふそくぶん:
		break

しゅつりょく(こたえ)


Measured memory_bytes: 19444
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#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 sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

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

    ll N; cin >> N;
    int ans = 0;
    FOR(i, 2, 1000010) {
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        FOR(j, 1, 10000) {
            if (cur < j) break;
            ans++; cur -= j;
        }
    }
    if (N > 1) ans++;
    cout << ans << nl;

	return 0;
}

// read the question correctly (ll vs int)


Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> water;
    for(int i=0; i<=f; i+=100){
        for(int aa=0; aa<=i/(100*a); aa++){
            if((i-aa*a*100)%(b*100)==0){
                water.push_back(i);
                break;
            }
        }
    }
    double ans[3]={0, 100*a,0};
    for(int w=0; w<water.size(); w++){
        for(int i=0; i<=water[w]/100*e/c; i++){
            if(i*c+water[w]>f) break;
            for(int j=0; j<=(water[w]/100*e-c*i)/d; j++){
                if(i*c+j*d+water[w]>f) break;
                double tmp=double(i*c+j*d)/(i*c+j*d+water[w]);
                if(ans[0]<tmp){
                    ans[0]=tmp;
                    ans[1]=i*c+j*d+water[w];
                    ans[2]=i*c+j*d;
                }
            }
        }
    }
    cout << ans[1] << ' ' << ans[2] << endl;

    return 0;
}

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

int main() {
	string ans = "No";
	int n;

	cin >> n;

	int cnt1 = n / 4;
	int cnt2 = n / 7;
	for( int i = 0; i <= cnt1; i++ ) {
		for( int j = 0; j <= cnt2; j++ ) {
			if( 4 * i + 7 * j == n ) {
				ans = "Yes";
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
	string s;
	cin >> s;
	
	vector<string> rev_ori, rev_s1, rev_s2;
	for (int i = 0; i < s.length(); ++i)
	{
		rev_ori.push_back(string(1, s[i]));
	}
	
	for (int i = 0; i < (s.length() - 1) / 2; ++i)
	{
		rev_s1.push_back(string(1, s[i]));
	}
	
	for (int i = (s.length() + 3) / 2 - 1; i < s.length(); ++i)
	{
		rev_s2.push_back(string(1, s[i]));
	}
	
	vector<string> t_ori = rev_ori;
	vector<string> t1 = rev_s1;
	vector<string> t2 = rev_s2;
	
	reverse(t_ori.begin(), t_ori.end());
	reverse(t1.begin(), t1.end());
	reverse(t2.begin(), t2.end());
	
	if ((t1 == rev_s1) and (t2 == rev_s2) and (t_ori == rev_ori))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v,u;
    pair<string, long long> n;
    set<long long> y;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=1,l=0,r=0,z,m,h,p;
    string t,s,x,q;
    double w;
    cin>>s>>t;
    for(i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            d++;
        }
    }
    cout<<d;
}

Measured memory_bytes: 3852
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define MOD 1000000007
# define INF 10000000000009
# define MAX 1000000

double prob[3001];
double dp[3001][3001];

double findNum(int i, int h){
    if(h == 0)
        return 1;
    if(i == 0)
        return 0;

    if(dp[i][h] > -0.9){
        return dp[i][h];
    }

    return dp[i][h] = prob[i]*findNum(i - 1, h - 1) + (1 - prob[i])*findNum(i - 1, h);

}

void solve(){
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++){
        cin >> prob[i];
    }

    memset(dp, -1, sizeof(dp));
    double ans = findNum(n, n/2 + 1);
    cout.precision(10);
    cout << ans;
}


int main(){
    int t;
    t = 1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 74340