akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let s: Vec<usize> = read_vec();
    let (N, C) = (s[0], s[1]);
    let mut D = vec![vec![0; C]; C];
    for i in 0..C {
        let s: Vec<i32> = read_vec();
        for j in 0..C {
            D[i][j] = s[j];
        }
    }
    let D = D;
    let mut c = vec![vec![0usize; N]; N];
    for i in 0..N {
        let s: Vec<usize> = read_vec();
        for j in 0..N {
            c[i][j] = s[j] - 1;
        }
    }
    let c = c;
    // println!("{:?}", D);
    // println!("{:?}", c);

    let mut groups = vec![vec![0usize; 0]; 3];
    for i in 0..N {
        for j in 0..N {
            groups[(i + j) % 3].push(c[i][j]);
        }
    }

    let groups = groups;
    let mut group_dict: Vec<std::collections::HashMap<usize, i32>> =
        vec![std::collections::HashMap::new(); 3];
    for i in 0..3 {
        for color in 0..C {
            group_dict[i].insert(color, 0);
        }
        for color in &groups[i] {
            (*group_dict[i].entry(*color).or_insert(0)) += 1;
        }
    }
    // println!("{:?}", group_dict);

    let mut cost_dict: Vec<std::collections::HashMap<usize, i32>> =
        vec![std::collections::HashMap::new(); 3];
    for i in 0..3 {
        for src_color in 0..C {
            for dst_color in 0..C {
                (*cost_dict[i].entry(dst_color).or_insert(0)) +=
                D[src_color][dst_color] * group_dict[i][&src_color];
            }
        }
    }
    // println!("{:?}", cost_dict);

    let mut ans = std::i32::MAX;
    for group_idx in 0..3 {
        for c_idx1 in 0..C {
            let cost1 = cost_dict[0][&c_idx1];
            for c_idx2 in 0..C {
                if c_idx1 == c_idx2 {
                    continue;
                }
                let cost2 = cost_dict[1][&c_idx2];
                for c_idx3 in 0..C {
                    if c_idx1 == c_idx3 || c_idx2 == c_idx3 {
                        continue;
                    }
                    let cost3 = cost_dict[2][&c_idx3];
                    ans = std::cmp::min(ans, cost1 + cost2 + cost3);
                }
            }
        }
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 12540
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;
int main(){
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	vector<pair<char, int>> E;
	E.push_back(make_pair(S[0], 1));
	for (int i = 1; i < N; i++){
		if (S[i] == E.back().first){
			E.back().second++;
		} else {
			E.push_back(make_pair(S[i], 1));
		}
	}
	int cnt = E.size();
	vector<int> s(cnt + 1, 0);
	for (int i = 0; i < cnt; i++){
		s[i + 1] = s[i] + E[i].second;
	}
	int ans = 0;
	for (int i = 0; i < cnt; i++){
		if (E[i].first == '0'){
			ans = max(ans, s[min(cnt, i + K * 2)] - s[i]);
		} else {
			ans = max(ans, s[min(cnt, i + K * 2 + 1)] - s[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4656
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


bool checked[410][410];
int h,w;
/*
探索して白黒交互に進んでって
塗った白黒の数をそれぞれ記憶しておいて
その数を掛け合わせたものを加えていく
checkつけていってもう見たマスは二度と見なくてよい
 */
char m[410][410];
ll solve(int a,int b){
    ll B=0,W=0;
    queue<pair<int,int>> q;
    q.push(make_pair(a,b));
    checked[a][b]=true;
    while(!q.empty()){
        auto now=q.front();
        q.pop();
        char can_go;
        if(m[now.first][now.second]=='#'){
            B++;can_go='.';
        }
        else{
            W++;can_go='#';
        }
        for(int i=0;i<4;i++){
            int na=now.first+dx[i],nb=now.second+dy[i];
            if(0<=na&&na<h&&0<=nb&&nb<w&&m[na][nb]==can_go&&!checked[na][nb]){
                q.push(make_pair(na,nb));
                checked[na][nb]=true;
            }
        }
    }
    return B*W;
}   
int main(){
    cin>>h>>w;
    ll ans=0;
    rep(i,h)rep(j,w) cin>>m[i][j];
    rep(i,h){
        rep(j,w)if(!checked[i][j]){
            ans+=solve(i,j);
        }
    }

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

Measured memory_bytes: 512
N_M = gets.chomp
N = N_M[0].to_i
M = N_M[2].to_i

arr = Array.new(N)

M.times{
  s_c = gets.chomp
  s = s_c[0].to_i
  c = s_c[2].to_i
  if arr[s - 1] && arr[s - 1] != c then
    puts "-1"
    exit
  end
  arr[s - 1] = c
}
  
if arr.count > 1 && arr[0] == 0 then
    puts "-1"
    exit
end
  
if !arr[0] && arr.count > 1 then
  arr[0] = 1
end

ret = arr.reduce(""){|sum, i|
  if (i) then
    sum = sum << i.to_s
  else
    sum = sum << "0"
  end
}

puts ret

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

int main(void){
    int n, knum;
    int *d;
    cin >> n;
    d = (int *)malloc(sizeof(int)*n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d, d+n);
    cout << d[n/2]-d[n/2-1] << "\n";
}

Measured memory_bytes: 640
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int h,w,k;
  cin>>h>>w>>k;
  string s[h];
  rep(i,h)cin>>s[i];
  int cnt=0,block;
  rep(rows,1<<h){
    rep(cols,1<<w){
      block=0;
      rep(i,h){
        if((rows>>i)%2==1)continue;
        rep(j,w){
          if((cols>>j)%2==1)continue;
          block+=s[i][j]=='#';
        }
      }
      if (block==k)cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3632
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		ll ans=0;
		RANGE(i, 1, 1000000) {
			ll s=i*(i+1)/2;
			if(N<=s) {ans=i;break;}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
int main()
{
	int A;
	int B;
    int C;
    
    cin >> A;
    cin >> B;
    cin >> C;
  
  	if(A+B>=C)
    {
         cout << "Yes" << endl;
    }
    else
    {
      	cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.ArrayList;
public class Main{	
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[V];
		for (int i = 0; i < V; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}
		vis = new boolean[V];
		sort(g);
		for(int i=lis.size()-1;i>=0;--i){
			System.out.println(lis.get(i));
		}
	}

	static boolean[] vis;
	static ArrayList<Integer> lis = new ArrayList<>();

	static void sort(ArrayList<Integer>[] g) {
		int n = g.length;
		for (int i = 0; i < n; ++i) {
			if (!vis[i]) {
				dfs(i, -1, g);
			}
		}
	}

	static void dfs(int cur,int pre, ArrayList<Integer>[] g) {
		vis[cur] = true;
		for (int to : g[cur]) {
			if (!vis[to]) {
				dfs(to, cur, g);
			}
		}
		lis.add(cur);
	}
}

Measured memory_bytes: 70680
#include<stdio.h>
#include<string.h> //strcmp、strncmp関数を使うために必要
     
int main(void)
{
    int h1, h2, m1, m2,k,tmp,ans,i;
    
    scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
    h2=h2-h1;
    m2=m2-m1;
    tmp=h2*60+m2;
    //printf("%d\n",tmp);
    if(tmp==k){
        printf("0\n");
    }else{
        ans=tmp-k;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
using namespace std;
int main(){
  int n,a[1000000],b=1,c=0,d=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  while(n--){
    b=a[b];
    c++;
    if(b==2){
      d++;
      break;
    }
  }
  if(d==1)cout<<c;
  else cout<<-1;
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s.at(i);
	vector<vector<int>> a(h,vector<int>(w)),b(h,vector<int>(w));
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='.'){
				a[i][j]++;
				b[i][j]++;
			}
		}
	}
	rep(i,h){
		rep(j,w-1){
			if(a[i][j+1]) a[i][j+1]+=a[i][j];
		}
	}
	rep(i,h){
		for(int j=w-1;j>0;--j){
			if(a[i][j] && a[i][j-1]) a[i][j-1]=a[i][j];
		}
	}
	rep(j,w){
		rep(i,h-1){
			if(b[i+1][j]) b[i+1][j]+=b[i][j];
		}
	}
	rep(j,w){
		for(int i=h-1;i>0;--i){
			if(b[i][j] && b[i-1][j]) b[i-1][j]=b[i][j];
		}
	}
	int ans=0;
	rep(i,h){
		rep(j,w){
			ans=max(ans,a[i][j]+b[i][j]-1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, b=0; cin>>N>>K; vector<int> A(N,0); string ans="IMPOSSIBLE";
  for(int i=0; i<N; i++) {
    int a; cin >>a;
    if(a==K){
      ans="POSSIBLE";
      cout<<ans<<endl;
      return 0;
    }
    A[i]=a; b=max(a,b);}
  if(K>b){
    cout<<ans<<endl;
    return 0;
  }
  int a=A[0];
  for(int i=1; i<N; i++){
    int b=A[i], c=a%b;
    while(c!=0){
      a=b;
      b=c;
      c=a%b;
    }
    a=b;
    if(a==1) break;
  }
  if(K%a==0) ans="POSSIBLE";
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    double ans = 0;

    vector<pair<double, string>> v(N);
    rep(i, N) {
        double a;
        string b;
        cin >> a >> b;
        if(b == "JPY"){
            ans += a;
        } else {
            ans += 380000.0 * a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
int main(void){
    ll n; cin>>n;
    for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==1){
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
    
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**5+1)
N = int(input())
es = [[] for i in range(N+1)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    es[u].append([v,w])
    es[v].append([u,w])
dfs_map = [1 for i in range(N+1)]
col = [None] * (N+1)
def dfs(v, c):
    col[v] = c
    for e in es[v]:
        if dfs_map[e[0]]:
            dfs_map[e[0]] = 0
            if e[1] % 2:
                dfs(e[0], c^1)
            else:
                dfs(e[0], c)
dfs_map[1] = 0
dfs(1, 0)
for i in range(1, N+1):
    print(col[i])

Measured memory_bytes: 86040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;

    int ans = 0;
    int nokori = 0;
    REP(i, 0, a+1)
        REP(j, 0, b+1){
            nokori = x - 500*i - 100*j;
            if(nokori >=0 && nokori/50 <=c){
                ans += 1;
            }
        }


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


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    }
}

Measured memory_bytes: 27188
#include<stdio.h>
int main(){
  char s[100010],c=0,b=0,i;
  scanf("%s",s);
  if(s[0]-'A')goto END;
  for(i=2;s[i+1];i++){
    if(s[i]=='C')c++;
  }
  for(i=0;s[i];i++){
    if('A'<=s[i]&&s[i]<='Z')b++;
  }
  if(b-2||c-1)goto END;
  printf("AC\n");
  return 0;
 END:;
  printf("WA\n");
  return 0;
}


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

void InputSet(std::vector<int> & a) {
	int n;
	cin >> n;
	a.resize(n,0);
	for(int i=0;i<n;++i) {
		cin >> a.at(i);
	}
}
void Print(std::vector<int> & a) {
	for(int j=0;j<(int)a.size();++j){
		if(j==0){
			cout << a[j];
		} else  {
			cout << " " << a[j];
		}
	}
	cout << endl;
}
int main(){
	vector<int> A;
	::InputSet(A);
	int n = (int)A.size();
		Print(A);
	for(int j=1;j<n;++j){
		int key = A[j];
		int i=j-1;
		while(i>=0 && A[i] > key) {
			A[i+1] = A[i];
			i--;
		}
		A[i+1] = key;
		Print(A);
	}
}

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

int main() {
    ll n;cin>>n;
    ll ans=1e18;
    for (ll i=1;i*i<=n;i++)
        if (n%i==0)
            ans=min(ans,i+n/i-2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

G = [[0 for tail in range(10)] for head in range(10)]

for i in range(1, N+1):
  n = str(i)
  G[int(n[0])][int(n[-1])] += 1

total = 0
for headA in range(10):
  for tailA in range(10):
    total += G[headA][tailA] * G[tailA][headA]
print(total)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
int64 a[1005],s[1005];
vector<int64> v,tmp;
void Solve() {
    read(N);read(K);
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
	s[i] = s[i - 1] + a[i];
    }
    for(int i = 1 ; i <= N ; ++i) {
	for(int j = i ; j <= N ; ++j) {
	    v.pb(s[j] - s[i - 1]);
	}
    }
    int64 ans = 0;
    for(int i = 40 ; i >= 0 ; --i) {
	tmp.clear();
	for(auto t : v) {
	    if(t >> i & 1) tmp.pb(t);
	}
	if(tmp.size() >= K) {
	    ans |= (1LL << i);
	    v.clear();v = tmp;
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 6384
using System;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var s = Console.ReadLine();
		var c = Count(s, 'R');
		var a = Count(s[..c], 'R');
		Console.WriteLine(c - a);
	}
	static int Count(string s, char c) => s.Length - s.Replace(c.ToString(), "").Length;
}

Measured memory_bytes: 28920
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int X;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X;

	if (30 <= X) cout << "Yes" << endl;
	else cout << "No" << endl;
}







Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <cstdint>

#define MOD 1000000007

uint64_t modpow(uint64_t n, uint64_t pow) {
  uint64_t res = 1;
  while (pow > 0) {
    if (pow & 1) res = res * n % MOD;
    n = n * n % MOD;
    pow >>= 1;
  }
  return res;
}

int main() {
  uint64_t A, B;
  std::cin >> A >> B;
  
  if ((A + B) % 3 != 0 || A > B * 2 || A < B / 2) {
    std::cout << 0 << std::endl;
    return 0;
  }
  
  auto a = (2 * B - A) / 3;
  auto b = B - 2 * a;
  
  std::vector<uint64_t> factorials(a+b+1, -1);
  factorials.at(0) = 1;
  factorials.at(1) = 1;
  
  for (uint64_t i=2; i<=a+b; ++i) {
    factorials.at(i) = factorials.at(i-1) * i % MOD;
  }
  
  auto sum = factorials.at(a+b) % MOD;
  auto ainv = modpow(factorials.at(a), MOD-2);
  auto binv = modpow(factorials.at(b), MOD-2);
  
  sum = sum * ainv % MOD;
  sum = sum * binv % MOD;
  
  std::cout << sum << std::endl;
}

Measured memory_bytes: 5504
from collections import deque
S=input()
Q=int(input())

ct=0
reverse=[]
string=[deque(''), deque('')]
# 先頭に付け足す->string[0]にappendleft
# 最後尾に付け足す->strint[1]にappend
# ctの偶奇が変わる毎に付け足す方を変える

for i in range(Q):
    l=list(input().split())
    if l==['1']:
        reverse.append(i)
        ct+=1
    elif (int(l[1])+ct)%2==1:
        string[0].appendleft(l[2])
    else:
        string[1].append(l[2])

# print(string)
# print(ct)
if ct%2==0:
    top=''.join(string[0])
    bottom=''.join(string[1])
else:
    top=''.join(reversed(string[1]))
    bottom=''.join(reversed(string[0]))
    S=S[::-1]
    # print(S)
print(top+S+bottom)

Measured memory_bytes: 93468
#[allow(dead_code)]
fn main() {
    let k = i::u();
    let s = i::s();
    if s.len() <= k {
        println!("{}", s.iter().collect::<String>());
        return;
    }
    for i in 0..k {
        print!("{}", s[i]);
    }
    println!("{}", "...");
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
    KAKA
    vector<ll> ar(n);
    pragi(0,n)
    {
        cin>>ar[i];
    }
    vector<ll> prefgcd(n);
    vector<ll> sufgcd(n);
    prefgcd[0] = ar[0];
    sufgcd[n - 1] = ar[n - 1];
    pragi(1,n)
    {
        prefgcd[i] = __gcd(prefgcd[i - 1],ar[i]);
    }
    pragk(n - 2,0)
    {
        sufgcd[k] = __gcd(sufgcd[k + 1],ar[k]);
    }
    vector<ll> vec;
    vec.eb(sufgcd[1]);
    vec.eb(prefgcd[n - 2]);
    pragi(1,n - 1)
    {
        vec.eb(__gcd(prefgcd[i - 1],sufgcd[i + 1]));
    }
    ll mx = *max_element(vec.begin(),vec.end());
    cout<<mx<<"\n";
}
int main()
{
    KAKA
    ll n;
    cin>>n;
    Compute(n);
}

Measured memory_bytes: 6628
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;


void ABC138C()
{
	int N;
	cin >> N;
	vector<int> v(N);
	for (auto& x : v)
		cin >> x;

	sort(v.begin(), v.end());

	double x = v.front();
	for (int i = 1; i < N; ++i)
	{
		x = (x + v[i]) * 0.5;
	}
	cout << std::fixed << std::setprecision(10) << x << endl;
}
int main()
{
	ABC138C();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pll = pair < ll, ll >;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
 
int main(){   
	int ans = 1;
	for(int i = 1; i <= 5; i++) {
		ll a; cin >> a;
		if(a == 0) ans = i;
	}
	cout << ans << endl;
}
	

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

immutable long MOD = 10^^9 + 7;


void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!long).array;
    auto uf = new UnionFind(N, A);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        uf.unite(s[0], s[1]);
    }

    int cnt = 0;
    foreach (i; 0..N) cnt += uf.table[i] < 0;
    cnt = 2 * (cnt - 1);

    if (cnt == 0) {
        writeln(0);
        return;
    }
    
    long ans = 0;
    auto pq = new BinaryHeap!(Array!long, "a > b");
    
    foreach (i; 0..N) {
        if (uf.group[i].length >= 1) {
            uf.group[i].sort();
            ans += uf.group[i].front;
            cnt -= 1;
            foreach (j; 1..uf.group[i].length) {
                pq.insert(uf.group[i][j]);
            }
        }
    }

    while (!pq.empty && cnt > 0) {
        ans += pq.front;
        pq.removeFront;
        cnt -= 1;
    }

    if (cnt > 0) {
        writeln("Impossible");
    } else {
        ans.writeln;
    }
}


class UnionFind {
    int N;
    int[] table;
    long[][] group;

    this(int n, long[] a) {
        N = n;
        table = new int[](N);
        fill(table, -1);
        group = new long[][](N);
        foreach (i; 0..N) group[i] = [a[i]];
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
        group[x] ~= group[y];
        group[y] = [];
    }
}


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

int main() {
  int h1, h2, k1, k2, a, b, c, d;
  cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
  int h = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
  int k = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
  if (h > k) cout << "hiroshi\n";
  else if (h < k) cout << "kenjiro\n";
  else cout << "even\n";
}


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

using namespace std;

int main(){
  int n,x;
  while(cin >> n >> x && n + x){
    int cnt = 0;
    for(int i = 1; i <= n; i++){
      for(int k = i + 1; k <= n; k++){
	for(int j = k + 1; j <= n; j++){
	  if(i + k + j == x){
	    cnt++;
	  }
	}
      }
    }
    cout << cnt << endl;

  }
  return 0;

}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long long sum = 0, k = n - 2;
	sum = a[n - 1];
	for (int i = n - 2; i >= 0 && k; --i)
	{
		if (k >= 2)
		{
			sum += 2 * a[i];
			k -= 2;
		}
		else
		{
			sum += a[i];
			k --;
		}
	}
	cout << sum;
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    map<string,int> cnt;

    string s;
    REP(i, n) {
        cin >> s;
        cnt[s]++;
    }

    ll cmax = 0;
    for(auto e : cnt){
        ll c = e.second;
        if (c > cmax) cmax = c;
    }
    for(auto e : cnt){
        if (e.second == cmax) cout << e.first << endl;
    }
}

Measured memory_bytes: 25216
#include <iostream>
using namespace std;
 
int main()
{
   int N,W;
   cin >> N >> W;
   long long int DP[N+1][W+1];
   long long int V[N];
   long long  int w[N];
   for(int i=0;i<N;i++)
      cin >> w[i] >> V[i];
   
   for(int i=0;i<=N;i++)
      for(int j=0;j<=W;j++)
      {
         if(i==0||j==0)
            DP[i][j]=0;
         else if(w[i-1]<=j)
            DP[i][j] = max(V[i-1] + DP[i-1][j-w[i-1]],  DP[i-1][j]);
         else
            DP[i][j] = DP[i-1][j]; 
      }
      cout<< DP[N][W];
}

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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int MAXN = 2E5 + 10;

int n;
int p[MAXN];
vector<pii> E[MAXN];

int vis[MAXN], mark[MAXN];
vector<int> sta, cir;

int val[MAXN];

bool DFS(int u){
	vis[u] = true;
	sta.push_back(u);
	for (auto &x: E[u]){
		if (mark[x.nd])
			continue;

		mark[x.nd] = true;
		int v = x.st;
		eput(u, v);
		if (vis[v]){
			for (; sta.back() != v; sta.pop_back())
				cir.push_back(sta.back());
			cir.push_back(v);
			return true;
		}
		if (DFS(v))
			return true;
	}
	sta.pop_back();
	return false;
}

void DFS1(int u){
	vis[u] = true;
	
	vector<int> son;
	for (auto &x: E[u]){
		int v = x.st;
		if (vis[v])
			continue;
		DFS1(v);
		son.push_back(val[v]);
	}
	sort(all(son));
	for (int &i = val[u] = 0; i < son.size() && son[i] == i; ++i);
}

int main(){
	scanf("%d", &n);
	for (int u, v, i = 1; i <= n; ++i){
		scanf("%d", &u);
		p[i] = u;
		E[i].emplace_back(u, i);
		E[u].emplace_back(i, i);
	}
	DFS(1);

	eput(cir);

	fill_n(vis + 1, n, false);
	for (auto &u: cir)
		vis[u] = true;
	if (p[cir[0]] == cir[1])
		reverse(all(cir));
	for (auto &u: cir)
		DFS1(u), eput(val[u]);

	int same = true;
	for (auto &u: cir)
		same &= val[u] == val[cir[0]];
	if (same){
		puts(cir.size() & 1 ? "IMPOSSIBLE" : "POSSIBLE");
		return 0;
	}
	else
		puts("POSSIBLE");

	int k = 0;
	for (int i = 1; i < cir.size(); ++i)
		if (val[cir[i - 1]] > val[cir[i]]){
			k = i;
			break;
		}
	for (int i = 1; i < cir.size(); ++i){
		int u = (k + i - 1) % cir.size();
		int v = (k + i) % cir.size();
		if (val[u] == val[v])
			++val[v];
	}
	return 0;
}


Measured memory_bytes: 26484
S = input()

if S == 'SUN':
    print('7')

elif S == 'MON':
    print('6')

elif S == 'TUE':
    print('5')

elif S == 'WED':
    print('4')

elif S == 'THU':
    print('3')

elif S == 'FRI':
    print('2')

elif S == 'SAT':
    print('1')

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double hs = 360.0 * h / 12.0 + 30.0 * m / 60.0;
    long double ms = 360.0 * m / 60.0;

    long double t;
    if (hs >= ms) {
        t = hs - ms;
    } else {
        t = ms - hs;
    }

    //余弦定理
    long double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(t * M_PI / 180.0));

    cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 4156
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

from math import gcd

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

s = ri()
t = ri()

n,m= len(s),len(t)
ans=  10**18
for i in range(0, n-m+1):
    tcnt = 0
    for j in range(m):
        if s[i+j] != t[j]:
            tcnt+=1
    ans = min(ans, tcnt)
print(ans)

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

int main(){
	int n,min=10000000;
	cin>>n;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin>>v.at(i);
	}
	for(int i=1; i<101; i++){
		int ans=0;
		for(int j=0; j<n; j++){
			ans+=(v.at(j)-i)*(v.at(j)-i);
		}
		if(min>ans) min=ans;
	}
	cout<<min<<endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var s = ReadLine();
            long ans = 0;
            for (int i = 000; i < 1000; i++)
            {
                var target = i.ToString("000");
                bool[] hoge = new bool[3];
                for (int j = 0; j < n; j++)
                {
                    if (!hoge[0])
                    {
                        if (target[0] == s[j])
                        {
                            hoge[0] = true;
                        }
                    }
                    else if (!hoge[1])
                    {
                        if (target[1] == s[j])
                        {
                            hoge[1] = true;
                        }
                    }
                    else
                    {
                        if (target[2] == s[j])
                        {
                            ans++;
                            break;
                        }
                    }
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>

int gcd(int x, int y);

int main(void){
	int a, b;
	int gcd_num, lcm_num;

	while(scanf("%d %d", &a, &b) != EOF){
		gcd_num = gcd(a, b);
		lcm_num = (a / gcd_num)*b;
		printf("%d %d\n", gcd_num, lcm_num);
	}

	return 0;
}

int gcd(int x, int y){
	if(y == 0) return x;
	else	   return gcd(y, x % y);
}

Measured memory_bytes: 596
a,b=map(int,input().split())

a_list = list(map(int, input().split()))

a_list.sort(reverse=True)

sum_d = 0

for i, x in enumerate(a_list):
    if(b != 0):
        b -= 1 
    else:
        sum_d += x

print(sum_d)


Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
ll n , m ,k;
ll nbr;

int main()
{
	IOS;
	 std::cout << std::setprecision(30);
    ll n;
    cin >> n;
    vector<vector<long double>> dp(n+1,vector<long double>(n+1,0));
    dp[0][0]=1.0;
    vector<long double> P;
    for(ll i=0;i<n;i++)
    {
        long double x;
        cin >> x;
        P.push_back(x);
    }

    for( ll i=1;i<=n;i++)
    {
        for( ll j=0;j<=i;j++)
           {
               if(j==0)
                    dp[i][j]=dp[i-1][j]*(1-P[i-1]);
               else
                    dp[i][j]=dp[i-1][j]*(1-P[i-1])+dp[i-1][j-1]*P[i-1];

           }
    }
    long double ans=0;
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout << ans;
    cout.precision(30);
    return 0;
}


Measured memory_bytes: 141184
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int ans = 0;
  rep(i, a+1) {
    rep(j, b+1) {
      rep(k, c+1) {
        if(500 * i + 100 * j + 50 * k == x) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        for i in range(H):
            if i%2==0:
                m="#."
                if W%2==0:
                    print(m*(W//2))
                else:
                    print(m*(W//2)+"#")
            else:
                m=".#"
                if W%2==0:
                    print(m*(W//2))
                else:
                    print(m*(W//2)+".")
               
            if i==H-1:
                print("")
                


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int d,n;
    cin>>d>>n;
    int x=1;
    rep(i,d){
        x *= 100;
    }
    if(n<100)
    cout<<x*n<<endl;
    else{
        cout<<x*n+x<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    int N,K;
    cin >> N >> K;
    int i=0;
    while(N > 0){
        N /= K;
        i++;
    }
    cout << i;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	puts((read()%2 && read()%2)?"Yes":"No");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<P>> to(n);
    rep(i, m){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        to[l].push_back(make_pair(r, d));
        to[r].push_back(make_pair(l, -d));
    }
    vector<int> d(n, 0);
    vector<bool> vis(n, false);
    rep(i, n){
        if(vis[i])continue;
        vis[i] = true;
        queue<P> que;
        que.push(make_pair(i, 0));
        while(!que.empty()){
            P p = que.front();
            que.pop();
            int v = p.first;
            int dist = p.second;
            for(P t : to[v]){
                if(vis[t.first])continue;
                vis[t.first] = true;
                d[t.first] = dist + t.second;
                que.push(make_pair(t.first, d[t.first]));
            }
        }
    }

    bool ans = true;
    rep(i, n){
        for(P p : to[i]){
            int t = p.first;
            int dist = p.second;
            if(d[t] - d[i] != dist)ans = false;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 9856
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

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

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

void solve() {
	string s;
	cin >> s;
	int ans = 0;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout << 3;
	} else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
		cout << 2;
	} else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		cout << 1;
	} else {
		cout << 0;
	}
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int tc = 1;
	// cin >> tc;
	while(tc--) {
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

string S;
int N,K;

string T;
int dp[303][303][303];

int rec(int uplef,int dwlef,int num){
    if(N-1-uplef<dwlef) return 0;
    if(N-1-dwlef<uplef) return 0;
    if(dp[uplef][dwlef][num]) return dp[uplef][dwlef][num];
    if(2*uplef>=N&&2*dwlef>=N) return 0;

    int res=0;
    chmax(res,rec(uplef+1,dwlef,num));
    chmax(res,rec(uplef,dwlef+1,num));

    int cost=2;
    if(N-1-uplef<=dwlef) cost=1;
    if(N-1-dwlef<=uplef) cost=1;
    if(S[uplef]==T[dwlef]) chmax(res,rec(uplef+1,dwlef+1,num)+cost);
    else if(num>0) chmax(res,rec(uplef+1,dwlef+1,num-1)+cost);

    return dp[uplef][dwlef][num]=res;
}

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

  cin>>S;
  cin>>K;
  N=S.size();

  T=S;
  reverse(T.begin(),T.end());

  cout<<rec(0,0,K)<<endl;

  return 0;
}


Measured memory_bytes: 108800
using System;
        using System.Linq;
        using System.Collections.Generic;
        using static System.Math;

        public class Program
        {
            public static void Main(string[] args)
            {
            int count = int.Parse(Console.ReadLine());
            int[] input = new int[] { };

            for(int i = 0; i < count; i++)
            {
                input = input.Concat(new int[] { int.Parse(Console.ReadLine()) }).ToArray();
            }

            Console.WriteLine(input.Sum() - input.Max() / 2);
            }
        }

Measured memory_bytes: 11348