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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<long long> a(n);
  vector<long long> b(m);
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
    for(int j=0;j<m;j++){
      cin >> b[j];
  }
  
  long long t = 0;
  for(int i=0;i<m;i++)
    t += b[i];
  
  int ans = 0;
  int j = m;
  for(int i=0;i<n+1;i++){
    while(j > 0 && t > k){
      j--;
      t -= b[j];
    }
    if(t > k) break;
    ans = max(ans, i + j);
    
    t += a[i];
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 6424
package main

import (
	"fmt"
)

func main() {
	var p, q, r int
	fmt.Scan(&p)
	fmt.Scan(&q)
	fmt.Scan(&r)

	if p+q <= q+r && p+q <= r+p {
		fmt.Println(p + q)
	} else if q+r <= p+q && q+r <= r+p {
		fmt.Println(q + r)
	} else {
		fmt.Println(r + p)
	}
}


Measured memory_bytes: 512
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    val h = sc.nextInt()
    println((a + b) * h / 2)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll x; cin >> x;

    if (x <= 6) {
        cout << 1 << endl;
        return 0;
    }

    if (x <= 11) {
        cout << 2 << endl;
        return 0;
    }

    if (x % 11 == 0) {
        cout << (x / 11) * 2 << endl;
        return 0;
    }

    if (x % 11 <= 6) {
        cout << (x / 11) * 2 + 1 << endl;
    } else {
        cout << (x / 11 + 1) * 2 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n-1],b[n-1];
    vector<vector<pair<int,int>>>pas(n);
    for(int i=0;i<n-1;i++){
        cin>>a[i]>>b[i];
        pas[a[i]-1].push_back({b[i]-1,i});
        pas[b[i]-1].push_back({a[i]-1,i});
    }
    int x=0;
    int color[n-1],check[n]={},used_c[n];
    used_c[0]=1000000;
    check[0]=1;
    queue<int>q;
    q.push(0);
    while(q.size()){
        int f=q.front();
        q.pop();
        int p=0;
        for(int i=0;i<pas[f].size();i++){
            if(check[pas[f][i].first]==0){
                q.push(pas[f][i].first);
                if(p==used_c[f])p++;
                color[pas[f][i].second]=p;
                used_c[pas[f][i].first]=p;
                p++;
                x=max(x,p);
                check[pas[f][i].first]=1;
            }
        }
    }
    cout<<x<<endl;
    for(int i=0;i<n-1;i++)cout<<color[i]+1<<endl;
    return 0;
}

Measured memory_bytes: 8576
#include <cmath>
#include <iostream>
#include <string>

int main() {
    std::string a, b;
    std::cin >> a >> b;

    const int x = std::stoi(a + b);
    const int max_num = static_cast<int>(std::sqrt(x) + 0.5) + 1;

    std::string ret = "No";
    for (int i = 1; i <= max_num; ++i) {
        if (i * i == x) {
            ret = "Yes";
            break;
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

As = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(As[K - 1])



Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int r,g,b;
   cin >> r >>b>>g;
   if(b==0 && g==0) cout << "YES" << endl;
   else if((b*10+g)%4==0) cout <<"YES" << endl;
   else cout <<"NO"<<endl; 
 }

Measured memory_bytes: 256
//control+option+n to run!
#include <iostream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <fstream>
using namespace std;
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18
int main()
{
    //REMEMBER TO GET RID OF THE "\n"!!!!
    //ifstream fin ("FILE.in");
    //ofstream fout ("FILE.out");
    long long a,b,c,d;
    cin>>a>>b>>c>>d;

    //C/b,A/d
    double x=(float)c/(float) b;
    double y= (float)a/(float)d;

 if (ceil(x)<=ceil(y)){
        cout<<"Yes";
    }
    else {
        cout<<"No";
    }

}

Measured memory_bytes: 3592
#include<stdio.h>
#define N 2000000

int A[N],B[N],C[N]={ };

int main(){

  int i,j,n;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=N;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n) printf(" ");
    else printf("\n");
  }
  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

double p[200000] = {};

int main(void) {

	lli n, k;
	cin >> n >> k;

	double answer = 0;
	double tmp = 0;

	for (int i = 0; i < k; i++) {
		cin >> p[i];
		tmp += (p[i] + 1) / 2;
	}

	answer = tmp;
	//cerr << tmp << endl;

	for (int i = k; i < n; i++) {
		cin >> p[i];
		tmp += -1 * (p[i - k] + 1) / 2 + (p[i] + 1) / 2;
		answer = max(tmp, answer);
		//cerr << tmp << endl;
	}

	cout << setprecision(10) << answer << endl;

	return 0;
}

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

int m;

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

  if(n==2 || n==4 || n==5 || n==7 || n==9){
    printf("hon\n");}
  else{
    if(n==0 || n==1 || n==6 || n==8){
      printf("pon\n");}
    else{
      printf("bon\n");}}
  
  return 0;
}


Measured memory_bytes: 1588
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
using int64 = long long;

int main() {
    int x, y;
    cin >> x >> y;
    if (y%2) {
        cout << "No" << endl;
        return 0;
    }
    y -= 2 * x;
    if (y < 0) {
        cout << "No" << endl;
        return 0;
    }

    if (y/2 > x) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <algorithm>
using namespace std;
 
int main(){
  int N;
  scanf("%d",&N);
  int a[N];
  int ans;
  for (int i=0;i<N;i++){
    scanf("%d",&a[i]);
  }

  sort(a,a+N);

  ans = a[N-1]-a[0];
  printf("%d\n",ans);
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n, y;
    cin >> n >> y;

    for(ll i = 0; i <= n; i++) {
        for(ll j = 0; i + j <= n; j++) {
            int k = n - i - j;
            int sum = i * 10000 + j * 5000 + k * 1000;
            if(sum == y && (n == i + j + k)) {
                cout << i << " " << j << " " << k << endl;
                exit(0);
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    string s;
    cin >> s;
    ll count = 0;
    ll r = 0;
    ll l = s.size()-1;
    while(l - r > 0){
        //cout << s[r] << "," << s[l] << endl;
        if(s[r] == s[l]){
            r++;l--;
        }else if(s[r] == 'x'){
            r++;
            count++;
        }else if(s[l] == 'x'){
            l--;
            count++;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << count << endl;
}


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

#define LL long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, z, w, a[2001]; cin >> n >> z >> w;
	for(int i=1;i<=n;i++) cin >> a[i];

	if(n >= 2) cout << max(abs(a[n] - w), abs(a[n] - a[n-1]));
	else cout << abs(a[n] - w);
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll N, K;

    cin >> N >> K;

    map<ll, ll> mp;

    for(ll i = 1; i*i <= N; i++){
        mp[i] = 1;
        mp[N/i] = N / i - N / (i+1);
    }
    
    vector<vector<ll>> dp(mp.size()+1);

    ll ind = 1;
    ll MOD = 1e9+7;
    dp[0].push_back(0);

    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        dp[ind].push_back(dp[ind-1][0] + itr->second);
        ind++;
    }

    for(ll i = 0; i < K; i++){
        dp[0].push_back(0);
        ind = 1;
        ll tmp;
        for(auto itr = mp.begin(); itr != mp.end(); itr++){
            tmp = (itr->second * dp[mp.size()-ind+1][i]) % MOD;
            dp[ind].push_back((dp[ind-1][i+1] + tmp) % MOD);
            ind++;
        }
    }

    // for(auto itr = mp.begin(); itr != mp.end(); itr++){
    //     cout << itr->first << " " << itr->second << endl;
    // }

    // for(int i = 0; i <= mp.size(); i++){
    //     for(int j = 0; j <= K; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[mp.size()][K-1] << endl;

    return 0;
}



Measured memory_bytes: 70272
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    map<ll, ll> s;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        s[a]++;
    }
    ll sum = 0;
    for (auto x : s)
    {
        if (x.second > x.first)
        {
            sum += x.second - x.first;
        }
        else if (x.second < x.first)
        {
            sum += x.second;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
     
#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005,inf=1e9,LN=20;
int a[N],rev[N],table[2][LN][N],n,logs[N],arr[2][N];
inline int query(int l,int r,int i)
{
  int j=logs[r-l+1];
  int ind1=table[i][j][l],ind2=table[i][j][r-(1<<j)+1];
  int val1=arr[i][ind1],val2=arr[i][ind2];
  return min(val1,val2);
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  rep(i,1,N) logs[i]=log2(i);
  cin>>n;
  rep(i,1,n+1) cin>>a[i],rev[a[i]]=i;
  rep(i,1,n+1)
    {
      arr[i&1][i]=a[i];
      arr[(i+1)&1][i]=inf;
    }
  rep(k,0,2)
    {
      rep(i,1,n+1) table[k][0][i]=i;
      rep(j,1,LN)
    	{
    	  rep(i,1,n+1-(1<<j)+1)
    	    {
    	      int ind1=table[k][j-1][i],val1=arr[k][ind1];
    	      int ind2=table[k][j-1][i+(1<<(j-1))],val2=arr[k][ind2];
    	      if(val1<val2) table[k][j][i]=ind1;
    	      else table[k][j][i]=ind2;
    	    }
    	}
    }
  set<pair<int,ii> > pq;
  pq.insert(mp(query(1,n,1),mp(1,n)));
  while(!pq.empty())
    {
      auto it=*pq.begin();
      pq.erase(pq.begin());
      int low=it.se.fi,high=it.se.se;
      int mn1=it.fi,ind1=rev[mn1];
      int mn2=query(ind1+1,high,(ind1+1)&1),ind2=rev[mn2];
      cout<<mn1<<" "<<mn2<<" ";
      if(ind1-low>0)
	pq.insert(mp(query(low,ind1-1,low&1),mp(low,ind1-1)));
      if(ind2-ind1-1>0)
	pq.insert(mp(query(ind1+1,ind2-1,(ind1+1)&1),mp(ind1+1,ind2-1)));
      if(high-ind2>0)
	pq.insert(mp(query(ind2+1,high,(ind2+1)&1),mp(ind2+1,high)));
    }
  cout<<endl;
  return 0 ;
}


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

void replace(char data[], int a, int b, char p[]){
    for(int i=a; i<=b; i++){
        data[i] = p[i-a];
    }
}

void reverse(char data[], int a, int b){
    char temp[1000];
    for(int i=a; i<=b; i++){
        temp[i-a] = data[b-(i-a)];
    }
    for(int i=a; i<=b; i++){
        data[i] = temp[i-a];
    }   
}

void print(char data[], int a, int b){
    for(int i=a; i<=b; i++){
        printf("%c", data[i]);
    }
    printf("\n");
}

int main()
{
    char data[1000];
    int m;
    char com[20];

    scanf("%s", &data);
    scanf("%d", &m);

    for(int i=0; i<m; i++){
        scanf("%s", &com);

        if(strcmp("replace", com)==0){
            int a, b;
            char p[1000];
            scanf("%d %d %s", &a, &b, &p);
            replace(data, a, b, p);
            //printf("%s\n", data);
        }
        else if(strcmp("reverse", com)==0){
            int a, b;
            scanf("%d %d", &a, &b);
            reverse(data, a, b);
            //printf("%s\n", data);
        }
        else if(strcmp("print", com)==0){
            //printf("%s\n", com);
            int a, b;
            scanf("%d %d", &a, &b);
            print(data, a, b);
        }
    }

    return 0;
}


Measured memory_bytes: 2092
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

signed main()
{
    IOS;
    string s;
    cin>>s;
    if (s.back()=='s')
        s+='e', s+='s';
    else
        s+='s';
    cout<< s <<"\n";    
}


Measured memory_bytes: 3660
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,h,m=map(int,input().split())
    theta_a=(60*h+m)*2*math.pi/720
    theta_b=m*2*math.pi/60
    print(math.sqrt((a*math.cos(theta_a)-b*math.cos(theta_b))**2+(a*math.sin(theta_a)-b*math.sin(theta_b))**2))

if __name__=='__main__':
    main()

Measured memory_bytes: 9580
n, m = gets.strip.split(" ").map(&:to_i)

ks = []
m.times do
  t = gets.strip.split(" ").map(&:to_i)
  t.shift
  ks << t
end

p = gets.strip.split(" ").map(&:to_i)

ans = 0
0.upto(2**n - 1) do |s|
  ok = true
  ks.each.with_index do |ks2, i|
    o = 0
    ks2.each do |t|
      o += 1 if s[t - 1] == 1
    end

    if (o % 2) != p[i]
      ok = false
      break
    end

    break unless ok
  end

  ans += 1 if ok
end

puts ans


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

int main(){
	int n;cin>>n;
	vector<int> v(n);
	for(auto&& w:v)cin>>w;
	map<int,int>a,b;
	for(int i=0;i<n;i++){
	if(i%2==0)a[v[i]]++;
	else b[v[i]]++;
	}
	vector<pair<int,int>> c(a.begin(),a.end());
	vector<pair<int,int>> d(b.begin(),b.end());
	sort(c.begin(),c.end(),[&](pair<int,int>x,pair<int,int>y){return x.second > y.second;});
	sort(d.begin(),d.end(),[&](pair<int,int>x,pair<int,int>y){return x.second > y.second;});
	int ans,m=n/2;
	if(c[0].first!=d[0].first)ans=n-c[0].second-d[0].second;
	else ans=min(n-c[0].second-d[1].second,n-c[1].second-d[0].second);
	cout<<ans<<endl;	

}


Measured memory_bytes: 6144
ss = input()
k = int(input())
save = []
num = ord("a")

while True:
  lst = []
  c = chr(num)
  for i in range(len(ss)):
    if ss[i] == c:
      lst.append(i)
  for ind in lst:
    for j in range(1,k + 1):
      if ind + j <= len(ss):
        save.append(ss[ind:ind + j])
#  print(save)

  if(len(list(set(save)))) >= k:
    flag = True
    break
  num += 1

save = list(set(save))
save.sort()
print(save[k - 1])




Measured memory_bytes: 4568
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  ll cN = N;
  int S = 0;
  while (cN >= 10) {
    S += cN % 10;
    cN /= 10;
  }
  S += cN % 10;
  if (N % S == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
int main()
{
    ll a,b,c,t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<string>v;

      cin>>n>>k;
      while(n--)
      {
          cin>>s; v.pb(s);
      }
      sort(v.begin(),v.end());
      for(ll i=0;i<v.size();i++) s1+=v[i];
      cout<<s1<<endl;

}





Measured memory_bytes: 3620
from math import*
n,*a=map(int,open(0).read().split())
b=[0]
for i in a:b+=gcd(b[-1],i),
w=m=0
for i in range(n):m=max(m,gcd(w,b[-i-2]));w=gcd(w,a[~i])
print(m)

Measured memory_bytes: 20532
import copy

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

# imos法
# log(N)ぐらいで収束するので、打ち切れば計算量的には問題なし？

for i in range(K):
    B = [0] * (N+1)
    for j in range(N):
        l = max(0, j-A[j])
        r = min(j+A[j]+1, N)
        B[l] += 1
        B[r] -= 1
    # print("B: {}".format(B))
    for j in range(N):
        B[j+1] += B[j]
    del B[N]
    # print("B: {}".format(B))
    if A == B:
        break
    A = copy.deepcopy(B)

print(*A)


Measured memory_bytes: 176732
#include<iostream>

using namespace std;

char A[3];

int main(){
	cin >> A[0] >> A[1] >> A[2];
	for(int i = 0; i < 3; i++){
		if(A[i] == '1') cout << '9';
		else cout << '1';
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int frog(int h[],int n,int dp[])
{
    if(n==0)
        return 0;
    if(n==1)
        return abs(h[1]-h[0]);
    if(dp[n]!=-1)
        return dp[n];
    int ans =min(frog(h,n-1,dp)+abs(h[n]-h[n-1]),frog(h,n-2,dp)+abs(h[n]-h[n-2]));
    dp[n]=ans;
    return dp[n];
}
int main()
{
    int n;
    cin>>n;
    int h[n+2];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int dp[n+2];
    memset(dp,-1,sizeof(dp));
    cout<<frog(h,n-1,dp)<<endl;
}


Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> suicchi(M, vector<int>(N));
    for(int i = 0; i < M; i++) {
        cin >> k.at(i);
        for(int j = 0; j < k.at(i); j++) {
            int s; cin >> s; s--;
            suicchi.at(i).at(s) = true;
        }
    }
    vector<int> p(M);
    for(int i = 0; i < M; i++) cin >> p.at(i);
    
    int ans = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool all_on = true;
        for(int i = 0; i < M; i++) { //M個の電球全てがつくかチェック
            int cnt = 0;
            for(int j = 0; j < N; j++) { //i個目の電球につながっていて、かつonのスイッチの数をカウント
                if(suicchi.at(i).at(j) && (bit & (1<<j))) cnt++;
            }
            if(cnt%2 != p.at(i)) all_on = false;
        }
        if(all_on) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int i = 1;
    int check = 0;
    while (i<100) {
      if(A * i % B == C) {
        check = 1;
        break;
      }
      i++;
    }
    if (check == 1) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
   }
}

Measured memory_bytes: 22612
use std::io::{self, BufReader, Read};
use std::str::FromStr;
use std::string::String;

fn main() {
	let mut sc = ::Scanner::new(io::stdin());
	let s = sc.next_str().unwrap();
	let v: Vec<char> = s.chars().collect();
	let ans = v[0] == 'A'
	          && s.contains('C')
	          && v[1] != 'C'
	          && v[s.len() - 1] != 'C'
	          && s.chars().filter(|c| c.is_lowercase() ).count() == s.len() - 2;
	println!("{}", if ans {"AC"} else {"WA"});
}

#[derive(Debug)]
pub struct Scanner<R> {
	reader: BufReader<R>
}

impl<R: io::Read> Scanner<R> {
	
	pub fn new(read: R) -> Scanner<R> {
		Scanner { reader: BufReader::new(read) }
	}

	pub fn next_str(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			None{}
		} else {
			let first = self.skip_whitespace(&mut buf);
			if first.is_none() {
				return None{}
			}
			let mut v = vec![buf[0]];
			loop {
				let size = self.reader.read(&mut buf).unwrap();
				if size == 0 || char::from(buf[0]).is_whitespace() {
					break;
				}
				v.push(buf[0]);
			}
			Some(String::from_utf8(v).unwrap())
		}
	}

	pub fn next_line(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let mut v :Vec<u8> = vec![];
		let mut size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			return None{}
		}
		loop {
			if size == 0 || char::from(buf[0]) == '\n' {
				return Some(String::from_utf8(v).unwrap())
			}
			v.push(buf[0]);
			size = self.reader.read(&mut buf).unwrap();
		}
	}

	pub fn next_vec<S: FromStr>(&mut self, size: u32) -> Vec<S> {
		let mut v: Vec<S> = vec![];
		for _ in 0..size {
			let token = self.next_str().unwrap();
			v.push(S::from_str(&token).ok().unwrap());
		}
		v
	}

	pub fn next_as<S: FromStr>(&mut self) -> Option<S> {
		if let Some(s) = self.next_str() {
			if let Ok(v) = S::from_str(&s) {
				return Some(v)
			}
		}
		None{}
	}

	pub fn next_i32(&mut self) -> Option<i32> {
		self.next_as::<i32>()
	}

	pub fn next_i64(&mut self) -> Option<i64> {
		self.next_as::<i64>()
	}

	pub fn next_f32(&mut self) -> Option<f32> {
		self.next_as::<f32>()
	}

	pub fn next_f64(&mut self) -> Option<f64> {
		self.next_as::<f64>()
	}

	fn skip_whitespace(&mut self, mut buf: &mut [u8]) -> Option<u8> {
		loop {
			if !char::from(buf[0]).is_whitespace() {
				return Some(buf[0])
			}
			let size = self.reader.read(&mut buf).unwrap();
			if size == 0 {
				return None{}
			}
		}
	}
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int A, B, N;
    cin >> A >> B >> N;
    int ans = A * min(B - 1, N) / B;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int h,w;
	cin>>h>>w;
	vector<int>map(h*w);
	char tmp;
	rep(i,h*w){
		cin>>tmp;
		if(tmp=='#'){
			map[i]=-1;
		}else{
			map[i]=0;
		}
	}
	int cnt,head;
	rep(i,h){
		cnt=0;
		head=0;
		while(head<w){
			if(map[head+i*w]==-1&&cnt>0){
				rep(t,cnt) map[head+i*w-t-1]+=cnt;
				cnt=0;
			}else if(map[head+i*w]>-1){
				cnt++;
			}
			head++;
		}
		if(cnt>0){
			rep(t,cnt) map[head+i*w-t-1]+=cnt;
			cnt=0;
		}
	}
	rep(i,w){
		cnt=0;
		head=0;
		while(head<h){
			if(map[head*w+i]==-1&&cnt>0){
				rep(t,cnt) map[head*w+i-(t+1)*w]+=cnt;
				cnt=0;
			}else if(map[head*w+i]>-1){
				cnt++;
			}
			head++;
		}
		if(cnt>0){
			rep(t,cnt) map[head*w+i-(t+1)*w]+=cnt;
			cnt=0;
		}
	}
	
	//show
	/*
	rep(i,h){
		rep(j,w){
			cout<<map[i*w+j]<<",";
		}
		cout<<endl;
	}
	*/
	int max=-1;
	rep(i,h*w){
		if(max<map[i]) max=map[i];
	}
	cout<<max-1<<endl;




	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int c[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        cin>>c[j][i];  
      }
    }
    for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
        if(c[j][i]+c[j+1][i+1]!=c[j+1][i]+c[j][i+1]){
          cout<<"No"<<endl; 
          return 0;
        }
      }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

		String[] s = new String[n];
		for ( int i=0; i<n; i++ ) {
			s[i] = sc.next();
		}
		Arrays.sort(s);

		int t = 0;
		int[] a = new int[n];
		int g = 0;

		a[0] = 0;
		for ( int i=1; i<n; i++ ) {
			if ( s[i].equals(s[i-1]) ) {
				t++;
			} else {
				g = Math.max(g,t);
				t = 0;
			}
			a[i] = t;
		}
		g = Math.max(g,t);

		for ( int i=0; i<n; i++ ) {
			if ( a[i] == g ) {
				System.out.println(s[i]);
			}
		}

	}
}

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(string, s);
  wt(700 + count(all(s), 'o') * 100);
}


Measured memory_bytes: 3572
n,m,x=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(n):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

ans=float('inf')
for i in range(2**n):
  now=0
  under=[0]*m
  for j in range(n):
    if i>>j & 1:
      now+=l[j][0]
      for s in range(m):
        under[s]+=l[j][s+1]

  cnt=0
  for u in under:
    if x<=u:
      cnt+=1
  
  if cnt==m:
    ans=min(ans,now)

if ans==float('inf'):
  print(-1)
else:
  print(ans)


Measured memory_bytes: 9108
#include <iostream>
#include  <string.h>
using namespace std;
int main()
{
    int a,b,c,count,i=0;
    cin>>a>>b>>c;
    
    for(i=1;i<=b;i++)
    {
        if(i*a%b==c){
            count ++;
        }
    }
    if(count >0){
        cout <<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    
    int count = 0;
    for(int x = 0; x <= K; x++){
      for(int y = 0; y <= K; y++){
        int z = S - x - y;
        // System.out.println(x + " " + y + " " + y);
        if(0 <= z && z <= K){
        	count++;
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#define  _CRT_SECURE_NO_WARNINGS
	#include <algorithm>
	#include <iostream>
	#include <iterator>
	#include <numeric>
	#include <sstream>
	#include <fstream>
	#include <cassert>
	#include <climits>
	#include <cstdlib>
	#include <cstring>
	#include <string>
	#include <cstdio>
#include<algorithm>
	#include <vector>
	#include <math.h>
	#include <queue>
	#include<memory>
	#include <deque>
	#include <stack>
	#include <list>
	#include <map>
	#include <set>
	#include <cmath>
	#include <bitset>
	#include<list>
	#include <iomanip>
	using namespace std;
	typedef long long ll;
	char maze[3000][3000];
	int r, c;
	long long dp[3000][3000];
	bool vis[(int)1e5 + 10];
	vector<int> graph[(int)1e5 + 10];
	
	int solve(int i, int j)
	{
		dp[0][0] = 1;
		for (int i = 0; i < r; i++)
		{
			for (int j = 0; j < c; j++)
			{
				if (maze[i][j] == '#')continue;
				if (maze[i - 1][j] == '.' && maze[i][j - 1] == '.')
					dp[i][j] =( dp[i - 1][j] + dp[i][j - 1] )% ((long long)1e9 + 7);
				else if (maze[i][j - 1] == '.')
					dp[i][j] = dp[i][j - 1];
				else if (maze[i - 1][j] == '.')dp[i][j] = dp[i - 1][j];
			}
		}
		return dp[r - 1][c - 1];
	}
	
	int main()
	{
		memset(dp, 0, sizeof dp);
		cin >> r >> c;
		for (int i = 0; i < r; i++)
		{
			for (int j = 0; j < c; j++)
			{
				cin >> maze[i][j];
			}
		}
		cout << solve(0, 0) << endl;;
		return 0;
	}

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

int main(void){
    int a, b; cin >> a >> b;
    double k;
    
    k = (a + b) /2.;
    
    if(ceil(k) == floor(k)){
        cout << int(k) << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

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

signed main(void)
{
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i, n) mp[i + 1] = 0;
	rep(i, n - 1) 
	{
		int x;
		cin >> x;
		mp[x]++;
	}
	for(auto p : mp)
	{
		cout << p.second << endl;
	}
	return 0;
}


Measured memory_bytes: 13008
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    pair<int,int> A[100010];
    for(int i=0;i<N;i++){
        int a;cin>>a;
        A[i]={a,i+1};
    }
    sort(A,A+N);
    for(int i=0;i<N;i++)
        cout<<A[i].second<<" ";
    return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
//最小费用最大流，求最大费用只需要取相反数，结果取相反数即可。
//点的总数为N，点的编号0~N-1
const int MAXN=1010;//点数的最大值
const int MAXM=750010;//边数的最大值
const long long INF=1e15;
namespace ISAP
{
	struct Edge
	{
		int to,next;
		long long cap,flow;
	}edge[MAXM];//注意是MAXM
	int tol;
	int head[MAXN];
	int gap[MAXN],dep[MAXN],cur[MAXN];
	void init()
	{
		tol=0;
		memset(head,-1,sizeof(head));
	}
	void addedge(int u,int v,long long w,long long rw=0)
	{
		edge[tol].to=v;edge[tol].cap=w;edge[tol].flow=0;
		edge[tol].next=head[u];head[u]=tol++;
		edge[tol].to=u;edge[tol].cap=rw;edge[tol].flow=0;
		edge[tol].next=head[v];head[v]=tol++;
	}
	int Q[MAXN];
	void BFS(int start,int end)
	{
		memset(dep,-1,sizeof(dep));
		memset(gap,0,sizeof(gap));
		gap[0]=1;
		int front=0,rear=0;
		dep[end]=0;
		Q[rear++]=end;
		while(front!=rear)
		{
			int u=Q[front++];
			for(int i=head[u];i!=-1;i=edge[i].next)
			{
				int v=edge[i].to;
				if(dep[v]!=-1)continue;
				Q[rear++]=v;
				dep[v]=dep[u]+1;
				gap[dep[v]]++;
			}
		}
	}
	int S[MAXN];
	long long sap(int start,int end,int N)//N总点数
	{
		BFS(start,end);
		memcpy(cur,head,sizeof(head));
		int top=0;
		int u=start;
		long long ans=0;
		while(dep[start]<N)
		{
			if(u==end)
			{
				long long Min=INF;
				int inser;
				for(int i=0;i<top;i++)
					if(Min>edge[S[i]].cap-edge[S[i]].flow)
					{
						Min=edge[S[i]].cap-edge[S[i]].flow;
						inser=i;
					}
				for(int i=0;i<top;i++)
				{
					edge[S[i]].flow+=Min;
					edge[S[i]^1].flow-=Min;
				}
				ans+=Min;
				top=inser;
				u=edge[S[top]^1].to;
				continue;
			}
			bool flag=false;
			int v;
			for(int i=cur[u];i!=-1;i=edge[i].next)
			{
				v=edge[i].to;
				if(edge[i].cap-edge[i].flow&&dep[v]+1==dep[u])
				{
					flag=true;
					cur[u]=i;
					break;
				}
			}
			if(flag)
			{
				S[top++]=cur[u];
				u=v;
				continue;
			}
			int Min=N;
			for(int i=head[u];i!=-1;i=edge[i].next)
			if(edge[i].cap-edge[i].flow&&dep[edge[i].to]<Min)
			{
				Min=dep[edge[i].to];
				cur[u]=i;
			}
			gap[dep[u]]--;
			if(!gap[dep[u]])
				return ans;
			dep[u]=Min+1;
			gap[dep[u]]++;
			if(u!=start)
				u=edge[S[--top]^1].to;
		}
		return ans;
	}
}


int num[1010];

int main()
{
    //freopen("2.in","r",stdin);
    //freopen("2.out","w",stdout);
    int i,j;
    int n;
    long long sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
        if(num[i]>=0) sum+=num[i];
    }
    ISAP::init();
    int S=n+1,T=n+2;
    for(i=1;i<=n;i++)
    {
        if(num[i]>=0) ISAP::addedge(i,T,num[i]);
        else ISAP::addedge(S,i,-num[i]);

        for(j=2*i;j<=n;j+=i)
        {
            ISAP::addedge(i,j,INF);
        }
    }
    long long cnt=ISAP::sap(S,T,n+2);
    sum-=cnt;
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;

int N;
vector<vector<pint>> v;

bool judge(int bit)
{
    for (int i = 0; i < N; ++i)
    {
        if (!((bit >> i) & 1))
            continue;
        for (pint xy : v[i])
        {
            int x = xy.first;
            int y = xy.second;

            if (y ^ ((bit >> x) & 1))
            {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i)
    {
        int A;
        cin >> A;
        v[i].resize(A);
        for (int j = 0; j < A; ++j)
        {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }

    int res = 0;
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        if (judge(bit))
        {
            int count = 0;
            for (int i = 0; i < N; ++i)
                if ((bit >> i) & 1)
                    ++count;
            res = max(res, count);
        }
    }
    cout << res << endl;
}

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

int main(){
  int n,m;cin>>n>>m;
  int a[100010];
  for(int i=0;i<m;++i)
	cin>>a[i];
  if(n>=m){cout<<0<<endl;return 0;}
  sort(a,a+m);
  int dif=a[m-1]-a[0];
  vector<int> b(m-1,0);
  for(int i=0;i<m-1;++i)
	b[i]=a[i+1]-a[i];
  sort(b.rbegin(),b.rend());
  for(int i=0;i<n-1;++i)
	dif-=b[i];
  cout<<dif<<endl;
  return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
hs = []
for i in range(N):
  h = int(input())
  hs.append(h)
hs.sort()
rs = []
for i in range(0, N+1-K):
  r = hs[i+K-1]-hs[i]
  rs.append(r)
r = min(rs)
print(r)


Measured memory_bytes: 11288
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N;
  cin >> K;
  
  int A = 1;
  for (int i=0; i < N; i++){
    if(A > K ) {
      A += K;
    }
    else {
      A *= 2;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
//typedef long long int ll;


int ans,ans2;

signed main(){

    int n,a,b,x[111111];
    cin>>n>>a>>b;
    rep(i,n)cin>>x[i];
    
    rep(i,n-1){
        ans+=min((x[i+1]-x[i])*a,b);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 1e6+3;

Int dp[100005];

int main() {
    Int n, m;
    cin >> n >> m;
    for (Int i = 0; i < m; i++) {
        Int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for (Int i = 0; i <= n; i++) {
        if (dp[i] < 0) continue;
        if (dp[i + 1] >= 0) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= mod;
        }
        if (dp[i + 2] >= 0) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= mod;
        }
    }
    dump(dp[n]);
    return 0;
}

Measured memory_bytes: 1024
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

typedef struct {double x; double y;} point_t;

#define PI 3.14159265

static point_t calc_internally_dividing(point_t a, point_t b, int32_t n, int32_t m)
{
  point_t ret = {.x = (n * a.x + m * b.x) / (n + m), .y = (n * a.y + m * b.y) / (n + m)};
  return ret;
}

static point_t add_vector(point_t vec1, point_t vec2)
{
  point_t ret = {.x = vec1.x + vec2.x, .y = vec1.y + vec2.y};
  return ret;
}

static point_t sub_vector(point_t vec1, point_t vec2)
{
  point_t ret = {.x = vec1.x - vec2.x, .y = vec1.y - vec2.y};
  return ret;
}

static point_t rotate_vector(point_t vec, double rad)
{
  point_t ret = {.x = vec.x * cos(rad) - vec.y * sin(rad), .y = vec.x * sin(rad) + vec.y * cos(rad)};
  return ret;
}

static void koch_curve_aux(point_t a, point_t b, point_t data[])
{
  point_t s = calc_internally_dividing(a, b, 2, 1);
  point_t t = calc_internally_dividing(a, b, 1, 2);
  point_t u = add_vector(rotate_vector(sub_vector(t, s), PI / 3), s);

  data[0] = a;
  data[1] = s;
  data[2] = u;
  data[3] = t;
  data[4] = b;
}

size_t koch_curve(uint32_t n, point_t a, point_t b, point_t data[])
{
  size_t len = ((int)pow(4, n)) + 1;

  if (n == 0) {
    data[0] = a;
    data[1] = b;
  } else {
    int32_t data_size = koch_curve(n - 1, a, b, data);
    point_t *tmpbuf = (point_t *)malloc(sizeof(point_t) * len);
    uint32_t i;
    for (i = 0; i < (data_size - 1); i++) {
      point_t buf[5];
      koch_curve_aux(data[i], data[i + 1], buf);
      tmpbuf[4 * i] = buf[0];
      tmpbuf[4 * i + 1] = buf[1];
      tmpbuf[4 * i + 2] = buf[2];
      tmpbuf[4 * i + 3] = buf[3];
      tmpbuf[4 * i + 4] = buf[4];
    }
    memcpy(data, tmpbuf, sizeof(point_t) * len);
    free(tmpbuf);
  }

  return len;
}

#if !defined(TEST)
static point_t buf[4096];

static void print_point(point_t a)
{
  printf("%.8f %.8f\n", a.x, a.y);
}

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);
  const point_t a = {.x = 0.0, .y = 0.0};
  const point_t b = {.x = 100.0, .y = 0.0};

  size_t len = koch_curve(num, a, b, buf);
  uint32_t i;
  for (i = 0; i < len; i++) {
    print_point(buf[i]);
  }

  return 0;
}

#endif

Measured memory_bytes: 816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi w(n);
    rep(i, n) cin >> w[i];
    int sum = 0;
    rep(i, n) sum += w[i];
    int ans = 1e9;
    int tmp = 0;
    rep(i, n) {
        tmp += w[i];
        ans = min(ans, abs(tmp-(sum-tmp)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256