akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;


template<int N=1000001>
class UnionFindTree {
public:
  const LL len = N;
  LL cnt;
  A<LL, N> uftq{};
  A<LL, N> s{};
  A<LL, N> rank{};

  UnionFindTree(LL n) : cnt(n) {
    FOR(i,0,n) {
        uftq[i] = i;
        s[i] = 1;
        rank[i] = 1;
    }
  }
  LL find(LL x) {
      LL xParent = uftq[x];
      V<LL> v;
      while(xParent != uftq[xParent]) {
          v.push_back(xParent);
          xParent = uftq[xParent];
      }
      REP(i, v.size()) {
          uftq[v[i]] = xParent;
      }
      return xParent;
  }
  LL size(LL idx) {
      return s[find(idx)];
  }
  LL count() {
      return cnt;
  }
  bool unite(LL x, LL y) {
      LL xRoot = find(x);
      LL yRoot = find(y);
      if(xRoot == yRoot) return false;
      if(rank[xRoot] > rank[yRoot])
          std::swap(xRoot, yRoot);
      if(rank[xRoot] == rank[yRoot])
          rank[yRoot] += 1 + rank[yRoot] - rank[xRoot];
      s[yRoot] = s[xRoot] + s[yRoot];
      s[xRoot] = 0;
      uftq[xRoot] = yRoot;
      cnt--;
      return true;
  }
};

int main(){
    INIT;
    int n, m;
    cin >> n >> m;
    V<PII> e;
    REP(i,m) {
        int x,y; cin >> x >> y; e.push_back(PII(x-1,y-1));
    }
    V<UnionFindTree<51>> uft;
    REP(i,m) uft.push_back(UnionFindTree<51>(n));

    int ans = 0;
    REP(i,m) {
        REP(j,m) {
            if(i == j) continue;
            uft[i].unite((LL)e[j].first,(LL)e[j].second);
        }
        if(uft[i].count() != 1) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }
 
bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n,l[114514],r[114514];
signed main(){
	cin>>n;
	rep(i,n){
		cin>>l[i]>>r[i];
		l[i]*=2;r[i]*=-2;
	}
	sort(l,l+n,greater<>());sort(r,r+n,greater<>());
	rep(i,n){
		l[i+1]+=l[i];r[i+1]+=r[i];
	}
	int ans=0;
	rep(i,n){
		int ans1,ans2,ans3;
		if(!i)ans1=l[i];
		else ans1=l[i]+r[i-1];
		ans2=l[i]+r[i];
		ans3=l[i]+r[i+1];
		chmax(ans,max({ans1,ans2,ans3}));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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 gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll n;
cin>>n;
ll b[n-1];
for(int i=0;i<n-1;i++){
    cin>>b[i];
}
ll a[n];
a[0]=b[0];
for(int i=1;i<n-1;i++){
    a[i]=min(b[i-1],b[i]);
}
a[n-1]=b[n-2];
ll sum=0;
for(auto f:a){
    sum+=f;
}
cout<<sum<<endl;
}





Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)
sorted_xs = (xs + [0]).sort
min = 100000000000
diff = 0
(n-k+1).times do |i|
  upper = sorted_xs[i+k]
  lower = sorted_xs[i]
  if (lower * upper) < 0
    diff = [lower.abs, upper.abs].min * 2 + [lower.abs, upper.abs].max
  else
    diff = [lower.abs, upper.abs].max
  end
  if min > diff
    min = diff
  end
end
puts min


Measured memory_bytes: 12664
#include<stdio.h>
#define N 101
#define NIL -1

void BFS(int); 
void Enqueue(int);
int Dequeue(void);
 
typedef struct{
  int id;
  int k;
  int v[N];
  int h;
}V;
 
int n=0, head=0, tail=0, d[N],Q[N];
V G[N];

int main(){
  int i,j;
  
  scanf("%d",&n);
  
  for(i=1 ; i<=n ; i++){
    scanf("%d%d",&G[i].id,&G[i].k);
    for(j=1 ; j<=G[i].k ; j++){
      scanf("%d",&G[i].v[j]);
    }
  }
  
  BFS(G[1].id);
  
  for(i=1 ; i<=n ; i++){
    printf("%d ",G[i].id);
    if(d[i] == NIL) printf("-1\n");
    else printf("%d\n",d[i]);
  }
  
  return 0;
}
void BFS(int s){
  int i,j,v;
  for(i=1 ; i<=n ; i++) {
    G[i].h = 0;
    d[i] = NIL;
  }
  G[s].h = 1;
  d[s] = 0;
   
  Enqueue(s);
   
  while(head != tail){
    i = Dequeue();
    for(j=1 ; j<=G[i].k ; j++){
      v =G[i].v[j];
      if(G[v].h == 0){
	G[v].h =1;
	d[v] = d[i]+1;
	Enqueue(v);
      }
    }
    G[i].h = 2;
  }
}
void Enqueue(int x){
  Q[tail] = x;
  tail++;
}
 
int Dequeue(){
  int x = Q[head];
  head++;
  return x;
}

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

int main()
{ 
  string str ;
  cin >> str ;
  int a = str.at(0) - '0' ;
  int b = str.at(1) - '0' ;
  int c = str.at(2) - '0' ;
  int d = str.at(3) - '0' ;

  //cout << a << b << c << d ;
  vector< tuple<int, int, int> > data ;
  for(int i = 0 ; i <= 1 ; i++)
  {
    for(int j = 0 ; j <= 1 ; j++)
    {
      for(int k = 0 ; k <= 1 ; k++)
      {
        data.push_back( make_tuple(i, j, k) ) ; 
      }
    }
  }
  
  int calcu = 0 ;
  for(int i = 0 ; i < 8 ; i++)
  {
    int x, y, z ;
    tie(x, y, z) = data.at(i) ;
    char op1, op2, op3 ;
    if(x == 0)
    {
      calcu = a + b ;
      op1 = '+' ;
    }
    else
    {
      calcu = a - b ;
      op1 = '-' ;
    }

    if(y == 0)
    {
      calcu += c ;
      op2 = '+' ;
    }
    else
    {
      calcu -= c ;
      op2 = '-' ;
    }

    if(z == 0)
    {
      calcu += d ;
      op3 = '+' ;
    }
    else
    {
      calcu -= d ;
      op3 = '-' ;
    }
    
    if(calcu == 7)
    {
      cout << a << op1 << b << op2 << c << op3 << d << "=" << 7 << endl ;
      break ;
    }
  }
}



Measured memory_bytes: 768
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int x,k,d;
    cin>>x>>k>>d;
    int gap=abs(x);
    int mov=gap/d;
    if(mov>=k)
    {
        int ses=abs(x)-k*d;
        cout<<ses<<endl;
        return 0;
    }
    int cur=abs(x)-(mov*d);
    k=k-mov;
    int abr_cur=abs(cur-d);
    if(k%2==0)
    {
        cout<<cur<<endl;
    }
    else
    {
        cout<<abr_cur<<endl;
    }
    return 0;

}





































Measured memory_bytes: 3584
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var total = 0.0;
            foreach(var i in a){
                total += (1.0 / i);
            }

            Console.WriteLine(string.Format("{0:f14}",1.0 / total));
        }
    }
}


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

#define ll long long int

#define endl '\n'

#define rep(i, a, b) for (ll i = a; i < b; i++)

void solve()

{

    ll n;

    cin >> n;

    ll a[n + 1];

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

    ll ps[n + 1], dp[n + 1];

    dp[0] = 0;
    dp[1] = 0;

    ps[1] = a[1];

    for (ll i = 3; i <= n; i += 2)
        ps[i] = ps[i - 2] + a[i];

    rep(i, 2, n + 1)
    {

        if (i & 1)
        {

            dp[i] = max(dp[i - 1], a[i] + dp[i - 2]);
        }

        else
        {

            dp[i] = max(dp[i - 2] + a[i], ps[i - 1]);
        }
    }

    cout << dp[n] << endl;
}

int32_t main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();

    return 0;
}


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

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
char arr[n][n];
char arr1[m][m];
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);
 
    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);
 
 
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int cnt=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        cnt++;
                }
 
            }
            if(cnt==(m*m))
            {
                printf("Yes\n");
                return 0;
            }
 
        }
    }
    printf("No\n");
 
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    ll ans = 0;
    vector<ll> v(n);
    for(auto& i : v){
        cin >> i;
    }

    REP(i, n-1){
        if(v[i]%2 == 1 && v[i+1]%2 == 1){
            v[i] += v[i+1];
            v[i+1] = 0;
        }else if(v[i]%2 == 1 && v[i+1]%2 == 0 && v[i+1] > 0){
            v[i]++;
            v[i+1]--;
        }
    }

    REP(i, n){
        ans += v[i] / 2;
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });            var N = Sarray()[0];
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var red = new bool[N];
            red[0] = true;
            var num = Enumerable.Repeat<long>(1, (int)N).ToArray();
            for(var i=0;i<M;++i)
            {
                var xy = Sarray();
                var x = xy[0]-1;
                var y = xy[1]-1;
                --num[x];
                ++num[y];
                if (red[x]) red[y] = true;
                if (0 == num[x]) red[x] = false;
            }
            WriteLine(red.Count(r => r));

            //Out.Flush();
        }
    }
}

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

int main(){
    ios_base::sync_with_stdio(false);
    string n;
    cin >> n;
    if(n[0] == n[1] && n[1] == n[2]){cout << "Yes" << endl;}
    else if(n[1] == n[2] && n[2] == n[3]){cout << "Yes" << endl;}
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string S,T;
  int A,B;
  cin >> S >> T;
  cin >> A >> B;
  string U;
  cin >> U;

  if(U == S){
  	cout << A - 1 << " " << B << endl;
  }
  else{
  	cout << A << " " << B - 1 << endl;
  }

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

int main() {
    int A, B;
    cin >> A >> B;
    A = (A == 1 ? 14 : A);
    B = (B == 1 ? 14 : B);
    cout << (A == B ? "Draw" : (A > B ? "Alice" : "Bob")) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
main(){
  int i,j,l,n,temp;
  long int max,min;
  char c[10];
  scanf("%d",&n);
  for(l=0;l<n;l++){
    scanf("%s",c);

    for(i=7;i>0;i--){
      for(j=0;j<i;j++){
	if(c[j]<c[j+1]){
	  temp=c[j];
	  c[j]=c[j+1];
	  c[j+1]=temp;
	}
      }
    }
    max=atol(c);
    for(i=7;i>0;i--){
      for(j=0;j<i;j++){
	if(c[j]>c[j+1]){
	  temp=c[j];
	  c[j]=c[j+1];
	  c[j+1]=temp;
	}
      }
    }
    min=atol(c);
    printf("%ld\n",max-min);
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
int main(){
	long long n,p,m;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		m=i*i;
		if(m<=n) p=m;
		if(m>n) break;
	}
	printf("%lld\n",p);
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

var K int

func main() {
	fmt.Scan(&K)
	ans := 0
	for a := 1; a <= K; a++ {
		for b := 1; b <= K; b++ {
			g := gcd(a, b)
			for c := 1; c <= K; c++ {
				ans += gcd(g, c)
			}
		}
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}


Measured memory_bytes: 1776
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int d, n;
	cin >> d >> n;
	if (d == 0)
	{
		if (n < 100)
		{
			cout << n;
			return 0;
		}
		else
		{
			cout << 101;
			return 0;
		}
	}
	else if (d == 1)
	{
		if (n < 100)
		{
			cout << n * 100;
			return 0;
		}
		else
		{
			cout << 10100;
			return 0;
		}
	}
	else
	{
		if (n < 100)
		{
			cout << n * 10000;
			return 0;
		}
		else
		{
			cout << 1010000;
			return 0;
		}
	}
	sp;
}

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

ans=0

cnt=[0]*(10**5+10)
for i in range(N):
    cnt[A[i]]+=1

for i in range(0,100000):
    sum=cnt[i]+cnt[i+1]+cnt[i+2]
    ans=max(ans,sum)

print(ans)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  vi32 ord(n);
  iota(all(ord), 0);
  sort(all(ord), [&](int i, int j) {
    return a[i] > a[j];
  });
  vector<vi64> dp(n + 1, vi64(n + 1));
  auto rec = [&](auto rec, int l, int r) -> i64 {
    if (l == r) {
      return 0;
    }
    if (dp[l][r] != 0) {
      return dp[l][r];
    }
    int i = l + (n - r);
    i64 ret = 0;
    amax(ret, rec(rec, l + 1, r) + (i64) a[ord[i]] * abs(l - ord[i]));
    amax(ret, rec(rec, l, r - 1) + (i64) a[ord[i]] * abs(r - 1 - ord[i]));
    return dp[l][r] = ret;
  };
  cout << rec(rec, 0, n) << endl;
}

Measured memory_bytes: 34900
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted

int main(){
	ll N,ans=0;
	cin >> N;
	vector<ll> A,B,C;
	set<ll> a,b,c;
	FOR(i,0,N){
		ll x;
		cin >> x;
		if(a.count(x)==0)A.push_back(x);
	}
	FOR(i,0,N){
		ll x;
		cin >> x;
		if(b.count(x)==0)B.push_back(x);
	}
	FOR(i,0,N){
		ll x;
		cin >> x;
		if(c.count(x)==0)C.push_back(x);
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	for(ll y:B){
		ans += (POSL(A,y))*(C.size()-POSU(C,y));
	}
	cout << ans << endl;
}


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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

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

  return 0;
}


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

int SumOfDigits(int n) {
  int sum = 0;
  while (n>0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    const int sum = SumOfDigits(i);
    if (A <= sum && sum <= B) total += i;
  }
  cout << total << endl;
  return 0;
}

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

public class Program
{

	public void Proc()
	{
        int inputCount = int.Parse(Reader.ReadLine());

        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        Dictionary<long, int> cnt = new Dictionary<long, int>();
        foreach(long item in inpt) {
            for (long i = item - 1; i <= item + 1; i++) {
                if(cnt.ContainsKey(i)) {
                    cnt[i]++;
                } else {
                    cnt.Add(i, 1);
                }
            }
        }
        Console.WriteLine(cnt.Max(a=>a.Value));
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



7
3 1 4 1 5 9 2


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 26464
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
      .map(|e| e.parse().ok().unwrap()).collect()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let st: Vec<String> = read_vec();
    let ab: Vec<u32> = read_vec();
    let u: String = read();

    println!("{} {}",
        if u == st[0] { ab[0] - 1 } else { ab[0] },
        if u == st[1] { ab[1] - 1 } else { ab[1] }
    );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;cin>>a>>b;
    if(b%a==0) cout<<a+b<<endl;
    else cout<<b-a<<endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(long A, ll B, ll N) {
  if (N < B)
    cout << floor(A * N / B) << endl;
  else
    cout << floor(A * (B - 1) / B) << endl;
}

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

  long A;
  ll B, N;
  cin >> A >> B >> N;

  solve(A, B, N);

  return 0;
}


Measured memory_bytes: 3768
using System;

namespace ABC062_B_Picture_Frame
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int h = int.Parse(input[0]);
			int w = int.Parse(input[1]);
			string[] pixel = new string[h];
			for (int row = 0; row < h; row++)
				pixel[row] = Console.ReadLine();
			
			for (int column = 0; column < w + 2; column++)
				Console.Write("#");
			Console.WriteLine();

			for (int row = 0; row < h; row++)
				Console.WriteLine("#" + pixel[row] + "#");
			
			for (int column = 0; column < w + 2; column++)
				Console.Write("#");
			Console.WriteLine();
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main(){

	int n; cin >> n;
	int s = 0, m = 0;

	for(int i=0; i<n; i++){
		int L; cin >> L;
		s += L;
		m = max(m, L);
	}

	if(m < s - m){
		cout << "Yes" << endl;
	}
	
	else{
		cout << "No" << endl;
	}
	
	return 0;

}

Measured memory_bytes: 256
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/

long long int calc(vector<pair<int,int> > v, int K){
	if(K==0){
		long long int res = 0;
		for(int i=0; i<v.size(); i++)
			if(v[i].first == 0)
				res += v[i].second;
		return res;
	}
	int hi = 0;while((1<<hi) <= K)hi++;hi--;
	vector<pair<int,int> > v2;
	long long int now = 0;
	for(int i=0; i<v.size(); i++){
		int x = v[i].first, y = v[i].second;
		if(x >= (1<<(hi+1)))continue;
		v2.push_back(make_pair(x&((1<<hi)-1), y));
		if(x < (1<<hi))
			now += y;
	}
	return max(now, calc(v2, K-(1<<hi)));
}
int main(){
	int n,k;
	vector<pair<int,int> > v;
	scanf("%d%d",&n,&k);
	for(int i=0; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		v.push_back(make_pair(x,y));
	}
	cout << calc(v,k) <<endl;
	return 0;
}

Measured memory_bytes: 49012
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X;
  cin >> X;
  X /= 200;
  X -= 2;
  X *= -1;
  X += 8;
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int cnt[101] = {};
    vector<int> V(N);
    bool ok = true;
    rep(i,0,N){
        cin >> V[i];
        cnt[V[i]]++;
        //if(V[i] > N)ok = false;
    }
    rep(i,1,N+1){
        if(cnt[i] > N - i + 1)ok = false;
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    stack<int> st;
    vector<int> vec = V;
    rep(i,0,N){
        int k = N - i - 1;
        int idx = -1;
        for(int j = k;j >= 0;j--){
            if(vec[j] == j + 1){
                idx = j;
                break;
            }
        }
        if(idx == -1){
            cout << -1 << endl;
            return 0;
        }
        st.push(vec[idx]);
        vec.erase(vec.begin() + idx);
    }
    rep(i,0,N){
        cout << st.top() << endl;
        st.pop();
    }
}

Measured memory_bytes: 256
//Selecting Subjects
#include <iostream>

using namespace std;

int main() {
    int Scores[6];
    for(int i = 0; i < 6; i++) cin >> Scores[i];

    int s = 0, minv = 101;
    for(int i = 0; i < 4; i++) {
        s += Scores[i];
        minv = min(minv, Scores[i]);
    }
    s -= minv;
    minv = 101;
    for(int i = 4; i < 6; i++) {
        s += Scores[i];
        minv = min(minv, Scores[i]);
    }
    s -= minv;
    
    cout << s << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);
static const int MAXN = 1e5+5;
static const long long mod = 1e9+7;
vector<vector<int>> G(MAXN);
int N;
long long K;
long long ans = 1LL;
bool vis[MAXN];

void dfs(int x, int depth) {
  int cnt = 1;
  vis[x] = true;

  if (depth == 0) {

    ans *= K;
    for (int i = 1; i <= G[x].size(); i++) {
      int nx = G[x][i-1];
      if (vis[nx]) continue;
      ans *= (K - cnt);
      ans %= mod;
      dfs(nx, 1);
      cnt++;
    }

  } else {

    for (int i = 1; i <= G[x].size(); i++) {
      int nx = G[x][i-1];
      if (vis[nx]) continue;
      ans *= (K - cnt - 1);
      ans %= mod;
      dfs(nx, 1);
      cnt++;
    }

  }
  
}

int main() {
  cin >> N >> K;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if (N == 1) {
    cout << K << endl;
    return 0;
  }

  for (int i = 1; i <= N; i++) {
    if (G[i].size() > 0) {
      dfs(i, 0);
      break;
    }
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 9344
use std::io;

pub trait ExRead {
    fn read_line(&mut self) -> io::Result<String>;
}

impl ExRead for io::StdinLock<'_> {
    fn read_line(&mut self) -> io::Result<String> {
        let mut buf = String::new();
        io::BufRead::read_line(self, &mut buf).map(|_| buf)
    }
}

pub trait SplitAndParse<T: std::str::FromStr> {
    type Result;
    fn split_and_parse(self) -> Self::Result;
}

impl<'a, T: std::str::FromStr> SplitAndParse<T> for &'a str {
    type Result = Result<Vec<T>, <T as std::str::FromStr>::Err>;
    fn split_and_parse(self) -> Self::Result {
        self.split_whitespace()
            .map(|e| e.parse())
            .fold(Ok(Vec::new()),
                |acc, e| acc.and_then(|mut v| e.map(|parsed| {v.push(parsed); v})))
    }
}

fn hundred_floor_pow(base: f64, exp: usize) -> usize {
    (0..exp).fold(100.0, |acc, _| (acc * base).floor()) as usize
}

fn main() {
    let x: f64;

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        x = lkin.read_line().unwrap().trim().parse().ok().unwrap();
    }
    let mut ans = (x / 100.0).log(1.01) as usize;

    while hundred_floor_pow(1.01, ans) < x as usize {
        ans += 1;
    }

    println!("{}", ans);
}


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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

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

    int n, l;
    cin >> n >> l;

    vector<int> a(n);

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

    int j = 1;

    for (int i = 2; i < n; ++i){
        if (a[i] + a[i - 1] > a[j] + a[j - 1])
            j = i;
    }

    if (a[j] + a[j - 1] < l){
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;

        int x = 1;
        while (x < j)
            cout << x++ << endl;

        x = n - 1;
        while (x >= j)
            cout << x-- << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
while gets do
  @n, @s = $_.split(' ').map(&:to_i)
  break if @n == 0 and @s == 0
  @arr = []
  @c = 0

  def dfs(i)
    if @arr.size == @n
      @c += 1 if @arr.inject(:+) == @s
      return
    end

    (i..9).each do |j|
      @arr.push(j)
      dfs(j+1)
      @arr.pop
    end
  end

  dfs(0)
  puts @c
end

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn = 1e2 + 7;
struct Edge
{
    int from, to;ll cap, flow;
};
struct Dinic
{
    int n, m, s, t;
    vector<Edge> edges;
    vector<int> G[maxn];
    bool vis[maxn];
    ll d[maxn];
    int cur[maxn];

    void AddEdge(int from, int to, ll cap, ll c = 0)
    {
        edges.push_back(Edge{from, to, cap, 0});
        edges.push_back(Edge{to, from, c, 0});
        m = edges.size();
        G[from].push_back(m - 2);
        G[to].push_back(m - 1);
    }

    bool BFS()
    {
        memset(vis, 0, sizeof(vis));
        queue<int> q;
        q.push(s);
        d[s] = 0;
        vis[s] = 1;
        while (!q.empty())
        {
            int u = q.front();
            q.pop();
            for (int i = 0; i < G[u].size(); i++)
            {
                Edge &e = edges[G[u][i]];
                if (!vis[e.to] && e.cap > e.flow)
                {
                    vis[e.to] = 1;
                    d[e.to] = d[u] + 1;
                    q.push(e.to);
                }
            }
        }
        return vis[t];
    }
    ll DFS(int u, ll dist)
    {
        if (u == t || dist == 0)
            return dist;
        ll flow = 0, f;
        for (int &i = cur[u]; i < G[u].size(); i++)
        {
            Edge &e = edges[G[u][i]];
            if (d[u] + 1 == d[e.to] && (f = DFS(e.to, min(dist, e.cap - e.flow))) > 0)
            {
                e.flow += f;
                edges[G[u][i] ^ 1].flow -= f;
                flow += f;
                dist -= f;
                if (!dist)
                    break;
            }
        }
        return flow;
    }
    ll Maxflow(int s, int t)
    {
        this->s = s;
        this->t = t;
        ll flow = 0;
        while (BFS())
        {
            memset(cur, 0, sizeof(cur));
            flow += DFS(s, INF);
        }
        return flow;
    }
}F;

int main()
{
	int n;
	cin>>n;
	int S=0,T=n+1;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		int tmp;
		cin>>tmp;
		if(tmp>0)
		{
			F.AddEdge(i,T,tmp);
			sum+=tmp;
		}
		else F.AddEdge(S,i,-tmp);
		for(int j=i*2;j<=n;j+=i)
			F.AddEdge(i,j,INF);
	}
	cout<<sum-F.Maxflow(S,T)<<endl;
}


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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    int maxN = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        maxN = max(maxN, itr->second);
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second == maxN){
            cout << itr->first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_094_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(12).

    01 INP2   PIC X(401).

    01 maxlen PIC 9(3)  VALUE 3.
    01 cur    PIC 9(3)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).

    01 m      PIC 9(3).
    01 n      PIC 9(3).

    01 len    PIC 9(2).
    01 ans    PIC X(3).
    01 NMX1.
        03 NMX11 OCCURS 3.
            05 NMX PIC 9(3).
    01 A1.
        03 A11 OCCURS 100.
            05 A PIC 9(3) VALUE 0.

    01 x      PIC 9(3).

    01 tmp    PIC 9(3).
    01 sm     PIC 9(3) VALUE 101.
    01 ZS     PIC Z(3)9.

    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.
    ACCEPT INP2.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO NMX(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    MOVE 1 TO cur.
    MOVE NMX(2) TO maxlen.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP2(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP2(cur:len) TO x
        MOVE 1 TO A(x)

        COMPUTE cur = j + 1

    END-PERFORM.

    MOVE 0 TO tmp.
    PERFORM VARYING m FROM NMX(3) BY 1 UNTIL NMX(1) < m
        ADD A(m) TO tmp
    END-PERFORM.

    COMPUTE sm = FUNCTION MIN(sm, tmp).

    MOVE 0 TO tmp.
    PERFORM VARYING n FROM NMX(3) BY -1 UNTIL n <= 0
        ADD A(n) TO tmp
    END-PERFORM.

    COMPUTE sm = FUNCTION MIN(sm, tmp).

    MOVE sm TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 760
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;

int main() {
  int cnt[26] = {};
  string w;
  cin >> w;
  for (int i=0; i < w.length(); i++) {
    cnt[w[i]-'a']++;
  }
  for (int i=0; i < 26; i++) {
    if (cnt[i]%2) { cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;

  deque<ll> q;
  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    auto itr = lower_bound(q.begin(), q.end(), tmp);
    int index = distance(q.begin(), itr);
    if(index == 0){
      q.push_front(tmp);
    } else { 
      q[index-1] = tmp;
    }
  }
  cout << q.size() << endl;
}


Measured memory_bytes: 1024
M, D = map(int, input().split())
cnt = 0

if M < 4:
    print('0')
else:
    for i in range(4, M+1):
        for j in range(22, D+1):
            j = str(j)
            jli = list(j)
            if jli[1] == '0' or jli[1] == '1':
                pass
            else:
                if int(jli[0])*int(jli[1]) == i:
                    # print(i, jli)
                    cnt += 1

    print(cnt)



Measured memory_bytes: 3060
from collections import defaultdict

N, P = map(int, input().split())
S = input()

"""
S = "s0 s1 ... s(N-1)"に対して"sl s(l+1) ... s(r-1)"が素数Pで割り切れるかを考える。
これはa_i := int("si s(i+1) ... s(N-1)")と定めることで、
    (a_l - a_r) / 10^{N-r} ¥cong 0  (mod P)
と定式化できる。

（整数関連の区間の問題は後ろからの累積和が相性良さそう。頭からの累積を考えたのが敗因な気がする）

Pが2でも5でもない場合は、上式は
    a_l - a_r ¥cong 0 (mod P)
に同値であるから、各a_iのmod Pでの値を辞書にまとめておけば良さそう。
Pが2, 5のいずれかの場合は偶然チェックが簡単なので解ける。
"""

ans = 0
if P == 2:
    for i in range(N):
        a = int(S[i])
        if a % 2 == 0:
            ans += i + 1
elif P == 5:
    for i in range(N):
        a = int(S[i])
        if a == 0 or a == 5:
            ans += i + 1
else:
    S += "0" # 上の定式化の都合上、r = Nのケースが必要なので
    d = defaultdict(int)
    r = 0
    d[0] += 1
    for i in range(N - 1, -1, -1):
        """
        ここでS[i:]を毎回Pで割るとTLEする（桁の大きい演算はやはり負担が大きいのか？）
        (a_i % P)をi = N, N-1,...の降順に求めていくことを考えれば、
        前の計算結果が使える、特に繰り返し二乗法が使えるのでだいぶ早くなるみたい。
        """
        r += int(S[i]) * pow(10, N - i - 1, P)
        r %= P
        d[r] += 1

    for num in d.values():
        ans += num * (num - 1) // 2

print(ans)


Measured memory_bytes: 43068
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N;
	cin >> N;
	int x = 111;
	while(x < N){
		x += 111;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256