akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    ll N;
    cin >> N;
    int sqrtN = sqrt(N);
    int A,B;
    for (int i = sqrtN; i >= 1; i--) {
        if (N % i == 0) {
            A = i;
            B = N / i;
            break;
        }
    }
    int cntA = 0,cntB = 0;
    while (A != 0) {
        A /= 10;
        cntA++;
    }
    while (B != 0) {
        B /= 10;
        cntB++;
    }
    cout << max(cntA,cntB) << endl;
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <class T> inline bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> inline bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}

int main() {
	int K, X;
	cin >> K >> X;
	rep(i, X-K+1, X+K){
		cout << i << " ";
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi A(N);
  cin>>A[0];
  int ans=0;
  rep(i,1,N){
    cin>>A[i];
    if(A[i]==A[i-1]){
      A[i]=-1;
      ans++;
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
def ansloop(wcnt1, fcnt, n):
    wcnt1 *= n
    fcnt *= n
    tans = 0
    while wcnt1 >= 0:
        tmpans = wcnt1 * inlst[2]
        if tmpans <= cnt1 * n:
            tmp = tmpans
            for i in range(fcnt):
                tmp += inlst[3]
                if tmp <= cnt1 * n:
                    tmpans = tmp
                else:
                    break
            tans = max(tans, tmpans)
        wcnt1 -= 1
    return tans

inlst = list(map(int, input().split()))
ans1 = 0
cnt1 = inlst[0] * inlst[4]
if cnt1 + (inlst[0] * 100) > inlst[-1]:
    cnt1 = inlst[-1] - (inlst[0] * 100)
wcnt1 = (cnt1 // inlst[2] + 1)
fcnt = wcnt1
roopcnt = inlst[-1] // (cnt1 + 100 * inlst[0])

index = 1
for i in range(1, roopcnt + 1):
    tmp = ansloop(wcnt1, fcnt, i)
    if (100 * ans1) / (index * 100 * inlst[0] + ans1) < (100 * tmp) / (i * 100 * inlst[0] + tmp):
        ans1 = tmp
        index = i
print(100 * inlst[0] * index + ans1, ans1)

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

using namespace std;
typedef long long ll;

int main()
{
  int N, Q;
  string S;
  cin >> N >> Q >> S;

  int tmp = 0;
  vector<int> cum(N);
  cum[0] = 0;
  for( int i=1;i<N;i++ )
    {
      if(S[i-1] == 'A' && S[i] == 'C')
	tmp++;
      cum[i] = tmp;
    }

  for( int i=0;i<Q;i++ )
    {
      int l,r;
      cin >> l >> r;
      cout << cum[r-1]-cum[l-1] << endl;
    }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    string S;cin >> S;
    vector<int> mozi(S.size());
    rep(i,S.size()){
        mozi[i] = S[i];
        int tmp = mozi[i] + N;
        if(tmp > 90)mozi[i] = tmp - 26;
        else mozi[i] = tmp;
    }
    rep(i,S.size())cout << char(mozi[i]);
    cout << endl;
}



Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int[] numbers = new int[scanner.nextInt() + 1];
    for (int ix = 1; ix < numbers.length; ix++) {
      numbers[ix] = scanner.nextInt();
    }

    int swaps = 0;
    for (int ix = 1; ix < numbers.length; ix++) {
      if (numbers[ix] == ix) {
        swaps++;
        if (ix < numbers.length - 1) {
          int temp = numbers[ix];
          numbers[ix] = numbers[ix + 1];
          numbers[ix + 1] = temp;
        } else if (ix > 0) {
          int temp = numbers[ix];
          numbers[ix] = numbers[ix - 1];
          numbers[ix - 1] = temp;
        }
      }
    }

    System.out.println(swaps);
  }
}

Measured memory_bytes: 50624
#include<stdio.h>
char str[1001],com[9],cp[1001],p[1001];
 
void reset(void);
void reset2(void);
 
 
main()
{
     
    int q,a,b,c,c2,FLAG;
     
    scanf("%s",str);
     
    scanf("%d",&q);
     
    while(q){
        FLAG=3;
        reset();
         
        scanf("%s",com);
         
        if(strcmp(com,"print")==0  ) {FLAG=0;}
        if(strcmp(com,"reverse")==0) {FLAG=1;}
        if(strcmp(com,"replace")==0) {FLAG=2;}
         
         
        switch(FLAG){
            case 0: //print
                scanf("%d %d",&a,&b);
                for(c=a;c<=b;c++){
                    printf("%c",str[c]);
                }
                printf("\n");
                break;
             
            case 1: //reverse
                scanf("%d %d",&a,&b);
                reset2();
                strcpy(cp,str);
                for(c=a,c2=b;c<=b;c++,c2--){
                    str[c]=cp[c2];
                }
                break;
             
            case 2: //replace
                scanf("%d %d",&a,&b);
                scanf("%s",p);
                 
                for(c=a,c2=0;c<=b;c++,c2++){
                    str[c]=p[c2];
                }
                break;
             
            default:q++;break;
        }
        q--;
    }
    return 0;
}
 
void reset(){
    int a;
     
    for(a=0;a<9;a++){
        com[a]=0;
    }
}
 
void reset2(){
    int a;
     
    for(a=0;a<1001;a++){
        cp[a]=0;
        p[a]=0;
    }
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n,k; cin >> n >> k;
	int a[n]; 
	forn(i,0,n) cin >> a[i];
	sort(a,a+n);
	int ans = 0;
	forn(i,0,k){
		ans += a[i];
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

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

  int n;
  cin >> n;
  int r, t;
  for(int i = 0;i < n;++i){
    cin >> r >> t;

    if(r % 100 == 0 && t % 30 == 0){
      cout << 5 * (t / 30) + r / 100 << endl;
    }
    else if(r % 100 == 0){
      cout << 5 * (t / 30) + r / 100 << ' ';
      cout << 5 * ((t + 30) / 30) + r / 100 << endl;
    }
    else if(t % 30 == 0){
      cout << 5 * (t / 30) + r / 100 << ' ';
      cout << 5 * (t / 30) + (r + 100) / 100 << endl;
    }
    else{
      cout << 5 * (t / 30) + r / 100 << ' ';
      cout << 5 * (t / 30) + (r + 100) / 100 << ' ';
      cout << 5 * ((t + 30) / 30) + r / 100 << ' ';
      cout << 5 * ((t + 30) / 30) + (r + 100) / 100 << endl;
    }
  }

  return 0;
}
 



Measured memory_bytes: 3196
ar = [[int(i) for i in input().split()] for j in range(3)]

if ar[0][0] + ar[1][1] + ar[2][2] == ar[0][1] + ar[1][2] + ar[2][0] == ar[0][2] + ar[1][0] + ar[2][1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include "fstream"
using namespace std;
#define PI acos(-1)
#define MOD (ll)1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-8
void display(vector<ll> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}
ll dx[8] = {0,1,0,-1,1,1,-1,-1};
ll dy[8] = {1,0,-1,0,1,-1,1,-1};

//Jai Shree Krishna
//:) :) :( :( :( :( :( :( :) :( :)
//Purple Dreams ??? 
//Shit ;More Shit and Hell lot of Shit and Still Shit 

const int MAXN = (ll)1e5+1000;
ll A[MAXN];
ll B[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll sum = 0 ;
    loop(i,n)
    {
        cin>>A[i];
        sum+=A[i];
    }
    ll t  = (n*(n+1))/2;
    
    if(sum%t)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    ll cnt = sum/t;
    loop(i,n)
    {
        B[i] = A[(i+1)%n]-A[i]-cnt;
    }
    bool flag = true;
    loop(i,n)
    {
        if(B[i]>0||(-B[i])%n)
        {
            flag = false;
        }
    }
    if(flag)
    {
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int n;
int graph[101][101];
int d[101];
int k[101];
bool beg[101];
int cnt=0;
int pre=-6;
queue<int>now;
queue<int>nextg;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        beg[i]=false;
        d[i]=-1;
        int number;
        cin>>number;
        cin>>k[i];
        for(int j=1;j<=k[i];j++)
        {  cin>>graph[i][j];
        }
    }
    for(int j=1;j<=k[1];j++)
    {  now.push(1);
        nextg.push(graph[1][j]);
    }
    d[1]=0;
    beg[1]=true;
    while(now.size())
    {
        int nowt=now.front();
        int nextt=nextg.front();
        
        now.pop();
        nextg.pop();
        if(beg[nextt]==false)
        {
            d[nextt]=d[nowt]+1;
            beg[nextt]=true;
            pre=nowt;
            for(int j=1;j<=k[nextt];j++)
            {
                now.push(nextt);
                nextg.push(graph[nextt][j]);
                //cout<<"now "<<nextt<<"nextg "<<graph[nextt][j]<<endl;
            }
        }
        
    }
    for(int i=1;i<=n;i++)
    {
        if(d[i]<0)
            d[i]=-1;
        cout<<i<<" "<<d[i]<<endl;
    }
   return 0;
}



Measured memory_bytes: 3140
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int a = Integer.parseInt(line1[0]);
        int b = Integer.parseInt(line1[1]);
        double sum = 0;
        int count = 0;
        for(int i = 1; i <= a; i++){
            int c = i;
            double sum1 = 0;
            double d = 1 / (double)a;
            double res = 1;
            for(int j = 0; c < b; j++){
                c = c * 2;
                count++;
                res = res * (1 / (double)2);
                //System.out.println(res);
                //System.out.println(c);
                //System.out.println(count);
            }
            //double res = Math.pow(1 / 2, count);
            sum1 = d * res;
            //System.out.println(sum1);
            sum = sum + sum1;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21204
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		int minv = 0;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int input = Integer.parseInt(br.readLine());
			if (i == 0) {
				minv = input;
				continue;
			}
			maxv = maxv < (input - minv) ? (input - minv) : maxv;
			minv = minv > input ? input : minv;
		}
		System.out.println(maxv);
	}
}

Measured memory_bytes: 42320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define dd double
#define f0(i, n) for(int i = 0; i < n; i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define f1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

ll dp[105][100005];

ll knapSack(ll W, ll wt[], ll val[], ll n) {

	if (W == 0 || n == 0) {
		return 0;
	}

	if (dp[n - 1][W] != -1) {

		return dp[n - 1][W];
	}

	if (wt[n - 1] > W) {
		return knapSack(W, wt, val, n - 1);
	}

	return dp[n - 1][W] = max(knapSack(W, wt, val, n - 1), val[n - 1] + knapSack(W - wt[n - 1], wt, val, n - 1));
}
int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);




//ios_base& scientific (ios_base& str);
	ll N, W;
	cin >> N >> W;

	ll w[N], val[N];
	memset(dp, -1, sizeof(dp));

	for (int i = 0; i < N; i++) {
		cin >> w[i] >> val[i];
	}

	ll ans = knapSack(W, w, val, N);
	cout << ans << endl;






	return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a[5];
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  sort(a,a+5);
  reverse(a,a+5);
  for(int i=0;i<5;i++){
    if(i>0){
      cout << ' ';
    }
    cout << a[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int N;
    string s,t;
    int si=0;
    cin >> N >> s >> t;
    if(s==t){cout << N;}else{
    for(int i=1;i<=N;i++){
        
        //cout << s.substr(t.size()-i,i) <<"   ";
         //cout << t.substr(0,i) <<endl;
        if(s.substr(t.size()-i,i)==t.substr(0,i)){
            si=i;
        }
    }
   // cout << s.size()<<endl;
   // cout << t.size() <<endl;
   // cout << si <<endl;
    cout << s.size()+t.size()-si <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

ll cs[110];
ll vs[110];


vector<ll> ks[10];
ll ss[10][110];

int main(void) {
  int n;
  ll limit;
  scanf("%d%lld", &n, &limit);
  REP(i, n) {
    scanf("%lld%lld", &cs[i], &vs[i]);
    ks[cs[i]-cs[0]].push_back(vs[i]);
  }
  REP(i, 4) {
    sort(ks[i].begin(), ks[i].end());
    reverse(ks[i].begin(), ks[i].end());
    REP(j, ks[i].size()) {
      ss[i][j+1] = ss[i][j] + ks[i][j];
    }
  }
  ll res = 0;
  REP(i0, ks[0].size()+1) REP(i1, ks[1].size()+1) REP(i2, ks[2].size()+1) {
    ll w = cs[0]*i0 + (cs[0]+1)*i1 + (cs[0]+2)*i2;
    if(w > limit) {
      continue;
    }
    int i3 = min((ll)ks[3].size(), (limit - w) / (cs[0]+3));
    // cerr << i0 << " " << i1 << " " << i2 << " " << i3 << " " << w << endl;
    res = max(res, ss[0][i0] + ss[1][i1] + ss[2][i2] + ss[3][i3]);
  }
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 256
# 一回で回していくバージョン
r, c = map(int, input().split())
sheet = [[0 for _ in range(c)] for _ in range(r)]
last_culmn = [0 for _ in range(c)]
s = 0
for y in range(r):
    row = list(map(int, input().split()))
    row_s = 0
    for x in range(c):
        sheet[y][x] = row[x]
        row_s += row[x]
        last_culmn[x] += row[x]
        s += sheet[y][x]
    sheet[y].append(row_s)
last_culmn.append(s)
sheet.append(last_culmn)

[print(" ".join(list(map(str, line)))) for line in sheet]



Measured memory_bytes: 5692
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

import numpy as np

n = int(input())
a = np.array([list(map(int, input().split())) for _ in range(n)])

g = csr_matrix(a)
dist = floyd_warshall(g)

if (dist == a).all():
    sm = a.sum()

    INF = 10 ** 18 + 1
    for i in range(n):
        a[i, i] = INF

    for u in range(n):
        for v in range(n):
            if u == v:
                continue

            mn = np.min(a[u] + a[v])
            if mn == a[u, v]:
                sm -= a[u, v]

    ans = sm // 2
    print(ans)

else:
    print(-1)


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

using int64 = long long;

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

    const int MAXM = 200005;

    vector<int> a(n);
    static vector<int> dest[MAXM];

    int64 sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;

        if (i == 0) continue;
        if (a[i - 1] > a[i]) dest[a[i] + m].push_back(a[i - 1]);
        else dest[a[i] + m].push_back(a[i - 1] + m);

        sum += (a[i] - a[i - 1] + m) % m;
    }

    // cerr << "sum is " << sum << endl;

    vector<int64> prize(2 * m, 0);
    priority_queue<int> Q;

    int64 score = 0;
    for (int i = 2 * m - 1; i >= 0; i--) {
        score -= Q.size();
        while (!Q.empty() and Q.top() > i) Q.pop();

        while (!dest[i].empty()) {
            int d = dest[i].back(); dest[i].pop_back();

            if (i >= d + 2) {
                Q.push(d + 2);
                score += i - d - 1;
            }
        }

        prize[i] += score;

        /*
        cerr << i << "'s Q size is " << Q.size() << endl;
        cerr << i << "'s score is " << score << endl;
        */
    }

    int64 ans = sum;
    for (int i = 0; i < m; i++) {
        // cerr << "" << i << "'s prize is " << prize[i] + prize[i + m] << endl;
        ans = min(ans, sum - prize[i] - prize[i + m]);
    } 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,a[2005],sum;
bitset<2005*2005> dp(1);
int main(){
    n=read();for(int i=1;i<=n;i++) a[i]=read(),sum+=a[i];
    for(int i=1;i<=n;i++) dp=dp|(dp<<a[i]);
    sum=(sum+1)/2;
    for(int i=sum;;i++) if(dp[i]) {printf("%d\n",i);return 0;}
    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main() {
  long long N, T, sum = 0, cur = 0;
  scanf("%lld %lld", &N, &T);

  for (int i = 0; i < N; i++) {
    long long t, add = T;
    scanf("%lld", &t);

    if (cur > t) add = T - (cur - t);
    sum += add;
    cur = t + T;
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

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

    qsort(a,n,sizeof(int),desc_cmp);
    int alice,bob;
    alice=bob=0;
    for(int i=0;i<n;i+=2)alice+=a[i];
    for(int i=1;i<n;i+=2)bob+=a[i];

    printf("%d\n",alice-bob);
}

Measured memory_bytes: 128
a, b, c, d = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al = sorted(al, reverse=True)
bl = sorted(bl, reverse=True)
cl = sorted(cl, reverse=True)
q = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
ans = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
#while True:
for i in range(d):
    s, aq, bq, cq = map(int, q.pop())
    if len(al) > aq+1:
        if [al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq] not in ans:
            q.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])
            ans.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])

    if len(bl) > bq+1:
        if [al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq] not in ans:
            q.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])
            ans.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])

    if len(cl) > cq+1:
        if [al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1] not in ans:
            q.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])
            ans.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])

    q = sorted(q)

    #if len(ans) > d:
    #   ans = sorted(ans, reverse=True)
    #    if ans[d][0] > q[len(q)-1][0]:
    #        break

ans = sorted(ans, reverse=True)
for i in range(d):
    print(ans[i][0])


Measured memory_bytes: 5228
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,i;cin>>n;
	vector<int>a(n);
	vector<int>wa(n+1);
	for(i=0;i<n;i++){cin>>a[i];wa[i+1]=wa[i]^a[i];}
	vector<int>zewa(n+1);zewa[0]=1;
	for(i=1;i<=n;i++){
		zewa[i]=zewa[i-1];
		if(wa[i]==0){zewa[i]++;}
	}
	llint dp=1,ep=0;
	if(wa[n]!=0){
		int ter=wa[n];
		
		for(i=1;i<n;i++){
			if(wa[i]==ter){ep+=dp;ep%=mod;}
			if(wa[i]==  0){dp+=ep;dp%=mod;}
		}
		cout<<dp<<endl;return 0;
	}
	llint ans=0;
	int mae=0,mb=0;
	vector<pair<int,int>>bas;
	bas.reserve(n+2-zewa[n]);
	for(i=1;i<n;i++){
		
		if(wa[i]==0){continue;}
		bas.pub(mp(wa[i],i));
	}
	bas.pub(mp(mod,0));
	SO(bas);
	for(auto it:bas){
		int p=it.sec;
		if(mae!=it.fir){mae=it.fir;ans+=ep;ans%=mod;dp=1;ep=1;}
		else{dp+=ep*(zewa[p]-zewa[mb]);dp%=mod;ep+=dp;ep%=mod;}
		mb=p;
	}
	dp=1;
	for(i=0;i<zewa[n]-2;i++){dp*=2;dp%=mod;}
	ans+=dp;ans%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  double s = w * h / 2;
  cout << fixed << setprecision(10) << s << " ";
  if (2 * x == w && 2 * y == h)
    cout << 1;
  else
    cout << 0;
  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 < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
const int MOD=998244353;
const ll MAX = 210000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll Pow(ll a,ll b){
    ll res=1ll;
    a%=MOD;
    while(b){
        if (b & 1)
            res = (1ll*res * a) % (1ll*MOD);
        a = (1ll*a * a) % (1ll*MOD);
        b >>= 1ll;
    }
    return 1ll*res%MOD;
}

int main(){
  ll N,M,K;cin>>N>>M>>K;
  COMinit();
  ll ans = 0;
  rep(i,K+1){
    ans += COM(N-1,i) % MOD * M % MOD * Pow(M-1,N-(i+1));
    //cout << "i " << i << "ans " << ans << endl;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8576
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v) { cout << v << endl; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

int main() {
  int n; in(n);
  vector<ll> A(n);
  loop(i,0,n) in(A[i]);
  ll sum = 0;
  loop(i,0,n) sum += A[i];
  ll b = sum;
  loop(i,0,n) if (i&1) b -= 2 * A[i];
  vector<ll> B { b };
  loop(i,1,n) B.push_back(2*A[i-1]-B[i-1]);
  loop(i,0,B.size()) {
    if (i!=0) cout << " ";
    cout << B[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  A, N ;

  cin >> N ;
  A = N % 1000 ;

  if (A == 0) {
    cout << 0 << endl;
  }

  else {
    cout << 1000 - A << endl;
  }
      
}

Measured memory_bytes: 3620
# https://atcoder.jp/contests/dp/tasks/dp_n

import itertools as it

INF = 1 << 62
N = int(input())
xs = [int(s) for s in input().split()]
acc = list(it.accumulate([0] + xs))

dp = [[INF] * (N + 1) for _ in range(N)]

for i in range(N):
    dp[i][i + 1] = 0

for w in range(2, N + 1):
    for i in range(N - w + 1):
        j = i + w
        subcost = min(dp[i][k] + dp[k][j] for k in range(i + 1, j))
        dp[i][j] = subcost + acc[j] - acc[i]

print(dp[0][N])


Measured memory_bytes: 45148
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;

    cin >>x>>y;
cout <<x*x-y;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 100000000;

int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

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

using namespace std;

vector<int> UFtree;

int root(int i) {
  if(UFtree[i] == i) return i;
  return (UFtree[i] = root(UFtree[i]));
}

bool is_same_set(int i, int j) {
  return root(i) == root(j);
}

void unite(int i, int j) {
  UFtree[root(i)] = root(j);
}


int main() {
  int n, q, op, x, y;
  cin >> n >> q;
  for(int i = 0; i < n; i++) UFtree.push_back(i);
  for(int i = 0; i < q; i++) {
    cin >> op >> x >> y;
    if(op == 0) unite(x, y);
    else cout << is_same_set(x, y) << endl;
  }
  return 0;
}

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

int main(){
    std::string S;
    std::cin >> S;
    int num = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'o') num++;
    }
    std::cout << 700 + 100 * num << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <ctype.h>
const int bufSize = 1e6;
#define DEBUG
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    static int flag;
    flag = 1, r = 0;
    for (c = nc(); !isdigit(c); c = nc()) if (c == '-') flag = -1;
    for (; isdigit(c); c = nc()) r = r * 10 + c - 48;
    return r *= flag;
}
const int maxn = 5e3 + 100;
int n,k,P[maxn],C[maxn];
long long sum[maxn],f[maxn];
int vis[maxn];
inline long long check(int s)
{
    for (int i = 0; i <= n; ++i) sum[i] = f[i] = -(1ll<<60),vis[i] = 0;
    sum[0] = 0;
    int u = s,i = 1;
    for(i = 1;;++i)
    {
        u = P[u];
        sum[i] = sum[i-1]  + C[u];
        f[i] = std::max(f[i-1],sum[i]);
        if(vis[u]) break;
        else vis[u] = i;
    }
    if(k <= i) return f[k];
    long long num = sum[i] - sum[vis[u]];
    if(num <= 0) return f[i];
    int len = i - vis[u];
    int times = (k - vis[u]) / len,pos = k - times * len;
    return f[pos] + num * times;
}
int main()
{
    read(n),read(k);
    for (int i = 1; i <= n; ++i) read(P[i]);
    for (int i = 1; i <= n; ++i) read(C[i]);
    long long ans = check(1);
    for (int i = 2; i <= n; ++i) ans = std::max(ans,check(i));
    printf("%lld\n",ans);
    return 0;
}

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

int n;

int main()
{
    while(cin >> n)
    {
        if(n % 2 == 0)
        {
            cout << (n / 2) * (n / 2) << endl;
        }
        else
        {
            cout << ((n + 1) / 2) * (n / 2) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
blue_card = [input() for i in range(n)]
m = int(input())
red_card = [input() for i in range(m)]

max = 0
for i in range(n):
    count = 0
    if blue_card[i] in red_card:
        count = blue_card.count(blue_card[i]) - red_card.count(blue_card[i]) 
    else:
        count = blue_card.count(blue_card[i])
    if count >= max:
        max = count
    
print(max)

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>

using namespace std;

int main()
{
	string s;
	cin >> s;
	cout << (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4] ? "Bad" : "Good") << endl;
}

Measured memory_bytes: 256
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD  (int)(1e9+7)
#define SIZE (int)(1e5+5)
#define all(x) x.begin(),x.end()
#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back
#define prDouble(x) cout<<fixed<<setprecision(10)<<x;
#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

double dp[3010][3010];
double prob[3010];
double solve(int n,int heads)
{
  if(heads == 0)
    return 1;
  
  if(n == 0)
    return 0;
 
  if( fabs(dp[n][heads] + 1 ) > 1e-9 ){
    //cout<<"in\n";
    return dp[n][heads];
  }
  
  dp[n][heads] = prob[n-1] * solve(n-1,heads - 1) + (1-prob[n-1])*solve(n-1,heads);  

 return dp[n][heads];
}


int main()
{
  IOfast;
  int q=1;
  //cin>>q;
  memset(dp,-1,sizeof(dp));
  while(q--)
  {
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>prob[i];
    
    prDouble( solve(n,(n+2)/2) );
  }
  
  return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n, cnt=0;
    int cnt_=0;
    cin >> n;

    for(int j=1; j<=n; j+=2){
        for(int i=1; i<=n; i++){
            if(j%i==0){
                cnt++;
            }
        }
        if(cnt==8){
            cnt_++;
        }
        cnt = 0;
    }
    cout << cnt_ << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n):fact(n+1),ifact(n+1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
} c(200005);
int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	mint ans = 0;
	mint col = m;
	for (int x = n-1; x >= 0; --x){ //同色がx組 
		mint now = col; // x個のグループをm色で塗る時が何通りあるか
		now *= c(n-1,x); // 組の作り方が何通りあるかをnowにかける。
		// now を計算する
		if (x <= k) ans += now;
		col *= m-1;
	}
	cout << ans << endl;
}


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


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 約数から1引いたものが候補
arr = make_divisors(n)
arr = [x - 1 for x in arr if x >= 2]

#　商と剰余が不一致ならbreakできる
ans = 0
for x in arr[::-1]:
    if n // x != n % x:
        break
    ans += x

print(ans)

Measured memory_bytes: 9292
#include <cstdio>
#include <utility>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main ()
{
  ios::sync_with_stdio(false);
  string str;
  int count = 0;
  int sum;
  int a;
  int offset;
  string splitString;
  vector<string> strList;

  while (1) {
    cin >> str;

    if (str == "0") {
      break;
    }

    strList.push_back(str);
    count++;
  }

  for (int i = 0; i < count; i++) {
    offset = 0;
    sum = 0;
    while (offset < strList[i].length()) {
      splitString = strList[i].substr(offset, 8);
      a = stoi(splitString);
      while (a > 0) {
        sum += a % 10;
        a /= 10;
      }
      offset += 8;
    }
    cout << sum << "\n";
  }

  return 0;
}

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

int main() {
  // ここにプログラムを追記
  int a,b;
  cin >> a >> b;
  int ans = a*b%2;
  if(ans == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}


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

int main(){
  int n;
  cin >> n;
  vector <float> A(1000);
  for (int i = 0;i<n;i++){
    cin >> A[i];
  }
  float B = 0;
  for (int j = 0;j<n;j++){
    B += 1/A[j];
  }
  float ans;
  ans = 1/B;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        int q = scanner.nextInt();
        boolean rev = false;
        for (int i = 0; i < q; i++) {
            int ti = scanner.nextInt();
            if (ti == 1) {
                if (rev) rev = false;
                else rev = true;
            } else {
                int f = scanner.nextInt();
                String c = scanner.next();
                if ((f == 1 && !rev) || (f == 2 && rev)) {
                    sb1.append(c);
                } else {
                    sb2.append(c);
                }
            }
        }
 
        if (!rev) {
            sb1.reverse();
            System.out.println(sb1 + s + sb2);
        } else {
            sb2.reverse();
            StringBuilder S = new StringBuilder(s);
            S.reverse();
            System.out.println(sb2 + S.toString() + sb1);
        }
    }
}



Measured memory_bytes: 122208
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;

struct Point{
	int x, y, v;
}res[2600];

int h, w, cnt, flag1;
char pic[55][55];
bool vis[55][55];
int xx[5] = {0, 1,-1, 0, 0};
int yy[5] = {0, 0, 0, 1,-1};

void bfs()
{
	int head = 1, tail = 1;
	int flag = 1;
	Point now, nxt;
	while(head <= tail){
		now = res[head];head++;
		for(int i = 1;i <= 4;i++){
			nxt.x = now.x + xx[i];
			nxt.y = now.y + yy[i];
			if(nxt.x < 1 || nxt.x > h || nxt.y < 1 || nxt.y > w) continue;
			if(vis[nxt.x][nxt.y] || pic[nxt.x][nxt.y] == '#') continue;
			nxt.v = now.v + 1;
			res[++tail] = nxt;
			vis[nxt.x][nxt.y] = true;
			if(nxt.x == h && nxt.y == w){
				cnt = nxt.v;
				flag = 0;
				return;
			}
		}
	}
	if(flag) flag1 = 0;
	return;
}

int main()
{
	flag1 = 1;
	int cnt1 = 0;
	cin >> h >> w;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			cin >> pic[i][j];
			if(pic[i][j] == '#') cnt1++;
		}
	}
	res[1].x = 1, res[1].y = 1, res[1].v = 1;
	vis[1][1] = true;
	bfs();
	if(flag1){
		int ans = h * w - cnt1 - cnt;
		cout << ans << endl;
	}
	else cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []
C = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
    C.append(list(map(int, input().split())))

INF = 10 ** 9 + 7
dp = [INF] * (2 ** N)
dp[0] = 0

for i, ((a, b), c) in enumerate(zip(AB, C)):
    num = int("".join(["01"[int(i + 1 in c)] for i in range(N)]), 2)
    for j in range(2 ** N):
        dp[j | num] = min(dp[j | num], dp[j] + a)

print(dp[-1] if dp[-1] < INF else -1)


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

D={}
for i in range(N):
    temp=input()
    if temp in D:
        D[temp]=D[temp]+1
    else:
        D[temp]=1

v=list(D.values())
mx=max(v)

lis=[]
for key,val in D.items():
    if val==mx:
        lis.append(key)

lis.sort()

for i in lis:
    print(i)





Measured memory_bytes: 32988
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

// 約数の列挙
vector<ll> divisors(ll n) {
    vector<ll> res;
    for(int i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; // 上の行で追加済み。
        res.push_back(n/i);
    }
    return res;
}

int main(){

  int N;
  ll K;
  cin >> N>>K;
  vector<ll> A(N);
  ll sum=0;

  rep(i,N){
    int a;
    cin>>a;
    A[i]=a;
    sum+=a;
  }

  SORT(A);

  vector<ll> yak=divisors(sum);

  sort(ALL(yak),greater<ll>());

  int yakl=yak.size();

  vector<ll> ama(N);

  rep(i,yakl){
    ll ks=0;
    ll ya=yak[i];
    ll cts=sum/ya;
    ll ct=0;
    ll sho;
    rep(j,N) {
      sho=A[j]/ya;
      ct+=sho;
      ama[j]=A[j]%ya;
    }
    sort(ALL(ama),greater<ll>());

    rep(j,N){
      if(j<cts-ct){
        ks+=ya-ama[j];
      }
      else ks+=ama[j];
    }
    if(ks/2<=K){

      std::cout << ya << '\n';
      return 0;
    }
  }

  cout << 1 <<endl;
  return 0;
}


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

int main(){
  
  while(true){
    int H,W;
    cin >> H >> W;
    if(H==0 && W==0)break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(i==0 || i==(H-1) || j==0 || j==(W-1)){
          cout << '#';
        }
        else cout << '.';
      }
      cout << endl;
    }

    cout << '\n';
  }

  return 0;

}


Measured memory_bytes: 3096
#include <cstdio>
const int MAXN = 51;
const int ZERO = 2551;
const int MAXM = ZERO*2;
typedef long long LL;
LL F[2][MAXM];
int main()
{
	int N, A, i, j, x;
	scanf("%d%d", &N, &A);
	F[0][ZERO] = 1;
	for(i=1; i<=N; ++i)
	{
		scanf("%d", &x);
		x -= A;
		for(j=MAXN; j+MAXN<MAXM; ++j)
			F[i&1][j] = F[(i-1)&1][j] + F[(i-1)&1][j-x];
	}
	printf("%lld\n", F[N&1][ZERO]-1);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n)in[i]*=-1;
	sort(all(in));
	vi dp(10010,inf);
	dp[0]=0;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		for(int j=10009;j>=0;j--){
			dp[j]=min(dp[j],dp[max(0,j-a)]+b);
		}
	}
	int out=0;
	int sum=0;
	rep(i,n){
		sum-=in[i];
		out=max(out,sum-dp[i+1]);
	}
	cout<<out<<endl;
	return 0;
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    int N;
    cin >> N;
    int base = 1000;
    REP(i,10){
        if(base*(i+1) >= N){
            cout << (base*(i+1)-N) << endl;
            break;
        }
    }
}

Measured memory_bytes: 3632
<?php
$nums = [];
fscanf(STDIN, '%d', $cnt);
$ins = explode(' ', trim(fgets(STDIN)));
for ($i=0; $i < $cnt; $i++) { 
    $nums[] = 1 / $ins[$i];
}
$total = array_sum($nums);
$ans = 1 / $total;
echo "$ans\n";

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

using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  if(x==1 && y==1){
    cout << 1000000 << endl;
    return 0;
  }
  else if(x==1){
    if(y==1){
      cout << 1000000 << endl;
    }
    else if(y==2){
      cout << 500000 << endl;
    }
    else if(y==3){
      cout << 400000 << endl;
    }
    else{
      cout << 300000 << endl;
    }
  }
  else if(x==2){
    if(y==1){
      cout << 500000 << endl;
    }
    else if(y==2){
      cout << 400000 << endl;
    }
    else if(y==3){
      cout << 300000 << endl;
    }
    else{
      cout << 200000 << endl;
    }
  }
  else if(x==3){
    if(y==1){
      cout << 400000 << endl;
    }
    else if(y==2){
      cout << 300000 << endl;
    }
    else if(y==3){
      cout << 200000 << endl;
    }
    else{
      cout << 100000 << endl;
    }
  }
  else if(x>=4){
    if(y==1){
      cout << 300000 << endl;
    }
    else if(y==2){
      cout << 200000 << endl;
    }
    else if(y==3){
      cout << 100000 << endl;
    }
    else{
      cout << 0 << endl;
    }
  }
  
}

Measured memory_bytes: 256