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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll a[n + 1];
    rep(i, n + 1) { cin >> a[i]; }

    if (n == 0) {
        if (a[0] == 1) {
            cout << 1 << endl;
        } else if (a[0] == 0) {
            cout << 0 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    } else {
        if (a[0] != 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll total[n + 1], next[n + 1], fin[n + 1];
    total[0] = 1;
    next[0] = 1;
    fin[0] = 0;

    repd(i, 1, n + 1) {
        total[i] = min(next[i - 1] * 2, mod * mod);
        fin[i] = a[i];
        next[i] = total[i] - fin[i];
        if (next[i] < 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans[n + 1];
    ans[n] = fin[n];
    repb(i, n) {
        if (i == 0) {
            ans[i] = 1;
            break;
        }
        ans[i] = min(next[i], ans[i + 1]) + fin[i];
    }

    ll result = 0;
    rep(i, n + 1) { result += ans[i]; }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 7524
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0
for i in range(n):
    now = a[i] - 1
    pre = a[i-1] - 1
    sum += b[ now ]
    if i > 0 and now - 1 == pre:
        sum += c[ pre ]

print(sum)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n, m;

	std::cin >> n >> m;

	std::vector<long long> v(n);
	
	for (long long i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	std::vector<long long> v2(n, true);
	long long color = 1;
	for (long long i = 0; i < m; i++)
	{
		long long a, b;

		std::cin >> a >> b;

		if (v[a - 1] > v[b - 1]) {
			v2[b - 1] = false;
		}
		else if (v[a - 1] < v[b - 1]){
			v2[a - 1] = false;
		}
		else {
			v2[a - 1] = v2[b - 1] = false;
		}
	}

	std::cout << std::accumulate(v2.begin(), v2.end(), 0LL) << std::endl;

	return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
using namespace std;

istream &operator>>(istream &is, vector<int> &v) {
  string s;
  is >> s;
  v.reserve(s.size());
  for (char c : s) v.emplace_back(c - '0');
  return is;
}

template <typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) {
  auto inner = vectors(tail...);
  return vector<decltype(inner)>(x, inner);
}

signed main() {
  vector<int> s;
  cin >> s;
  int n = static_cast<int>(s.size());

  auto dp = vectors(n + 1, 2, 5, 2, 0LL);
  dp[0][0][0][0] = 1;

  auto f = [](int k, int l, int m) -> int {
    if ( k == 4                ) return 4;
    if ( k == 3       && m == 3) return 4;
    if ( k == 2                ) return 3;
    if ((k == 1 || l) && m == 1) return 2;
    if (                 m == 5) return 1;
    return 0;
  };

  rep(i, n) rep(j, 2) rep(k, 5) rep(l, 2) rep(m, (j ? 9 : s[i]) + 1) {
    dp[i + 1][j || m < s[i]][f(k, l, m)][k == 2 && m == 5] += dp[i][j][k][l];
  }

  cout << dp[n][0][4][0] + dp[n][1][4][0] << endl;
}



Measured memory_bytes: 3248
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)
#define EPS (1e-4)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

#define HASH(x) (x[0] + x[1]*4 + x[2]*16 + x[3]*64)

int dp[4][256];
int rev[4][4];
int board[5][5];

int ten[4] = { 0,60,70,80 };

int solve(int now, int h){
  if(dp[now][h] != -1) return dp[now][h];
  int ret = 0;
  int *x = rev[now];

  for(x[0]=0;x[0]<4;x[0]++){
    for(x[1]=0;x[1]<4;x[1]++){
      for(x[2]=0;x[2]<4;x[2]++){
        for(x[3]=0;x[3]<4;x[3]++){
          int point = 0;
          REP(i,5){
            int p = board[now][i];
            if(p == 0) continue;
            p = p - 1;
            if(now != 0){
              if(i != 4) p += rev[now-1][i];
              if(i != 0) p += rev[now-1][i-1];
            }
            if(i != 4) p += rev[now][i];
            if(i != 0) p += rev[now][i-1];
            p = p % 4;
            point += ten[p];
          }

          if(now == 3){
            REP(i,5){
              int p = board[now+1][i];
              if(p == 0) continue;
              p = p - 1;
              if(i != 4) p += rev[now][i];
              if(i != 0) p += rev[now][i-1];
              p = p % 4;
              point += ten[p];
            }
            ret = max(ret, point);
          }else{
            int hash = HASH(x);
            ret = max(ret, point + solve(now+1,hash));
          }
        }
      }
    }
  }
  return dp[now][h] = ret;
}

int main(){
  int n = getInt();
  while(n --> 0){
    REP(i,5) REP(j,5) board[i][j] = getInt();
    memset(dp, -1, sizeof(dp));
    print(solve(0,0));
  }
  return 0;
}

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

const int N = 200005;

int n, u, v;
bool f[N];
vector<int> adj[N];

pair<int, int> DFS(int u, int p = 0)
{
    pair<int, int> ret = {-1, u};
    for (int &v : adj[u])
        if (v != p)
            ret = max(ret, DFS(v, u));
    ret.first++;
    return ret;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i < n; i++)
    {
        scanf("%d%d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int d = DFS(DFS(1).second).first;
    f[0] = true; f[1] = false;
    for (int i = 2; i <= d; i++)
        f[i] = (!f[i - 1] || !f[i - 2]);
    printf("%s\n", f[d] ? "First" : "Second");
}


Measured memory_bytes: 27008
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n,m;
    cin>>n>>m;
    vector<tuple<int,int,int>> P,Q;
    int p,y;
    for(int i=0;i<m;i++){
        cin>>p>>y;
        P.push_back(make_tuple(y,p,i));
    }
    sort(All(P));
    map<int,int> d;
    for(int i=0;i<m;i++){
        int b = get<1>(P[i]);
        int c = get<2>(P[i]);
        d[b]++;
        Q.push_back(make_tuple(c,b,d[b]));
    }
    sort(All(Q));
    for(int i=0;i<m;i++){
        cout<<(setfill('0'))<<right<<setw(6)<<(get<1>(Q[i]))<<(setfill('0'))<<right<<setw(6)<<(get<2>(Q[i]))<<endl;
    }

}

Measured memory_bytes: 8564
import java.util.Scanner;

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

		int[] p = new int[d];
		int[] c = new int[d];
		for (int i = 0; i < d; i++) {
			p[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}

		int answer = 1000000000;
		for (int i = (1 << d); i >= 0; i--) {
			int count = 0;
			int score = 0;
			for (int j = 0; j < d; j++) {
				if (((i >> j) % 2 == 1)) {
					score += p[j] * (j + 1) * 100;
					score += c[j];
					count += p[j];
				}
			}
			if (score >= g) {
				answer = Math.min(answer, count);
				continue;
			}

			for (int j = d - 1; j >= 0; j--) {
				if (((i >> j) % 2 == 0)) {
					if ((p[j] - 1) * (j + 1) * 100 >= g - score) {
						count += (g - score) / ((j + 1) * 100) + ((g - score) % ((j + 1) * 100) > 0 ? 1 : 0);
						answer = Math.min(answer, count);
					}
					break;
				}
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 21844
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var abm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int a = abm[0], b = abm[1], m = abm[2];
        var aa = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var bb = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var ans = int.MaxValue;
        ans = aa.Min() + bb.Min();
        for (int i = 0; i < m; i++)
        {
            var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            ans = Math.Min(ans, aa[line[0] - 1] + bb[line[1] - 1] - line[2]);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 53248
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int check(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a[i]>b[i])return 1;
        if(b[i]>a[i])return -1;
    }
    return 0;
}
class data{
public:
    ll v,d,p;
    data(){}
    data(ll vv, ll dd, ll pp){
        v=vv;  d=dd; p=pp;
    }
};

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
ll w[105], p[105], n, x;
ll dpp[105][100005], dpw[105][100005];

int main()
{
    Fastio();
    ll n,k; cin>>n>>k;
    ll arr[n];
    for(int i=0; i<n; i++){cin>>arr[i];}
    ll dp[k+1]={0};
    for(int i=0; i<=k; i++){
        for(int y=0; y<n; y++){
            if(i>=arr[y] && !dp[i-arr[y]])dp[i]=1;
        }
    }
    if(dp[k])cout<<"First\n";
    else cout<<"Second\n";


    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8

n = int(input().rstrip())
ai = list(map(int,input().rstrip().split()))
q = int(input().rstrip())
mi = list(map(int,input().rstrip().split()))

dp = [[False for i in range(max(mi)+10)] for j in range(n+1)]

dp[0][0] = True

for i in range(n):
    for j in range(max(mi)+1):
        dp[i+1][j] = (dp[i+1][j] or dp[i][j])
        if j - ai[i] >= 0:
            dp[i+1][j] = (dp[i+1][j] or dp[i][j-ai[i]])

for i in range(q):
    if dp[n][mi[i]] == True:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5972
def solve(h):
    dp = [1000000000] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1, K + 1):
            if i +  j >= N:
                break
            dp[i + j] = min(dp[i]+abs(h[i]-h[i+j]),dp[i + j])
    return dp[-1]

N, K = map(int, input().split())
h = list(map(int, input().split()))
print(solve(h))

Measured memory_bytes: 52448
from functools import reduce

n, x = map(lambda x: int(x), input().split(' '))
m = []
for i in range(n):
    m.append(int(input()))

def add_num(a, b):
    return int(a) + int(b)

result = len(m)
m_sum = reduce(add_num, m)
x -= m_sum

m_min = min(m)
while(x >= m_min):
    x -= m_min
    result += 1
else:
    print(result)


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

int A, B, E, match[5009]; vector<int> G[5009];
bool used[5009];

bool dfs(int pos) {
	used[pos] = true;
	for (int i = 0; i < G[pos].size(); i++) {
		if (match[G[pos][i]] < 0 || (used[match[G[pos][i]]] == false && dfs(match[G[pos][i]]) == true)) {
			match[pos] = G[pos][i];
			match[G[pos][i]] = pos;
			return true;
		}
	}
	return false;
}

int main() {
	cin >> A >> B >> E;
	for (int i = 0; i < E; i++) {
		int p1, p2; cin >> p1 >> p2;
		G[p1].push_back(p2 + A);
		G[p2 + A].push_back(p1);
	}
	for (int i = 0; i < A + B; i++) match[i] = -1;

	int cnt = 0;
	for (int i = 0; i < A + B; i++) {
		if (match[i] >= 0) continue;
		for (int j = 0; j < A + B; j++) used[j] = false;
		bool I = dfs(i);
		if (I == true) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3376
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

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

void solve() {
    int n , m;
    cin>>n>>m;
    char x[n][m+1];
    char xx[n][m+1];
    for (int i = 0; i < n; ++i) {
        cin>>x[i];
    }
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < m; ++i) {
            if(x[j][i] == '#') {
                xx[j][i] = '#';
                continue;
            }
            int c = 0;
            for(int k = 0 ; k < 8 ; k++){
                int ii = j + dx[k];
                int jj = i + dy[k];
                if(ii >= 0 && jj >= 0 && ii < n && jj < m && x[ii][jj] == '#')
                    c++;
            }
            xx[j][i] = (char)(c + '0');
        }
    }
    for (int l = 0; l < n; ++l) {
        for (int i = 0; i < m; ++i) {
            cout<<xx[l][i];
        }
        cout<<endl;
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;

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

    if(D == 25){
        cout << "Christmas" << endl;
    }
    if(D == 24){
        cout << "Christmas Eve" << endl;
    }
    if(D == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    if(D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> x(N); vector<int> y(N);
  for (int i =0; i<N; i++) cin >> x[i] >> y[i];
  
  double ans =0;
  for (int i =0; i<N; i++) {
    for (int j =i+1; j<N; j++) {
      double tmp = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
      ans += sqrt(tmp);
    }
  }    
  
  ans *= (double)2 / N;                                                     
  cout << fixed << setprecision(12) << ans << endl;  
}

Measured memory_bytes: 3748
#include <stdio.h>

int main(){
  char line[100];
  int num;
  int count=0;
  while(1){
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d", &num);
	if(num==0)
	  break;
	++count;
	printf("Case %d: %d\n", count, num);
}
  return 0;
}



Measured memory_bytes: 1980
from collections import deque


def main():
    vertices = int(input())
    tree = [[] for _ in range(vertices)]
    for _ in range(vertices - 1):
        u, v, length = map(int, input().split())
        u -= 1
        v -= 1
        tree[u].append([v, length])
        tree[v].append([u, length])
    root_index = 0
    max_deg = 0
    for i in range(vertices):
        if max_deg < len(tree[i]):
            root_index = i
            max_deg = len(tree[i])
    queue = deque([[root_index, 0]])
    is_checked = [False for _ in range(vertices)]
    is_checked[root_index] = True
    answer = ["0" for _ in range(vertices)]
    while queue:
        now_v, dist_from_root = queue.pop()
        for next_v, length in tree[now_v]:
            if not is_checked[next_v]:
                is_checked[next_v] = True
                if (dist_from_root + length) % 2:
                    answer[next_v] = "1"
                queue.append([next_v, dist_from_root + length])
    print("\n".join(answer))


if __name__ == '__main__':
    main()



Measured memory_bytes: 45936
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b) {
    var result = a < b ? 'a < b' : (a > b ? 'a > b' : 'a == b');
    // ????????????????????????
    console.log(result);
  }(params[0], params[1]));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15452
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct edge{
	int from, to, cost;
	edge(int a, int b, int c){
		from = a, to = b, cost = c;
	}
	bool operator<(const edge& e){
		return this->cost < e.cost;
	}
};

int n, m;
vector<edge> G;

int parent[1005];
void init(){
	for(int i = 0; i < n; i++) parent[i] = i;
}

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

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

void unite(int i, int j){
	int root_i = root(i);
	int root_j = root(j);
	if(root_i == root_j) return;
	parent[root_i] = root_j;
}


int main(void)
{
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		
		G.clear();
		
		int s, t, c;
		for(int i = 0; i < m; i++){
			cin >> s >> t >> c;
			G.push_back( edge(s, t, c) );
		}
		sort(G.begin(), G.end());
		
		init();
		
		int cnt = 0;
		for(int i = 0; i < m; i++){
			if(same(G[i].from, G[i].to)) continue;
			unite(G[i].from, G[i].to);
			cnt++;
			if(cnt == n/2){
				cout << G[i].cost << endl;
				break;
				
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3220
use proconio::input;

#[allow(unused_mut)]
fn main() {
    input! {
        n: usize,
        p: [usize;n],
        q: [usize;n],
    };
    let mut perm = Vec::new();
    permutation(n, &mut vec![], &mut perm);
    let a = perm.iter().position(|v| v == &p).unwrap() as isize;
    let b = perm.iter().position(|v| v == &q).unwrap() as isize;
    let res = (a - b).abs();
    println!("{}", res);
}

fn permutation(max: usize, v: &mut Vec<usize>, all: &mut Vec<Vec<usize>>) {
    for i in 1..=max {
        if !v.contains(&i) {
            v.push(i);
            permutation(max, v, all);
            v.pop();
        }
    }
    if v.len() == max {
        let v = v.clone();
        all.push(v);
    }
}


Measured memory_bytes: 5912
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
          for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
         if(prime[i]==0)
           seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         ll w,h,x,y;
         ld ans;
         cin>>w>>h>>x>>y;
         ans=((float)w*h)/2;
         cout<<ans<<" ";
         if((2*x==w)&&(2*y==h))
          cout<<1;
        else
          cout<<0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main(){
    ll N,M; cin >> N >> M;
    ll a[N],b[N],c[M],d[M];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < M; i++)
    {
        cin >> c[i] >> d[i];
    }
    int ans[N];
    for (int i = 0; i < N; i++)
    {
        ll min = 100000000000;
        for (int j = 0; j < M; j++)
        {
            if(abs(a[i]-c[j])+abs(b[i]-d[j]) < min){
                ans[i] = j+1;
                min = abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        
    }
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    
    
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    n = int(input())
    a_list = [int(input()) for _ in range(n)]
    a_list.insert(0, 0)

    position = 1
    cnt = 0
    for i in range(n):
        position = a_list[position]
        cnt += 1
        if position == 2:
            print(cnt)
            exit()
    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7084
#include<bits/stdc++.h>
    using namespace std;
    #define sz(a) int(a.size())
     
    int main(){
    	int r; cin>>r;
    	if(r <1200){
    		puts("ABC");
    	}
    	else if(r < 2800){
    		puts("ARC");
    	}
    	else puts("AGC");
    }

Measured memory_bytes: 256
#!/usr/bin/python3

import heapq
import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, M, A):
    hq = [-a for a in A]
    heapq.heapify(hq)
    for _ in range(M):
        v = -hq[0]
        if v < 1:
            break
        v //= 2
        heapq.heapreplace(hq, -v)

    return sum([math.floor(-v) for v in hq])


def main():
    N, M = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    print(solve(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78316
package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}



Measured memory_bytes: 1156
#include <iostream>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> odd;
    for(ll i = 0; i < N; ++i){
        ll tmp;
        cin >> tmp;
        if(tmp % 2 == 1) odd.push_back(tmp);
    }
    if(odd.size() % 2 == 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

const LL INF = 1e12;
template<class T> int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}

template<class T> int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}
int main() {
    int a, b, q; cin >> a >> b >> q;
    vector<LL> s(a), t(b);;
    rep(i, a)cin >> s[i];
    rep(i, b) cin >> t[i];
    s.push_back(INF); s.push_back(-INF); sort(s.begin(), s.end());
    t.push_back(INF); t.push_back(-INF); sort(t.begin(), t.end());

    rep(zzz, q) {
        LL x; cin >> x;
        LL res = INF;

        // s を先に
        rep(i, 2) {
            LL first = (i ? s[former(s, x)] : s[latter(s, x)]);

            rep(j, 2) {
                LL second = (j ? t[former(t, first)] : t[latter(t, first)]);
                res = min(res, abs(x - first) + abs(first - second));
            }
        }
        // t を先に
        rep(i, 2) {
            LL first = (i ? t[former(t, x)] : t[latter(t, x)]);

            rep(j, 2) {
                LL second = (j ? s[former(s, first)] : s[latter(s, first)]);
                res = min(res, abs(x - first) + abs(first - second));
            }
        }
        cout << res << endl;
    }

}


Measured memory_bytes: 2912
N = input()
oishisa_list = input().split(" ")

N = int(N)

goukei = 0

for i in oishisa_list:
  for j in oishisa_list:
    goukei += int(i) * int(j)

issyo = 0
for i in oishisa_list:
  issyo += int(i) ** 2

print((goukei - issyo) // 2)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int gcd(int a, int b){
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}

int main(){
  int N, K, maxa = -1;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
    maxa = max(A[i], maxa);
  }
  int G = A[0];
  REP(i, N-1){
    G = gcd(G, A[i+1]);
  }

  if(K <= maxa && K % G == 0){
    cout << "POSSIBLE" << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


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

int main(void)
{
  string s;
  int farst, last;
  cin >> s;
  for(int i = 0;i < s.size();i++) {
    if(s.at(i) == 'A') {
      farst = i;
      break;
    }
  }
  for(int i = s.size() - 1;i > 0;i--) {
    if (s.at(i) == 'Z') {
      last = i;
      break;
    }
  }
  cout << last - farst + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
   cin >> s;
  for(int i = 1;i<s.size();++i) {
    if(s[i] == s[i - 1]) 
      return cout << "Bad" << endl,0;
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
using namespace std;
ll ksm(ll a,ll b)
{
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
ll C(ll a,ll b)
{
    ll s1=1,s2=1;
    for(ll i=1;i<=b;i++) s2=s2*i%mod;
    for(ll i=a-b+1;i<=a;i++) s1=s1*i%mod;
    return s1*ksm(s2,mod-2)%mod;
}
int main()
{
    int x,y;cin>>x>>y;
    if((2*y-x)%3==0&&(2*y)-x>=0)
    {
        int a=(2*y-x)/3;
        int b=(2*x-y)/3;
        cout<<C(a+b,a)<<endl;
    }
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3640
// luogu-judger-enable-o2
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
    cin>>s;
    int len=s.size();
    if((s[0]==s[len-1]&&len%2==0)||(s[0]!=s[len-1]&&len%2==1))cout<<"First\n";
    else cout<< "Second\n";
    return 0;
}

Measured memory_bytes: 512
n = int(input())
v_list = list(map(int, input().split()))

min_num = 0

even = {}
odd = {}

for i, v in enumerate(v_list):
    if i % 2 == 0:
        if v in even:
            even[v] += 1
        else:
            even[v] = 1
    else:
        if v in odd:
            odd[v] += 1
        else:
            odd[v] = 1

even_max = sorted(even.items(), key=lambda x: -x[1])
odd_max = sorted(odd.items(), key=lambda x: -x[1])

even_num = even_max[0][0]
odd_num = odd_max[0][0]

if odd_num == even_num:
    if len(odd_max) == 1 and len(even_max) == 1:
        odd_num = 10 ** 5 + 1
    elif len(odd_max) == 1:
        even_num = even_max[1][0]
    elif len(even_max) == 1:
        odd_num = odd_max[1][0]
    else:
        first_e = even_max[0][1]
        first_d = odd_max[0][1]
        if first_e > first_d:
            odd_num = odd_max[1][0]
        elif first_e < first_d:
            even_num = even_max[1][0]
        elif first_e == first_d:
            second_e = even_max[1][1]
            second_d = odd_max[1][1]
            if second_e >= second_d:
                even_num = even_max[1][0]
            else:
                odd_num = odd_max[1][0]

for i, v in enumerate(v_list):
    if i % 2 == 0:
        if v != even_num:
            min_num += 1
    else:
        if v != odd_num:
            min_num += 1
print(min_num)

Measured memory_bytes: 20892
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[] caps = new long[5];
        for (int i = 0; i < 5; i++) {
            caps[i] = sc.nextLong();
        }

        long min = Arrays.stream(caps).min().getAsLong();

        long ans = (n + min + - 1) / min + 4;
        System.out.print(ans);
    }

}


Measured memory_bytes: 28752
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	static int[] costMasuList;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		try {
			String[] inputTmp = scanner.nextLine().split(" ");
			int masuLength = Integer.parseInt(inputTmp[0]);
			// int costMasuLength = Integer.parseInt(inputTmp[1]);
			int startMasu = Integer.parseInt(inputTmp[2]);
			String[] costMasuListTmp = scanner.nextLine().split(" ");
			costMasuList = Stream.of(costMasuListTmp).mapToInt(Integer::parseInt).toArray();

			int startLeftCost = 0;
			int startRightCost = 0;
			for (int i = 1; i < masuLength; i++) {
				if (!isCostMasu(i)) {
					continue;
				}
				if (i < startMasu) {
					startLeftCost++;
				} else if (i > startMasu) {
					startRightCost++;
				}
			}

			System.out.print(startLeftCost < startRightCost ? startLeftCost : startRightCost);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			scanner.close();
		}
	}

	private static boolean isCostMasu(int input) {
		for (int i = 0; i < costMasuList.length; i++) {
			if (costMasuList[i] == input) {
				return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 26704
s = input()
if s == "MON":
    print("6")
elif s == "TUE":
    print("5")
elif s == "WED":
    print("4")
elif s == "THU":
    print("3")
elif s == "FRI":
    print("2")
elif s == "SAT":
    print("1")
else:
    print("7")

Measured memory_bytes: 2940
#include <stdio.h>
int main()
{
    int i,x,y;
    for(i=1;;i++)
    {
        scanf("%d %d",&x,&y);
        if(x==0 && y==0)
            break;
        else{
                if(x>y)
                printf("%d %d\n",y,x);
            else
                printf("%d %d\n",x,y);



        }
    }


    return 0;
}



Measured memory_bytes: 1988
N,M = map(int, input().split())
INF = 10**6
Edge = [[INF]*N for _ in range(N)]
for _ in range(M):
    a,b,c = map(int, input().split())
    Edge[a-1][b-1] = c
    Edge[b-1][a-1] = c
    
dp = [[INF]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            dp[i][j] = 0
        else:
            dp[i][j] = Edge[i][j]
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if Edge[i][j] == INF:
            continue
        if Edge[i][j] > dp[i][j]:
            ans += 1
            
print(ans)

Measured memory_bytes: 3444
#include <stdio.h>

int main(int argc, char* argv[])
{
        int N, A, B;
        scanf("%d %d %d", &N, &A, &B);

        int max;
        int min;
        
        max = (A < B) ? A : B;
        min = A + B - N;

        if (max > 100) max = 100;
        if (min > 100) min = 100;
        if (min < 0) min = 0;

        printf("%d %d\n", max, min);

        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  map<int, bool> memo;
  int N;
  cin>>N;
  int cnt=0;
  for(int i=0;i<N;i++){
    int p[3];
    cin>>p[0]>>p[1]>>p[2];
    sort(p,p+3);
    int k=((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
    if(memo.find(k)!=memo.end()){
      cnt++;
    }else{
      memo[k]=true;
    }
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
#define mod 1000000007
/****************************/
using namespace std;
ll n,m;
string s;
int main()
{
	cin>>s;
	cout<<s;
	if(s[s.size()-1]!='s') cout<<'s';
	else cout<<"es";
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int x, y;
	cin >> x >> y;
	vector<int>DataX;
	vector<int>DataY;
	int count = 0;
	int memo = 0;
	for (int i = 0; i < S.size(); ++i) {
		if ('T' == S[i]) {
			if (0 == memo % 2) {
				DataX.push_back(count);
			}
			else {
				DataY.push_back(count);
			}
			count = 0;
			memo++;
			memo %= 2;
		}
		else {
			count++;
		}
	}
	if (0 != count) {
		if (0 == memo % 2) {
			DataX.push_back(count);
		}
		else {
			DataY.push_back(count);
		}
	}
	//X
	vector<vector<bool>> DPX(1 + DataX.size(), vector<bool>(S.size() * 2 + 1, false));
	{
		DPX[0][S.size() + 0] = true;			
		for (int i = 0; i < DataX.size(); ++i) {
			for (int j = 0; j < 2 * S.size() + 1; ++j) {
				if (DPX[i][j]) {
					DPX[i + 1][j + DataX[i]] = true;
					if (0 != i) {
						DPX[i + 1][j - DataX[i]] = true;
					}
				}
			}
		}
	}
	//Y
	vector<vector<bool>> DPY(1 + DataY.size(), vector<bool>(S.size() * 2 + 1, false));
	{
		DPY[0][S.size() + 0] = true;
		for (int i = 0; i < DataY.size(); ++i) {
			for (int j = 0; j < 2 * S.size() + 1; ++j) {
				if (DPY[i][j]) {
					DPY[i + 1][j + DataY[i]] = true;
					DPY[i + 1][j - DataY[i]] = true;
				}
			}
		}
	}
	if (DPX[DataX.size()][S.size()+x] && DPY[DataY.size()][S.size() + y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"<<endl;
	}
	return 0;
}

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

#define N 110
int n, a, b, p[N];

bool check(int x)
{
	if (n - x + 1 <= x) return false;
	if (p[x] > a) return false;
	if (p[n - x + 1] <= b) return false;
	int cnt = 0;
	for (int i = x + 1, j = 1; j <= x && i <= n - x; ++i)
	{
		if (p[i] > b) break;
		if (p[i] > a) 
		{
			++j;
			++cnt;
		}
	}
	return cnt >= x;
}

int main()
{
	while (scanf("%d", &n) != EOF)
	{
		scanf("%d%d", &a, &b);
		for (int i = 1; i <= n; ++i) scanf("%d", p + i);
		sort(p + 1, p + 1 + n);
		int l = 0, r = n, res = 0;
		while (r - l >= 0)
		{
			int mid = (l + r) >> 1;
			if (check(mid))
			{
				l = mid + 1;
				res = max(res, mid);
			}
			else 
				r = mid - 1;
		}
		printf("%d\n", res);
	}
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N, K, L;
vector<int> R[200010], T[200010];
int ID[200010];
bool used[200010];

void f1(int v, int id)
{
	ID[v] = id;
	used[v] = true;
	for (auto e : R[v])
	{
		if (used[e])continue;
		f1(e, id);
	}
}

void f2(int v, int id)
{
	ID[v] += 200010 * id;
	used[v] = true;
	for (auto e : T[v])
	{
		if (used[e])continue;
		f2(e, id);
	}
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> K >> L;
	int s, t;
	rep(i, 0, K)
	{
		cin >> s >> t;
		s--, t--;
		R[s].push_back(t);
		R[t].push_back(s);
	}
	rep(i, 0, L)
	{
		cin >> s >> t;
		s--, t--;
		T[s].push_back(t);
		T[t].push_back(s);
	}

	fill(used, used + N, false);
	int id = 1;
	rep(i, 0, N)
	{
		if (!used[i])
		{
			f1(i, id);
			id++;
		}
	}

	fill(used, used + N, false);
	id = 1;
	rep(i, 0, N)
	{
		if (!used[i])
		{
			f2(i, id);
			id++;
		}
	}

	map<int, int> vmap;
	rep(i, 0, N)
	{
		vmap[ID[i]]++;
	}

	rep(i, 0, N)
	{
		cout << vmap[ID[i]] << endl;
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector <int> A(N, 0);
  vector <int> child(N, 0);
  for(int i = 1; i < N; ++i){
    cin >> A.at(i);
  }

  for(int i = 1; i < N; ++i){
    ++ child.at(A.at(i)-1);
  }

  for(int i = 0; i < N; ++i){
    cout << child.at(i) << endl;
  }
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long r, d, ans = 0, n, sum = 0;
    string t;
    cin >> n;
    vector<string> s(n);
    vector<int> index(n);
    vector<int> p(n);
    vector<pair<string, int>> cnt(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        cin >> p[i];
        cnt[i].first = s[i];
        cnt[i].second = p[i];
        index[i] = i;
    }
    sort(index.begin(), index.end(), [&](int i, int j) {
        if (s[i] == s[j]) {
            return p[i] > p[j];
        }
        return s[i] < s[j];
    });
    for (int i = 0; i < n; i++) {
        cout << index[i] + 1 << endl;
    }
    sort(s.begin(), s.end());
}

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

int main() {
	int n , i , j , k , l;
	cin >> n >> k;
	int a[n] , dp[n];
	fill(dp , dp+n , INT_MAX);
	for(i=0;i<n;++i) cin >> a[i];
	dp[0] = 0;dp[1] = abs(a[1] - a[0]);
	for(i=2;i<n;++i) {
	    for(j=1;j<=k;j++) {
	        if(i - j >= 0) {
	           // cout << i << ' ' <<j << endl;
	            dp[i] = min(dp[i] , dp[i-j] + abs(a[i] - a[i-j]));
	        }
	        else break;
	    }
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
def saigo(data):
	count = 0
	for d in data:
		if d == 0:
			count += 1
	return count == len(data)-1

n = input()
n = int(n)
data = list(map(int, input().split()))


while(saigo(data) == False):
	min_val = 10e9
	min_idx = 0
	for i,d in enumerate(data):
		if min_val > d and d != 0:
			min_val = d
			min_idx = i
	for i in range(n):
		if i != min_idx:
			data[i] = data[i] % min_val

for i,d in enumerate(data):
	if d != 0:
		print(d)

Measured memory_bytes: 14252
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double sum = 0;
		for(int i = 0; i < n; i++){
			double x = sc.nextDouble();
			String u = sc.next();
			if(u.equals("JPY")){
				sum += x;
			}else{
				sum += x*380000;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22740
from collections import deque
process_count, process_limit = map(int, input().split())

_target_list = []
for i in range(process_count):
    _input = input().split()
    _target_list.append([_input[0], int(_input[1])])
target_list = deque(_target_list)

def calc_process_time(target_list, process_limit):
    process_end_list = []
    process_time = 0
    while target_list:
        target_value = target_list.popleft()
        if target_value[1] > process_limit:
            target_value[1] -= process_limit
            target_list.append(target_value)
            process_time += process_limit
        else:
            process_time += target_value[1]
            process_end_list.append([target_value[0], process_time])
    return process_end_list

process_end_list = calc_process_time(target_list, process_limit)
for value in process_end_list:
    print(value[0], value[1])


Measured memory_bytes: 19580
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
  LL sum[200005]={};
  LL sum1[200005]={};
LL A[200005]={};

int main()
{
    int a;
    while(cin>>a){

  for(int i=1;i<=a;i++){
    cin>>A[i];
    sum[i]=sum[i-1]+A[i];
    sum1[i]=sum1[i-1]^A[i];
  }

  LL ans=0;
  LL l=1;
  for(LL r=1;r<=a;r++){
    for(; (sum[r]-sum[l-1])!=(sum1[r]^sum1[l-1]);l++);

    ans+=r-l+1;
  }
  cout<<ans<<endl;


    }
    return 0;
}


Measured memory_bytes: 4992
n = int(input())
abl = []
for _ in range(n):
    a,b = map(int, input().split())
    abl.append((b,a))

abl.sort()
curr = 0
for b,a in abl:
    curr += a
    if curr > b:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 94540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    int k = K;
    int c = 0;
    while(true){
        if(k>N){
            cout << c+1 << "\n";
            return 0;
        }
        c++;
        k *= K;
    }
}

Measured memory_bytes: 256
import random
def dice(a, b, c, d, e, f, l) :  #def = 関数定義
  if(l == "N") :
    return [b, f, c, d, a, e]
  elif(l == "S") :
    return [e, a, c, d, f, b]
  elif(l == "W") :
    return [d, b, a, f, e, c]
  else :
    return [c, b, f, a, e, d]
  
d1 = list(map(int, input().split()))
a, b, c, d, e, f = map(int, input().split())
L = ["N", "S", "W", "E"]

cnt = 0

while(cnt <= 10000) :
  x = random.randrange(4)  #0～3の中からランダムに1つ整数を選択
  d1 = dice(d1[0], d1[1], d1[2], d1[3], d1[4], d1[5], L[x])
  
  if(d1[0] == a and d1[1] == b and d1[2] == c and d1[3] == d 
     and d1[4] == e and d1[5] == f) :
    print("Yes")
    break
  elif(cnt == 10000) :
    print("No")
    break
  else :
    cnt += 1


Measured memory_bytes: 8176
// N serving of skewer meal
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> length_skewer(2*n);
	for(int i=0; i<2*n; i++)
		cin>>length_skewer[i];
	sort(length_skewer.rbegin(), length_skewer.rend());
	int ans= 0;
	for(int i=0; i<2*n; i++)
	{
		if(i%2!=0)
		ans = ans+length_skewer[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
from itertools import *
g=lambda a,x,b:a+b if x=='+'else a-b if x=='-'else a*b
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(g(a,x,b),y,c),z,d)==10:return f"(({a} {x} {b}) {y} {c}) {z} {d}"
   if g(g(a,x,b),y,g(c,z,d))==10:return f"({a} {x} {b}) {y} ({c} {z} {d})"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5660
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int ans = a*b/2;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256