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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    string S; cin >> S;
    string T; cin >> T;
    int N = S.length();
    REP(d,N){
        bool chk = true;
        REP(i,N){
            if (S[(i + d) % N] != T[i]) chk = false;
        }
        if (chk){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}

Measured memory_bytes: 256
#include<stdio.h>


  
int LCS_Length(char [] ,char []);
char X[1001],Y[1001];
int c[1001][1001];
int x,y;
int main(void){
  int i;
  int n;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%s %s",X,Y);
  
    printf("%d\n",LCS_Length(X,Y));
    
}
   
   
  return 0;
}
 
int LCS_Length(char X[] ,char Y[]){
  int i,j;
  x = strlen(X);
  y = strlen(Y);
   
  for(i=1;i<=x;i++){
    c[i][0] = 0;
  }
  for(j=0;j<=y;j++){
    c[0][j] = 0;
  }
   
  for(i=1;i<=x;i++){
    for(j=1;j<=y;j++){
      if(X[i-1]==Y[j-1]){
    c[i][j]=c[i-1][j-1]+1;
      }
      else if(c[i-1][j]>=c[i][j-1]){
    c[i][j]=c[i-1][j];
      }
      else{
    c[i][j]=c[i][j-1];
      }
    }
  }
  return c[x][y];
}

Measured memory_bytes: 4524
n, k =map(int, input().split())
ans = 0
for i in range(1, n+1):
    temp = k
    count = 0
    if temp > i: 
        while 1:
            temp /= 2
            count+= 1
            if temp <=  i :
                break
    ans +=  (1/(n * 2**(count)))
    
print(ans)

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

#define ll long long
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define sz(x) (int)x.size()
#define PI 3.14159265
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int solve(string &s, string &t, int i)
{
    int n = s.length();
    int m = t.length();
    int ans = 0;
    for (int j = 0; j < m; j++)
    {
        ans += (s[i + j] != t[j]);
    }
    return ans;
}
void solution()
{
    string s, t;
    cin >> s >> t;
    int ans = inf;
    int n = s.length(), m = t.length();
    for (int i = 0; n - i >= m; i++)
    {
        ans = min(ans, solve(s, t, i));
    }
    cout << ans << endl;
    return;
}
int32_t main()
{
    run();
    solution();
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
    bool i; cin >> i;
	cout << (!i) << endl;

	return 0;
}

Measured memory_bytes: 3672
A = [list(map(int, input().split())) for _ in range(3)]

b2_1 = A[0][1] - A[0][0]
b3_1 = A[0][2] - A[0][0]

if any([b2_1 != A[x][1] - A[x][0] for x in [1, 2]]) or any([b3_1 != A[x][2] - A[x][0] for x in [1,2]]):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  int n,a,b;
  std::cin >> n >> a >> b;
  if(n==2)   std::cout << "Borys" << '\n';
  else if((b-a-1)%2==1) std::cout << "Alice" << '\n';
  else std::cout << "Borys" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	string s;
	cin >> s;
	ll n = stoll(s);
	ll sum = 0;
	rep(i,s.size()) sum+=(s[i]-'0');
	if(n%sum == 0) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3552
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		d: usize,
		mut n: usize,
	}

	if n == 100 {
		n += 1;
	}
	match d {
		0 => println!("{}", n),
		1 => println!("{}", 100*n),
		_ => println!("{}", 100*100*n),
	}
}


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

int main(){
  string str; cin >> str;
  int len = (int)(str.length());
  int ans = 0;
  
  for(int i = 0; i < len ; i++){
    if((i+1) % 2 == 0){
      if(str[i] == 'R'){
        cout << "No" << endl;
        ans = 1;
        break;
      }
    }
    else{
      if(str[i] == 'L'){
        cout << "No" << endl;
        ans = 1;
        break;
      }
    }
  }
      
  if(ans == 0) cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int flag1 = 0,flag2=0;
	char a[4];
	string s;
	cin >> s;
	for (int j = 0; j<4; j++)
	{
		for (int i = 0; i<4; i++)
		{
			if (s.at(j) == s.at(i)) flag1++;
		}
		if (flag1 != 2)flag2 = 1;
		flag1 = 0;
	}
	if (flag2 == 0) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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

int main(){
	double T,X;
	cin >> T >> X;
	cout << T/X;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAX_N = 100;
const int MAX_V = 1000;
const int INF = 1000000005;
int w[MAX_N],v[MAX_N];
int dp[MAX_N + 5][MAX_N * MAX_V + 5];

int main()
{
	int n,W;
	for (int i = 0; i < MAX_N * MAX_V + 5; ++i)
	{
		dp[0][i] = INF;
	}
	dp[0][0] = 0;

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

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < MAX_N * MAX_V + 5; ++j)
		{
			if (j < v[i])
			{
				dp[i+1][j] = dp[i][j];
			}
			else
			{
				dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < MAX_N * MAX_V + 5; ++i)
	{
		if (dp[n][i] <= W)
		{
			ans = i;
		}

		//cout << dp[n][i] << " ";
	}


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


Measured memory_bytes: 42572
x,y,a,b,c = map(int,input().split())
p=list(map(int,input().split()))
p=sorted(p)[-x:]
q=list(map(int,input().split()))
q=sorted(q)[-y:]
r=list(map(int,input().split()))

print( sum(sorted(p+q+r)[c:]) )

Measured memory_bytes: 108140
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    char c='2';
    string s;
    cin>>s;
    int ans=0;
    rep(i,s.length()){
        if(i==0)continue;
        if(s[i]==s[i-1]){
            if(s[i]=='1')s[i]='0';
            else s[i]='1';
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

const int N = 2e4 + 11;
int dp[N] = {};
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, n;
    cin >> h >> n;
    for (int i = 0; i < N; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 0, a, b; i < n; i++) {
        cin >> a >> b;
        for (int j = 0; j + a < N; j++) {
            umin(dp[j + a], dp[j] + b);
        }
    }
    int ans = INF;
    for (int i = h; i < N; i++) umin(ans, dp[i]);
    cout << ans << '\n';
}


Measured memory_bytes: 3704
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
main(){
  while(1){
    int n,m;
    map<int,map<int,int> > star;
    pair<int,int> sxy[250];
    pair<int,int> hxy[1050];
    
    cin >> n;

    if(n==0) break;
    
    for(int i=0;i<n;i++)
      scanf("%d %d",&sxy[i].first,&sxy[i].second);
    cin >> m;
    for(int j=0;j<m;j++){
      scanf("%d %d",&hxy[j].first,&hxy[j].second);
      star[hxy[j].first][hxy[j].second]=10;
    }
    
    sort(sxy,sxy+n);
    
    int kx=sxy[0].first;
    int ky=sxy[0].second;
    
    pair<int,int> sa[205];
    
    for(int i=1;i<n;i++){
      sa[i-1].first=sxy[i].first-kx;
      sa[i-1].second=sxy[i].second-ky;
    }
    
    sort(hxy,hxy+m);
    
    int rex,rey;
    
    for(int i=0;i<m;i++){
      int co=0;
      for(int j=0;j<n-1;j++){
	if(star[hxy[i].first+sa[j].first][hxy[i].second+sa[j].second]==10) co++;
	else break;
      }
      if(co==n-1){
	rex=hxy[i].first-sxy[0].first;
	rey=hxy[i].second-sxy[0].second;
	break;
      }
    }
    
    cout << rex <<" "<<rey<<endl;
  }
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	// Code for A - UOIAUAI
	var c string
	fmt.Scanf("%s", &c)

	if c[0] == 'a' || c[0] == 'e' || c[0] == 'i' || c[0] == 'o' || c[0] == 'u' {
		fmt.Println("vowel")
	} else {
		fmt.Println("consonant")
	}
}


Measured memory_bytes: 1836
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        String[][] s = new String[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                s[i][j] = sc.next();
            }
        }
        sc.close();

        // 主処理
        String result = "";
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ("snuke".equals(s[i][j])) {
                    result = String.valueOf((char) ((int) 'A' + j)) + (i + 1);
                }
            }
        }

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int ans = 0;
  int coeff = -1;
  for(int i = 0; i < N; i++) ans += (coeff *= -1) * a[i];
  cout << ans << endl;
  return 0;
}


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

MAX_Y = 8
MAX_X = 8

def main():
    # 入力
    N = int(raw_input())

    for i , j in enumerate(range(N)):
        raw_input()

        data = []
        for j in range(MAX_Y):
            input_list = map(int, raw_input())
            data.append(input_list)
        bomb_X = int(raw_input())
        bomb_Y = int(raw_input())
        
        bomb_town = explosion(data, ((bomb_X-1, bomb_Y-1),))
        print("Data " + str(i+1) + ":")
        printBomb(bomb_town)

def printBomb(bomb):
    for x in bomb:
        print(reduce(lambda x, y: x+y, (map(str, x))))

# 盤面内か判定
def isIn(x, y):
    return 0<=x<MAX_X and 0<=y<MAX_Y

# 爆弾を爆破
def explosion(data, bomb):
    for b in bomb:
        if data[b[1]][b[0]] == 1:
            new_bomb = bom(data, b)
            burned_data = burned(data, b)
            data = explosion(burned_data, new_bomb)

    return data

# 燃やす
def burned(data, b):
    data[b[1]][b[0]] = 0
    return data

# 燃焼範囲をチェック
def bom(data, b):
    bom_area =  [(-3, 0), (-2, 0), (-1, 0), (1, 0), (2, 0), (3, 0),
                (0, -3), (0, -2), (0, -1), (0, 1), (0, 2), (0, 3)]
    new_bomb = []
    for x in bom_area:
        bomb = tuple([sum(x) for x in zip(x,b)])
        if isIn(*bomb):
            new_bomb.append(bomb)

    return new_bomb

if __name__=='__main__':
    main()

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, R; cin >> N >> R;
    if(N >= 10) cout << R << endl;
    else cout << R + 100*(10-N) << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
	int n,k,s=1,i;
	cin >> n >> k;
	for(i=0;i<n;i++){
		if(s<k)
			s*=2;
		else{
			s=s+(n-i)*k;
			break;
		}
	}
	cout << s << endl;
	return 0;
}


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

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

    int N;
    cin >> N;
    int cx = 0, cy = 0, ct = 0;
    REP(i, N) {
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(cx - x) + abs(cy - y);
        if (d > t - ct || d % 2 != (t - ct) % 2) {
            cout << "No" << endl;
            return 0;
        }
        cx = x; cy = y; ct = t;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    int ux = X;
    for (int i = 0; i < N; ++i) {
        int xi;
        cin >> xi;
        if (xi > ux) {
            ux = xi;
        }
    }
    int ly = Y;
    for (int i = 0; i < M; ++i) {
        int yi;
        cin >> yi;
        if (yi < ly) {
            ly = yi;
        }
    }
    if (ux < ly) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  int n,m;
  while(cin>>n>>m,n){
    ll land[201][201],sea[201][201];
    int a[1001];
    for(int i=0;i<201;i++){
      for(int j=0;j<201;j++){
        land[i][j]=inf;
        sea[i][j]=inf;
      }
    }
    for(int i=0;i<201;i++){
      land[i][i]=0;
      sea[i][i]=0;
    }
    for(int i=0;i<m;i++){
      int x,y;ll t;
      char sl;
      cin>>x>>y>>t>>sl;
      x--;y--;
      if(sl=='S'){
        sea[x][y]=t;
        sea[y][x]=t;
      }else{
        land[x][y]=t;
        land[y][x]=t;
      }
    }
    int r;cin>>r;
    for(int i=0;i<r;i++){
      cin>>a[i];a[i]--;
    }
    for(int k=0;k<n;k++){
      for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
          sea[i][j]=min(sea[i][j],sea[i][k]+sea[k][j]);
          land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
        }
      }
    }
    ll dp[1001][201];
    for(int i=0;i<r;i++)for(int j=0;j<n;j++)dp[i][j]=inf;
    dp[0][a[0]]=0;
    for(int i=0;i<r-1;i++){
      for(int j=0;j<n;j++){
        if(dp[i][j]==inf)continue;
        for(int k=0;k<n;k++){
          dp[i+1][k]=min(dp[i+1][k],dp[i][j]+land[a[i]][j]+sea[j][k]+land[k][a[i+1]]);
          if(j==k){
            dp[i+1][k]=min(dp[i+1][k],dp[i][j]+land[a[i]][a[i+1]]);
          }
        }
      }
    }
    /*for(int i=0;i<r;i++){
      for(int j=0;j<n;j++){
        cout<<dp[i][j]<<" ";
      }
      cout<<endl;
    }
    cout<<endl;*/
    ll ans=inf;
    for(int i=0;i<n;i++){
      ans=min(ans,dp[r-1][i]);
    }
    cout<<ans<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 5364
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
total=0
#通常のコストを計算
for i in range(1,n+2):
    total+=abs(a[i]-a[i-1])
for i in range(1,n+1):
    ans=total-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1])
    print(ans)

Measured memory_bytes: 14048
#include <iostream>
#include <vector>

int main() {
    int N, K;
    std::cin >> N >> K;

    std::vector<int> v(N);
    for (int i = 0; i < K; i++) {
        int d;
        std::cin >> d;

        for (int j = 0; j < d; j++) {
            int A;
            std::cin >> A;
            A--;
            v[A]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) if (v[i] == 0) ans++;
    std::cout << ans << "\n";
}

Measured memory_bytes: 3596
#include<stdio.h>

int main()
{
 
  int n=0,m=0,l=0;
  scanf("%d %d %d", &n, &m, &l);
 
  int i,j,A[n][m];
   
  for (i=0;i<n;i++)
  {
	  for ( j = 0 ; j < m ; j++) 
	  {
		scanf("%d", &A[i][j]);
	  }
  }
  int B[m][l];
 
  for (i=0;i<m;i++)
  {
		for(j=0;j<l;j++)
		{
			scanf("%d", &B[i][j]);
		}    
  }
 
  long sum,C[n][l];
  int k;
  sum =0;
 
  for (i=0;i<n;i++)
  {
		for (j=0;j<l;j++)
		{
		for(k=0;k<m;k++)
		{
			sum=sum+A[i][k]*B[k][j];
		}
		C[i][j]=sum;
		sum=0;
		}
  }
 
  for(i=0;i<n;i++)
  {
		for(j=0;j<l;j++)
		{
			printf("%ld", C[i][j]);
		if (j==l-1)
		{
			printf("\n");
			break;
		}
		printf(" ");
		}
  }
  return 0;
}

Measured memory_bytes: 756
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> X;
    
    rep(i,N+1){
        ll tmp; cin>>tmp;
        X.pb(tmp);
    }
    
    ll tmp=X[1]-X[0];
    rep(i,sz(X)-1){
        tmp=gcd(tmp,abs(X[i+1]-X[i]));
    }
    cout<<tmp<<endl;
}


Measured memory_bytes: 4092
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  string s[256];
  string sta;
  int n,m;
  int fl = 1;
  bool judge;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> sta;
    judge = false;
    for(int j=0;j<n;j++){
      if(sta == s[j] && fl == 1){
	cout << "Opened by " << s[j] << endl;
	fl = 0;
	judge = true;
      }
      else if(sta == s[j] && fl == 0){
	cout << "Closed by " << s[j] << endl;
	fl = 1;
	judge = true;
      }
    }
    if(!judge) cout << "Unknown " << sta << endl;
  }

}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    string str; cin >> str;
    stack<char> st;
    int ans = 0;
    rep(i, str.length()){
        if(str[i] == 'S')st.push('S');
        else{
            if(st.size() == 0) ans++;
            else st.pop();
        }
    }
    cout << ans + st.size() << endl;
}

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

int main() {
    char S[4]; for (int i = 0; i < 4; ++i) cin >> S[i];

    string res = "Good";
    if (S[0] == S[1]) res = "Bad";
    if (S[1] == S[2]) res = "Bad";
    if (S[2] == S[3]) res = "Bad";

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
YYMM=MMYY=False
if s[:2]<="12" and s[:2]>="01":
    MMYY=True
if s[2:]<="12" and s[2:]>="01":
    YYMM=True
if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>

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

int main()
{
	int N,L,e=100000,res=0;
	cin>>N>>L;
	for(int i=0;i<N;i++)
	{
		int r=L+i;
		e=abs(e)>abs(r)?r:e;
		res+=r;
	}
	cout<<res-e;
}

Measured memory_bytes: 256
/*
	Author: Luis Manuel D?az Bar?n (LUISMO)
	Problem: S - DigitSum
	Online Judge: AtCoder
	Idea: Digit DP. dp[i][j] - the amount of number-strings of lenght i such that the digSum of its digits leaves remainder rem with D.
	Numbers with leading zeros are managed as if such zeroes were "trimmed" eg. 00023 would mean
	23
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e4 + 2;


string str;
ll D;


// dp[i][j] - the amount of number-strings of lenght i such that the digSum of its digits leaves remainder rem with D
ll dp[lim][102];
bool mark[lim][102];

ll DynamicProgramming(int len, int rem)
{	
	if(len == 1)
	{		
		int cnt = 0;		
		for(int i = 0; i <= 9; i++)
			if(i % D == rem)
				cnt++;
		return cnt;
	}

	if(mark[len][rem])
		return dp[len][rem];

	// for each possible ending digit
	for(int dig = 0; dig <= 9; dig++)
	{
		int r = dig % D;
		int rr = (rem - r + D) % D; 
		ll k = DynamicProgramming(len - 1, rr);

		dp[len][rem] = (dp[len][rem] + k) % mod;
	}

	mark[len][rem] = true;
	return dp[len][rem];
}


void BruteForce()
{
	if(str.size() > 4)
		return;
	ll N = 0;
	ll ten = 1;
	for(int i = 0; i < str.size(); i++)
	{
		int idx = str.size() - 1 - i;
		N += ten * (str[idx] - '0');
		ten*= 10;
	}
	// BRUTE FORCE
	ll sansw = 0;
	for(int i = 1; i <= N; i++)
	{
		ll digSum = 0;
		int k = i;
		while(k > 0)
		{
			digSum += k % 10;
			k /= 10;
		}

		if(digSum % D == 0)
			sansw++;

		sansw %= mod;
	}

	cout << sansw << endl;
}

void solve()
{
	cin >> str >> D;
	// lenght of the number
	int sz = str.size();

	ll answ = 0;
		
	int digSum = 0; // keeps the sum of the first digits from left to right
	for(int i = 0; i < sz - 1; i++)
	{
		// current digit
		int d = str[i]-'0';
		// for each possible value (from 0 to d - 1)
		for(int j = 0; j < d; j++)
		{
			// remainder to search
			int r = (digSum + j) % D;

			ll k = DynamicProgramming(sz - 1 - i, (D - r)%D);			
			// update answer
			answ = (answ + k) % mod;
		}
		// add the current digit to the sum
		digSum = (digSum + d) % mod;
	}
	// checking the sum with the last digit
	for(int i = 0; i <= str[sz-1]-'0'; i++)
		if((digSum + i) % D == 0)
			answ++;
	// removing case 00000000....0000
	answ--;
	// printing answer
	cout << (answ + mod) % mod << endl;

	//cerr << "Brute Force Solution:" << endl;
	//BruteForce();
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


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

int main() {
  int N;
  cin >> N;
  vector<int> Mochi(N);
  for(int i = 0; i < N; i++) cin >> Mochi.at(i);
  for(int i = 1; i < N; i++){
    int temp;
    for(int j = i; j > 0; j--){
      if(Mochi.at(j) > Mochi.at(j - 1)){
        temp = Mochi.at(j - 1);
        Mochi.at(j - 1) = Mochi.at(j);
        Mochi.at(j) = temp;
      }else break;
    }
  }
  int count = 1;
  for(int i = 0; i < N - 1; i++){
    if(Mochi.at(i) != Mochi.at(i + 1)) count += 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INF = (1 << 21);
int n, m;
vector<vector<int> >v;
vector<int>color, dis, p;
int s, g, V, P;

void dijkstra(int s) {
	int minv;
	for (int i = 0; i < n; i++) {
		dis[i] = INF;
		color[i] = WHITE;
	}
	dis[s] = 0;
	color[s] = GRAY;
	while (1) {
		minv = INF;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > dis[i] && color[i] != BLACK) {
				minv = dis[i];
				u = i;
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int r = 0; r < n; r++) {
			if (color[r] != BLACK&&v[u][r] != INF) {
				if (dis[r] > dis[u] + v[u][r]) {
					dis[r] = dis[u] + v[u][r];
					color[r] = GRAY;
				}
			}
		}
	}

}


int main() {
	cin >> n >> m;
	color = p = dis = vector<int>(n);
	for (int i = 0; i < n; i++) {
		vector<int>x;
		v.push_back(x);
		for (int j = 0; j < n; j++) {
			v[i].push_back(INF);
		}
	}
	int a, b, c, d;
	char e;
	for (int i = 0; i < m; i++) {
		cin >> a >> e >> b >> e >> c >> e >> d;
		a--; b--;
		v[a][b] = c;
		v[b][a] = d;
	}
	cin >> s >> e >> g >> e >> V >> e >> P;
	s--; g--;
	V -= P;
	dijkstra(s);
	V -= dis[g];
	dijkstra(g);
	V -= dis[s];
	cout << V << endl;
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,n) for(Int i=0;i<n;++i)
using namespace std;

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

    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int numMinus = 0;
    rep(i, N) if (A[i] < 0) ++numMinus;

    Int res = 0;
    if (numMinus % 2 == 0) {
        rep(i, N) res += (A[i] > 0 ? A[i] : -A[i]);
    }
    else {
        int minAbs = INT_MAX;
        Int absSum = 0;
        rep(i, N) {
            minAbs = min(minAbs, abs(A[i]));
            absSum += (A[i] > 0 ? A[i] : -A[i]);
        }
        res = absSum - minAbs * 2;
    }

    cout << res << "\n";
}

Measured memory_bytes: 640
import sys,math
import numpy as np

r=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

print(2*math.pi*r)


Measured memory_bytes: 27124
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a[int(2e5)], cur = 0;
  long long ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (a[i] > cur) cur = a[i];
    else {
      ans += cur - a[i];
    }
  }
  cout << ans;
}

Measured memory_bytes: 4368
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    S = input()
    if S[-1] == 's':
        print(S+'es')
    else:
        print(S+'s')
if __name__ == '__main__':
    main()


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

using namespace std;
#define ll long long
#define M 1000000007



int main()
{
   string s1,s2;
   cin>>s1>>s2;
   ll n1=s1.size(),n2=s2.size();
   ll dp[n1+1][n2+1];
   for(ll i=0;i<=n1;i++)
    for(ll j=0;j<=n2;j++)
        dp[i][j]=0;
   // ll i=n1,j=n2;
   for(ll i=1;i<=n1;i++)
   {
    for(ll j=1;j<=n2;j++)
    {
        if(s1[i-1]==s2[j-1])
        {
            dp[i][j]=dp[i-1][j-1]+1;
        }
        else
        {
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
   }
   stack<char>st;
   ll i=n1,j=n2;
   while(i>0 && j>0)
   {
    if(s1[i-1]==s2[j-1])
    {
        st.push(s1[i-1]);
        i--;
        j--;
    }
    else
    {
        if(dp[i][j-1]>dp[i-1][j])
            j--;
        else
            i--;
    }
   }
   while(!st.empty())
    {cout<<st.top();
        st.pop();}
    cout<<endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
void call(int n){
    for(int i=1;i<=n;i++){
        int x=i;
        if(x%3==0)cout<<" "<<i;
        else while(x>0){
            if(x%10==3){
                cout<<" "<<i;
                break;
            }
            x/=10;
        }
    }
    cout<<endl;
}
int main(){
    int n;cin>>n;
    call(n);
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    int sm = 0, minb = INF;
    REP(i, N){
        cin >> A[i] >> B[i];
        sm += A[i];
        if(A[i] > B[i]) minb = min(minb, B[i]);
    }


    int ans = 0, f = 0;
    REP(i, N){
        if(A[i] > B[i]){
            ans += A[i] - B[i];
            f++;
        }
        else ans += A[i];
    }
    if(f == 0) ans = 0;
    else if(f >= 2){
        ans = sm - minb;
    }
    cout << ans << "\n";
    
    return 0;
}

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


void solve(long long N, long long D, std::vector<std::vector<long long>> X){
    int ans = 0;
    for(int i = 0;i < N-1;i++){
        for(int j = i+1;j < N; j++){
            float tmp = 0.0;
            for(int k = 0;k <D;k++){
                tmp += ((X[i][k] - X[j][k]) * (X[i][k] - X[j][k]));
            }
            tmp = sqrt(tmp);
            if(floor(tmp) == tmp) ans ++;
            else continue;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

const int maxn = 3005;

int n;

typedef long long LL;

const int mod = 1e9 + 7;

int dp[maxn][maxn];
char s[maxn];
int pre[maxn][maxn];

void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}


int main(){
    cin >> n;
    scanf("%s", s + 1);
    for(int i = 1;i <= n;i++){
        dp[1][i] = 1;
        pre[1][i] = dp[1][i];
        add(pre[1][i], pre[1][i - 1]);
    }
    for(int i = 2;i <= n;i++){
        for(int j = 1;j <= n - i + 1;j++){
            if(s[i - 1] == '<'){
                dp[i][j] = pre[i - 1][j];
            }else{
                dp[i][j] = (pre[i - 1][n] - pre[i - 1][j] + mod) % mod;
            }
        }
        for(int j = 1;j <= n;j++){
            pre[i][j] = dp[i][j];
            add(pre[i][j], pre[i][j - 1]);
        }
    }
    //for(int i = 1;i <= n;i++){
    //    for(int j = 1;j <= n;j++){
    //        cout << i << " " << j << " " << dp[i][j] << endl;
    //    }
    //}
    cout << dp[n][1] << endl;
    return 0;
}


Measured memory_bytes: 70144
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	ll N;
	cin >> N;
	vll A;
	ll i, j;
	for (i = 0; i < N; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	ll init = 0;
	ll sum_all = accumulate(A.begin(), A.end(), init);
	ll sum_s = A[0];
	ll sum_a = sum_all - A[0];
	ll ans = abs(sum_s - sum_a);
	for (i = 1; i < N - 1; i++){
		sum_s += A[i];
		sum_a -= A[i];
		ans = min(ans, abs(sum_s - sum_a));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint n;
  cin>>n;
  vector<char> result;
  while(n>0){
    result.push_back((n%26==0?'z':'a'+n%26-1));
    n--;
    n/=26;
  }
  reverse(result.begin(),result.end());
  for(auto c:result){
    cout<<c;
  }
  cout<<endl;


  return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i,n,N) for(ll i=(n);i<(ll) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod=1e9+7;

int main(){
	ll N;
	cin>>N;
	string a,b;
	cin>>a>>b;
	ll ans=3;
	ll st=1;
	bool flag=true;
	if(a[0]==a[1]) {
		ans=6;
		flag=false;
		st=2;
	}
	REP(i,st,N){
		if(a[i]!=b[i]){
			if(!flag) ans*=3;
			else ans*=2;
			flag=false;
			i++;
		}else{
			if(flag){
				ans*=2;
			}
			flag=true;
		}
		ans%=mod;
	}
	p(ans%mod);
	return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "5", "2 1 5 4 3" ].solve == 4 );
	assert( [ "5", "3 3 3 3 3" ].solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	auto ans = 0L;
	auto m = 0L;
	foreach( a; as )
	{
		if( a < m ) ans += m - a;
		else        m = a;
	}
	return ans;
}


Measured memory_bytes: 12196
/*
 *  author : Atul Anand   
 *  created on : Thu Apr 02 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        println(Math.min(N*A, B));
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int x, y, z;
  int k;
  cin >> x >> y >> z;
  cin >> k;
  vll a(x), b(y), c(z);

  rep(i,x) cin >> a[i];
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i];

  vll ab;
  rep(i,x) {
    rep(j,y) {
      ab.pb(a[i]+b[j]);
    }
  }
  RSORT(ab);

  vll abc;
  rep(i,min(k, sz(ab))) {
    rep(j,z) {
      abc.pb(ab[i]+c[j]);
    }
  }
  RSORT(abc);

  rep(i,k) {
    printf("%lld\n", abc[i]);
  }
  
  return 0;
}

Measured memory_bytes: 43240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			
			if (n == 0) {
				break;
			} else if (n == 1) {
				System.out.println(1);
				continue;
			} else if (n == 2) {
				System.out.println(1);
				continue;
			}
			
			int[] dp = new int[n+1];
			dp[0] = 1;
			dp[1] = 1;
			dp[2] = dp[0] + dp[1];
			
			for (int i = 3; i <= n; i++) {
				dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
			}
			
			int d = dp[n] / 10;
			int y = (d-1) / 365 + 1;
			System.out.println(y);
		}
	}
}

Measured memory_bytes: 17192
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
    }

    let r = n % 10;

    let string = match r {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => "Something else",
    };
    
    println!("{}", string);

}

Measured memory_bytes: 2120