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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define FOR(i, c) for(decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

template <class T>
void Dijkstra(Graph &G, ll s, vec<T> &d) { //O(|E|log|V|)
    d.resize(G.size());
    REP(i, d.size()) { d[i] = INF; }
    d[s] = 0;
    priority_queue<pair<T, ll>, vector<pair<T, ll>>, greater<pair<T, ll>>> q;
    q.push(make_pair(0, s));
    while(!q.empty()) {
        P a = q.top();
        q.pop();
        if(d[a.second] < a.first)
            continue;
        REP(i, G[a.second].size()) {
            Edge e = G[a.second][i];
            if(d[e.to] > d[a.second] + e.cap) {
                d[e.to] = d[a.second] + e.cap;
                q.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

void solve() {
    ll sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    vec<tuple<ll, ll, ll>> xyr;
    xyr.push_back({sx, sy, 0});
    xyr.push_back({gx, gy, 0});
    ll n;
    cin >> n;
    REP(i, n) {
        ll x, y, r;
        cin >> x >> y >> r;
        xyr.push_back({x, y, r});
    }

    Graph g(n + 2);

    auto dis = [&](int i, int j) -> long double {
        auto [xi, yi, ri] = xyr[i];
        auto [xj, yj, rj] = xyr[j];
        return max(0.0L, sqrt((ld)(xi - xj) * (xi - xj) + (yi - yj) * (yi - yj)) - ri - rj);
    };

    REP(i, n + 2) {
        rep(j, i + 1, n + 2) {
            ld cap = dis(i, j);
            add_edge(g, i, j, cap, true, cap);
        }
    }

    vec<ld> d;
    Dijkstra(g, 0, d);
    cout << fixed << setprecision(12) << d[1] << en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<vector<int> > c(3);
    REP(i,3){
        REP(j,3){
            int in; cin>>in;
            c[i].push_back(in);
        }
    }
    string ans = "Yes";
    
    REP(i,2){
        REP(j,2){
            if(c[i+1][j]-c[i][j]!=c[i+1][j+1]-c[i][j+1]) ans = "No";
        }
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
def apple():
    inStr = input().split()
    a = int(inStr[0])
    p = int(inStr[1])
    ans = (a * 3 + p) / 2
    print(int(ans))


def dance_beta():
    s = input()

    odd_keep = []
    even_keep = []

    for i in range(len(s)):
        if ((i + 1) % 2 == 1):  # WHEN THE LETTER IS A ODD NUMBER
            odd_keep.append(s[i])
        else:                   # WHEN THE LETTER IS A EVEN NUMBER
            even_keep.append(s[i])

    if ("R" in odd_keep and "L" in even_keep):
        print("Yes")
    else:
        print("No")


apple()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return (power((a*a)%mod,n/2))%mod;
  else
    return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}
int main(){
FASTIO
ll k,n;
cin>>k>>n;
vector<ll> v(n);
for(int i=0;i<n;i++)
    cin>>v[i];
vector<ll> v1(n);
for(int i=0;i<n-1;i++){
   v1[i]=v[i+1]-v[i];
}  
v1[n-1]=(k-v[n-1])+v[0];
ll ans=k-v1[0];
for(int i=1;i<n;i++){
   ans=min(ans,k-v1[i]);
}
cout<<ans;
return 0;
}

Measured memory_bytes: 3328
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# N点を含む最小包含円の中心と半径を返す
def smallest_enclosing_circle(N,x,y):
    if N==2:
        return ((x[0]+x[1])/2, (y[0]+y[1])/2),\
               (((x[0]-x[1])**2 + (y[0]-y[1])**2)**0.5)/2

    # 3点を通る円の中心と半径を返す
    def three_point_circle(x1,y1,x2,y2,x3,y3):
        a = (y1-y2)*(x1-x3) - (y1-y3)*(x1-x2)
        # 3点が一直線上にある場合
        if abs(a) < 10**(-10):
            return (None,None), None
        else:
            A = (x1**2-x2**2) + (y1**2-y2**2)
            B = (x1**2-x3**2) + (y1**2-y3**2)
            x0 = -(A*(y1-y3)-B*(y1-y2)) / (2*a)
            y0 = (A*(x1-x3)-B*(x1-x2)) / (2*a)
            r = ((x1-x0)**2 +(y1-y0)**2)**0.5
            return (x0,y0), r

    r_min = float('inf')
    c_ans = (float('inf'), float('inf'))

    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                c,r = three_point_circle(x[i],y[i],x[j],y[j],x[k],y[k])
                if r is not None:
                    if r < r_min:
                        check = False
                        for h in range(N):
                            if h in [i,j,k]:
                                continue
                            if (x[h]-c[0])**2 + (y[h]-c[1])**2 > r**2:
                                check = True
                        if not check:
                            r_min = r
                            c_ans = (c[0],c[1])

    for i in range(N-1):
        for j in range(i+1,N):
            c = ((x[i]+x[j])/2, (y[i]+y[j])/2)
            r = (((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5)/2
            flag = False
            for k in range(N):
                if k in [i,j]:
                    continue
                else:
                    if (x[k]-c[0])**2 + (y[k]-c[1])**2 > r**2:
                        flag = True
                        break
            if not flag:
                if r < r_min:
                    r_min = r
                    c_ans = (c[0],c[1])

    return c_ans,r_min

N = I()
x,y = LIR(N,2)
c,r = smallest_enclosing_circle(N,x,y)
print(r)

Measured memory_bytes: 51676
#include <iostream>
using namespace std;
int main(){
  long long a, b;
  cin >> a >> b;
  int a1=a, b1=b;
  while(a1!=b1){
    if(a1>b1)a1-=b1;
    else b1-=a1;
  }
  long long ans=a*b/a1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    char S[10];scanf("%s",S);
    int ans=0,now=0;
    for (int i = 0; i < 10; i++)
    {
        if(S[i]=='A' or S[i]=='T' or S[i]=='G' or S[i]=='C')now++;
        else ans=max(ans,now),now=0;
    }
    printf("%d\n",max(ans,now));
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *, int *);

int main(void)
{
	int p[6], sum = 0, i, j;

	for (i = 0; i < 6; i++) {
		scanf("%d", &p[i]);
	}
	for (i = 0; i < 3; i++) {
		for (j = i + 1; j < 4; j++) {
			 if (p[i] < p[j])
			 	swap(&p[i], &p[j]);
		}
	}
	for (i = 0; i < 3; i++)
		sum += p[i];
	if (p[4] < p[5])
		swap(&p[4], &p[5]);
	sum += p[4];	
	printf("%d\n", sum);
	return 0;
}

void swap(int *x, int *y)
{
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
int w[100], v[100], dp[100][100001];
// dp[id][value] = minimum weight
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,W; cin >> n >> W;
        FOR(i,0,n){
            cin >> w[i] >> v[i];
        }
        FOR(i,0,100){
            FOR(j,0,100001)
            dp[i][j] = 1e18;
        }
        dp[0][0] = 0;
        dp[0][v[0]] = w[0];
        FOR(i,1,n){
            dp[i][0] = 0;
            FOR(j,1,100001){
                dp[i][j] = dp[i-1][j];
                if(j >= v[i])
                    dp[i][j] = min(dp[i][j], w[i] + dp[i-1][j - v[i]]);
            }
        }
        REV(val,100000,0){
            if(dp[n-1][val] <= W){
                cout << val;
                return 0;
            }
        }
    }   
}


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

int ari;
int jiku[102];
int u[102];
int v[102][102];
int ushi[102][102];
int main(){
  cin>>ari;
  for(int i=1;i<ari+1;i++){
    cin>>u[i];
    cin>>jiku[u[i]];
      for(int j=1;j<jiku[u[i]]+1;j++){
	cin>>v[u[i]][j];
      }
  }
  for(int k=1;k<ari+1;k++){
  //	cout << jiku[k] << endl;
    for(int l=1;l<jiku[k]+1;l++){
    //	cout << k << " " << l << endl;
      for(int m=1;m<ari+1;m++){
		//cout<<v[k][l];
	if(v[k][l]==u[m]){ushi[k][m]=1;}
	//	cout<<ushi[k][m];
      }
    }
  }
    for(int k=1;k<ari+1;k++){
      for(int m=1;m<ari;m++){
	cout<<ushi[k][m]<<" ";
      }cout<<ushi[k][ari];
      cout<<endl;}
}

Measured memory_bytes: 1240
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 55;
const int di[] = {-1, 1, 0, 0};
const int dj[] = {0, 0, -1, 1};

int n, m;
char c[MAXN][MAXN];
bool ok[MAXN][MAXN];

int main() { 

  scanf("%d %d\n", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &c[i][j]);
    }
    scanf("\n");
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i][j] != '#') {
        continue;
      }
      for (int k = 0; k < 4; k++) {
        int ci = i + di[k], cj = j + dj[k];
        if (ci < 0 || ci >= n || cj < 0 || cj >= m || c[ci][cj] == '.') {
          continue;
        }
        ok[i][j] = true;
        ok[ci][cj] = true;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i][j] == '#' && !ok[i][j]) {
        puts("No");
        return 0;
      }
    }
  }

  puts("Yes");

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt(); 	

      if((A-B)%2 == 0){
         System.out.println(A-(A-B)/2);
      }else{
        System.out.println("IMPOSSIBLE");
      }
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define fi first
#define se second
template <typename A, typename B> inline bool chmax(A &a, B b) {if (a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmin(A &a, B b) {if (a > b) {a = b; return 1;} return 0;}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const bool debug = 0;
/****************************/

int main() {
	string s;
	int y, m, d;
	while (cin >> s, s != "#") {
		cin >> y >> m >> d;
		
		if (y < 31 || y == 31 && m < 5) printf("HEISEI %d %d %d\n", y, m, d);
		else printf("? %d %d %d\n", y - 30, m, d);
	}
}



Measured memory_bytes: 3140
# dp[i][w_sum]: i番目までの品物で重さがw_sumを超えないように選んだときの、価値の総和の最大値

N,W=map(int,input().split())
items=[tuple(map(int,input().split())) for i in range(N)]
items.insert(0, (0,0))

dp=[[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(W+1):
        # take item
        if j-items[i][0]>=0:
            dp[i][j]=dp[i-1][j-items[i][0]]+items[i][1]
        
        dp[i][j]=max(dp[i][j],dp[i-1][j])

print(dp[N][W])



Measured memory_bytes: 171784
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    ll D;
    cin >> D;
    D *= D;
    forn(i, n){
        ll x, y;
        cin >> x >> y;
        ll d = x * x + y * y;
        if (d <= D) ans++;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3616
--締切の早いやつからやるべき？
local n=io.read("*n")
local works={}
for i=1,n do
    works[i]={io.read("*n","*n")}
end
table.sort(works,function(a,b)
    return a[2]<b[2]
end)

local total=0
for i=1,n do
    total=total+works[i][1]
    if total>works[i][2] then
        print("No")
        return
    end
end
print("Yes")

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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)
#define TRAV(a, e) for(auto x : e)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    int n, l;
    cin >> n >> l;
    vector<int> v(n);
    LL s = 0;
    REP(i, n) v[i] = l + i, s += v[i];
    LL mini = LONG_MAX;
    LL ans = 0;
    REP(i, n) {
        if (abs(s - (s - v[i])) < mini) {
            mini = abs(s - (s - v[i]));
            ans = s - v[i];
        }
    }
    cout << ans << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define M                 1000000007
#define MM                998244353
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define mem0(x)           memset(x, 0, sizeof (x))
#define mem1(x)           memset(x, -1, sizeof (x))
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
//coded by Avijit Mandal 18CS30010
int main(){
   ll i,j,n,k,t1,t2,count=0,mx=INT_MIN,mn=INT_MAX;
   cin>>n>>k;
   ll a[n+1];
   ll dp[n+1];
   for(i=0;i<n;i++)cin>>a[i+1];
   dp[1]=0;
   for(i=2;i<n+1;i++){
      dp[i]=INT_MAX;
      for(j=1;j<=min(i-1,k);j++)
         dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));

   }
   cout<<dp[n]<<"\n";

}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

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

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

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

int main()
{
    fsscan();
    
    ll n;
    cin>>n;
    
    ll val1 = (n/500)*1000;
    ll val2 = ((n%500)/5)*5;
    
    cout<<val1+val2;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x,y,c,d=0;
	cin>>x>>y;
	if(y>4*x)
	{
		cout<<"No";
		return 0;
	}
	while(x+1){
		c=x*2+d;
		if(c==y){
			cout<<"Yes";
			return 0;
		}
		else
		{
			d+=4;
			x--;	
		}
		
	}
	cout<<"No";	
	return 0;
}

Measured memory_bytes: 3596
import math

def main():
    r = []
    while True:
        n = int(input())
        if n == 0:
            break
        m = []
        for i in range(n):
            m.append(int(input()))
        r.append(math.floor((sum(m) - max(m) - min(m))/(n-2)))
    for j in r:
        print(j)

main()



Measured memory_bytes: 5660
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		n          int
		alice, bob int
	)
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	// alice
	for i := 0; i < n; i += 2 {
		alice += a[i]
	}
	// bob
	for i := 1; i < n; i += 2 {
		bob += a[i]
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include <string>
#include <iostream>
using namespace std;
int main() {
  string s;
	cin >> s;
  string ans;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '1' || s[i] == '0')
      ans += s[i];
    else if(ans.size() > 0)
      ans.erase(ans.end() - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int N,A[105][105]={0},i,j,k,l,R,t;
int main()
{
	R=-100000005;
	scanf("%d",&N);
	for(i=0;i<N;i++)
		for(j=0;j<N;j++)
			scanf("%d",&A[i][j]);
	for(i=0;i<N;i++)
		for(j=N-2;j>=0;j--)
			A[i][j]+=A[i][j+1];
	for(i=0;i<N;i++)
		for(j=0;j<N;j++)
			for(k=j+1;k<=N;k++)
				for(l=i,t=0;l<N;l++)
				{
					t+=A[l][j]-A[l][k];
					R=R>t?R:t;
				}
	printf("%d\n",R);
	return 0;
}

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

typedef long long ll;

int n, p, cur;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> cur;
        --cur;
        if (cur < p) {
            ++cur;
            if (cur < p) {
                cout << "No" << endl;
                exit(0);
            }
        }
        p = cur;
    }
    cout << "Yes" << endl;

    return 0;
}



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

#define pb push_back
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

int const N = 2e5 + 7;

int ar[N];
int dp[N];

int main()
{
	fastio;

	int n;
	cin >> n;

	for (int i = 1; i <= n; ++i)
		cin >> ar[i];

	dp[1] = 0;
	dp[2] = abs(ar[2] - ar[1]);
	for (int i = 3; i <= n; ++i)
	{
		dp[i] = min(dp[i-1] + abs(ar[i] - ar[i-1]), dp[i-2] + abs(ar[i] - ar[i-2]));
	}
	cout << dp[n] << '\n';

	return 0;
}


Measured memory_bytes: 4356
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)

if (a+b)>(b+c) and (c+a) >(b+c):
    print(b+c)
elif (b+c)>(a+b) and (c+a)>(a+b):
    print(a+b)
else:
    print(c+a)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int main(void){
    int a,d,n,c,i,j;
    while(1){
        a=in();
        d=in();
        n=in();
        if(!a&&!d&&!n)break;
        c=0;
        for(i=a;;i+=d){
            if(i==1)continue;
            for(j=2;j*j<=i;j++){
                if(i%j==0)break;
            }
            if(j*j>i)c++;
            if(c==n){
                print(i);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1924
def abc164_d():
    # 解説放送
    s = str(input())
    n = len(s)
    m = 2019
    srev = s[::-1]  # 下の位から先に見ていくために反転する
    x = 1  # 10^i ??
    total = 0  # 累積和 (mod 2019 における累積和)
    cnt = [0] * m  # cnt[k] : 累積和がkのものが何個あるか
    ans = 0
    for i in range(n):
        cnt[total] += 1
        total += int(srev[i]) * x
        total %= m
        ans += cnt[total]
        x = x*10 % m
    print(ans)

abc164_d()

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

int main() {
  int N;
  cin >> N;
  long a[N], s[N], sum = 0, ans = LONG_MAX;
  for (int i=0; i<N; i++) {
    cin >> a[i];
    sum += a[i];
    s[i] = sum;
  }
  for (int i=0; i<N-1; i++) {
    long a = s[i];
    if (abs(sum - 2*a)<ans)
      ans = abs(sum-2*a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	num_s := strings.Split(nextLine(), " ")

	a, _ := strconv.ParseFloat(num_s[0], 64)
	b, _ := strconv.ParseFloat(num_s[1], 64)
	d, _ := strconv.ParseFloat(num_s[2], 64)

	r := d / 180.0 * math.Pi

	c := math.Sqrt(a*a + b*b - 2.0*a*b*math.Cos(r))

	h := b * math.Sin(r)

	S := a * h / 2.0
	L := a + b + c

	fmt.Printf("%.8f\n", S)
	fmt.Printf("%.8f\n", L)
	fmt.Printf("%.8f\n", h)
}



Measured memory_bytes: 1164
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random




def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    n,t = map(int, input().split())
    minx=sys.maxsize
    for i in range(n):
        cc,tt = map(int, input().split())
        if tt<=t:
            minx = cc if cc<minx else minx
    if minx<sys.maxsize:
        print(minx)
    else:
        print("TLE")



if __name__ == '__main__':
    main()


Measured memory_bytes: 64364
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m1,m2,d1,d2;
    cin >> m1>>d1 >> m2>>d2;
    if(m1!=m2){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int K = input.nextInt();
        long ans = 0L;
        for (int i = 1; i < K+1; i++){
            for (int j = 1; j < K+1; j++){
                int tmp = gcd(i,j);
                for (int k = 1; k < K+1; k++){
                    ans += gcd(tmp,k);
                }
            }
        }
        System.out.println(ans);
    }
    static int gcd(int a, int b){
        return b > 0 ? gcd(b,a%b) : a;
    }
}

Measured memory_bytes: 35680
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    A = reversed(A)
    left = 0
    right = N - 1
    res = [0] * N
    for i,val in enumerate(A):
        if i % 2 == 0:
            res[left] = val
            left += 1
        else:
            res[right] = val
            right -= 1
    print(" ".join(map(str,res)))


Measured memory_bytes: 28228
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N,Y = map(int, input().split())

for sen in range(0, N+1):
  for gosen in range(0, N+1):
    man = N - sen - gosen
    if man < 0: break
    if 10000*man + 5000*gosen + 1000*sen == Y:
      print("{} {} {}".format(man, gosen, sen))
      exit(0)

print("-1 -1 -1")


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    ll k=in,n=9,s,i;
    if (k<10) {
        out(k);
        return 0;
    }
    vector<ll> m={1,2,3,4,5,6,7,8,9};
    for(i=0;n!=k;i++){
        s=m[i]%10;
        if (s==0){
            m.push_back(10*m[i]);
            n++;
            if(n==k) break;
            m.push_back(10*m[i]+1);
            n++;
        }
        else if (s==9){
            m.push_back(10*m[i]+8);
            n++;
            if (n==k) break;
            m.push_back(10*m[i]+9);
            n++;
        }
        else{
            m.push_back(10*m[i]+s-1);
            n++;
            if (n==k) break;
            m.push_back(10*m[i]+s);
            n++;
            if (n==k) break;
            m.push_back(10*m[i]+s+1);
            n++;
        }
    }
    out(m[k-1]);
}


Measured memory_bytes: 1464
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

int N, K;

int main() {
    cin >> N >> K;
    vector<int> P(N);
    vector<ll> C(N);
    rep(i,N) cin >> P[i], P[i]--;
    rep(i,N) cin >> C[i];

    ll res = -INF;

    rep(i,N) {
        int v = i;
        int cycle_sz = 0;
        ll cycle_sum = 0;
        while (true)
        {
            cycle_sz++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }

        int cnt = 0;
        ll path = 0;
        while(true) {
            cnt++;
            path += C[v];

            if(cnt > K) break;

            int num = (K - cnt) /cycle_sz;
            ll score = path + max(0LL, cycle_sum) * num;
            chmax(res, score);

            v = P[v];
            if (v == i) break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
 
//素数かどうかが真のものの数（カウントアップ）を返す
int countup(vector<bool>::iterator begin, vector<bool>::iterator end) 
{
    int counter = 0;
    while (begin++ != end) {
        if (*begin) 
            counter++;
    }
    return counter;
}
int main()
{
    int n;
    
    while (cin >> n) {
        int                     max = sqrt(static_cast<double>(n));
        vector<bool>            is_prime(n, true);
        vector<bool>::iterator  begin, end;
 
        is_prime[0] = is_prime[1] = false;
        
        for (int i=2; i<=max; i++) {
            if (!is_prime[i]) {
                continue;
            }
            else { // iがもし素数だったら、(自分以外の)その倍数全部潰す
                for (int cntr = 2, j = 2*i; j<=n; j = i*(cntr++)) { 
                    is_prime[j] = false;
                }
            }
        }
        begin   = is_prime.begin();
        end     = is_prime.end();
        cout << countup(begin, end) << endl;
    }
}

Measured memory_bytes: 1316
#include<stdio.h>
int main(void)
{
	int a,b;
	while(1)
	{
		scanf("%d%d",&a,&b);
		if (a==0&&b==0)
		return 0;
		if (a>b)
{
		a^=b;
		b^=a;
		a^=b;
}
		printf("%d %d\n",a,b);
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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

int main(int argc, char *argv[])
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = b / c - (a - 1) / c;
    ll f = b / d - (a - 1) / d;
    ll t = icm(c, d);
    ll g = b / t - (a - 1) / t;
    cout << b - a + 1 - (e + f - g) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
int const maxn = 1e5 + 5, K = 425;
ll x[maxn];
int used[maxn], cur, oks[maxn], tmp, timer, was[maxn], no[maxn], rev[maxn];
set < int > g[maxn];
multiset < int > G[maxn];
ll sum[maxn], f;

void dfs3(int v) {
    no[v] = 1;
    for (auto u : g[v]) if (no[u] == 0) dfs3(u);
}

void dfs2(int v) {
    dfs3(rev[v]);
    for (auto key : G[v]) {
        if (no[rev[key]] == 0) dfs2(key);
    }
}

void dfs1(int v) {
    oks[v] = tmp;
    f += sum[v];
    for (auto u : G[v]) {
        if (oks[u] != tmp) dfs1(u);
    }
}

void dfs(int v) {
    was[v] = timer, used[v] = cur, sum[cur] += x[v];
    for (auto u : g[v]) if (was[u] != timer) dfs(u);
}

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, u, v, c, ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> x[i];
    vector < vector < int > > go;
    for (int i = 1; i <= m; ++i) {
        cin >> u >> v >> c;
        g[u].insert(v);
        g[v].insert(u);
        go.push_back({c, u, v});
    }
    sort(go.rbegin(), go.rend());
    for (int i = 0; i < m; i += K) {
        int R = min(m, i + K);
        for (int j = i; j < R; ++j) {
            u = go[j][1], v = go[j][2];
            g[u].erase(v), g[v].erase(u);
        }
        cur = 0, timer++;
        for (int j = 1; j <= n; ++j) {
            if (no[j] == 0 && was[j] != timer) {
                cur++;
                rev[cur] = j;
                sum[cur] = 0;
                dfs(j);
            }
        }
        for (int j = i; j < R; ++j) {
            u = go[j][1], v = go[j][2];
            if (no[u]) continue;
            if (used[u] != used[v]) G[used[u]].insert(used[v]), G[used[v]].insert(used[u]);
        }
        for (int j = i; j < R; ++j) {
            c = go[j][0], u = go[j][1], v = go[j][2];
            if (no[u]) continue;
            tmp++, f = 0;
            dfs1(used[u]);
            if (f < c) {
                ans++;
                u = used[u], v = used[v];
                if (u == v) continue;
                G[u].erase(G[u].find(v));
                G[v].erase(G[v].find(u));
            }
            else {
                dfs2(used[u]);
            }
        }
        for (int j = i; j < R; ++j) {
            u = used[go[j][1]], v = used[go[j][2]];
            G[u] = {}, G[v] = {};
        }
    }
    cout << ans << '\n';
    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int a;
    cin >> a;
    string s,t;
    cin >> s;cin>>t;
    rep(i, a) cout << s[i] << t[i];
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string n;
	cin>>n;
	for(int i=0;i<n.length();i++)
	{
		if(n[i]=='9')cout<<1;
		else if(n[i]=='1')cout<<9;
	}	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define pq priority_queue
#define st first
#define nd second

using namespace std;
typedef long long ll;
ll const inf = 1e9;
ll const mod = 1e9 + 7;

bool ok(int bit, int m){
    fr(j, 0, m - 1){
        if((bit & (1 << j)) && (bit & (1 << (j + 1)))) return false;
    }
    return true;
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    k --;
    ll dp[n + 1][m + 1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    fr(i, 0, n){
        fr(bit, 0, (1 << (m - 1))){
            if(!ok(bit, m - 1)) continue;
            fr(j, 0, m){
                dp[i][j] = dp[i][j] % mod;
                if(j + 1 < m && ((1 << j) & bit)) dp[i + 1][j + 1] += dp[i][j];
                else if(j > 0 && ((1 << (j - 1)) & bit)) dp[i + 1][j - 1] += dp[i][j];
                else dp[i + 1][j] += dp[i][j];


            }
        }
    }

    cout << dp[n][k] % mod << endl;


}



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

typedef long long ll;
typedef unsigned long long ull;

struct edge{
    int to;
    int cost_y;
    int cost_s;
    edge(int t, int y, int s){
        to=t;
        cost_y=y;
        cost_s=s;
    }
};


int main(){
    ll n,m,s,t;
    cin >> n >> m >> s >> t;

    vector<edge> E[100001];
    for(int i=0;i<m;i++){
        ll u,v,a,b;
        cin >> u >> v >> a >> b;
        E[u].push_back(edge(v,a,b));
        E[v].push_back(edge(u,a,b));
    }

    ll d_y[100001], d_s[100001];
    for(int i=1;i<=n;i++){
        d_y[i]=INT64_MAX;
        d_s[i]=INT64_MAX;
    }
    
    bool checked[100001];
    priority_queue<pair<ll,ll>> Q_y,Q_s;
    
    for(int i=1;i<=n;i++) checked[i]=false;
    Q_y.push(make_pair(0,s));
    while(!Q_y.empty()){
        auto tp=Q_y.top();
        Q_y.pop();
        if(checked[tp.second]) continue;

        d_y[tp.second]=-tp.first;
        checked[tp.second]=true;
        for(auto e : E[tp.second]){
            if(!checked[e.to]){
                Q_y.push(make_pair(tp.first-e.cost_y,e.to));
            }
        }
    }

    for(int i=1;i<=n;i++) checked[i]=false;
    Q_s.push(make_pair(0,t));
    while(!Q_s.empty()){
        auto tp=Q_s.top();
        Q_s.pop();
        if(checked[tp.second]) continue;

        d_s[tp.second]=-tp.first;
        checked[tp.second]=true;
        for(auto e : E[tp.second]){
            if(!checked[e.to]){
                Q_s.push(make_pair(tp.first-e.cost_s,e.to));
            }
        }
    }

    ll cost[100001];
    cost[n]=d_y[n]+d_s[n];
    for(int i=1;i<n;i++){
        cost[n-i]=min(cost[n-i+1],d_y[n-i]+d_s[n-i]);
    }

    for(int i=1;i<=n;i++){
        cout << 1000000000000000LL-cost[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 13168
s=gets.split()
cnt=0
t=0
sz=0
frq=""
lgst=""
temp=""

s.each{|x|
	cnt=0
	s.each{|y|
		cnt+=1 if x==y
	}
	if cnt>t
		frq=x
		t=cnt
	end
}


while !s.empty?
	temp=s.pop
	if temp.size>sz
		lgst=temp
		sz=temp.size
	end
end

print frq," ",lgst,"\n"

Measured memory_bytes: 6100
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Control.Arrow
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    x <- readLn :: IO Int
    print $ slv x 100 0

di :: Int -> Int
di x = floor (fromIntegral x * 1.01)

slv x am ac
    | am >= x = ac
    | otherwise = slv x (di am) (ac+1)

Measured memory_bytes: 3972
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> color(8, 0);
  int m = 0;
  rep(i, n) {
    if (a[i] >= 3200) {
      m++;
      continue;
    } else {
      color[a[i]/400]++;
    }
  }
  int mn = 0;
  for (int i = 0; i < 8; i++) {
    if (color[i] > 0) {
      mn++;
    }
  }
  
  cout << max(mn, 1) << endl << mn+m << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

ll INF=1e14;

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,w;
    cin >> n >> w;
    vector<ll> weights(n),vals(n);
    ll sum=0;
    F0R(i,n)
    {
        cin >> weights[i] >> vals[i];
        sum+=vals[i];
    }
    vector<vector<ll>> dp(n,vector<ll>(sum+1,INF));
    F0R(i,n)
        dp[i][0]=0;
    F0R(j,sum+1)
    {
        if(vals[0]==j)
            dp[0][j]=weights[0];
    }
    for(ll j=1; j<sum+1; j++)
    {
        FOR(i,1,n)
        {
            dp[i][j]=dp[i-1][j];
            if(j-vals[i]>=0)
                dp[i][j]=min(dp[i][j],dp[i-1][j-vals[i]]+weights[i]);
        }
    }
    ll best=0;
    F0R(i,n)
    {
        F0R(j,sum+1)
        {
            if(dp[i][j]<=w)
                best=max(best,(ll)j);
        }
        // cout << endl;
    }
    cout << best << endl;

    return 0;
}


Measured memory_bytes: 79488
# -*- coding: utf-8 -*-
import sys
import math
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()

    if n % 2 != 0:
        print('No')
        return

    for i in range(int(n/2)):
        if s[i] != s[i + int(n/2)]:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


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

m = 0

g = []

for i in range(n):
    g.append(list(input().split()))

for i in range(n):
    if g[i][1]=="JPY":
        m += float(g[i][0])
    else:
        m += float(g[i][0])*380000

print(m)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(s[k-1] == 'A')s[k-1] = 'a';
    if(s[k-1] == 'B')s[k-1] = 'b';
    if(s[k-1] == 'C')s[k-1] = 'c';

    cout << s << endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UF{
    vint par,sz;
    vector<set<int>>st;
    vint dif;
    void init(int n){
        par=sz=dif=vint(n);
        st=vector<set<int>>(n);
        rep(i,n){
            par[i]=i;
            sz[i]=1;
            dif[i]=0;
            st[i].insert(i);
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void update(int a,int b,int w){
        int x=find(a),y=find(b);
        if(x==y)return;
        if(sz[x]>sz[y]){
            swap(x,y);
            swap(a,b);
            w*=-1;
        }
        
        int d=dif[b]-dif[a];
        each(it,st[x]){
            int v=*it;
            dif[v]+=d-w;
            st[y].insert(v);
        }
        sz[y]+=sz[x];
        par[x]=y;
    }
    int query(int a,int b){
        int x=find(a),y=find(b);
        if(x!=y)return 1001001001;
        return dif[b]-dif[a];
    }
};

signed main(){

    int N,Q;
    while(scanf("%lld%lld",&N,&Q),N||Q){
        UF uf;uf.init(N);
        rep(i,Q){
            char c;
            scanf(" %c",&c);
            if(c=='!'){
                int a,b,w;
                scanf("%lld%lld%lld",&a,&b,&w);
                a--;b--;
                uf.update(a,b,w);
            }
            else{
                int a,b;
                scanf("%lld%lld",&a,&b);
                a--;b--;
                int tmp=uf.query(a,b);
                if(tmp==1001001001)puts("UNKNOWN");
                else printf("%lld\n",tmp);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 17572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		List<String> base = new ArrayList<String>();
		List<Integer> inning = new ArrayList<Integer>();
		int inningCnt =0;

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		int num = Integer.parseInt(br.readLine());

		while(inningCnt < num){

			inning.add(0);
			int out = 0;

			String str;
			while((str=br.readLine())!=null){

				switch(str){

				case "HIT":
					base.add("runner");
					if(base.size() == 4){
						inning.set(inningCnt, inning.get(inningCnt) + 1);
						base.remove(3);
					}
					break;

				case "HOMERUN":
					inning.set(inningCnt, inning.get(inningCnt) + base.size() + 1);
					base.removeAll(base);
					break;

				case "OUT":
					out++;
					break;
				}

				if(out == 3){
					base.removeAll(base);
					break;
				}

			}

			inningCnt++;
		}

		for(int i = 0; i < inningCnt; i++){

			System.out.println(inning.get(i));

		}
	}

}

Measured memory_bytes: 24288