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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> W(n), B(n);
	int cntw = 0;
	int cntb = 0;
	for (int i=0; i<n; i++) {
		if (s[i]=='#') cntb++;
		B[i] = cntb;
		if (s[n-1 - i]=='.') cntw++;
		W[n-1-i] = cntw;
	}
	int ret = W[0];
	W.push_back(0);
	for (int i=0; i<n; i++) {
		ret = min(ret, B[i] + W[i+1]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    b.at(i)=a.at(i);
  }
  sort(a.begin(),a.end());
  for(int j=0;j<n;j++){
    if(b.at(j)==a.at(n-1))cout<<a.at(n-2)<<endl;
    else cout<<a.at(n-1)<<endl;
  }
}
  

Measured memory_bytes: 3200
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
using namespace std;


int main() {
    string S;
    cin >> S;
    if(S[0] == 'A'){
        int Cnum = 0;
        bool j = true;
        for (int i = 1; i < S.size(); i++)
        {
            if(i!=1 and i!=S.size()-1 and S[i] == 'C') Cnum++;
            else if(S[i] <= 'Z') j = false;
        }
        if(j and Cnum == 1){
            cout << "AC" << endl;
        }
        else cout << "WA" << endl;
    }
    else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, n) cin >> a[i];
   llong sum = 0;
   int mn = 1e6, mx = -1e6;
   rep(i, n) {
      sum += a[i];
      mx = max(mx, a[i]);
      mn = min(mn, a[i]);
   }
   printf("%d %d %lld\n", mn, mx, sum);
   return 0;
}


Measured memory_bytes: 3252
<?php
    $a = str_split(trim(fgets(STDIN)));
    $flg = 0;
    if($a[0] == "9"){
        $flg = 1;
    }elseif($a[1] == "9"){
        $flg = 1;
    }
    if($flg == 1){
        echo "Yes";
    }else{
        echo "No";
    }
?>

Measured memory_bytes: 4728
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	ll a, b, n;
	cin >> a >> b >> n;
	ll g = gcd(a, b);
	cout << a * min(b - 1, n) / b;
}


Measured memory_bytes: 3652
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    N = I()
    P = LI()
    A = [N*(i+1) for i in range(N)]
    B = [N*(N-i) for i in range(N)]
    for i,p in enumerate(P):
        A[p-1] += i
    print(" ".join(map(str,A)))
    print(" ".join(map(str,B)))
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 7716
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

constexpr ll INF = LLONG_MAX / 2;

struct Edge {
    ll to, cost;
};
vector<vector<Edge>> edges;

struct Element {
    ll node, cost;
    bool operator<(const Element& rhs) const {
        return cost < rhs.cost;
    }
    bool operator>(const Element& rhs) const {
        return cost > rhs.cost;
    }
};

vector<ll> dijkstra(const vector<vector<Edge>>& edges, ll s) {
    vector<ll> cost(edges.size(), INF);
    priority_queue<Element, vector<Element>, greater<Element>> pq;

    cost[s] = 0;
    pq.push({ s, 0 });
    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost > cost[t.node]) {
            continue;
        }

        for (const Edge& edge : edges[t.node]) {
            ll new_cost = t.cost + edge.cost;
            if (new_cost < cost[edge.to]) {
                cost[edge.to] = new_cost;
                pq.push({ edge.to, new_cost });
            }
        }
    }

    return cost;
}

constexpr ll MOD = (ll)1e9 + 7;

vector<ll> numOfShortestPath(const vector<vector<Edge>>& edges, ll s) {
    vector<ll> cost(edges.size(), INF);
    priority_queue<Element, vector<Element>, greater<Element>> pq;
    vector<ll> dp(edges.size(), 0);

    cost[s] = 0;
    dp[s] = 1;
    pq.push({ s, 0 });
    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost > cost[t.node]) {
            continue;
        }

        for (const Edge& edge : edges[t.node]) {
            ll new_cost = t.cost + edge.cost;
            if (new_cost < cost[edge.to]) {
                cost[edge.to] = new_cost;
                pq.push({ edge.to, new_cost });
                dp[edge.to] = dp[t.node];
            } else if (new_cost == cost[edge.to]) {
                (dp[edge.to] += dp[t.node]) %= MOD;
            }
        }
    }

    return dp;
}

int main() {
    ll N, M, S, T;
    cin >> N >> M >> S >> T;
    S--; T--;

    edges.resize(N);
    for (ll i = 0; i < M; i++) {
        ll U, V, D;
        cin >> U >> V >> D;
        U--; V--;
        edges[U].push_back({ V, D });
        edges[V].push_back({ U, D });
    }

    auto dS = dijkstra(edges, S);
    auto dT = dijkstra(edges, T);
    auto dp1 = numOfShortestPath(edges, S);
    auto dp2 = numOfShortestPath(edges, T);

    auto squareMOD = [&](ll x) {
        return x * x % MOD;
    };

    ll ans = squareMOD(dp1[T]);
    for (ll u = 0; u < N; u++) {
        //頂点上で出会う
        if (2 * dS[u] == dS[T]) {
            ans = (ans - squareMOD(dp1[u]) * squareMOD(dp2[u]) % MOD + MOD) % MOD;
        }

        for (Edge edge : edges[u]) {
            //辺上で出会う
            ll v = edge.to;
            if (2 * dS[u] < dS[T] && 2 * dS[v] > dS[T] && dS[u] + edge.cost + dT[v] == dS[T]) {
                ans = (ans - squareMOD(dp1[u]) * squareMOD(dp2[v]) % MOD + MOD) % MOD;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 20120
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
#define Vanya Unstoppable
 
using namespace std;

const int N = 2507;

map<int, int> dp[57];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    
    int a[n + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] = a[i] - k;
    }
    
    for (int i = 1; i <= n; ++i) {
        dp[i][a[i]] += 1;
        for (int j = -N; j <= N; ++j) {
            if (i + 1 > n) continue;
            int val = j + a[i + 1];
            if (val >= -N && val <= N) {
                dp[i + 1][val] += dp[i][j];
            }
            dp[i + 1][j] += dp[i][j];
        }
    }
    
    cout << dp[n][0];
}


Measured memory_bytes: 19244
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;

  while(a>=b){
    b*=2; k--;
  }
  while(b>=c){
    c*=2; k--;
  }

  if(k<0) cout << "No" << endl;
  else cout << "Yes" << endl;



  return 0;
}


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

int main(){
  long long n;
  cin>>n;
  
  long long a[n];
  for(long long i = 1; i <= n  ; i++) a[i] = i;
  
  long long sum = 0;
  
  for(long long i = 1; i <= n; i++){
      if((a[i] % 3) == 0 or (a[i] % 5) == 0)a[i] = 0;
      sum += a[i];
  }
  
  cout<<sum<<endl;
  
}
  
  

Measured memory_bytes: 11444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
ll gcd(ll x, ll y) {
	if (!y)return abs(x);
	return gcd(abs(y), abs(x % y));
}
ll lcm(ll x, ll y) {
	if (x == 0)return y;
	if (y == 0)return x;
	return x / gcd(x, y) * y;
}
int main() {
	//file();
	fast();
	int a, b; cin >> a >> b;
	cout << lcm(a, b) << endl;
	return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define M 1000000007

/*--------------------------------------------------------------------------------------------------------------------------------*/

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

void init()
{
    int N,mx = -1;
    cin >> N;
    int a[N+5],b[N+5];
    rep(i,0,N)
    {
        cin >> a[i];
        mx = max(mx,a[i]);
    }
    rep(i,0,N)
    {
        cin >> b[i];
        mx = max(mx,b[i]);
    }
    int ans = 0,d, u = log(mx);
    vi a1,b1;
    rep(i,0,30)
    {
        d = (1<<(i+1));
        a1.clear();
        b1.clear();
        rep(i,0,N)
        {
            a1.pb(a[i]%d);
            b1.pb(b[i]%d);
        }
        sort(b1.begin(),b1.end());

        /*for(auto it : b1)
            cout << it << endl ;*/

        rep(j,0,N)
        {
            int v = 0;
            int id1 = lower_bound(b1.begin(),b1.end(),d/2 - a1[j]) - b1.begin();
            int id2 = upper_bound(b1.begin(),b1.end(),d - a1[j] - 1) - b1.begin() - 1;
            if(id1 < N && id2>=id1)
                v += (id2-id1+1);

            int id3 = lower_bound(b1.begin(),b1.end(),(3*(d/2)) - a1[j]) - b1.begin();
            int id4 = upper_bound(b1.begin(),b1.end(),2*d - a1[j] - 1) - b1.begin() - 1;
            if(id3 < N && id4>=id3)
                v += (id4-id3+1);

            //cout << id1 << " " << id2 << " " << id3 << " " << id4 << endl ;

            if(v%2 == 1)
                ans^=(d/2);// cout <<"asd" << ans << endl;
         }
    }
    cout << ans << endl ;
}

int main()
{
    clock_t time1=clock();
	/*#ifndef ONLINE_JUDGE
	freopen("abc_091.in","r",stdin);
	#else
	//ONLINE_JUDGE
	#endif*/
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC <<" seconds" <<endl;
	return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int prev;
  cin >> prev;
  int i = 1;
  for ( int j = 0; j < n - 1; j++ ) {
    int now;
    cin >> now;
    if ( now >= prev ) {
      i++;
      prev = now;
    }
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

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

Measured memory_bytes: 3608
import math
N, D = map(int, input().split())
X =[]
distance = 0
ans = 0

for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)

for i in range(N):
    for j in range(i + 1,N):
        for k in range(D):
            distance += (X[i][k] - X[j][k]) ** 2
        distance = math.sqrt(distance)
        if distance == math.ceil(distance):
            ans += 1
        distance = 0

print(ans)

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

using namespace std;

int main()
{
    int n, i;
    string s;
    cin >> s;
    cin >> n;
    for (i = 0; i < s.size(); ++i)
    {
        if (s[i] != 'a' && ((int) 'z' - s[i] + 1 <= n))
            n -= (int) 'z' - s[i] + 1, s[i] = 'a';
    }
    s[s.size() - 1] = ((int) s[s.size() - 1] - 'a' + n) % 26 + 'a';
    cout << s;
    return 0;
}


Measured memory_bytes: 888
def main():
    import sys
    from operator import itemgetter
    buf = sys.stdin.buffer

    n, d, a = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    monsters = sorted(zip(m, m), key=itemgetter(0))

    bomb_area = []
    bomb_power = []
    bomb_length = 0
    total_damage = 0
    ans = 0
    idx = 0
    for pos, hp in monsters:
        while idx < bomb_length:
            area = bomb_area[idx]
            if area < pos:
                power = bomb_power[idx]
                total_damage -= power
                idx += 1
            else:
                break
        if hp <= total_damage:
            continue
        else:
            count = (hp - total_damage + a - 1) // a
            ans += count
            power = a * count
            total_damage += power
            bomb_area.append(pos + 2 * d)
            bomb_power.append(power)
            bomb_length += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55880
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int n,m,ans;
	cin>>n>>m;
	ans=n*(n-1)/2+m*(m-1)/2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()

int main(){
	
	int N;
	cin >> N;
	vector<pair<int,int>> v;
	int mark;
	if(N%2 == 0) mark = N+1;
	else mark = N;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			if(i+1+j+1 == mark) continue;
			v.PB(MP(i+1, j+1));
		}
	}

	cout << v.size() << endl;
	for(int i=0; i<v.size(); i++){
		cout << v[i].first << " " << v[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 384
import math
from functools import reduce
N, X = map(int, input().split())
x = list(map(int,input().split()))
 
for i in range(N):
    x[i] = abs(x[i]-X)
 
x = sorted(x)[::-1]
cnt = 0
 
for i in range(N):
    cnt = math.gcd(cnt, x[i])
 
print(cnt)

Measured memory_bytes: 20324
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var list = new List<string>();
        
        while(true){
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(a);
            if(a[0] == 0 && a[1] == 0){
                break;
            }else{
                list.Add($"{a[0]} {a[1]}");
            }
        }
        
        foreach(var i in list){
            Console.WriteLine(i);
        }
    }
}



Measured memory_bytes: 9536
N, K = map(int, input().split())

V = list(map(int, input().split()))
ans = 0
for i in range(K+1):
    li = V[:i]
    for j in range(K+1):
        if i+j > N or i+j > K:
            break
        if j:
            lj = li + V[-j:]
        else:
            lj = li[:]
        for k in range(K+1):
            if i+j+k>K:
                break
            if i+j >= k:
                lj.sort()
                ans = max(ans, sum(lj[k:]))
print(ans)  

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
using namespace std;
int uluu(int x)	
{
	if(x%400==0 || (x%100!=0 && x%4==0))	return 1;
	else return 0;
}
int main(void)
{
	int b,ka,t,w,ki,y,m,d,i,j,k,ff,p,len;
	char buf[100];
	long long cnt,day;
	int mon[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},
					{0,31,29,31,30,31,30,31,31,30,31,30,31}};
	int smon[2][13];
	int uday[2]={365,366};
	int ulu;
	while(1)	{
		scanf("%s",buf);
		if(buf[0]=='#')	break;
		cnt=0;
		len=strlen(buf);
		for(i=0;i<len;i++)	{
			if(buf[i]=='.')	cnt++;
		}
		if(cnt==2)	ff=1;
		else ff=2;
		
		if(ff==1)	{
			p=0;
			y=0;
			while(buf[p]!='.')	{
				y*=10;
				y+=buf[p]-'0';
				p++;
			}
			p++;
			m=0;
			while(buf[p]!='.')	{
				m*=10;
				m+=buf[p]-'0';
				p++;
			}
			p++;
			d=0;
			while(buf[p]!='\0')	{
				d*=10;
				d+=buf[p]-'0';
				p++;
			}
			day=0;
			if(y==2012)	{
				day+=d-21;
			}
			else {
				day=10;
				for(i=2013;i<y;i++)	{
					if(uluu(i)==1)	day+=366;
					else day+=365;
				}
				for(i=1;i<m;i++)	{
					ulu=uluu(y);
					day+=mon[ulu][i];
				}
				day+=d;
			}
//			printf("day=%d\n",day);
			
			b=day/(20*20*18*20);
			b%=13;
			day%=(20*20*18*20);
			ka=day/(20*18*20);
			day%=(20*18*20);
			t=day/(18*20);
			day%=18*20;
			w=day/20;
			ki=day%20;
			printf("%d.%d.%d.%d.%d\n",b,ka,t,w,ki);
		}
		else {
			p=0;
			b=buf[p]-'0';
			p++;
			if(buf[p]!='.')	{
				b=b*10+buf[p]-'0';
				p++;
			}
			p++;
			
			ka=buf[p]-'0';
			p++;
			if(buf[p]!='.')	{
				ka=ka*10+buf[p]-'0';
				p++;
			}
			p++;			
		
			t=buf[p]-'0';
			p++;
			if(buf[p]!='.')	{
				t=t*10+buf[p]-'0';
				p++;
			}
			p++;			
		
			w=buf[p]-'0';
			p++;
			if(buf[p]!='.')	{
				w=w*10+buf[p]-'0';
				p++;
			}
			p++;	

			ki=buf[p]-'0';
			p++;
			if(buf[p]!='\0')	{
				ki=ki*10+buf[p]-'0';
				p++;
			}
			p++;	
		
			day=b*20*20*18*20+ka*20*18*20+t*18*20+w*20+ki;
//			printf("day=%d\n",day);
//			printf(" %d %d %d %d %d\n",b,ka,t,w,ki);
			if(day<=10)	{
				y=2012;	m=12;	d=day+21;
			}
			else {
				day=day-10;
				y=2013;
				while(1)	{
					ulu=uluu(y);
					if(uday[ulu]>=day)	break;
					day-=uday[ulu];
					y++;
				}
				m=1;
				ulu=uluu(y);
				while(1)	{
					if(mon[ulu][m]>=day)	break;
					day-=mon[ulu][m];
					m++;
				}
				d=day;
			}
			printf("%d.%d.%d\n",y,m,d);
		}
	}
	return 0;
}


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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define pb push_back              // push_back
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

void Main(void)
{
    int s, w;
    cin >> s >> w;
    if (s <= w)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
}

int main(int argc, char *argv[])
{
    // cin, coutの高速化、ただしcのIOと一緒にしない
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // fixed -> 少数の形で出力、setprecision -> 少数第n位まで出力
    cout << fixed << setprecision(15);
    // main実行
    Main();

    return 0;
}


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

int main(void){
  int a,b,n, ans=1;
  
  cin >> a >> b >> n;
  for (int i=0; i<n; i++){
    int s, f;
    cin >> s >> f;
    ans &= b<=s||f<=a;
  }
  cout << !ans << endl;
  return 0;
}


Measured memory_bytes: 3124
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N, long long K, std::vector<long long> h) {
  LL ans=0;
  REP(i,N){
    if(h[i]>=K)ans++;
  }
  cout<<ans<<endl;

}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  solve(N, K, std::move(h));
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
h = list(map(int,input().split()))
h.reverse()
combo = 0
can = [0]
for i in range(1,n):
  if h[i-1] <= h[i]:
    combo += 1
  else:
    combo = 0
  can.append(combo)
print(max(can))
#print(can)
#print(h)

Measured memory_bytes: 14252
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define REP(i,n) for(int i=0; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if (0<=x-r && x+r<=W && 0<=y-r && y+r<=H) printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  string _S = "keyence";
  int N = S.size();
  int _N = _S.size();
  for (int i = 0; i <= _N; ++i) {
    if (_S.substr(0, i) == S.substr(0, i) && _S.substr(i) == S.substr(N - _N + i)) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    cout << ((g*10 + b) % 4 ? "NO":"YES") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{int H,N,j,i,a,flag=0;
    scanf("%d",&H);
    scanf("%d",&N);
    int arr[N];
    for (i=0;i<N;i++)
    {scanf("%d",&arr[i]);
    }

    for (i=0;i<N;i++)
    {H=H-arr[i];
        if(H<=0)
        {flag=1;
            break;
    }
    }
    if (flag==1)
    {printf("Yes");
    }
    else
    {printf("No");
    }
    return 0;
}

Measured memory_bytes: 512
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
A=many_int()

if len(set(A) ) == len(A):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 25936
n,W = map(int,input().split())
w = []
v = []
for i in range(n):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)

dp = [[0]*(W+1) for j in range(n+1)]

for i in range(n-1,-1,-1):
    for j in range(W+1):
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]]+v[i])
print(dp[0][W])

Measured memory_bytes: 120300
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int f=0;
    int a;
    
    for(int i=1;i<n&&k>0;i++){
        if(s.at(i)!=s.at(i-1)&&f==1){
            k--;
            for(int j=a;j<i;j++){
                if(s.at(j)=='R') s.at(j)='L';
                else if(s.at(j)=='L') s.at(j)='R';
            }
            f=0;
        }
        else if(s.at(i)!=s.at(i-1)&&f==0){
            a=i;
            f=1;
        }
        
    }
    if(k>=1) cout<<n-1;
    else{
        int z=0;
        for(int i=0;i<n-1;i++){
            if(s.at(i)=='R'&&s.at(i+1)=='R') z++;
        }
        for(int i=n-1;i>=1;i--){
            if(s.at(i)=='L'&&s.at(i-1)=='L') z++;
        }
        cout<<z;
    }
}

Measured memory_bytes: 512
import bisect
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))

# 負の個数
num_neg = bisect.bisect_left(A, 0)
# 0の個数
num_zero = bisect.bisect_right(A, 0) - num_neg
# 正の個数
num_pos = N - num_neg - num_zero

A_neg_rev = A[:num_neg] # 絶対値が大きいものからになるようにソート
A_pos = A[num_neg + num_zero:] # 絶対値が小さいものからになるようにソート

A_neg = A_neg_rev[::-1] # 絶対値が大きいものからになるようにソート
A_pos_rev = A_pos[::-1] # 絶対値が小さいものからになるようにソート

# 値が0になるペアの個数
cnt_zero = num_zero * (num_pos + num_neg) + (num_zero * (num_zero - 1) // 2)
# 値が負になるペアの個数
cnt_neg = num_pos * num_neg

# 値が正になるとき
def syakutori_pos(arr, mid):
    if len(arr) == 0:
        return 0
    cnt = 0
    l = 0
    r = len(arr) - 1
    while l < r:
        if arr[l] * arr[r] <= mid:
            cnt += r - l
            l += 1
        else:
            r -= 1
    return cnt

# 値が負になるとき
def syakutori_neg(arr_pos, arr_neg, mid):
    if len(arr_pos) == 0 or len(arr_neg) == 0:
        return 0
    arr = arr_neg + arr_pos
    cnt = 0
    l = 0
    r = len(arr) - 1
    while l < len(arr_neg) and r >= len(arr_neg):
        if arr[l] * arr[r] <= mid:
            cnt += r - len(arr_neg) + 1
            l += 1
        else:
            r -= 1
    return cnt

# 自分以下の数になるペアの個数がK個以上になる
ok = 10 ** 18
ng = -ok - 1
while ng + 1 < ok:
    mid = (ok + ng) // 2
    cnt = 0
    if mid > 0:
        cnt += cnt_zero
        cnt += cnt_neg
        cnt += syakutori_pos(A_pos, mid) + syakutori_pos(A_neg, mid)
    elif mid == 0:
        cnt += cnt_zero
        cnt += cnt_neg
    else:
        cnt += syakutori_neg(A_pos_rev, A_neg_rev, mid)
    if cnt >= K:
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 119940
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long LL;

int main()
{ 
    int n[33]={0,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};
    int k;
    cin>>k;
    cout<<n[k]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef pair<int,string> xx;
typedef pair<xx,ii> iii;
const int INF=(int)2e9;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
const ll MOD=(ll)1e9+7;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define MAX 100005
#define wa cout<<"wa"<<endl;
#define LEFT 2*node
#define RIGHT 2*node+1
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

ll n,arr[MAX];
bool num[MAX];
double k;

int main(){
//	base();
	ll a,b;
	cin>>a>>b;
	if (a%b==0){
		cout<<-1<<endl;
	}else {
		for(ll i=2*a;i<=1e18;i+=a){
			if (i%b!=0){
				cout<<i<<endl;
				return 0;
			}
		}
		cout<<-1<<endl;
	}
	return 0;
}



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;

int main(){
  int a,b,c,x,y;
  cin >>a >>b >>c >>x >>y;
  ll ans = 0;
  if(a+b>2*c){
    int z = min(x,y);
    ans += 2*z*c;
    x -= z;
    y -= z;
  }
  if(a>2*c){
    ans += 2*x*c;
    x = 0;
    y = max(0,y-x);
  }
  if(b>2*c){
    ans += 2*y*c;
    y = 0;
    x = max(0,x-y);
  }
  ans += a*x+b*y;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
S = [list(input()) for _ in range(n)]
A = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
     'u', 'v', 'w', 'x', 'y', 'z']
C = [{'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0,
      'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, 'z':0} for _ in range(n)]
for i in range(n):
    for s in S[i]:
        C[i][s] += 1
P = ''
for a in A:
    p = 100
    for i in range(n):
        p = min(p, C[i][a])
    P += p * a
print(P)

Measured memory_bytes: 9552
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

set<P> black,candidate;
ll ans[10];

int main(void){
	int h,w,n,a,b,i,j,k,cnt;
	set<P>::iterator itr;
	cin >> h >> w >> n; ans[0] = 1ll*(h-2)*(w-2);
	for(k=0; k<n; ++k){
		cin >> a >> b;
		black.insert(P(a,b));
		for(i=0; i<3; ++i){
			for(j=0; j<3; ++j){
				if(1<=(a-i) && (a-i)<=h-2 && 1<=(b-j) && (b-j)<=w-2){
					candidate.insert(P(a-i,b-j));
				}
			}
		}
	}
	for(itr=candidate.begin(); itr!=candidate.end(); ++itr){
		a = (*itr).first; b = (*itr).second;
		cnt = 0;
		for(i=0; i<3; ++i){
			for(j=0; j<3; ++j){
				if(black.find(P(a+i,b+j))!=black.end()){
					++cnt;
				}
			}
		}
		++ans[cnt];
	}
	for(i=1; i<10; ++i){
		ans[0] -= ans[i];
	}
	for(i=0; i<10; ++i){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

bool isPrimary(int num){
    for(int i = 2; i < num; i++){
        if(num % i == 0){
            return false;
        }
    }
    return true;
}

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

    int num;
    num = X;
    
    while(1){
        if(isPrimary(num)){
            cout << num << endl;
            return 0;
        }
        num++;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
	char s[4];
	scanf("%s", s);
	if ((int) strlen(s) == 2) {
		printf("%s", s);
	}
	else {
		printf("%c%c%c", s[2], s[1], s[0]);
	}
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[4];
	cin >> s;
	int a[28] = {0};
	int flag = 0;
	for (int i=0;i<strlen(s);i++)
	a[s[i]-'A']++;
	if(strlen(s)<4)
	{
		cout << "No";
		return 0;
	}	
	for (int i=0;i<28;i++)
	{
		if(a[i]==2)
		{
			flag++;
		}
	}
	if(flag == 2)
	{
		cout << "Yes";
	}
	else
	cout << "No";
	
	return 0;
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type Pos struct {
	X int
	Y int
}

type Poses []Pos

func main() {
	var N, M, x, y int
	fmt.Scan(&N, &M)
	var ss, cs Poses
	for i := 0; i < N; i++ {
		fmt.Scan(&x, &y)
		ss = append(ss, Pos{X: x, Y: y})
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&x, &y)
		cs = append(cs, Pos{X: x, Y: y})
	}
	for i := 0; i < len(ss); i++ {
		var p int
		m := math.MaxInt64
		for j := 0; j < len(cs); j++ {
			w := abs(ss[i].X-cs[j].X) + abs(ss[i].Y-cs[j].Y)
			if w < m {
				m = w
				p = j + 1
			}
		}
		fmt.Println(p)
	}
}
func abs(a int) int {
	return int(math.Abs(float64(a)))
}

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

using namespace std;

int main(){
	long long t,d;
	cin>>t>>d;
	int c=0;
	while(t--){
		long long x,y;
		cin>>x>>y;
		if((x*x)+(y*y)<=d*d){
			c++;
		}
	}
	cout<<c<<endl;
}


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

void solve(){
	int n; cin >> n;
	int a[n];
	forn(i,0,n) cin >> a[i];
	
	ll total_sum = 0;
	map<ll,ll> m;
	forn(i,0,n){
		total_sum += a[i];
		++m[a[i]];
	}
	
	int q; cin >> q;
	forn(i,0,q){
		ll b,c; cin >> b >> c;
		ll cnt = m[b];
		total_sum -= cnt*b;
		total_sum += cnt*c;
		
		m[c] += cnt;
		m.erase(b);
		
		cout << total_sum << '\n';
	}
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
int main(){
     
    double x;
    double y;
    cin>>x>>y; 		
	if(x>y)
	cout<<"GREATER";
	else if(x<y)
	cout<<"LESS";
	else
	cout<<"EQUAL";
	    
    
	 
     
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const LL N = 105,M = 20005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL ec = 1,hed[N],cur[N],cap[M],nxt[M],to[M];
void add_edge(LL f,LL t,LL c){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec; cap[ec] = c;
	++ ec; to[ec] = f; nxt[ec] = hed[t]; hed[t] = ec; cap[ec] = 0;
}

LL lev[N];
queue <LL> q;
void bfs(LL s){
	memset(lev,0,sizeof(lev));
	while(!q.empty()) q.pop();
	q.push(s); lev[s] = 1; 
	while(!q.empty()){
		LL u = q.front(); q.pop();
		for(LL i = hed[u];i;i = nxt[i]){
			LL v = to[i];
			if(lev[v] || !cap[i]) continue;
			lev[v] = lev[u] + 1;
			q.push(v);
		}
	}
}

LL dfs(LL u,LL t,LL f){
	if(u == t) return f;
	for(LL i = cur[u];i;i = nxt[i]){
		cur[u] = i;
		LL v = to[i];
		if(lev[v] == lev[u] + 1 && cap[i]){
			LL tmp = dfs(v,t,min(cap[i],f));
			if(tmp){
				cap[i] -= tmp;
				cap[i ^ 1] += tmp;
				return tmp;
			}
		}
	}
	return 0;
}

LL mxf = 0;
void dinic(LL s,LL t){
	LL f = 0;
	while(1){
		bfs(s);
		if(!lev[t]) return;
		for(LL i = 1;i <= t;i ++) cur[i] = hed[i];
		while(1){
			f = dfs(s,t,INF);
			mxf += f;
			if(!f) break;
		}	
	}
}

int main(){
	LL n,S,T,a,sum = 0;
	cin >> n; S = n + 1; T = S + 1;
	for(LL i = 1;i <= n;i ++){
		cin >> a; sum += max(0LL,a);
		if(a > 0) add_edge(i,T,a);
		if(a < 0) add_edge(S,i,-a);
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = i + 1;j <= n;j ++){
			if(j % i == 0) add_edge(i,j,INF);
		}
	}
	dinic(S,T);
	cout << sum - mxf << '\n';
	return 0;
}
//

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    string S, T;
    cin >> S >> T;
    rep(i, S.size()){
        if(S[i] != T[i]){
            cout << "No";
            return 0;
        }
    }
    if(T.size() != S.size()+1){
        cout << "No";
        return 0;
    }
    cout << "Yes";
}

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

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n, Abel SUM_UNITY) {
        init(n, SUM_UNITY);
    }

    void init(int n, Abel SUM_UNITY) {
        par.resize(n+1); rank.resize(n+1); diff_weight.resize(n+1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    while(N>0){
        UnionFind<int> uf(N,0);
        char c;
        int a,b,w;
        int i;
        for(i=0; i<M; i++){
            cin >> c;
            if(c=='!'){
                cin >> a >> b >> w;
                uf.merge(a,b,w);
            }else{
                cin >> a >> b;
                if(uf.issame(a,b)){
                    cout << uf.diff(a,b) << endl;
                }else{
                    cout << "UNKNOWN" << endl;
                }
            }
        }
        cin >> N >> M;
    }
    return 0;
}


Measured memory_bytes: 4140
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int[] x = new int[5];
                x[1] = 6000;
                x[2] = 4000;
                x[3] = 3000;
                x[4] = 2000;
                for (int i = 0; i < 4; i++) {
                        System.out.println(x[sc.nextInt()] * sc.nextInt());
                }

        }
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n = in();
  int upper[n+1];
  int lower[n+1];
  upper[0] = 0; lower[0] = 0;
  int candies[2][n];
  REP(i,2) {
    REP(j,n) {
      cin >> candies[i][j];
      if(i == 0) {
        upper[j+1] = upper[j] + candies[i][j];
      } else {
        lower[j+1] = lower[j] + candies[i][j];
      }
    }
  }
  int ans = 0;
  REPS(i,1,n+1) {
    ans = max(ans, upper[i] + lower[n]-lower[i-1]);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
N=int(input())
h = list(map(int , input().split()))
dp = [10**9+1]*N
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

Measured memory_bytes: 13904
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << max(A * B, C * D) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

  string s;
  cin>>s;

  long long int num[10];
  long long int ans=0;

  for(int i=0;i<s.size();i++){
    num[s.size()-(i+1)]=s[i]-'0';
    //cout << num[s.size()-(i+1)] << endl;
  }
  for(int i=0;i<(1<<(s.size() -1 )) ;i++){
    long long int tmp_cnt=num[0];
    int p_cnt=0;
    for(int j=0;j<(s.size() -1 );j++){
      if( (i >> j) & 1 ){
        ans += tmp_cnt;
        p_cnt=0;
        tmp_cnt=num[j+1];
        //cout << ans << endl;
      }
      else{
        tmp_cnt += pow(10,p_cnt+1)*num[j+1];
        p_cnt++;
      }
      //cout << "tmp_cnt:" << tmp_cnt << endl;
    }
    ans += tmp_cnt;
    //cout << ans << endl;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int n,k;
    cin >>n>>k;
    vector<int>a(n);
    rep(i,k){
        int d;
        cin >>d;
        rep(j,d){
            int x;
            cin>>x;
            a[x-1]++;
        }
    }

    int ans =0;
    rep(i,n){
        if(a[i]==0)
            ans++;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3628