akhauriyash/Code-Regression huggingface dataset:
H, W, K = map(int,input().split())
B = [input() for k in range(H)]
S = [[0]*(W+1) for k in range(H)]

for k in range(H):
    for l in range(W):
        if B[k][l] == "1":
            S[k][l+1] = S[k][l] + 1
        else:
            S[k][l+1] = S[k][l]

ans = 1000000
for k in range(2**(H-1)):
    t = [0]*W
    u = []
    for d in range(H):
        if (k>>d)&1 == 1:
            for l in range(W):
                t[l] += int(B[d][l])
        else:
            for l in range(W):
                t[l] += int(B[d][l])
            u.append(t)
            t = [0]*W
    temp = len(u)-1
    d = [0]*len(u)
    for i in range(len(u)):
        d[i] = u[i][0]
        if d[i] > K:
            temp = 1000000
    for j in range(1,W):
        for i in range(len(u)):
            if u[i][j] > K:
                temp = 1000000
                break
            d[i] += u[i][j]
            if d[i] > K:
                temp += 1
                for l in range(len(u)):
                    d[l] = u[l][j]
                break
    ans = min(ans,temp)
print(ans)


Measured memory_bytes: 53212
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string x;
    cin >> x;
    string r;
    for (int i = 0; i < (int)x.size(); ++i) {
        if (x[i] == 'S')
            r.push_back(x[i]);
        else {
            if (!r.empty() && r.back() == 'S')
                r.pop_back();
            else
                r.push_back('T');
        }
    }
    cout << r.size() << "\n";
    return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), K = input();
    vector< int > h(N);
    cin >> h;

    whole(sort, h);
    int ans = inf;
    range(i, K - 1, N) {
        chmin(ans, h[i] - h[i - K + 1]);
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    s = input()
    ans = [1 for _ in range(len(s))]
    for i in range(len(s)-2):
        if s[i] == 'R' and s[i+1] == 'R':
            ans[i+2] += ans[i]
            ans[i] = 0
    for i in range(len(s)-1, 1, -1):
        if s[i] == 'L' and s[i-1] == 'L':
            ans[i-2] += ans[i]
            ans[i] = 0
    print(" ".join(map(str, ans)))



if __name__ == '__main__':
    main()


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

using namespace std;

struct State{
    int x, y, s, w, c; // (x, y), state, sWitch, cost
    bool operator < (const State& st) const {
        if(c != st.c) return c > st.c;
        return make_tuple(x, y, s, w) < make_tuple(st.x, st.y, st.s, st.w);
    }
};
void print(const State& s) {
    printf("x = %d y = %d s = %d w = %x c = %d\n", s.x, s.y, s.s, s.w, s.c);
}

int main(){
    int H, W, L;
    while(cin >> H >> W >> L){

        string grid[25];
        priority_queue<State> que;
        static bool used[25][25][3][1 << 5] = {};
        memset(used, 0, sizeof(used));

        int dx[3][4] = {
            {1, 0, -L, 0},
            {L, 0, -1, 0},
            {1, 0, -1, 0}
        };
        int dy[3][4] = {
            {0, 1, 0, -L},
            {0, 1, 0, -1},
            {0, L, 0, -1}
        };
        int ds[3][4] = {
            {1, 2, 1, 2},
            {0, 1, 0, 1},
            {2, 0, 2, 0}
        };

        auto valid = [&](const State& st) {
            int x = st.x, y = st.y, s = st.s, w = st.w;
            assert(0 <= s && s < 3);
            for(int cy = y; cy < y + (s == 2 ? L : 1); cy++) {
                for(int cx = x; cx < x + (s == 1 ? L : 1); cx++) {
                    if(cx < 0 || W <= cx) return false;
                    if(cy < 0 || H <= cy) return false;
                    if(grid[cy][cx] == '#') return false;
                    if(s == 0 && grid[cy][cx] == '^') return false;
                    if(islower(grid[cy][cx]) && !(w >> (grid[cy][cx] - 'a') & 1)) {
                        return false;
                    }
                }
            }
            return true;
        };
        auto push = [&](const State& s) {
            bool& u = used[s.y][s.x][s.s][s.w];
            if(!u) {
                u = true;
                que.push(s);
            }
        };

        REP(y, H) cin >> grid[y];
        State init;
        REP(y, H) REP(x, W) if(grid[y][x] == 'S') init.x = x, init.y = y;
        init.s = init.w = init.c = 0;
        push(init);

        int ans = -1;

        while(!que.empty()) {
            State s = que.top(); que.pop();
            // print(s);
            if(s.s == 0 && grid[s.y][s.x] == 'G') {
                ans = s.c;
                break;
            }
            for(int r = 0; r < 4; r++) {
                State ns = s;
                ns.x += dx[s.s][r];
                ns.y += dy[s.s][r];
                ns.s = ds[s.s][r];
                if(!valid(ns)) continue;
                if(ns.s == 0 && 'A' <= grid[ns.y][ns.x] && grid[ns.y][ns.x] <= 'E') {
                    ns.w ^= (1 << (grid[ns.y][ns.x] - 'A'));
                }
                ns.c += 1;
                push(ns);
            }
        }

        cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e6+5;
const dd eps = 1e-8;
const ll mod = 1e9+7;


struct node{
  int val,cost;
}a[3005];

bool cmp(node p1,node p2){
  return p1.cost < p2.cost;
}

int dp[10005],n,t,ans;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>t;
  for(int i = 1;i <= n;i++) cin>>a[i].cost>>a[i].val;
  sort(a+1,a+1+n,cmp);
  dp[a[1].cost] = a[1].val;
  for(int i = 2;i <= n;i++){
    for(int j = 10000;j >= a[i].cost && j >= a[1].cost;j--){
      if(j - a[i].cost < t) dp[j] = max(dp[j],dp[j-a[i].cost]+a[i].val);
    }
  }
  for(int i = a[1].cost;i < 10000;i++){
    ans = max(dp[i],ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
	int a[3005];
	int n;
	scanf("%d", &n);
	int ans = 0;
	for(int i = 1 ; i <= n ; i++){
		scanf("%d", &a[i]);
		ans += a[i] - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char line[100];
  int num;
  int hour, min, sec;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &num);
  hour=num/3600;
  num=num%3600;
  min=num/60;
  sec=num%60;
  printf("%d:%d:%d\n", hour, min, sec);
  return 0;
}



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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


pair<int,ll>ppow(int a,ll b){
	if(a==0)return {a,b-1};
	int res=a;b--;
	ll op=0;
	ll op2=0;
	while(b){
		if(b&1){
			res+=a;
			op++;
			op+=op2;
			if(res>=10){
				op++;
				res=res/10+res%10;
			}
		}
		a+=a;
		op2*=2;
		op2++;
		if(a>=10){
			op2++;
			a=a/10+a%10;
		}
		b>>=1;
	}
	return {res,op};
}
int main(){
	int m;cin>>m;
	string s;
	ll ans=0;
	rep(i,m){
		int d;ll c;scanf("%d%lld",&d,&c);
		auto p=ppow(d,c);
		ans+=p.second;
		s+=p.first+'0';
	}
	while(s.size()>1){
		int a=s[s.size()-2]-'0',b=s[s.size()-1]-'0';
		int n=a+b;
		ans++;
		if(n>=10){
			ans++;
			n=n/10+n%10;
		}
		rep(i,2)s.pop_back();
		s+='0'+n;
	}
	cerr<<s<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 640
from collections import deque

n, m = map(int, input().split())
G = [[] for i in range(n)]
used = [0]*n
prev = [-1]*n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

q = deque([0])
used[0] = 1
while q:
    u = q.popleft()
    for v in G[u]:
        if used[v] == 1:
            continue
        q.append(v)
        used[v] = 1
        prev[v] = u + 1

for i in range(n):
    if used[i] != 1:
        print("No")
        exit()

print("Yes")
for i in range(1,n):
    print(prev[i])

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

int main(){
  int n;
  char ch[201];

  while(cin>>n){
    if(n==0)break;
    int count=0;
    for(int i=0;i<2*n;i++)
      cin>>ch[i];

    for(int i=0;i+3<2*n;i+=4)
      if(ch[i]!=ch[i+2])count++;
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;

class Main {
	static final int M = 1000000007;

	private static long[][] dp;
	private static List<Integer>[] g;

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		dp = new long[n][2];
		g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}

		for (int i = 0; i < n - 1; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			g[x].add(y);
			g[y].add(x);
		}

		dfs(0, -1);
		System.out.println((dp[0][0] + dp[0][1]) % M);
	}

	private static void dfs(int v, int p) {
		dp[v][0] = dp[v][1] = 1;
		for (int c : g[v]) {
			if (c == p) continue;
			dfs(c, v);
			dp[v][0] = dp[v][0] * ((dp[c][0] + dp[c][1]) % M) % M;
			dp[v][1] = dp[v][1] * dp[c][0] % M;
		}
	}
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    int cake_num[3];
    VVL cake(3);
    REP(i, 3) {
        cin >> cake_num[i];
        cake[i].resize(cake_num[i]);
    }
    cin >> k;
    REP(i, 3)REP(j, cake_num[i]) cin >> cake[i][j];
    REP(i, 3) sort(ALL(cake[i]), greater<ll>());

    VL ans;
    REP(i, cake_num[0])REP(j, cake_num[1])REP(l, cake_num[2]) {
        if((ll)(i + 1) * (ll)(j + 1) * (ll)(l + 1) <= k) 
            ans.push_back(cake[0][i] + cake[1][j] + cake[2][l]);
        else break;
    }
    sort(ALL(ans), greater<ll>());
    REP(i, k) cout << ans[i] << ln;
    return 0;
}


Measured memory_bytes: 1404
'use strict'

function Main(input) {
  const inputList = input.split('\n');
  const n = inputList[0]
  const numberStringList = inputList[1].split(' ')
  let numberList = []
  for (let i=0; i<n; i++) {
    numberList.push(Number(numberStringList[i]))
  }
  const sortedNumberList = mergeSort(numberList)

  let aliceTotal = 0
  let bobTotal = 0
  for (let i=0; i<n; i++) {
    if (i%2 === 0) {
      aliceTotal += sortedNumberList[n-i-1]
    } else {
      bobTotal += sortedNumberList[n-i-1]
    }
  }

  const result = aliceTotal - bobTotal

  console.log(result)
}

function mergeSort (array) {
  const sortedArray = array.concat()
  if (sortedArray.length <= 1) {
    return sortedArray
  } 

  let middleIndex = Math.floor(sortedArray.length / 2)

  let leftArray = sortedArray.splice(0, middleIndex)
  let rightArray = sortedArray

  leftArray = mergeSort(leftArray)
  rightArray = mergeSort(rightArray)

  return merge(leftArray, rightArray)
}

function merge(leftArray, rightArray) {
  let mergedArray = []

  while(leftArray.length > 0 && rightArray.length > 0) {
    if (leftArray[0] > rightArray[0]) {
      mergedArray.push(rightArray.shift())
    } else {
      mergedArray.push(leftArray.shift())
    }
  }

  if (leftArray.length > 0) {
    mergedArray = [...mergedArray, ...leftArray]
  }
  if (rightArray.length > 0) {
    mergedArray = [...mergedArray, ...rightArray]
  }

  return mergedArray
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
N = int(input())
A = sorted([int(x) for x in input().split()])

flg = True
if N%2 == 0:
  for i in range(0, N//2): flg &= A[2*i] == A[2*i+1] == 2*i+1
else:
  flg &= A[0] == 0
  for i in range(1, (N+1)//2): flg &= A[2*i-1] == A[2*i] == 2*i

def modpow(n, r, m):
  if r == 0: return 1
  if r%2 == 0: return modpow(n, r//2, m)**2 % m
  return n * modpow(n, r-1, m) % m

print(modpow(2, N//2, 10**9+7) if flg else 0)


Measured memory_bytes: 13880
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXS 26
#define MAXH 100
#define MAXW 100
int main(int argc,char const* argv[])
{
  int h,w,i,j;
  char a[MAXH][MAXW+1];
  char b[MAXH+2][MAXW+2];
  cin >> h >> w;
  for(i=0;i<h+2;i++)
    {
      for(j=0;j<w+2;j++)
	{
	  b[i][j]='#';
	}
    }
  for(i=0;i<h;i++)
    {
      cin >> a[i];
    }
  for(i=0;i<h;i++)
    {
    for(j=0;j<w;j++)
      {
	b[i+1][j+1]=a[i][j];
      }
    }
  for(i=0; i<h+2;i++)
    {
      for(j=0;j<w+2;j++)
	{
	  cout << b[i][j];
	}
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;
 

int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };


int main() {
	int k;
	cin >> k;
	cout << a[k-1] << endl;
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
using namespace std;

ll n,wr;
ll v[100001];
ll w[100001];
ll dp[102][100001];

ll knapsack1(ll n, ll wr)
{
    if(n<0) return 0;
    if(dp[n][wr]!=0) return dp[n][wr];
    if(wr < w[n]) {
        dp[n][wr] =  knapsack1(n-1,wr);
    }
    else dp[n][wr] = max(v[n]+knapsack1(n-1,wr-w[n]),knapsack1(n-1,wr));
    return dp[n][wr];
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>wr;
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    cout<<knapsack1(n-1,wr)<<endl;
}


Measured memory_bytes: 75092
S = input()

def saiki(n, s=S[0]):
    _sum = 0
    
    if n==len(S)-1:
#         print(s)
        return eval(s)
    
    _sum += saiki(n+1, s + "+" + S[n+1])
    _sum += saiki(n+1, s + S[n+1])
    
    return _sum
    
print(saiki(0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, s, n) for(int i = s; i < n; i++)
#define rRep(i, n) for(int i = n - 1; i >= 0; i--)
#define pii pair<int, int>
#define vii vector<pair<int, int>>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define endl "\n"


int32_t main() {
	FAST
	//ofstream fout ("test.out");
    //ifstream fin ("test.in");
    string s, t;
    cin >> s >> t;
    if(s == t.substr(0, s.length()) && t.length() == s.length() + 1)
    	cout << "Yes" << endl;
    else 
    	cout << "No" << endl;
}

Measured memory_bytes: 3652
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt(); 
        }
        for(int i=n-1;i>=0;i--){
            if(i == 0) System.out.println(a[i]);
            else System.out.print(a[i] + " ");
        }
    }
}


Measured memory_bytes: 26400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class ARounding {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int N,A;
    cin >> N >> A;
    cout << (N < A ? 0 : 10) << endl;
}
};


#undef int
int main() {
	ARounding solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray = br.readLine().split(" ");
		int[] low = new int[n];
		int result = 1;
		
		low[0] = Integer.parseInt(tmpArray[0]);
		
		for(int i = 1; i < n; i++) {
			int tmp = Integer.parseInt(tmpArray[i]);
			
			if(tmp > low[i - 1]) {
				low[i] = low[i - 1];
			}
			else {
				low[i] = tmp;
				result++;
			}
		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 50644
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <functional>
#include <stack>
#include <numeric>
#define PI 3.1415926535

using namespace std;

int a[100][100], b[100], n, m, t;

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++){
		cin >> t;
		a[i][j] = t;
	}
	for (int i = 0; i < m; i++) {
		cin >> t;
		b[i] = t;
	}
	t = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			t += a[i][j] * b[j];
		cout << t << endl;
		t = 0;
	}
}

Measured memory_bytes: 1204
#include<iostream>

using namespace std;

int main(){
  string S;
  int counts[4]={0};
  
  cin >> S;
  
  for(int i=0; i<4; i++){
    for(int j=0; j<4; j++){
      if(S[i] == S[j]){
        counts[i]++;
      }
    }
  }
  
  int sum=0;
  for(int i=0; i<4; i++){
    sum+=counts[i];
  }
  
  cout << (sum == 8 ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
string t, p;

int main() {
  ios::sync_with_stdio(false);
  cin >> t >> p;
  for (int i = 0; i < t.length(); i++) {
    i = t.find(p, i);
    if (i == string::npos) break;
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  int N;
  int count = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    int C = i / 10000 + (i % 10000) / 1000 + (i % 1000) / 100 + (i % 100) / 10 + i % 10;
    if (A <= C && C <= B) {
      count += i;
    }
  }
  cout << count << endl;  
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int zet(int a, int b){
  if(a-b>=0){
    return a-b;
  }
  if(a-b<0){
    return b-a;
  }
}
int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> vec(N+1);
  vector<vector<int>> A(N+1,vector<int>(N+1));
  for(int i=1;i<N;i++){
    for(int j=i+1;j<N+1;j++){
      A.at(i).at(j)=min(zet(i,j), min(zet(X,i)+zet(Y,j)+1, zet(X,j)+zet(Y,i)+1));
    }//A.at(i).at(j)=(i,j)の最短距離
  }
  
  for(int i=1;i<N;i++){
    for(int j=i+1;j<N+1;j++){
      vec.at(A.at(i).at(j))++;
    }
 }
    for(int i=1;i<N;i++){
      cout << vec.at(i) << endl;
    }
}


          


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 100100100;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main(){
    int n, k; cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int ans = inf;
    if(n == k){
        ans = min(abs(v[n-1]) + abs(v[0] - v[n-1]), abs(v[0]) + abs(v[0] - v[n-1]));
    }
    rep(i, n-k+1){
        ans = min(ans, min(abs(v[i+k-1]) + abs(v[i] - v[i+k-1]), abs(v[i]) + abs(v[i] - v[i+k-1])));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >>Y;
    vector<int> x_n(N, 0), y_m(M, 0);
    REP(i, N) { cin >> x_n[i]; }
    REP(i, M) { cin >> y_m[i]; }

    for(int z = X+1; z <= Y; ++z) {
        bool isNoWar = true;
        REP(i, N) {
            if(x_n[i] >= z) {
                isNoWar = false;
                break;
            }
        }
        if(!isNoWar) { continue; }
        REP(i, M) {
            if(y_m[i] < z) {
                isNoWar = false;
                break;
            }
        }
        if(isNoWar) {
            printf("No War\n");
            return 0;
        }
    }
    printf("War\n");
    return 0;
}


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

using namespace std;

string s;
int bit[8];
string::iterator it;

map<int, int> merge(map<int, int> &a, map<int, int> &b)
{
    map<int, int> res;
    for (int i = 0; i < (1<<4); i++) {
        for (int j = 0; j < (1<<4); j++) {
            if (!a.count(i) || !b.count(j)) continue;
            res[i&j] += a[i] * b[j];
            res[i|j] += a[i] * b[j];
            res[i^j] += a[i] * b[j];
        }
    }
    return res;
}

map<int, int> solve()
{
    if (*it == '(') {
        ++it;
        auto l = solve();        
        ++it;
        auto r = solve();        
        ++it;        
        return merge(l, r); 
    } else {
        int x = *it - '1'; ++it;
        return {{bit[x], 1}};
    }
}

int main()
{
    while (getline(cin, s), s != "END") {
        int N, x;
        cin >> N;
        for (int i = 0; i < N; i++) {
            bit[i] = 0;
            for (int j = 0; j < 4; j++) {
                cin >> x;
                bit[i] |= (1<<j) * x;
            }
        }
        it = s.begin();
        auto res = solve();
        cout << res[(1<<4)-1] << endl;
        cin.ignore();
    }
    return 0;
}

Measured memory_bytes: 3008
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int dpl[1<<20],dpr[1<<20],n,v,x[200011],l[21][200001],r[21][200001],q[100001];bool ans[200001];
int main()
{
	scanf("%d%d",&n,&v);
	for(int i=1;i<=n;++i)scanf("%d",&x[i]);
	int tmp=v;while(tmp)q[++q[0]]=tmp,tmp>>=1;q[++q[0]]=0;for(int i=1;i<=q[0]-i+1;++i)swap(q[i],q[q[0]-i+1]);
//	for(int i=1;i<=q[0];++i)printf("%d ",q[i]);putchar(10);
	for(int i=1;i<=q[0];++i)
	{
		int pt=1;
		for(int j=1;j<=n;++j){if(x[j]-x[j-1]>q[i])pt=j;l[i][j]=pt;}pt=n;
		for(int j=n;j;--j){if(x[j+1]-x[j]>q[i])pt=j;r[i][j]=pt;}
	}
//	for(int i=1;i<=n;++i)printf("%d %d\n",l[q[0]][i],r[q[0]][i]);
	for(int i=0;i<(1<<q[0]);++i)dpl[i]=1,dpr[i]=n;
	for(int i=0;i<(1<<q[0]);++i)
	{
		for(int j=1;j<=q[0];++j)
		{
			if(i&(1<<j-1))continue;
			if(dpl[i]>n)dpl[i|(1<<j-1)]=dpl[i];else dpl[i|(1<<j-1)]=max(dpl[i|(1<<j-1)],r[j][dpl[i]]+1);
			if(dpr[i]<1)dpr[i|(1<<j-1)]=dpr[i];else dpr[i|(1<<j-1)]=min(dpr[i|(1<<j-1)],l[j][dpr[i]]-1);
		}
	}
	int cnt=0;for(int i=1;i<=n;i=r[q[0]][i]+1)++cnt;if(cnt>q[0]){for(int i=1;i<=n;++i)printf("Impossible\n");return 0;}
//	for(int i=0;i<(1<<q[0]);++i)printf("%d %d %d\n",i,dpl[i],dpr[i]);
	for(int i=1;i<=n;i=r[q[0]][i]+1)
	{
		bool flg=false;
		for(int j=0;j<(1<<q[0]-1);++j)if(dpl[j]>=l[q[0]][i]&&dpr[((1<<q[0]-1)-1)^j]<=r[q[0]][i]){flg=true;break;}
		for(int j=l[q[0]][i];j<=r[q[0]][i];++j)ans[j]=flg;
	}
	for(int i=1;i<=n;++i)printf(ans[i]?"Possible\n":"Impossible\n");return 0;
}

Measured memory_bytes: 42112
import copy
S=list(input())

ans=1000

A=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
Li=[]
li=[]
for i in range(26):
    li=copy.deepcopy(S)
    if li.count(A[i])==len(li):
        print(0)
        exit()
    else:
        Li=copy.deepcopy(li)
        li=[]
        for k in range(len(S)):
            for j in range(len(Li)-1):
                if Li[j]==A[i] or Li[j+1]==A[i]:
                    li.append(A[i])
                else:
                    li.append("1")
            #print(li)
            if li.count(A[i])==len(li):
                if ans>len(S)-len(li):
                    ans=len(S)-len(li)
                break
            else:
                Li=copy.deepcopy(li)
                li=[]
print(ans)

Measured memory_bytes: 3444
import java.util.*;

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("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 21972
def draw_rec(h, w)
	h.times do
		w.times do
			print("#")
		end
		puts ""
	end
	puts ""
end

inputs = gets.strip().split(" ")
h  = inputs[0].to_i
w  = inputs[1].to_i

until h == 0 && w == 0
	draw_rec(h, w)
	inputs = gets.strip().split(" ")
	h  = inputs[0].to_i
	w  = inputs[1].to_i		
end


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

int main()
{
    int x,y;
    cin>>y>>x;
    int arr[101]= {0};
    for(int i=0; i<x; i++) {
        int temp;
        cin>>temp;

        arr[temp]++;
    }
    int mn=105,val=0;
    for(int i=0; i<=100; i++) {
        if(arr[i]==0) {
            int p;
            if(y>i)p=y-i;
            else p=i-y;
            if(p<mn) {
                val=i;
                mn=p;
            }
        }
    }
    int u=y+1;
    if(u<mn){val=-1;mn=u;}
    int v=101-y;
    if(v<mn){val=101;mn=v;}
    cout<<val<<endl;

}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc. nextInt();
        int B = sc. nextInt();
        int C = sc. nextInt();
        
        int X = sc. nextInt();
        int Y = sc. nextInt();
        
        boolean Aflag = X > Y;
        
        int Z = 0;
        
        if (Aflag){ 
            Z = X - Math.abs(X-Y);
        }else{
            Z = Y - Math.abs(X-Y);
        }
        
        long price = 0;
        
        if ((A+B) > C*2){
            price += Z*C*2;
            if (Aflag){
                if (A < 2*C){
                    price += (X-Z)*A;
                }else{
                    price += (X-Z)*2*C;
                }
            }else{
                if (B < 2*C){
                    price += (Y-Z)*B;
                }else{
                    price += (Y-Z)*2*C;
                }
            }
            
        }else{
            price += A*X;
            price += B*Y;
        }
        
        System.out.println(price);
    }
}


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

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X > Y) {
        cout << ">" << endl;
    } else if (X < Y) {
        cout << '<' << endl;
    } else {
        cout << '=' << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(ll i=(n);i<(x);++i)
#define pb push_back
using ll = long long;

int main() {
	int n; cin >> n;
	vector<vector<int>> to(n), cost(n);
	rep(i, 0, n - 1) {
		int u, v, w; cin >> u >> v >> w;
		--u; --v;
		to[u].pb(v);
		to[v].pb(u);
		cost[u].pb(w);
		cost[v].pb(w);
	}

	vector<int> ans(n, -1);
	queue<int> que;
	ans[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		rep(i, 0, to[v].size()) {
			int u = to[v][i];
			int w = cost[v][i];
			if (ans[u] != -1) continue;
			ans[u] = (ans[v] + w) % 2;
			que.push(u);
		}
	}

	for (auto x : ans) cout << x << endl;

	return 0;
}

Measured memory_bytes: 11904
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	ll x, y,ans,now;
	char kari;
	cin >> x >> y;
	now = x;
	for (ans = 0; now <=y; ++ans) {
		now *= 2;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

int main()
{
  string s;
  cin >> s;
  int a[27];
  memset(a, 0, sizeof(a));
  for (int i = 0; i < 4; i++)
  {
    a[(int)(s[i] - 'A')]++;
  }
  bool ans = true;
  for (int i = 0; i < 27; i++)
  {
    if (a[i] != 0 && a[i] != 2)
    {
      ans = false;
    }
  }
  cout << (ans ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100];
int main()
{
    ll n;
    cin>>n;
    memset(a,0,sizeof(a));
    for(ll i=1;i<=50;i++)
    {
        a[i]=(49+n/50);
    }
    ll m=n%50;
    for(ll i=1;i<=50;i++)
    {
        a[i]=a[i]-m;
    }
    for(ll i=1;i<=m;i++)
    {
        a[i]+=50;
    }
    cout<<50<<endl;
    for(ll i=1;i<=49;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<a[50]<<endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()

  val c0 = s.filter { it == '0' }.length
  val c1 = s.filter { it == '1' }.length

  val min = Math.min(c0, c1)

  println(min * 2)
}



Measured memory_bytes: 34348
import java.util.Scanner;

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

        String S = sc.next();

        System.out.println(solve(S));

        sc.close();
    }

    static String solve(String S) {
        return (Integer.parseInt(S.substring(5, 7)) <= 4) ? "Heisei" : "TBD";
    }
}

Measured memory_bytes: 35560
a, b, c, x, y = map(int, input().split())
a_l = []


def abs0(inp):
    if inp < 0:
        return 0
    else:
        return inp


for i in range(x+1):
    a_l.append(a*i + c*2*(x-i) + b*abs0(y-(x-i)))
b_l = []
for i in range(y+1):
    b_l.append(b*i + c*2*(y-i) + a*abs0(x-(y-i)))
print(min(a_l + b_l))


Measured memory_bytes: 12524
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    for(int bit=0; bit<(1<<s.size()-1); bit++){
        bool pre;
        string ss = "0";
        rep(i, s.size()){
            if(i==0){
                pre = (bit & (1<<i));
                ss += s[i];
            }else{
                if(((bit & (1<<i))>0 and pre>0) or ((bit & 1<<i)==0 and pre==0)){
                    ss += s[i];
                }else{
                    ans += stoll(ss);
                    ss = s[i];
                    pre = !pre;
                }
            }
        }
        ans += stoll(ss);
        ss = "0";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	vector<int>a(n); int sum = 0;
	rep(i, n) {
		if (s.at(i) == 'E')a[i] = 1;
		else a[i] = 0;
		if (i >= 1)sum += a[i];
	}
	int ans = sum;
	for (int i = 1; i < n; i++) {
		sum -= a[i];
		if (a[i - 1] == 0)sum += 1;
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	int n;
	cin >> n;
	vector<int> v(n), c(n);
	rep(i, n) cin >> v[i];
	rep(i, n) cin >> c[i];

	int ans = 0;
	rep(i, n) {
		if (v[i] >= c[i])
			ans += (v[i] - c[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, x, a, b, c;
	int s = 0;
	while (true) {
		cin >> n >> x;
		if (n == 0 && x == 0) {
			break;
		}
		a = x / 3 + 1;
		for (int i = a; i <= n; i++) {
			c = (x - i) / 2 + 1;
			for (int j = c; j < i; j++) {
				if (0 < x - i - j&&x - i - j < a) {
					s += 1;
				}
			}
		}
		cout << s << endl;
		s = 0;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,l;
    cin>>n>>l;
    vector<string>s;
    while(n--)
    {
        string d;
        cin>>d;
        s.push_back(d);
    }
    sort(s.begin(),s.end());
    
    for(int i=0;i<s.size();i++)
    cout<<s[i];
	return 0;
}

Measured memory_bytes: 3616
import itertools

def main():
    N, M = map(int, input().split())
    VE = tuple(tuple(map(lambda x: int(x)-1, input().split())) for _ in range(M))
    # print(VE)

    adj_mat = [[0 for _ in range(N)] for _ in range(N)]
    for ve in VE:
        adj_mat[ve[0]][ve[1]] = 1
        adj_mat[ve[1]][ve[0]] = 1
    # for row in adj_mat:
    #     print(row)

    ans = 0
    for perm in itertools.permutations([i for i in range(1, N)]):
        # print(perm)
        flag = True
        now_V = 0
        for next_V in perm:
            # print('{} to {}'.format(now_V, next_V))
            # print('{}'.format(adj_mat[now_V][next_V]))
            if not adj_mat[now_V][next_V]:
                flag = False
                break
            now_V = next_V
        if flag:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < str.length() - 2; i++) {
			ans = Math.min(ans, Math.abs(753 - Integer.parseInt(str.substring(i, i + 3))));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N;cin>>N;
    if(N==1)cout<<"Hello World"<<endl;
    else {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long n = 0;
  long a = 0;
  long b = 0;
  long minhoge = 0;
  long maxhoge = 0;
  long sumnum = 0;
  scanf("%d %d %d",&n,&a,&b);
  minhoge = ((n-1)*a)+b;
  maxhoge = a+((n-1)*b);
  if((n == 1 && a!=b)|| a > b){
    sumnum = 0;
  }else if(n == 1 && a == b){
    sumnum = 1;
  }else{
    sumnum = maxhoge - minhoge + 1;
  }
  
  printf("%lu",sumnum);
  return 0;
}
        
    

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  cin >> n;
  switch (n%10)
  {
  case 0:
  case 1:
  case 6:
  case 8:
    printf("pon\n");
    break;
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    printf("hon\n");
    break;
  case 3:
    printf("bon\n");
  }
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),OUT(YES),OUT(NO))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE],B[SIZE],C[SIZE];string s;
LL solve2(int x){
	VI v;
	REP(i,3){
		v.pb(x%10);
		x/=10;
	}
	int now=0;
	REP(i,N){
		if(s[i]==v[now]+'0') now++;
		if(now==3) return 1;
	}
	return 0;
}
LL solve(){
	cin >> N;
	cin >> s;
	int ans=0;
	REP(i,1000){
		ans+=solve2(i);
	}
	cout <<ans << endl;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	LL T;
	DEFAULT;
	
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


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

int main(){
    int n;
    cin >> n;
    vector<int> c(n-1),s(n-1),f(n-1);
    for(int i=0; i<n-1; i++){
        cin >> c.at(i) >> s.at(i) >> f.at(i);
    }
    for(int i=0; i<n; i++){
        //開始時に駅iにいる
        int time=0;
        for(int j=i; j<n-1; j++){
            //駅jから駅j+1に移動
            int train=s.at(j);
            while(train<time){
                train+=f.at(j);
            }
            time=train+c.at(j);
        }
        cout << time << endl;
    }
}

Measured memory_bytes: 3620
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  private static final int M = 1_000_000_007;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int n = scanner.nextInt();
    HashMap<Integer, Integer> position = new HashMap<>();
    int left = -1;
    int right = -1;
    for (int i = 0; i < n + 1; i++) {
      int a = scanner.nextInt();
      if (position.containsKey(a)) {
        if (right >= 0) throw new AssertionError();
        left = position.get(a);
        right = i;
      } else {
        position.put(a, i);
      }
    }
    if (left < 0 || right < 0) throw new AssertionError();

    int r = left + n - right;

    long[] nck = chooseForN(n + 1);
    long[] rck = chooseForN(r);
    StringBuilder sb = new StringBuilder();
    for (int k = 1; k <= n + 1; k++) {
      long p = 0;
      if (k - 1 <= r) p = rck[k - 1];
      long ans = nck[k] - p;
      if (ans < 0) ans = M + ans;
      sb.append(ans).append('\n');
    }
    System.out.println(sb.toString());
  }

  private static long[] chooseForN(int n) {
    long[] C = new long[n + 1];
    long[] fact = new long[n + 1];
    long[] factinv = new long[n + 1];

    fact[0] = 1;
    for (int i = 0; i < n; i++) fact[i + 1] = fact[i] * (n - i) % M;
    factinv[0] = 1;
    for (int i = 1; i <= n; i++) factinv[i] = factinv[i - 1] * inverse(i) % M;

    for (int i = 0; i <= n; i++) C[i] = fact[i] * factinv[i] % M;

    return C;
  }

  private static long inverse(long a) {
    return modpow(a, M - 2);
  }

  private static long modpow(long a, long n) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % M;
      a = (a * a) % M;
      n >>= 1;
    }
    return res % M;
  }
}


Measured memory_bytes: 65108
n,m,k = map(int,input().split())

able_set = set()
for ni in range(n+1):
  base = ni * m
  for mi in range(m+1):
    black = base - ni*mi + (n-ni)*mi    
    able_set.add(black)    
    
if k in able_set:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 20892
#include<iostream>

using namespace std;

int main(){
  int a;
  int b;
  int c;
  int x;
  int y;
  int z;
  cin >> a >> b >> c;
  if (a <= b && a <= c){
    x = a;
    if(b <= c){
    y = b;
    z = c;
    }else{
    y = c;
    z = b;
    }
  }else if(b <= a && b <= c){
    x = b;
    if(a <= c){
      y = a;
      z = c;
    }else{
      y = c;
      z = a;
    }
  }else{
    x = c;
    if (a <= b){
      y = a;
      z = b;
    }else{
      y = b;
      z = a;
    }
  }
  cout << x << " " << y << " " << z << endl;
  return 0;
}



Measured memory_bytes: 3096
n = int(input())
a = set(map(int, input().split()))

if len(a) == 1:
    result = list(a)[0]
    print("{} {}".format(result, result))

x = max(a)
result = min(a)
for i in sorted(a):
    if i == (x // 2):
        result = i
        break
    elif i < x / 2:
        result = i
    elif (i - x / 2) < (x / 2 - result):
        result = i
        break
    else:
        break

print("{} {}".format(x, result))

Measured memory_bytes: 19684