akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()
S = [input() for _ in range(H)]

ans = 0
dy = [1, 0, -1, 0]
dx = [0, -1, 0, 1]
check = [[0]*W for _ in range(H)]

for y0 in range(H):
	for x0 in range(W):
		if S[y0][x0] ==  "." or check[y0][x0] == 1:
			continue
		cnt_black = 1
		cnt_white = 0
		check[y0][x0] = 1
		q = deque([(y0, x0)])
		while q:
			#print(q)
			y, x = q.popleft()
			for i in range(4):
				ny = y + dy[i]
				nx = x + dx[i]
				if 0 <= ny < H and 0 <= nx < W:
					if S[y][x] == "#" and S[ny][nx] == "." and check[ny][nx] == 0:
						check[ny][nx] = 1
						#print((y0, x0), (ny, nx))
						cnt_white += 1
						q.append((ny, nx))
					if S[y][x] == "." and S[ny][nx] == "#" and check[ny][nx] == 0:
						check[ny][nx] = 1
						cnt_black += 1
						q.append((ny, nx))
		ans += cnt_white*cnt_black
print(ans)


Measured memory_bytes: 12016
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	string s;
	cin >> s;
	ll cnt = 0;
	ll n = s.size();
	rep(i, n) {
		if (s.at(i) == '0') cnt++;
	}
	cout << 2 * min(cnt, n - cnt);
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < n-2; i++) {
    if (p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
    else if (p[i] > p[i+1] && p[i+1] > p[i+2]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
typedef long long ll;

int main (int argc, char **argv) {
  ll n, a, b;
  scanf("%lld %lld %lld", &n, &a, &b);
  if (a > b || (n==1 && a!=b)) {
    std::cout << "0" << std::endl;
    return 0;
  }
  ll ans = (n-2)*(b-a) + 1;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll num[10][10];
    fill(num[0], num[10], 0);
    rep2(i, 1, N){
        int j = i%10, k = i;
        while(k >= 10) k /= 10;
        num[j][k]++;
    }
    ll ans = 0;
    rep2(i, 1, 9) rep2(j, 1, 9){
        ans += num[i][j]*num[j][i];
    }
    cout << ans << endl;
}

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

void solve()
{
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; ++i) cin >> p[i];

    sort(p.begin(),p.end());
    int ans = 0;
    for (int i = 0; i < K; ++i) ans += p[i];
    cout << ans << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    // input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

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

int main()
{
  int A, B, C;
  vector<int> nums(3);
  
  for(int i = 0; i < 3; ++i)
  {
    cin >> nums.at(i);
  }
  
  sort(nums.begin(), nums.end());
  
  cout << nums.at(2) * 10 + nums.at(1) + nums.at(0) << endl;
  
  return 0;
}    

Measured memory_bytes: 256
n, k = map(int, input().split())
hash_list = [False for i in range(n)]

for i in range(k):
    d = int(input())
    okashi_list = list(map(int,input().split()))
    for j in range(d):
        having = okashi_list[j] - 1
        if not hash_list[having]:
            hash_list[having] = True

count = 0
for i in range(n):
    if not hash_list[i]:
        count += 1
        

print(count)

Measured memory_bytes: 9208
'use strict';

const main = input => {
  input = input
    .split('\n')
    .map(v => v.trim())
    .filter(v => v)
    .map(Number);
  input.shift();

  let maxProfit = input[1] - input[0];
  let min = input.shift();

  input.forEach(R => {
    maxProfit = Math.max(R - min, maxProfit);
    min = Math.min(R, min);
  });

  console.log(maxProfit);
};

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



Measured memory_bytes: 71344
def main():
    n, m = map(int, input().split())

    cities = [0 for _ in range(n)]

    for i in range(m):
        a, b = map(int, input().split())

        cities[a - 1] += 1
        cities[b - 1] += 1
    
    for bridges in cities:
        print(bridges)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
using namespace std; 
inline int gi() {
    register int data = 0, w = 1;
    register char ch = 0;
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
}
const int MAX_N = 2e5 + 5;
const int INF = 2e9; 
struct Edge { int u, v, w; } e[MAX_N << 1]; 
bool operator < (const Edge &l, const Edge &r) { return l.w < r.w; } 
int N, cnt, Q, ds[MAX_N]; 
int pa[MAX_N]; 
int getf(int x) { return x == pa[x] ? x : pa[x] = getf(pa[x]); }
long long ans = 0; 
int main () {
	N = gi(), Q = gi();
	for (int i = 1; i <= N; i++) ds[i] = INF; 
	while (Q--) { 
		int A = gi() + 1, B = gi() + 1, C = gi(); 
		e[++cnt] = (Edge){A, B, C};
		ds[A % N + 1] = min(ds[A % N + 1], C + 1); 
		ds[B % N + 1] = min(ds[B % N + 1], C + 2); 
	} 
	int pos = min_element(&ds[1], &ds[N + 1]) - ds; 
	for (int i = pos % N + 1, j = pos; i != pos; j = i, i = i % N + 1) ds[i] = min(ds[j] + 2, ds[i]); 
	for (int i = 2; i <= N; i++) e[++cnt] = (Edge){i - 1, i, ds[i]}; 
	e[++cnt] = (Edge){N, 1, ds[1]}; 
	sort(&e[1], &e[cnt + 1]);
	for (int i = 1; i <= N; i++) pa[i] = i; 
	for (int i = 1; i <= cnt; i++) {
		int u = getf(e[i].u), v = getf(e[i].v); 
		if (u == v) continue;
		ans += e[i].w, pa[u] = v; 
	} 
	printf("%lld\n", ans); 
    return 0; 
} 


Measured memory_bytes: 9600
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int m = in.nextInt();
        boolean ac[] = new boolean[n+1];
        int pen[] = new int[n+1];
        for(int i=0;i<m;i++){
            int tmp = in.nextInt();
            String s = in.next();
            if(s.charAt(0)=='A') ac[tmp] = true;
            else if(!ac[tmp]){
                pen[tmp]++;
            }
        }
        int cnt=0,sum=0;
        for(int i=0;i<=n;i++) if(ac[i]) {cnt++; sum+=pen[i];}
        out.println(cnt+" "+sum);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 41636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
};

int main()
{
    ll N, M;
    cin >> N >> M;
    UnionFind uf = UnionFind(N);
    REP(i, M) {
        ll A, B;
        cin >> A >> B;
        A--;
        B--;
        uf.unite(A, B);
    }
    ll ans = 0;
    REP(i, N) {
        ans = max(ans, (ll)uf.size(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

    string s,t;
    int a,b;
    string u;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;

    if(s==u)    cout<<a-1<<' '<<b<<endl;
    else    cout<<a<<' '<<b-1<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

string s;
int dp[30][30];

int main(){

  cin >> s;
  int ans = 3;
  rep(c, 0, s.size()){
    if(s[c] == 'w'){
      int dp[30][30];
      rep(i, 0, s.size() - c + 1){
	rep(j, 0, c+1){
	  dp[i][j] = 1;
	}
      }
      rep(i, c, s.size()){
	if(s[i] == '(') s[i] = ')';
	else if(s[i] == ')') s[i] = '(';
	else if(s[i] == '[') s[i] = ']';
	else if(s[i] == ']') s[i] = '[';
	else if(s[i] == '{') s[i] = '}';
	else if(s[i] == '}') s[i] = '{';
      }
      rep(i, 0, s.size() - c){
	rep(j, 0, c+1){
	  dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
	  rep(k, j+1, c+1){
	    if(s[c+i+1] == s[c-k]) dp[i+1][k] = max(dp[i+1][k], dp[i][j] + 2);
	  }
	  ans = max(ans, dp[i+1][j]);
	  //cout<< "a " << i+1 << " " << j << " "<< ans << " " << dp[i+1][j] << endl;
	}
      }
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1188
n = gets.to_i
s1 = gets.chomp!
s2 = gets.chomp!
mod = 10 ** 9 + 7

pattern = {"nil,tate" => 3, "nil,yoko" => 6, "tate,tate" => 2,
            "tate,yoko" => 2, "yoko,tate" => 1, "yoko,yoko" => 3}
pre = "nil"

i = 0
ans = 1
while i < n do
    if s1[i] == s2[i]
        i += 1
        ans = ans * pattern["#{pre},tate"] % mod
        pre = "tate"
    else
        i += 2
        ans = ans * pattern["#{pre},yoko"] % mod
        pre = "yoko"
    end
end

puts ans

Measured memory_bytes: 1788
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v<=w)
    {
        cout<<"NO\n";
        return;
    }
    ll diff=v-w;
    if((t*diff)>=abs(b-a))
    {
        cout<<"YES\n";
    }
    else
        cout<<"NO\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main() {
  string o,e;
  cin>>o>>e;
  int O,E;
  O=o.size();
  E=e.size();
  for(int i=0;i<E;i++){
  	cout<<o.at(i)<<e.at(i);
  }
  if((O+E)%2==0) cout<<endl;
  else cout<<o.at(O-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

void warshall_floyd(int n,vector<vector<LL>> &d) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
    LL N,M;cin >> N >> M;
    LL L;cin >> L;

    //隣接行列
    vector<vector<LL>> G(N,vector<LL>(N,INF));
    rep(i,M){
        LL a,b;cin >> a >> b;
        ll c;cin >> c;
    
        a--;b--;
        G[a][b] = c; G[b][a] = c;
    }
    rep(i,N)G[i][i] = 0;

    warshall_floyd(N,G);    //一回目の各町ごとの最短距離リスト作成

    vector<vector<LL>> path(N,vector<LL>(N,INF));     //必要燃料L以下の街間に重み1の経路を追加したグラフを作成。L以下で通過できない街の経路は自然に淘汰されている。
    rep(i,N) rep(j,N) if(G[i][j] <= L)path[i][j] = 1;

    warshall_floyd(N,path); //二回目のWFで重み1の経路を使った最短経路リストを作る。


    int Q;cin >> Q;
    rep(i,Q){
        int s,t;cin >> s >> t;
        s--;t--;

        if(path[s][t] >= 1 << 30)cout << -1 << endl;
        else cout << path[s][t] - 1 << endl;
    }


}



Measured memory_bytes: 1920
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int x = sc.nextInt();
  int y = sc.nextInt();
  if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
    System.out.println("Yes");
  else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))
    System.out.println("Yes");
  else System.out.println("No");
}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


map<ll, ll> memo;
map<ll, bool> done;

ll n, a, b, c, d;

ll dp(ll x) {
  if (done[x]) return memo[x];
  if (x == 0) return 0;
  if (x == 1) return d;

  ll res = INFll;
  if (ld(res)/d - 1 >= x) res = d*x;
  chmin(res, dp(x/2) + (x%2)*d + a);
  chmin(res, dp(x/3) + (x%3)*d + b);
  chmin(res, dp(x/5) + (x%5)*d + c);
  chmin(res, dp((x+1)/2) + (2-x%2)*d + a);
  chmin(res, dp((x+2)/3) + (3-x%3)*d + b);
  chmin(res, dp((x+4)/5) + (5-x%5)*d + c);

  done[x] = true;
  memo[x] = res;
  return res;
}


int main() {
  int t; cin >> t;
  rep(_, t) {
    done.clear();
    memo.clear();
    cin >> n >> a >> b >> c >> d;
    cout << dp(n) << "\n";
  }
  return 0;
}


Measured memory_bytes: 5332
#include<bits/stdc++.h>
using namespace std;
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int x;
    cin>>x;
    long long int a[8]={8,7,6,5,4,3,2,1};long long int count=400;
    for(long long int i=1;i<=8;i++)
    {
        if(x>=count && x<count+200)
        {
            cout<<a[i-1];return;
        }
        else
        count+=200;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    int count=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3648
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        x1: i32,
        y1: i32,
        x2: i32,
        y2: i32,
    }
    let x3 = x2 - (y2-y1);
    let y3 = y2 - (x1-x2);
    let x4 = x1 - (y2-y1);
    let y4 = y1 - (x1-x2);
    println!("{} {} {} {}",x3,y3,x4,y4);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{

    int X, A;
    cin >> X >> A;
    if (X < A)
        cout << 0 << endl;
    else
    {
        cout << 10 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, two = 1, tmp = 0;
    cin >> n >> m;
    tmp += 1900 * m + 100 * (n - m);
    while(m>0){
        two *= 2;
        m--;
    }
    cout << tmp * two << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
string s[9999];
int h,w,dp[1002][10002][3],a,b,c,d,n;
main(){
  cin>>h>>w>>n;
  r(i,w+1)s[0]+='@';
  r(i,h)cin>>s[i+1],s[i+1]='@'+s[i+1];
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++){
      r(k,3)dp[i][j][k]+=dp[i][j-1][k];
      if(s[i][j]=='J')dp[i][j][0]++;
      if(s[i][j]=='O')dp[i][j][1]++;
      if(s[i][j]=='I')dp[i][j][2]++;
    }
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      r(k,3)dp[i][j][k]+=dp[i-1][j][k];
  while(n--){
    scanf("%d%d%d%d",&a,&b,&c,&d);a--;b--;
    cout<<dp[c][d][0]-dp[a][d][0]-dp[c][b][0]+dp[a][b][0]<<' ';
    cout<<dp[c][d][1]-dp[a][d][1]-dp[c][b][1]+dp[a][b][1]<<' ';
    cout<<dp[c][d][2]-dp[a][d][2]-dp[c][b][2]+dp[a][b][2]<<endl;
  }
}

Measured memory_bytes: 19736
#include <stdio.h>

int main(void){
    int x,i,five_hundred,five,happy=0;
    scanf("%d",&x);
    five_hundred = x / 500;
    happy += five_hundred * 1000;
    x -= five_hundred * 500;

    five = x / 5;
    happy += five * 5;
    
    printf("%d\n",happy);
    return 0;
}

Measured memory_bytes: 1716
import java.util.Scanner;

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

		boolean[] table = new boolean[1000000];

		for (int i = 2; i < 1000000; i++) {
			table[i] = true;
		}
		table[0] = false;
		table[1] = false;
		for (int i = 2; i < 1000000; i++) {
			if (table[i]) {
				for (int j = i + i; j < 1000000; j += i)
					table[j] = false;
			}
		}

		while (true) {
			int a = scan.nextInt();
			int d = scan.nextInt();
			int n = scan.nextInt();

			int count = 0;
			int ans = 0;

			if (a == 0 && d == 0 && n == 0)
				break;

			for (int i = a; i < 1000000; i += d) {
				if (table[i]) {
					count++;
				}
				if (n == count) {
					ans = i;
					break;
				}

			}
			System.out.println(ans);
		}

		scan.close();
	}
}

Measured memory_bytes: 23604
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP1(i,n) for(ll i=1;i<=(ll)(n);i++)

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

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

ll power(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}

int main() {
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);

    ll n;
    cin >> n;
    ll a[n];
    REP(i,n){
        a[i] = 0;
    }
    int cons;
    for( int i = 1; i < n; i++){
        cin >> cons;
        a[cons-1]++;
    }

    REP(i,n){
        cout << a[i] << endl;
    }
   
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int arr[n];
  fi(0, n) {
    cin >> arr[i];
  }
  for(int i = 0; i < n; i++) {
    if(arr[i] == i + 1) {
      if(i < n - 1) {
        swap(arr[i], arr[i + 1]);
      }
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <boost/foreach.hpp>
using namespace std;

typedef map<string, int> container;
typedef pair<string, int> value_type;

struct second_order {
  bool operator()(const value_type& x, const value_type& y) const {
    if(x.second != y.second){
    	return x.second < y.second;
    }
    else{
      return (strcmp(x.first.c_str(), y.first.c_str()) > 0);
    }
  }
};

int main() {
  container src;
  int n;
  cin >> n;
  
  for(string x; n--; src[x]++){
    cin >> x;
  }
  
  priority_queue<value_type, vector<value_type>, second_order> que;
  pair<string, int> p;
  BOOST_FOREACH(p, src) {
    que.push(p);
  }
  
  int max = que.top().second;
  while ( !que.empty() && que.top().second == max) {
    value_type item = que.top();
    cout << item.first << endl;
    que.pop();
  }
  
  return 0;
}

Measured memory_bytes: 29552
#include<iostream>
#include<stdio.h>
using namespace std;

int paper[10][10]={0};

void small_ink(int x,int y){
  paper[y][x]++;
  if(x+1<10)paper[y][x+1]++;
  if(x-1>=0)paper[y][x-1]++;
  if(y+1<10)paper[y+1][x]++;
  if(y-1>=0)paper[y-1][x]++;
}
void midium_ink(int x,int y){
  for(int i=-1;i<2;i++){
    for(int j=-1;j<2;j++){
      if(y+i>=0 && y+i<10 && x+j>=0 && x+j<10)paper[y+i][x+j]++;
    }
  }
}
void big_ink(int x,int y){
  for(int i=-1;i<2;i++){
    for(int j=-1;j<2;j++){
      if(y+i>=0 && y+i<10 && x+j>=0 && x+j<10)paper[y+i][x+j]++;
    }
  }
  for(int i=-1;i<2;i=i+2){
      if(y+i*2>=0 && y+i*2<10)paper[y+i*2][x]++;
  }
  for(int i=-1;i<2;i=i+2){
      if(x+i*2>=0 && x+i*2<10)paper[y][x+i*2]++;
  }
}

int main(){
  int x,y,s;
  int white=0;
  int darkest=0;
  while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
    if(s==1)small_ink(x,y);
    else if(s==2)midium_ink(x,y);
    else if(s==3)big_ink(x,y);
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(paper[i][j]==0)white++;
      if(paper[i][j]>darkest)darkest=paper[i][j];
    }
  }
  cout<<white<<endl<<darkest<<endl;
}



Measured memory_bytes: 3136
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);

    foreach (i ; 0 .. 100) {
        foreach (j ; 0 .. 100) {
            if (4*i + 7*j == n) {
                writeln("Yes");
                return;
            }
        }
    }

    writeln("No");
}




























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
     int N,A,B,C,D,a,b=0,c=0;
     scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);
     for(a=0;a*A<N;a++){};
     b=a*B;
     for(a=0;a*C<N;a++){};
     c=a*D;
     if(b<c){printf("%d\n",b);}else{
         printf("%d\n",c);
     };
     return 0;
}



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


int main(){
    string S;
    cin >> S;
    int keep=0, ans=0;
    rep(i,S.size()){
        if(S.at(i) == 'A' || S.at(i) == 'C'||S.at(i) =='G'||S.at(i) == 'T'){
            keep++ ;
        }
        else{
            if(ans<keep) {
                ans = keep;
                keep = 0 ;
            }
        }
    }
    if(ans<keep) ans = keep;
    cout << ans << endl;
}

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

#define ll long long 
using namespace std;
int main(){
    ll n;
    cin>>n;
    int c2=0;
    while(n%2==0){
        n/=2;
        c2++;
    }
    int a=1,ans=0;
    for(int i=1; i<=40; i++){
        if(c2>=a){
            c2-=a;
            ans++;
            a++;
        }
        else break;
    }
    for(ll i=3; i<=sqrt(n); i+=2){
        if(n%i==0){
            int cnt=0;
            while(n%i==0){
                n/=i;
                cnt++;
            }
            int b=1;
            for(int i=1; i<=40; i++){
                if(cnt>=b){
                    cnt-=b;
                    ans++;
                    b++;
                }
                else break;
            }
        }
    }
    if(n>2 && ans==0)cout<<1<<endl;
    else if(ans!=0 && n>2)cout<<ans+1<<endl;
    else cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3676
class Node:
	def __init__(self):
		self.p = self.l = self.r = -1

def pre_order(nodes, u):
	if u == -1: return
	print(' ' + str(u), end='')
	pre_order(nodes, nodes[u].l)
	pre_order(nodes, nodes[u].r)

def in_order(nodes, u):
	if u == -1: return
	in_order(nodes, nodes[u].l)
	print(' ' + str(u), end='')
	in_order(nodes, nodes[u].r)

def post_order(nodes, u):
	if u == -1: return
	post_order(nodes, nodes[u].l)
	post_order(nodes, nodes[u].r)
	print(' ' + str(u), end='')

n = int(input())
nodes = []
for i in range(n): nodes.append(Node())
for i in range(n):
	id, l, r = map(int, input().split())
	nodes[id].l = l
	nodes[id].r = r
	if l != -1: nodes[l].p = id
	if r != -1: nodes[r].p = id
for i in range(n):
	if nodes[i].p == -1:
		rootId = i
		break
print('Preorder')
pre_order(nodes, rootId)
print()
print('Inorder')
in_order(nodes, rootId)
print()
print('Postorder')
post_order(nodes, rootId)
print()



Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 998244353
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n,k;
    cin >> n >> k;
    vector<pair<int,int> > a;
    rep(i,n){
        int x;
        cin >> x;
        a.push_back(MP(x,i+1));
    }
    sort(a.rbegin(),a.rend());
    int id = -1;
    int c = 0;
    vector<int> res;
    while(1){
        bool breakflag = 0;
        int iid = -1;
        for(int i=0;i<n;i++){
            if(a[i].second==id)continue;
            if(a[i].first==0){
                breakflag = true;
                break;
            }
            iid = a[i].second;
            res.push_back(a[i].second);
            a[i].first--;
        }
        if(breakflag)break;
        c++;
        id=iid;
        sort(a.rbegin(),a.rend());
    }
    //cerr << c << " " << k << endl;
    if(c>k){
        cout << res.size() << endl;
        rep(i,res.size()){
            cout << res[i] << " ";
        }
        cout << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1e9+7;
const int INF=1001001001;

int main() {
  string s;
  cin>>s;
  int n=s.size();
  string t;
  for(int i=0;i<n;i++){
    if(s[i]=='B'){
      if(!t.empty()){t.pop_back();}
    }
    else{t.push_back(s[i]);}
  }
  cout<<t<<endl;
  return 0;  
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
     ll n=0;
     cin>>n;
     int array[n]={0};
     for(int i=0;i<n;i++)
     cin>>array[i];
     sort(array,array+n);
    cout<<array[n/2]-array[n/2-1];
   
    }

    return 0;
}


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

void solve() {
    char b;
    cin >> b;
    if (b == 'A') cout << "T" << endl;
    else if (b == 'C') cout << "G" << endl;
    else if (b == 'G') cout << "C" << endl;
    else cout << "A" << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
int N;
int d_fe[100005], d_su[100005];
vector<vector<int> > G;

void dfs_fe(int x, int d, int par) {
  d_fe[x] = d;
  for(auto to : G[x]) {
    if(to == par) continue;
    dfs_fe(to,d+1,x);
  }
  return;
}
void dfs_su(int x, int d, int par) {
  d_su[x] = d;
  for(auto to : G[x]) {
    if(to == par) continue;
    dfs_su(to,d+1,x);
  }
  return;
}

int main()
{
  cin >> N;
  G.resize(N);
  FOR(i,0,N-1) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs_fe(0,0,-1);
  dfs_su(N-1,0,-1);
  int cnt = 0;
  FOR(i,0,N) {
    if(d_fe[i] <= d_su[i]) cnt++;
  }
  cout << (cnt > N - cnt ? "Fennec" : "Snuke") << endl;
  return 0;
}

Measured memory_bytes: 11136
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s1=S()
  s2=S()

  if s1==s2[:-1]:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 10632
h,w=map(lambda x:range(int(x)),input().split())
g=[[c=='.'for c in input()]for _ in h]
a=[[-3]*len(w)for _ in h]
for i in h:
  l=r=0
  for j in w: l=-~l*g[i][j]; a[i][j]+=l; r=-~r*g[i][~j]; a[i][~j]+=r
for i in w:
  d=u=0
  for j in h: d=-~d*g[j][i]; a[j][i]+=d; u=-~u*g[~j][i]; a[~j][i]+=u
print(max(a[i][j] for i in h for j in w))

Measured memory_bytes: 111452
import math
a,b,h,m=map(int,input().split())

ti=h*30+m*0.5
oo=m*6

#print(ti,oo)

kakudo = abs(ti-oo)-max(0,(abs(ti-oo)-180)*2)
#print(kakudo)

#print(math.cos(kakudo))

c=a**2+b**2 - 2*a*b*math.cos(math.radians(kakudo))
print(c**0.5)

Measured memory_bytes: 9508
#include<iostream>
#include<map>

int main()
{
  std::map<std::string,int> count;
  std::string run;
  int maxlen=0;
  std::string maxstr;
  while(std::cin>>run)
  {
    if(run.size()>maxlen)
    {
      maxlen = run.size();
      maxstr = run;
    }
    if(count.find(run)!=count.end())
      ++count[run];
    else
      count[run]=0;
  }
  std::map<int,std::string> rcount;
  std::map<std::string, int>::iterator itr;
  for(itr=count.begin();itr!=count.end();++itr)
    rcount.insert(std::pair<int,std::string>(itr->second,itr->first));
  std::map<int,std::string>::iterator print=rcount.end();;
  std::cout<<(--print)->second<<" "<<maxstr<<std::endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  ll A, B;
  IN(A,B);

  OUT(max({A+B, A-B, A*B}));

  return 0;
}

Measured memory_bytes: 256
var cc : array [0..100] of int64;
    i,j,k,n : int64 ;
begin
 readln(n) ;
 cc[0]:=2;
 cc[1]:=1;
 for i:=2 to n do
  cc[i]:=cc[i-1]+cc[i-2];
 writeln(cc[n]);
end.

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int c=0;
    rep(i,N-2){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') c++;
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    vector<bool> removed_h(h,false);
    vector<bool> removed_w(w,false);
    rep(i,h) {
        string s = a[i];
        bool flag = true;
        rep(j,s.size()) if(s[j] == '#') flag = false;
        if(flag) removed_h[i] = true;
    }
    rep(i,w) {
        bool flag = true;
        rep(j,h) if(a[j][i] == '#') flag = false;
        if(flag) removed_w[i] = true;
    }
    rep(i,h) {
        if(removed_h[i]) continue;
        string s = a[i];
        rep(j,w) if(!removed_w[j]) cout << s[j];
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N,M,max,tmp;
    string str;
    max = 0;
    tmp = 0;
 
    cin >> N;
 
    map<string,int> B;
    map<string,int> R;
    
    
    for(int i = 0; i < N; i++){
        cin >> str;
        B[str]++;
    }
  
  	cin >> M;
 
    for(int i = 0; i < M; i++){
        cin >> str;
        R[str]++;
    }
 
    auto begin = B.begin(), end = B.end();
 
    for(auto iter = begin; iter != end; iter++){
        tmp = B[iter->first] - R[iter->first];
        if(tmp > max) max = tmp;
        tmp = 0;
    }
    
    cout << max << endl;
 
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
using namespace std;

const ll INF = 1e18;

int main(){

ll a, b, c, k;

cin >> a >> b >> c >> k;

if(k % 2 == 0) {cout << a - b;}
else {cout << b - a;}

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


ll light(ll a, ll b){
    if(a==b)return a*3;
    if(a==0)return 0;
    ll m=max(a,b),n=min(a,b);
    return n*(m/n)*3+light(m%n,n);
}

int main(){
    
    ll N,X;
    cin>>N>>X;
    
    cout<<light(X,N-X)<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = vals[0];
            var B = vals[1];
            var P = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var first = P.Where(x => x <= A).Count();
            var second = P.Where(x => x >= A + 1 && x <= B).Count();
            var third = P.Where(x => x >= B + 1).Count();

            Console.WriteLine(Math.Min(Math.Min(first, second), third));
        }

    }
}
//A

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,arra[]={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};
    cin>>k;
    cout<<arra[k-1]<<endl;
}


Measured memory_bytes: 256