akhauriyash/Code-Regression huggingface dataset:
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            var ta = InputNumList();
            var h = InputNumList();

            double ansT = 100000000;
            int ans = -1;
            for (int i = 0; i < n; i++)
            {
                double tmp = 0;
                tmp = ta[0] - 0.006 * h[i];
                if (Math.Abs(tmp - ta[1]) < ansT)
                {
                    ans = i + 1;
                    ansT = Math.Abs(tmp - ta[1]);
                }
            }

            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13340
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>




int ASCttenannoryaku(const void *a,const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void)
{
	int a, b;
	int ans = -1;
	scanf("%d%d",&a,&b);
	for (int i = 0; i < 1010; i++) {
		if ((int)(i*0.08)==a&&(int)(i*0.1)==b) {
			ans = i;
			break;
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;
    Vec cnt(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        cnt[a]++;
        cnt[b]++;
    }
    rep(i,n){
        out(cnt[i]);
    }
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

    int l[N], i;
    for(i=0; i<N; i++) {
        cin >> l[i];
    }

    sort(l, l+N, greater<int>());

    int sum=0;
    for(i=0; i<K; i++) {
        sum += l[i];
    }

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <iterator>

using namespace std;

int main() {
	set<int> A, B;
	set<int> V;
	int n, m;
	int x;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		A.insert(x);
	}

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> x;
		B.insert(x);
	}
	
	set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(V, V.end()));
	   
	for (auto it = V.begin(); it != V.end(); it++) 
		cout << *it << endl;
}


Measured memory_bytes: 31228
#include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
int main() {
    int n, c, k; cin >> n >> c >> k;
    vector<int> t(n); repeat (i,n) cin >> t[i];
    whole(sort, t);
    int cnt = 0;
    int l = 0;
    while (l < n) {
        int r = l;
        while (r < n and r - l < c and t[r] <= t[l] + k) ++ r;
        ++ cnt;
        l = r;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		
		long ans=1;
		long mod=1000000007L;
		for(int i=1;i<=n;i++) {
			ans*=i;
			ans%=mod;
		}
        System.out.println(ans);
		
	}
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 21204
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int ans;

    if(a>b && a>c){
      ans = b + c;
    }else if (b>a && b>c) {
      ans = a + c;
    }else{
      ans = a + b;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int k;
vector<ll> solve(ll low,ll high) {
    vector<ll> res;
    stack<ll> tmp;
    int cnt=0;
    for(long long i=0;i<10;i++)
        tmp.push(i);
    while(tmp.size()){
        long long val=tmp.top();
        tmp.pop();
        if(val>=low && val<=high){
            res.push_back(val);
            cnt++;
        }
        if(val==0)
            continue;
        if(val>high)
            continue;
        long long mod=val%10;
        if(mod>0)
            tmp.push(val*10+mod-1);
        tmp.push(val*10+mod);
        if(mod<9)
            tmp.push(val*10+mod+1);
    }
    sort(res.begin(),res.end());
    return res;
}
    
int main(){
    ios::sync_with_stdio(0); 
    cin.tie(0);
    cout.tie(0);
    cin>>k;
    vector<ll> ans=solve(1,3234566667);
    cout<<ans[k-1]<<'\n';
}

Measured memory_bytes: 1400
from itertools import combinations

def solve():
  N, K = map(int, input().split())
  vertices = [tuple(map(int, input().split())) for _ in [0]*N]
  sorted_v = sorted(vertices)
  result = float("inf")

  for l in combinations(sorted_v, min(4, K)):
    xs = sorted(x for x, y in l)
    ys = sorted(y for x, y in l)
    min_x, max_x = xs[0], xs[-1]
    min_y, max_y = ys[0], ys[-1]
    if sum(1 for x, y in vertices if min_x <= x <= max_x and min_y <= y <= max_y) >= K:
      s = (max_x - min_x) * (max_y - min_y)
      if result > s:
        result = s
  print(result)

if __name__ == "__main__":
  solve()

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

typedef long long ll;

const ll INF = 1e10;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;
  std::vector< std::vector<ll> > vopen(N, std::vector<ll>(10, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 10; x++) {
      std::cin >> vopen[y][x];
    }
  }
  std::vector< std::vector<ll> > vp(N, std::vector<ll>(11, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 11; x++) {
      std::cin >> vp[y][x];
    }
  }

  ll ans = -INF;
  for (ll S = 1; S < std::pow(2, 10); S++) {
    ll benefit = 0;
    for (ll y = 0; y < N; y++) {
      ll cnt = 0;
      for (ll k = 0; k < 10; k++) {
	ll x = S >> k;
	if (x & 1 && vopen[y][k] == 1) {
	  cnt++;
	}
      }
      benefit += vp[y][cnt];
    }
    ans = std::max(ans, benefit);
  }

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


Measured memory_bytes: 256
N = int(input())
ans = 0
C = [[0 for j in range(10)] for i in range(10)]

for k in range(N+1):
    sk = str(k)
    C[int(sk[0])][int(sk[-1])] += 1

for i in range(10):
    for j in range(10):
        if i == j == 0:continue
        ans += C[i][j] * C[j][i]

print(ans)

Measured memory_bytes: 40428
from collections import deque
S = deque(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:S.appendleft(query[4])
if rev == 1: S.reverse()  
print("".join(S))    
    

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

using namespace std;
const int MAXN = 100010;
int n;
vector<int> graph[MAXN];
bool visited[MAXN];
int dist1[MAXN];
int distn[MAXN];

void init() {
  for (int i=0;i<MAXN;i++) {
    visited[i] = false;
  }
}

void dfs(int x, int level, bool startFrom1) {
  visited[x] = true;
  if (startFrom1) {
    dist1[x] = level;
  } else {
    distn[x] = level;
  }
  for (int i=0;i<graph[x].size();i++) {
    int next = graph[x][i];
    if (!visited[next]) {
      dfs(next, level + 1, startFrom1);
    }
  }
}

void solve() {
  init();
  dfs(0, 0, true);
  init();
  dfs(n-1, 0, false);
  int closeTo1 = 0;
  int closeToN = 0;
  for (int i=0;i<n;i++) {
    if (dist1[i] <= distn[i]) {
      closeTo1++;
    } else {
      closeToN++;
    }
  }
  if (closeTo1 > closeToN) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
}

int main() {
  int a, b;
  cin >> n;
  for (int i=0;i<n-1;i++) {
    cin >> a >> b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  solve();
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){
    int N,K;
    cin >> N >> K;
    double ans = 0;
    for (int i=1;i<=N;i++) {
        int cnt = 0;
        int s = i;
        while(s<K) {
            s*=2;
            cnt++;
        }
        ans += pow(0.5,cnt);

    }
    ans /= N;
    cout << fixed << setprecision(10) <<ans << endl;



}





Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B;
	cin >> A >> B;

	int diff = B - A;
	cout << (diff + 1) * diff / 2 - B << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

const ll MOD = 998244353;

int main() {
  ll N;
  cin >> N;
  ll S;
  cin >> S;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }

  vvi dp(N + 1, vi(S + 1, 0));
  // dp[i+1][j] := i番目までの整数の中からいくつかの整数を選んで、
  // 総和がjとする方法をすべて考えたときの、方法の数.
  // dp[i+1][j] = dp[i][j] + dp[i][j-A[i]]
  // O(NS) = O(9e6)

  dp[0][0] = 1;

  for (ll j = 0; j <= S; j++) {
    for (ll i = 0; i < N; i++) {
      if (j >= A[i])
        dp[i + 1][j] = dp[i][j] * 2 + dp[i][j - A[i]];
      else
        dp[i + 1][j] = dp[i][j] * 2;

      dp[i + 1][j] %= MOD;
    }
  }

  cout << dp[N][S] << endl;
}


Measured memory_bytes: 73628
/**
 *  Kaiwen Zhou,
 *  CUHK
**/
#include <bits/stdc++.h>
using namespace std;
#define INS ios::sync_with_stdio(false);cin.tie(0)
typedef long long LINT;
#define INF 1000000000000

int main(void) {
    INS;
    LINT n, a, b, c;
    cin >> n;
    LINT dp[n][3];
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(int i = 1; i < n; i ++) {
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a);
        dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b);
        dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c);
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << '\n';
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  }
}


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

int main(void)
{
	char c;
	string str;

	while(scanf("%c", &c), c != '\n'){
		if(c >= 'a' && c <= 'z')
			c += 'A' - 'a';
		str.push_back(c);
	}
	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
     ll n;
    cin>>n;
    ll p[14];
    p[0]=1;
    p[1]=26;
    for(ll i=2;i<=13;i++)
        p[i]=p[i-1]*26;
    ll sz=1;
    while(true)
    {
        if(n>=p[sz])
        {
            n-=p[sz];
            if(n==0)
            {
                n+=p[sz];
                break;
            }
        }
        else
        {
            break;
        }
        sz++;
    }
    //cout<<sz<<' '<<n<<endl;;
    string ans;
    for(ll i=1;i<=sz;i++)
    {
        ll now=0;
        now=p[sz-i];

        for(char c='a';c<='z';c++)
        {
            if(n>=now)
            {
                n-=now;
                if(n==0)
                {
                    ans+=c;
                    n+=now;
                    break;
                }
            }
            else
            {
                ans+=c;
                break;
            }
        }
    }
    cout<<ans;
}


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

int main()
{
	int mmax, n;
	cin >> mmax >> n;
	int l, r;
	cin >> l >> r;
	int L = l, R = r;
	for (int i = 1; i < n; ++i)
	{
		cin >> l >> r;
		if (R<l || L>r)
		{
			R = L - 1; break;
		}
		L = max(L, l), R = min(r, R);

	}
	cout << R - L + 1;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans=0;
    while(a>=b){
        b *= 2;
        ans++;
    }
    while(b>=c){
        c *= 2;
        ans++;
    }
    if(ans <= k){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int H,W;
int sum;
char temp;
char garden[100][100];
void dfs(int x,int y){
	temp=garden[x][y];
	garden[x][y]='a';
	for(int i=-1;i<=1;i++)
	for(int j=-1;j<=1;j++)
	{
		if((i==0)&&(j!=0)||(i!=0)&&(j==0))
		{
			if((x+i>=0)&&(y+j>=0)&&(x+i<H)&&(y+j<W)&&(garden[x+i][y+j]!='a')&&(garden[x+i][y+j]==temp)){
				dfs(x+i,y+j);
			}
		}
	}
}
void solve(){
	while(cin>>H>>W){
		if(H==0) break;
		for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		cin>>garden[i][j];
		sum=0;
		for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		if(garden[i][j]!='a')
		{
			sum++;
			dfs(i,j);
		}
		cout<<sum<<endl;
	}
}
int main(){
	solve();
}


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

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

    string s;
    cin >> s;
    
    int n = s.size();
    map<char, int> mp;
    for(int i = 0; i < n; i++){
        mp[s[i]]++;
    }

    int ma = 0, mi = 1e9;
    for(auto x : mp){
        ma = max(ma, x.second);
        mi = min(mi, x.second);
    }

    if(mp.size() == 1){
        if(n > 1) cout << "NO" << endl;
        else cout << "YES" << endl;
        return 0;
    }

    if(mp.size() == 2){
        if(ma == mi and n == 2) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }

    if(ma - mi <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int solve(const VI &pop) {
  if(pop[0] != 0 || pop[12] >= 2) {
    return 0;
  }
  REP(i,1,12) {
    if(pop[i] >= 3) {
      return 0;
    }
  }
  int ans = -1;
  REP(i,0,1<<11) {
    VI place({0,24});
    if(pop[12]) {
      place.push_back(12);
    }
    REP(t,1,12) {
      if(pop[t] == 1) {
        if((i >> (t-1)) & 1) {
          place.push_back(t);
        } else {
          place.push_back(24-t);
        }
      } else if(pop[t] == 2) {
        place.push_back(t);
        place.push_back(24-t);
      }
    }
    sort(place.begin(), place.end());
    int m = 1000;
    REP(j,1,place.size()) {
      m = min(m, place[j] - place[j-1]);
    }
    ans = max(ans, m);
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  VI pop(13);
  REP(i,0,N) {
    int d;
    cin >> d;
    pop[d]++;
  }
  cout << solve(pop) << endl;
  
  return 0;
}


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

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

  int H, W, N, ans;
  cin >> H >> W >> N;

  if(H > W) ans = (N + H - 1) / H;
  else ans = (N + W - 1) / W;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3576
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        char[] charArray = scan.next().toCharArray();
        if(charArray.length < 1 || charArray.length > 10) {
            System.exit(-1);
        }
        List<String> list = new ArrayList<String>();
        for(char ch: charArray) {
            if( ch == '0' || ch == '1') {
                list.add(String.valueOf(ch));
            } else if ( ch == 'B' && list.size() > 0) {
                list.remove(list.size()-1);
            }
        }
        if (list.size() == 0) {
            System.exit(-2);
        }
        System.out.println(String.join("", list));
    }
}

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

typedef long long ll;

// chmax, chmin
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; }

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    int right = 1;
    ll sum = A[0];
    ll ans = 0;
    for ( int left = 0; left < N; ++left ){
        while ( right < N and (( sum ^ A[right] ) == ( sum + A[right] ))){
            sum += A[right];
            ++right;
        }
        // 現時点で[left,right)が条件を満たす
        ans += ( right - left );
        
        // left をインクリメントする条件
        if ( left + 1 == right ){
            right = left + 2;
            sum = A[left+1];
        } else {
            sum -= A[left];
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4844
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}

int main() {
    char s;
    cin>>s;
    if(s=='A')cout<<'T';
    else if(s=='T')cout<<'A';
    else if(s=='C')cout<<'G';
    else if(s=='G')cout<<'C';
    return 0;
}

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

int main(){
  long int A;
  cin >> A;
  long int a[A];
  for(int i=0;i<A;i++){
    cin >> a[i];
  }
  for(int y=A;y>0;y--){
    if(y!=A){
      cout << " " ;
    }
    cout << a[y-1] ;
  }
  cout << endl;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
using namespace std;
#define rep(i,a,b) for(i=a;i<=b;i++)
#define INF 2100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define sz(x) ((int)(x).size())
int glid[4545][4545],leng[4545];
typedef pair<int,int> PPAP;
int main(void)
{
	int n,k,i,j,kk;
	int a,b,c,d,cost,go,ff;
	while(cin>>n>>k&&n&&k) {
		rep(i,1,n)rep(j,1,n)glid[i][j]=INF;
		rep(i,1,k) {
			cin>>a;
			rep(j,1,n) leng[j]=INF;
			if(a==1) {
				cin>>b>>c>>d;
				glid[b][c]=min(glid[b][c],d);
				glid[c][b]=min(glid[c][b],d);
			}
			else {
				cin>>b>>c;
				leng[b]=0,ff=0;
				priority_queue<PPAP,vector<PPAP>,greater<PPAP> > que;
				que.push(PPAP(0,b));
				while(!que.empty()) {
					go=que.top().sec;
					que.pop();
					if(go==c) {
						ff=1;
						break;
					}
					rep(j,1,n) {
						if((leng[go]+glid[go][j])<leng[j]) {
							leng[j]=leng[go]+glid[go][j];
							que.push(PPAP(leng[j],j));
						}
					}
				}
				if(ff==0) cout<<"-1"<<endl;
				else cout<<leng[c]<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
int calc(int x){
	int c=0;
//	for(int i=2;i<=x;++i)if(x%i==0)for(++c;x%i==0;x/=i);
	for(int i=2;i<=x;++i)if(x%i==0)for(;x%i==0;++c,x/=i);
	return c;
}
const int N=505;
typedef long long ll;
int a[N*2],aa[N*2],xb,i,j,n;ll b[N][N];
inline ll lcm(ll a,ll b){
	return a/std::__gcd(a,b)*b;
}
inline void spj(){
	unordered_set<ll>s;
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)s.insert(b[i][j]),
		assert(b[i][j]<=1e15);
	assert(s.size()==n*n);
	for(i=1;i<=n;++i)for(j=1;j<n;++j)assert(max(b[i][j],b[i][j+1])%min(b[i][j],b[i][j+1])==1); 
	for(i=1;i<n;++i)for(j=1;j<=n;++j)assert(max(b[i+1][j],b[i][j])%min(b[i+1][j],b[i][j])==1); 
}
int main(){
	scanf("%d",&n);
	if(n==2){
		puts("4 7\n23 10");
		return 0;
	}
	int l=0,r=n*2+1;
	for(i=2;xb<n*2;++i)if(calc(i)<2)a[++xb]=i;
	
	for(i=1;i<=n;++i)for(j=1;j<=n;++j){
		int x=i+j,y=i-j+n;
		if(x&1)b[i][j]=a[x/2]*a[n+(y+1)/2];
		if(x%2==1 && abs(i-2)+abs(j-222)==1){
			++i,--i;
		}
	}
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)if((i+j)%2==0){
		ll ans=1;
		if(i>1)ans=lcm(ans,b[i-1][j]);
		if(i<n)ans=lcm(ans,b[i+1][j]);
		if(j>1)ans=lcm(ans,b[i][j-1]);
		if(j<n)ans=lcm(ans,b[i][j+1]);
		if(ans>1ll*a[n*2]*a[n*2-1]*a[n]*a[n-1]) {
			++i,--i;
		}
		b[i][j]=ans+1;
	}
	spj();
	for(i=1;i<=n;++i,puts(""))for(j=1;j<=n;++j)printf("%lld ",b[i][j]);
	return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int p[200010];
int a[200010], b[200010];

int main() {
	cin >> N;
	rep(i, N) a[i] = b[N-1-i] = N * i;

	rep(i, N) {
		cin >> p[i]; --p[i];
		a[p[i]] += i;
	}

	rep(i, N) cout << a[i] + 1 << (i == N-1 ? '\n' : ' ');
	rep(i, N) cout << b[i] + 1 << (i == N-1 ? '\n' : ' ');	

	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
    int n,x,k;double sum=0;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        for( x=0;;x++)
        {
            if(i*(int)pow(2,x)>=k)
            {
             break;
            }
        }
        sum+=pow(0.5,x)*(1/(double)n);
    }
    printf("%.12lf",sum);
}

Measured memory_bytes: 128
s = gets.chomp
n = s.size
ans = Array.new(n, 0)

c = 0
x = 0
(n - 1).times do |i|
    c += 1
    if s[i] == "R" && s[i+1] == "L"
        x = i
        ans[x] += (c + 1) / 2
        ans[x + 1] += c / 2
        c = 0
    elsif s[i] == "L" && s[i+1] == "R"
        ans[x] += c / 2
        ans[x+1] += (c + 1) / 2
        c = 0
    end
end

c += 1
ans[x] += c / 2
ans[x + 1] += (c + 1) / 2

puts ans.join(" ")

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

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 2e5;
const int maxn = 1e5 + 5;
ll mod = 1e9 + 7;

struct Edge
{
	int u, v, nxt;
	Edge(int _u = 0, int _v = 0, int _nxt = 0)
	{
		u = _u;
		v = _v;
		nxt = _nxt;
	}
}edg[maxn << 1];
int n, m, q;
int g[maxn], ecnt;
struct QRY
{
	int u, d, c;
}qry[maxn];

int vis[maxn][11],col[maxn];
void color(int u, int d, int c)
{
	if (vis[u][d]) return;
	vis[u][d] = 1;
	if (!col[u]) col[u] = c;
	if (!d) return;
	
	for (int i = g[u]; ~i; i = edg[i].nxt)
	{
		int &v = edg[i].v;
		color(v, d - 1, c);
	}
}

int main()
{
	memset(g, ecnt = -1, sizeof(g));
	scanf("%d%d", &n, &m);
	while (m--)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		edg[++ecnt] = Edge(u, v, g[u]); g[u] = ecnt;
		edg[++ecnt] = Edge(v, u, g[v]); g[v] = ecnt;
	}
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) scanf("%d%d%d", &qry[i].u, &qry[i].d, &qry[i].c);

	while (q)
	{
		color(qry[q].u, qry[q].d, qry[q].c);
		q--;
	}
	for (int i = 1; i <= n; i++) printf("%d\n", col[i]);
}


Measured memory_bytes: 9216
import java.util.ArrayDeque
import kotlin.Comparator
import kotlin.String

fun main(args: Array<String>) {
    val s = readString()
    val q = readInt()
    val query = List(q) { readStringList() }

    val ans = ArrayDeque<Char>()
    s.forEach { ans.addLast(it) }
    var reverse = false
    query.forEach {
        when (it[0]) {
            "1" -> {
                if (ans.size > 1) {
                    reverse = !reverse
                }
            }
            "2" -> {
                if (reverse) {
                    when (it[1]) {
                        "1" -> ans.addLast(it[2][0])
                        "2" -> ans.addFirst(it[2][0])
                    }
                } else {
                    when (it[1]) {
                        "1" -> ans.addFirst(it[2][0])
                        "2" -> ans.addLast(it[2][0])
                    }
                }
            }
        }
    }
    if (reverse) {
        println(ans.reversed().joinToString(separator = ""))
    } else {
        println(ans.joinToString(separator = ""))
    }
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


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

#define pb push_back
#define pbk pop_back
#define mk_pr make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<string> vss;
typedef queue<int> qi;

const int MX = 123456;
int ar[130], dp[120][10050];

int ff( int i, int sm ) {
        if( i == 0 ) {
                if( sm%10 == 0 ) return 0;
                else return sm;
        }
        if( dp[i][sm] != -1 ) return dp[i][sm];
        return dp[i][sm] = max( ff(i-1, sm+ar[i]), ff(i-1, sm) );
}

int main() {
        ios_base :: sync_with_stdio(0); cin.tie(0);
        int n;
        cin >> n;
        for(int i=1; i<=n; i++) cin >> ar[i];
        memset(dp, -1, sizeof dp);
        int ans = ff(n, 0);
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
  int N,L; cin >> N >> L;
  vector<int> aji(N);
  int sum = 0;
  vector<pair<int,int>> m(N);
  rep(i,N){
    aji[i] = L + i;
    m[i].first = abs(aji[i]);
    m[i].second = i;
    sum += aji[i];
  }
  sort(m.begin(),m.end());
  int res = sum -= aji[m[0].second];
  cout << res << endl;

}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        x: [i64; n],
    }

    let mut ans = std::i64::MAX;
    for i in 0..n - k + 1 {
        // println!("edge: {} {}", x[i], x[i+k-1]);
        let dist = if x[i] * x[i + k - 1] < 0 {
            (x[i] - x[i + k - 1]).abs() + x[i].abs().min(x[i + k - 1].abs())
        } else {
            x[i].abs().max(x[i + k - 1].abs())
        };
        if dist < ans {
            ans = dist;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3608
##templete
n = gets.chomp.to_i
s = gets.chomp.split("")


def group(a)
  head = a[0]
  count = 0
  lst = []
  for i in a do
    if head == i
      count += 1
    else
      lst.push(count)
      head = i
      count = 1
    end
  end
  lst.push(count)
  lst.unshift(0) if a[0] == "#"
  lst.push(0) if lst.length % 2 == 1
  return lst
end

def sum_white_black(lst)
  black = 0
  white = 0

  for i in 0..lst.length-1 do
    black += lst[i] if i % 2 == 1
    white += lst[i] if i % 2 == 0
  end

  return [black, white]
end

lst = group(s)
arr = []
sum_b, sum_w = sum_white_black(lst)
if sum_w == 0 || sum_b == 0
  puts 0
  exit 0
end
black = 0
white = sum_w
ans = 1000000000
for i in 0..lst.length-1 do
  black += lst[i] if i % 2 == 1
  white -= lst[i] if i % 2 == 0
  ans = ans < (black + white) ? ans : (black + white)
end

puts ans


Measured memory_bytes: 14516
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 410;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

ll A[N],pre[N];
ll dp[N][N];
ll INF = 1e18+5;
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,m;
    cin>>n;
    rep(i,1,n){
        cin>>A[i];
        pre[i]=pre[i-1];
        pre[i]+=A[i];
    }
    rep(i,1,n)rep(j,1,n)dp[i][j]=INF;

    rep(i,1,n)dp[i][i]=0;
    rep(i,1,n-1)dp[i][i+1]=A[i]+A[i+1];
    int sz=0;
    rep(sz,3,n)
    {
        rep(i,1,n)
        {
            int en = i+sz-1;
            if(en>n)break;

            for(int j=i+1;j<=en;j++)
            {
                dp[i][en]= min(dp[i][en],dp[i][j-1]+dp[j][en]+pre[en]-pre[i-1]);
            }

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


    
    return 0;
}


Measured memory_bytes: 1536
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> vp;
	while (n--)
	{
		int a, b;
		cin >> a >> b;
		vp.emplace_back(a, b);
	}
	sort(vp.begin(), vp.end());
	LL ans = 0;
	for (auto& p : vp)
	{
		int o = min(p.second, m);
		m -= o;
		ans += 1LL * o * p.first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,k;
    cin>>h>>w>>k;
    vector<string> v(h);
    FOR(i,0,h)cin>>v[i];

    vector<ll> f(h,1);
    FOR(i,0,h){
        FOR(j,0,w){
            if(v[i][j] == '#') f[i] = 0;
        }
    }

    ll x = 1;
    vector<vector<ll>> ans(h, vector<ll> (w));
    FOR(i,0,h){
        ll sharp = 0;
        FOR(j,0,w){
            if(f[i] == 1) ans[i][j] = 0;
            else{
                if(sharp == 0){
                    ans[i][j] = x;
                    if(v[i][j] == '#') sharp = 1;
                }
                else{
                    if(v[i][j] == '#')x++;
                    ans[i][j] = x;
                }
            }
        }
        if(f[i] == 0)x++;
    }
    FOR(i,1,h){
        FOR(j,0,w){
            if(ans[i][j] == 0)ans[i][j] = ans[i-1][j];
        }
    }
    FORr(i,0,h-2){
        FOR(j,0,w){
            if(ans[i][j] == 0)ans[i][j] = ans[i+1][j];
        }
    }
    

    FOR(i,0,h){
        FOR(j,0,w){
            cout<<ans[i][j];
            if(j != w-1)cout<<" ";
            else cout<<endl;
        }
    }

}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;

  int w[n+2] = {};
  int e[n+2] = {};
  for (int i = 1; i < n+1; i++) {
    w[i] = w[i-1];
    if (s[i-1] == 'W') {
      w[i]++;
    }
    e[n+1-i] = e[n+2-i];
    if (s[n-i] == 'E') {
      e[n+1-i]++;
    }
  }

  // cout << "W:" << endl;
  // for (int i=0; i<n+2; i++) {
  //   printf("%d,", w[i]);
  // }
  // cout << endl;

  // cout << "E:" << endl;
  // for (int i=0; i<n+2; i++) {
  //   printf("%d,", e[i]);
  // }
  // cout << endl;

  int ans = INT_MAX;
  for (int i = 1; i < n+1; i++) {
    int tmp = w[i-1] + e[i+1];
    if (tmp < ans) {
      ans = tmp;
    }
  }

  cout << ans << endl;

  return 0;
}


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

char Acid(const char c) {
  switch (c) {
  case 'A': return 'T';
  case 'T': return 'A';
  case 'C': return 'G';
  case 'G': return 'C';
  }
  return '\0';
}

int main() {
  char b;
  cin >> b;
  cout << Acid(b) << "\n";
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const pair<int, int> &element1, const pair<int, int> &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
/*int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}*/
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}
int dx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
//using Graph = vector<vector<int>>;

int main()
{
	int H, W;
	cin >> H >> W;
	string A[H];
	rep(i, H)
	{
		cin >> A[i];
	}
	queue<P> que;
	int ans = 0;
	int dist[H][W];
	rep(i, H)
	{
		rep(j, W)
		{
			dist[i][j] = -1;
			if (A[i][j] == '#')
			{
				//黒ならqueに突っ込み、初期化
				que.push(make_pair(i, j));
				dist[i][j] = 0;
			}
		}
	}

	while (!que.empty())
	{
		pair<int, int> v = que.front(); //先頭を取り出す
		que.pop();
		int x = v.first, y = v.second;
		rep(i, 4)
		{
			//4方向へ移動
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx < 0 || nx >= H || ny < 0 || ny >= W)
			{//範囲内で
			}
			else if (A[nx][ny] == '#')
			{//黒くない
			}
			else
			{

				que.push(make_pair(nx, ny));
				//黒くなったのでqueに入れる
				dist[nx][ny] = dist[x][y] + 1;
				//距離を更新
				ans = dist[nx][ny];	
				//最大値を更新
				A[nx][ny] = '#';
			}
		}
	}
	print(ans);
}

Measured memory_bytes: 13456
n = int(input())
d, x = map(int, input().split())
ls_a = [int(input()) for _ in range(n)]

cnt = 0

for i in range(n):
    for j in range(101):
        if 1 + j * ls_a[i] <= d:
            cnt += 1
        else:
            break

print(cnt + x)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();

            var A = cin.nextInt();
            var B = cin.nextInt();

            var harf = B / 2;

            if(A <= 5)
            {
                Console.WriteLine("0");
            }
            else if(6 <= A && A <= 12)
            {
                Console.WriteLine(harf);
            }
            else
            {
                Console.WriteLine(B);
            }
        }
    }
    
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11220
import java.io.*;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String buf = br.readLine();
			boolean First = true;
			for (int i=0;i<buf.length();i++) {
				String str = "";
				while (NotStop(buf.charAt(i))) {
					str = str+buf.charAt(i);
					i++;
				}
				if (str.length()>=3&&str.length()<=6) {
					if (First) {
						System.out.print(str);
						First = false;
					}
					else System.out.print(" "+str);
				}
			}
			System.out.println("");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean NotStop(char a) {
		if (a=='.'||a==' '||a==',') return false;
		else return true;
	}
}

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

int main() {
	int n, l, ans=0;
	cin >> n >> l;
	if (l >= 0) ans = n * (n - 1) / 2 + (n - 1) * l;
	else if (n <= abs(l)) ans = (n - 1) * (n - 2) / 2 + (n - 1) * l;
	else ans = n * (n - 1) / 2 + n * l;
	cout << ans << endl;
	return 0;
}

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

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int func(int a,int b){
    //if(a<b)return func(b,a);
    if(b==0)return a;
    return func(b,a%b);
}

int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<w*h/2<<" ";
    if(w/2==x && h/2==y){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
l = [int(input()) for i in range(5)]
a = []
b = []
c = []
total = 0
for i in l:
    if i % 10 == 0:
        a.append(i)
    else:
        b.append(i)
minNum = 10
ans = 0
for i in b:
    if i % 10 < minNum:
        minNum = i % 10
        ans = i
if b:
    c.append(ans)
    b.remove(ans)
if a:
    for i in a:
        total += i
if b:
    for i in b:
            total += i + (10 - i % 10)
if c:
    total += c[0]
print(total)

Measured memory_bytes: 3064