akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void)
{
    const int inf = 100000000;

    int n, m;
    cin >> n >> m;

    int a[1000], b[1000], c[1000], dist[100][100];

    for (int i = 0; i < m; ++i)
    {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
            {
                dist[i][j] = 0;
            }
            else
            {
                dist[i][j] = inf;
            }
        }
    }

    for (int i = 0; i < m; ++i)
    {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
    }

    for (int k = 0; k < n; ++k)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = m;
    for (int i = 0; i < m; ++i)
    {
        bool shortest = false;
        for (int j = 0; j < n; ++j)
        {
            if (dist[j][a[i]] + c[i] == dist[j][b[i]])
            {

                shortest = true;
            }
        }
        if (shortest == true)
        {
            ans = ans - 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"

int main(int argc, char const *argv[]) {

  int H, W;
  std::cin >> H>>W;


  int a[H][W];

  for (size_t i = 0; i< H; i++) {
    for (size_t i2 = 0; i2 < W; i2++) {
      int temp;
      std::cin >> temp;
      a[i][i2] = temp % 2;
    }
  }

  int N = 0;

  int xy[H*W][4];
  //
  // std::cout << "pre" << '\n';
  // for (size_t i = 0; i< H; i++) {
  //   for (size_t i2 = 0; i2 < W; i2++) {
  //     std::cout << a[i][i2] << ' ';
  //   }
  //   std::cout  << '\n';
  // }

  // yoko ido
  for (size_t i = 0; i< H; i++) {
    for (size_t i2 = 0; i2 < W - 1; i2++) {
      if (a[i][i2] == 1) {
        a[i][i2] = 0;
        a[i][i2+1] = (a[i][i2+1] + 1)%2;

        xy[N][0] = i;
        xy[N][1] = i2;
        xy[N][2] = i;
        xy[N][3] = i2 + 1;
        N++;

      }
    }
  }

  for (size_t i = 0; i < H - 1; i++) {
    if (a[i][W-1] == 1) {
      a[i][W-1] = 0;
      a[i+1][W-1] = (a[i+1][W-1]+1) %2;

      xy[N][0] = i;
      xy[N][1] = W-1;
      xy[N][2] = i+1;
      xy[N][3] = W-1;
      N++;

    }
  }
  //
  //
  // std::cout << "pro" << '\n';
  //
  // for (size_t i = 0; i< H; i++) {
  //   for (size_t i2 = 0; i2 < W; i2++) {
  //     std::cout << a[i][i2] << ' ';
  //   }
  //   std::cout  << '\n';
  // }
  //
  // std::cout << "N" << '\n';
  std::cout << N << '\n';

  for (size_t i = 0; i < N; i++) {
    std::cout << xy[i][0] +1<< ' '<< xy[i][1]+1 <<' '<< xy[i][2]+1<<' '<<
    xy[i][3] +1<< '\n';
  }


  return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define B       (cout << "Sehen Sie mich!" << endl)
#define VB(val) (cout << val << endl)

int main()
{
        int n;
        cin >> n;
        string str = to_string(n);

        for (int i = 0; i < (int)str.length(); i++) {
                int count = 0;
                for (int j = i + 1; j < (int)str.length(); j++) {
                        if (str[i] == str[j])
                                count++;
                        else
                                break;

                        if (count == 2) {
                                VB("Yes");
                                return 0;
                        }
                }
        }
        VB("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  long long ans=1e9;
  for(int x=-100;x<=100;x++){
    long long mini=0;
    rep(i,n){
      mini+=(a.at(i)-x)*(a.at(i)-x);
    }
    ans=min(ans,mini);
  }
  cout << ans;
}
      
      
  

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int i, j[1000] = {0};
	int a[1000], b[1000], c[1000];
	int N;
	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}
	
	for (i = 0; i < N; i++){
		if (a[i] * a[i] == b[i] * b[i] + c[i] * c[i]){
			j[i] = -1;
		}
		if (b[i] * b[i] == a[i] * a[i] + c[i] * c[i]){
			j[i] = -1;
		}
		if (c[i] * c[i] == b[i] * b[i] + a[i] * a[i]){
			j[i] = -1;
		}
	}
	
	for (i = 0; i < N; i++){
		if (j[i] == -1){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 592
#include<iostream>
using namespace std;
int main(){
  int H,W;
  while (1){
    cin >> H >> W ;
    if (0<H&&0<W){
      for(int I=1; I<=W; I++){
        cout << '#' ;
      }cout << endl;
      for(int l=1; l<=H-2; l++){
        cout << '#' ;
        for(int i=1; i<=W-2; i++){
          cout << '.' ;
        }
        cout << '#' << endl;
      }
      for(int j=1; j<=W; j++){
        cout << '#' ;
      }cout << endl;
      cout << endl;
    }else if(H==0&&W==0){
      break;
    }
  }
}



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

int main()
{
	int X, N;
	cin >> X >> N;
	vector<int> vp;
	for (int i = 0; i < N; ++i)
	{
		int p;
		cin >> p;
		vp.emplace_back(p);
	}

	for (int i = 0; i < 102; ++i) {
		int xl = X - i;
		if (find(vp.begin(), vp.end(), xl) == vp.end()) {
			cout << xl;
			return 0;
		}
		int xr = X + i;
		if (find(vp.begin(), vp.end(), xr) == vp.end()) {
			cout << xr;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
const int maxn=100000;
int n,m,fa[maxn+10],dfa[maxn+10];
int getfa(int x){
/*	int u=x,d=0; 
	for(;fa[u]!=u;u=fa[u]) d+=dfa[u];
	for(int i=x,p;fa[i]!=i;i=p){
		p=fa[i]; fa[i]=u; d-=dfa[i]; dfa[i]+=d;
	}*/
	if(fa[x]==x) return x;
	int f=getfa(fa[x]); dfa[x]+=dfa[fa[x]]; return fa[x]=f;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=1;i<=m;++i){
		int l,r,d; scanf("%d%d%d",&l,&r,&d);
		int ll=getfa(l),rr=getfa(r);
		if(ll!=rr){
			fa[ll]=rr; dfa[ll]=dfa[r]-dfa[l]-d;
		}else if(dfa[r]-dfa[l]-d){
			printf("No"); return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 896
while True:
    a,b = map(int, input().split())
    if a==b==0: break
    for i in range(a):
        for j in range(b):
            if i == 0 or i == a-1 or j == 0 or j == b-1:
                print("#", end='')
            else:
                print(".", end='')
        print("")
    print("")


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  vector<string> strs(N);
  
  string firstS;
  cin >> firstS;
  strs.at(0) = firstS;
  char last = firstS.at(firstS.size() -1);
  
  bool ret = true;
  
  for(int i = 1; i < N;i++){
    string s; cin >> s;
    if(last != s.at(0)) {ret = false; break;}
    
    for(int j = 0; j < i ; j++){
      if(strs.at(j) == s){ret = false;}
    }
    strs.at(i) = s;
    last = s.at(s.size() - 1);
  }
  
  if(ret){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
       
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	set<string>s;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		s.insert(str);
	}
	cout<<s.size()<<endl;
	return 0; 
}

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<long> a(n), b(n), c(m), d(m);
	for(int i=0; i<n; i++){
		cin >> a.at(i) >> b.at(i);
	}
	for(int i=0; i<m; i++){
		cin >> c.at(i) >> d.at(i);
	}
	vector<vector<long>> ans(n, vector<long>(m));
	vector<int> res(n);
	for(int i=0; i<n; i++){
		vector<long> sam(m);
		for(int j=0; j<m; j++){
			long x, y;
			x=a.at(i)-c.at(j);
			y=b.at(i)-d.at(j);
			if(x<0) x=-x;
			if(y<0) y=-y;
			ans.at(i).at(j)=x+y;
			sam.at(j)=ans.at(i).at(j);
		}
		sort(sam.begin(), sam.end());
		long min=sam.at(0);
		for(int j=0; j<m; j++){
			if(min==ans.at(i).at(j)){
				res.at(i)=j+1;
				break;
			}
		}
	}
	for(int i=0; i<n; i++){
		cout << res.at(i) << endl;
	}
}


Measured memory_bytes: 3560
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ VecDeque, BinaryHeap };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

const K: usize = 100000;

fn main() {
    let mut sc = Scanner::new();
    let mut count = [0; K];
    let mut n: usize = sc.cin();
    for i in 0..n {
        let a: usize = sc.cin();
        count[a] += 1;
    }

    let mut ones = BinaryHeap::new();
    let mut manys = BinaryHeap::new();

    for i in 0..K {
        if count[i] == 1 {
            ones.push(-(i as i32));
        } else if count[i] > 1 {
            manys.push(-(i as i32));
        }
    }

    // trace!(ones);
    // trace!(manys);

    for i in 0..K {

        if count[i] == 0 { continue; }

        if count[i] == 1 {
            let _ = ones.pop();
        } else if count[i] > 1 {
            let _ = manys.pop();
        }

        if count[i] >= 3 {
            let rest = (count[i] - 1) % 2 + 1;
            n -= count[i] - rest;
            count[i] = rest;
        }

        if n == 1 { continue; }

        if n == 3 {
            if ones.len() == 3 {
                continue;
            } else {
                n -= 2;
            }
            break;
        }

        // n >= 5
        // 1 <= d[i] <= 2
        if count[i] == 1 { continue; }

        // d[i] == 2
        if let Some(j_) = manys.pop() {
            let j = (-j_) as usize;
            count[j] -= 1;
            n -= 2;
            if count[j] == 1 {
                ones.push(-(j as i32));
            } else if count[i] > 1 {
                manys.push(-(j as i32));
            }
        } else {
            n -= 2;
            break;
        }
    }

    println!("{}", n);
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


Measured memory_bytes: 6524
#include <iostream>
using namespace std;
int main(){
 int n; cin >> n;
 bool ok = false;
 for(int x=1; x<=9; x++){
  for(int y=1; y<=9; y++){
   if(x*y == n){
    ok = true;
   }
  }
 }
 if (ok == true){
  cout << "Yes" << endl;
 }else{
  cout << "No" << endl;
 }
 
 return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int p, n;
  int s = 0, t = 0, u = 0;
  char c;
  while (cin >> p >> c >> n) {
    s += p * n;
    t += n;
    u++;
  }
  cout << s << endl;
  cout << (int)(1. * t / u + 0.5) << endl;

  return 0;
}


Measured memory_bytes: 3220
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    string s;
    while (cin >> s) {
        int ans = INT_MAX;
        for (char c = 'a'; c <= 'z'; ++c) {
            int r = sz(s), x = 0;
            for (int i = sz(s) - 1; i >= 0; --i) {
                if (s[i] == c) {
                    r = i;
                }
                smax(x, r - i);
            }
            smin(ans, x);
        }
        cout << ans << endl;
    }
}


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

int main(){

    int n,l;
    cin>>n>>l;

    int sum=0;

    for(int i=1;i<n+1;i++){
        sum+=l+i-1;
    }

    int meal=l;

    for(int i=1;i<n+1;i++){
        if(abs(l+i-1)<abs(meal)){
            meal=l+i-1;
        }
    }

    cout<<sum-meal<<endl;


return 0;
}

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

const int MAX_SIZE = 1000;

int calc(int N, int c[], int w[]) {
  bool g[MAX_SIZE][MAX_SIZE];
  int s[MAX_SIZE][MAX_SIZE], a[MAX_SIZE];
  for (int i = 0; i < N; ++i) {
    for (int j = i; j < N; ++j) {
      s[i][j] = (j > 0 ? s[i][j - 1] : 0) + w[j];
    }
  }
  for (int i = 0; i < N; ++i) g[i][i] = true;
  for (int k = 1; k < N; ++k) {
    for (int i = 0; i < N - k; ++i) {
      int j = i + k;
      g[i][j] = (g[i][j - 1] && s[i][j - 1] <= c[j]) || (g[i + 1][j] && s[i + 1][j] <= c[i]);
    }
  }
  a[0] = 1;
  for (int i = 1; i < N; ++i) {
    a[i] = g[0][i] ? 1 : a[i - 1] + 1;
    for (int j = 0; j < i; ++j) {
      if (g[j + 1][i] && a[j] + 1 < a[i]) a[i] = a[j] + 1;
    }
  }
  return a[N - 1];
}

int main() {
  int N, c[MAX_SIZE], w[MAX_SIZE];
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> c[i] >> w[i];
  }
  cout << calc(N, c, w) << endl;
}

Measured memory_bytes: 6052
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N, M;
    cin >> N >> M;
    
    vec<vec<int>> G(N);
    rep(i, M){
        int a,b;
        cin >> a >> b;
        --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    function<void(int,int,vec<bool>)> dfs = [&](int now,int count ,vec<bool> v){
        v[now] = true;
        ++count;
        if(count == N) {
            ++ans;
            return;
        }
        for(auto e:G[now]){
            if(v[e]) continue;
            dfs(e,count,v);
        }

    };

    dfs(0,0,vec<bool>(N,false));
    cout << ans << '\n';
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

bool notp[100010];
ll  ans[100010];

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

  ll N; cin >> N;
  vector<pair<ll,ll> > lr;
  rep(i,N){
    ll l,r; cin >> l >> r;
    lr.pb(mp(l,r));
  }
  
  rep(i,100001){
    rep(j,100001){
      if(i == 1 || j==1) continue;
      if(i*j > 100000) break;
      notp[i*j] = true;
    }
  }
  notp[1] = true;
  
  for(ll i = 1; i<=100000; i+=2){
    if(notp[i]==false && notp[(i+1)/2]==false) ans[i]=1;
  }

  for(ll i=1; i<=100000;i++){
    ans[i]+=ans[i-1];
  }

  rep(i,N){
    cout << ans[lr[i].second]- ans[lr[i].first-1] << endl;
  }

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 3184
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	int now=0;
	for(int i=0;i<a;i++){
		if(p[i]==now+1)now++;
	}
	int ret=a-now;
	if(now==0)ret=-1;
	printf("%d\n",ret);
}

Measured memory_bytes: 896
#include<cstdio>
using namespace std;
int main(){
	int min=2000,min2=2000,pasta,drink,cnt;
	for(cnt=0;cnt<5;cnt++){
		if(cnt<3){
//			cin << pasta;
			scanf("%d",&pasta);
			if(min>pasta){
				min=pasta;
			}
		}
		else{
//			cin << drink;
			scanf("%d",&drink);
			if(min2>drink){
				min2=drink;
			}
		}
	}
	printf("%d\n",min+min2-50);
}

Measured memory_bytes: 2616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>

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

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
int memo[3][100005];

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > g(n);


    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
    }

    int s, t;
    cin >> s >> t;
    s--;
    t--;

    rep(i, n) rep(j, 3) memo[j][i] = INF;

    queue<P> q;
    q.push(P(s, 0));
    memo[0][s] = 0;
    while (!q.empty()) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for (int nv: g[v]) {
            int nl = (l+1)%3;
            if (memo[nl][nv] != INF) continue;
            memo[nl][nv] = memo[l][v] + 1;
            q.push(P(nv, nl));
        }
    }

    if (memo[0][t] == INF) cout << -1 << endl;
    else cout << memo[0][t]/3 << endl;

    return 0;
}

Measured memory_bytes: 6912
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]

    let ab: [(Int, Int)] = (1...n).map { _ in 
        let ab = readWords { Int($0)! }
        return (ab[0], ab[1])
    }.sorted(by: <)

    var ans = 0
    var pq = PriorityQueue<Int>(>=)
    var i = 0
    for day in 1...m {
        while i < n && ab[i].0 <= day {
            pq.push(ab[i].1)
            i += 1
        }
        if let b = pq.pop() {
            ans += b
        }
    }

    print(ans)
}

private struct PriorityQueue<T> {
    private var data: [T]
    private var ordered: (T, T) -> Bool
    
    public var isEmpty: Bool {
        return data.isEmpty
    }
    
    public var count: Int {
        return data.count
    }

    init(_ order: @escaping (T, T) -> Bool) {
        self.data = []
        self.ordered = order
    }

    init<Seq: Sequence>(_ seq: Seq, _ order: @escaping (T, T) -> Bool) where Seq.Element == T {
        self.data = []
        self.ordered = order
        
        for x in seq {
            push(x)
        }
    }
    
    public mutating func pop() -> T? {
        return data.popLast().map { item in
            var item = item
            if !isEmpty {
                swap(&item, &data[0])
                siftDown()
            }
            return item
        }
    }
    
    public mutating func push(_ item: T) {
        let oldLen = count
        data.append(item)
        siftUp(oldLen)
    }
    
    private mutating func siftDown() {
        var pos = 0
        let end = count
        
        data.withUnsafeMutableBufferPointer { bufferPointer in
            let _data = bufferPointer.baseAddress!
            swap(&_data[0], &_data[end])
            
            var child = 2 * pos + 1
            while child < end {
                let right = child + 1
                if right < end && ordered(_data[right], _data[child]) {
                    child = right
                }
                swap(&_data[pos], &_data[child])
                pos = child
                child = 2 * pos + 1
            }
        }
        siftUp(pos)
    }
    
    private mutating func siftUp(_ pos: Int) {
        var pos = pos
        while pos > 0 {
            let parent = (pos - 1) / 2;
            if ordered(data[parent], data[pos]) {
                break
            }
            data.swapAt(pos, parent)
            pos = parent
        }
    }
}

extension PriorityQueue: Sequence, IteratorProtocol {
    mutating func next() -> T? {
        return pop()
    }
}

main()



Measured memory_bytes: 16928
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
const ll MOD = 1000000007;
using namespace std;

int main(void)
{
    ll n;
    cin >> n;
    ll ans = 1;
    while (ans <= n)
        ans *= 2;

    cout << (ans / 2) * 2 - 1 << endl;
}


Measured memory_bytes: 3556
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *ri;
  struct node *lf;
  struct node *prt;
  int key;
};
typedef struct node * Node;

 
Node root;

Node treeMinimum(Node x){
  while (x->lf != NIL) { 
    x = x->lf;
  }
  return x;
}
Node treeSearch(Node u, int k){
  if (u == NIL || k == u->key){
    return u;
  } 
  if(k < u->key) {
    return treeSearch(u->lf,k);
  }
  else return treeSearch(u->ri,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->ri != NIL) {
    return treeMinimum(x->ri);
  }
  y = x->prt;
  while (y != NIL && x == y->ri){
    x = y;
    y = y->prt;
  }
    return y;
}
 
void treeDelete(Node z){
  Node y; 
  Node x; 
  if(z->lf == NIL || z->ri == NIL) {
    y = z; 
  }
  else y = treeSuccessor(z); 
  if(y->lf != NIL){
    x = y->lf;
  } 
  else x = y->ri;
  if(x != NIL) {
    x->prt = y->prt;
  }
  if(y->prt == NIL) {
    root = x;
  }  
  else if(y == y->prt->lf) {
    y->prt->lf = x; 
  }
  else y->prt->ri = x; 
  if(y != z){ 
    z->key = y->key; 
  }
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->lf = NIL;
  z->ri = NIL;
 
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->lf;
    }
    else x = x->ri;
    }
  z->prt = y;
  if(y == NIL) {
    root = z; 
  }
  else if(z->key < y->key){
    y->lf = z;
  } 
  else y->ri = z;
}
 
void inorder(Node u){
  if(u != NIL){
    inorder(u->lf);
    printf(" %d",u->key);
    inorder(u->ri);
  }
}
 
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->lf);
    preorder(u->ri);
  }
}
 
int main(){
  int n, i, x;
  char cm[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", cm);
    if ( cm[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( cm[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( cm[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( cm[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0; 
}

Measured memory_bytes: 19360
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n;
  str s;
  cin >> n >> s;
  ll cnt=0;
  for(auto c:s) if(c=='R') cnt++;
  ll ans=0;
  rep(i,0,cnt) if(s[i]=='W') ans++;
  cout << ans << endl;
}

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

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

int main() {
    int K, N;
    ll sum = 0;
    cin >> K >> N;
    vector<int> data(N);

    rep(i, N) cin >> data.at(i);

    vector<int> dist(N);

    rep(i, N) {
        if (i != N - 1) dist.at(i) = data.at(i + 1) - data.at(i);
        else dist.at(i) = K - data.at(i) + data.at(0);
    }

    sort(all(dist));

    rep(i, N - 1) {
        sum += dist.at(i);
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str="";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n; cin >> n;
	vector<int>l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	ssort(l);
	int sum = 0;
	for (int i = 0; i < n-1; i++) {
		sum+= l[i];
	}
	if (l[n - 1] < sum) cout << "Yes";
	else cout << "No";


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{int x,a,b,c,d;
cin>>x>>a>>b;
c=abs(a-x);
d=abs(b-x);
if(d<c)
cout<<"B";
if(d>c)
cout<<"A";
return 0;
}

Measured memory_bytes: 256
n=int(input())
sosuu=[11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451,1471,1481,1511,1531,1571,1601,1621,1721,1741,1801,1811,1831,1861,1871,1901,1931,1951,2011,2081,2111,2131,2141,2161,2221,2251,2281,2311,2341,2351,2371,2381,2411,2441,2521,2531,2551,2591,2621,2671,2711,2731,2741,2791,2801,2851,2861,2971,3001,3011,3041,3061,3121,3181,3191,3221,3251,3271,3301,3331,3361,3371,3391,3461,3491,3511,3541,3571,3581,3631,3671,3691,3701,3761,3821,3851,3881,3911,3931,4001,4021,4051,4091,4111,4201,4211,4231,4241,4261,4271,4391,4421,4441,4451,4481,4561,4591,4621,4651,4691,4721,4751,4801,4831,4861,4871,4931,4951,5011,5021,5051,5081,5101,5171,5231,5261,5281,5351,5381,5431,5441,5471,5501,5521,5531,5581,5591,5641,5651,5701,5711,5741,5791,5801,5821,5851,5861,5881,5981,6011,6091,6101,6121,6131,6151,6211,6221,6271,6301,6311,6361,6421,6451,6481,6491,6521,6551,6571,6581,6661,6691,6701,6761,6781,6791,6841,6871,6911,6961,6971,6991,7001,7121,7151,7211,7321,7331,7351,7411,7451,7481,7541,7561,7591]
print(*sosuu[:n])

Measured memory_bytes: 9328
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e12
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n, k;
vector<double> p, q;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

ll calc(ll a) {
	if (a == 1)return 1;
	return calc(a / 2) * 2 + 1;
}

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

	cin >> n >> k;
	p = vector<double>(n);
	REP(i, n) {
		cin >> p[i];
		p[i] = (1 + p[i]) / 2;
	}
	q = vector<double>(n - k + 1);
	REP(i, k) {
		q[0] += p[i];
	}

	double max = q[0];
	REP(i, n - k) {
		q[i + 1] = q[i] + p[i + k] - p[i];
		chmax(max, q[i + 1]);
	}

	printf("%.12f\n",max);
}

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

    string s;
    cin >> s;

    int a[3] {};
    rep(i, s.length()){
        if(s[i] == 'a'){
            a[0]++;
        }
        else if(s[i] == 'b'){
            a[1]++;
        }
        else{
            a[2]++;
        }
    }
    
    sort(a, a+3);
    if( ((a[0]==a[1] || a[0]+1 == a[1]) && a[1] == a[2]) || (a[0] == a[1] && a[1]+1 == a[2]) ){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 512
// ref: https://atcoder.jp/contests/abc110/submissions/3251714

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

struct fact{
private:
public:
    fact(){ prime=0ull; num=0ull; }
    fact(const uint64 p_in, const uint64 n_in){ prime=p_in; num=n_in; }
    ~fact(){}
    
    uint64 prime;
    uint64 num;
};

struct fact divNum(uint64& target, const uint64 divisor){
    struct fact fa(divisor, 0ull);
    for(;;){
        uint64 div = target / divisor;
        uint64 mod = target - divisor * div;
        if(mod!=0ull){ break; }
        target = div;
        ++fa.num;
    }
    return fa;
}

vector<struct fact> factor(uint64 target){
    vector<struct fact> vecFact;
    
    struct fact fa2 = divNum(target, 2ull);
    if(fa2.num!=0ull){ vecFact.push_back(fa2); }
    
    for(uint64 divisor=3; divisor<=target; divisor+=2){
        if(target==1){ break; }
        
        struct fact fa = divNum(target, divisor);
        if(fa.num==0ull){ continue; }
        
        vecFact.push_back(fa);
    }
    return vecFact;
}

uint64 pow_mod(uint64 base, uint64 exp, const uint64 mod){
    uint64 ret=1ull;
    for(; exp>0ull; exp>>=1ull){
        if(exp & 1){
            ret = ret*base;
            ret %= mod;
        }
        base = base*base;
        base %= mod;
    }
    return ret;
}
uint64 comb_mod(uint64 n, uint64 r, const uint64 mod){
    if(n==r || n==0ull || r==0ull){ return 1ull; }
    
    uint64 p=1ull, q=1ull;
    r = min(r,n-r);
    for(uint64 i=1ull; i<=r; ++i){
        p *= n; --n;
        p %= mod;
        
        q *= i;
        q %= mod;
    }
    return (p*pow_mod(q,mod-2,mod)) % mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    const uint64 mod = 1e9 + 7;
    
    uint64 N, M; cin >> N >> M;
    
    vector<struct fact> vecFact = factor(M);
    vector<uint64> vecA(vecFact.size());
    for(uint i=0; i<vecFact.size(); ++i){
        vecA[i] = vecFact[i].num;
    }
    
    uint64 ans=1ull;
    for(uint i=0; i<vecA.size(); ++i){
        ans *= comb_mod((uint64)vecA[i]+(uint64)N-1ull, (uint64)N-1ull, mod);
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int R,C,N;
    cin>>C>>R>>N;
    vector<pii> p;
    REP(i,N) {
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if((x1==0 || x1==C || y1==0 || y1==R) && (x2==0 || x2==C || y2==0 || y2==R)) {
            auto getlen=[&](int x,int y) {
                if(x==0) return y;
                if(y==R) return x+R;
                if(x==C) return R+C+(R-y);
                if(y==0) return R*2+C+(C-x);
            };
            int a=getlen(x1,y1);
            int b=getlen(x2,y2);
            p.push_back({min(a,b),i+1});
            p.push_back({max(a,b),-(i+1)});
        }
    }
    sort(ALL(p));
    stack<int> st;
    REP(i,SZ(p)) {
        if(p[i].second<0) {
            if((-p[i].second)!=st.top()) {
                cout<<"NO"<<endl;
                return 0;
            }
            st.pop();
        } else {
            st.push(p[i].second);
        }
    }
    cout<<"YES"<<endl;
    return 0;
}



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

using namespace std;

int co[256];
int n,k;
string arr[10004];

int get()
{
    int i;
    int ans=0;
    for(i=0;i<255;i++)
        if(!co[i])
            return i;
}

void del()
{
    int i;
    for(i=0;i<k;i++)
    {
        co[i]--;
    }
}

int main()
{
    cin >> n >> k;
    int i;
    for(i=0;i<n;i++)
    {
        cin >> arr[i];
        co[arr[i][0]]++;
    }
    int ans=0;
    while(1)
    {
        sort(co,co+256);
        reverse(co,co+256);
        if(get()>=k)
        {
            ans++;
            del();
        }
        else
        {
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <stack>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto
#define M int main()
#define For(itr,max) for(int itr = 0;itr <= max;itr++)

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;


const int Max = 60;
const int MOD = 1e9 + 7;

/*
int main()
{

}
*/

/*
// Result VALUE , FROM 1 TO INDEX
ll dp[Max][110];
ll w[Max];
ll val[Max];
int main()
{
	int n, W; cin >> n >> W;

	for (int i = 1; i <= n; i++)
	{
		cin >> w[i] >> val[i];
	}

	for (int i = 0; i <= n; i++)
	{
		for (int j = 1; j <= Max; j++)
			dp[j][i] = 1e18;
	}

	for (int i = 1; i <= n; i++)
	{
		cout << i << ':' << w[i] << '\n';
		for (int j = 0; j <= Max; j++)
		{
			// dp[j][i]  Minimum Hazine Baraye Shadie J Dar I Taye Aval
			if (j >= val[i])
				dp[j][i] = min(dp[j][i - 1], dp[j - val[i]][i - 1] + w[i]);
			else
				dp[j][i] = dp[j][i - 1];
		}
	}

	int maxAble = 0;
	for (int i = 0; i <= Max; i++)
	{
		if (dp[i][n] <= W)
		{
			maxAble = i;
		}
	}
	cout << maxAble;
}
*/


ll dp[Max][Max][Max * 5];
map<ll, int> convert;
int lastAdded = 0;
int n;
bool conectivity[Max][Max];

ll Ways(int strt, int end, ll length)
{
	var itr = convert.find(length);
	int idx = 0;
	if (itr == convert.end())
	{
		idx = lastAdded;
		convert.insert({ length, lastAdded++ });
	}
	else
	{
		idx = itr->s;
	}

	if (dp[strt][end][idx] == -1)
	{
		dp[strt][end][idx] = 0;
		if (length > 1)
		{
			for (int u = 0; u < n; u++)
			{
				ll half1 = Ways(strt, u, length / 2);
				ll half2 = Ways(u, end, length / 2 + length % 2);
				dp[strt][end][idx] = (dp[strt][end][idx] + half1 * half2 % MOD) % MOD;
			}
		}
		else
		{
			dp[strt][end][idx] = conectivity[strt][end];
		}
	}

	return dp[strt][end][idx];
}

int main()
{
	ll k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> conectivity[i][j];
		}
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			for (int l = 0; l < 5 * Max; l++)
			{
				dp[i][j][l] = -1;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			res += Ways(i, j, k);
		}
	}
	cout << res % MOD;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int N;
int now=0;
string S1,S2;
bool ask(int k){
	if(k>=4){
		string SS1,SS2;
		if(k==4){
			SS1='.'+S1;
			SS2='.'+S2;
		}
		else if(k==5){
			SS1='.'+S1;
			SS2='#'+S2;
		}
		else if(k==6){
			SS1='#'+S1;
			SS2='.'+S2;
		}
		else{
			SS1='#'+S1;
			SS2='#'+S2;
		}
		cout << SS1 << "\n" << SS2 << "\n";
		string ans;
		cin >> ans;
		if(ans=="T")return true;
		return false;
	}
	else{
		string SS1,SS2;
		if(k==0){
			SS1=(S1+'.');
			SS2=(S2+'.');
		}
		else if(k==1){
			SS1=(S1+'.');
			SS2=(S2+'#');
		}
		else if(k==2){
			SS1=(S1+'#');
			SS2=(S2+'.');
		}
		else{
			SS1=(S1+'#');
			SS2=(S2+'#');
		}
		cout << SS1 << "\n" << SS2 << "\n";
		string ans;
		cin >> ans;
		if(ans=="T")return true;
		return false;
	}
}
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		bool F=false;
		if(now==0){
			for(int j=0;j<4;j++){
				if(ask(j)){
					F=true;
					if(j==0){
						S1+='.';S2+='.';
					}
					else if(j==1){
						S1+='.';S2+='#';
					}
					else if(j==2){
						S1+='#';S2+='.';
					}
					else{
						S1+='#';S2+='#';
					}
					break;
				}
			}
			if(i==N-1&&F)return 0;
			if(!F){
				now=1;
				i--;
			}
		}
		else{
			for(int j=4;j<8;j++){
				if(ask(j)){
					F=true;
					if(j==4){
						S1=('.'+S1);S2=('.'+S2);
					}
					else if(j==5){
						S1=('.'+S1);S2=('#'+S2);
					}
					else if(j==6){
						S1=('#'+S1);S2=('.'+S2);
					}
					else{
						S1=('#'+S1);S2=('#'+S2);
					}
					break;
				}
			}
			if(i==N-1&&F)return 0;
		}
	}
	
	return 0;
}



Measured memory_bytes: 596
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};

use std::collections::HashMap;
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    let mut iter = buf.split_whitespace();
 
    let s: String = iter.next().unwrap().parse().unwrap();
    
    let s: Vec<char> = s.chars().collect();
    
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int gcd(int p, int q){
    if(p%q==0) return q;
    return gcd(q, p%q);
}

int main() {
    ll K;
    cin >> K;

    ll answer = 0;
    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            for(int c=1; c<=K; c++){
                answer += gcd(gcd(a,b),c);
            }
        }
    }

    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	int a[n],b[m],i,c[n],d[m];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		c[i]=a[i];
		if(i)
			c[i]+=c[i-1];
	}
	for(i=0;i<m;i++)
	{
		cin>>b[i];
		d[i]=b[i];
		if(i)
			d[i]+=d[i-1];
	}
	i=0;
	int ans=0,total;
	while(i<n && c[i]<=k )
		i++;
	int x=i-1,j=0;
	for(i=x;i>=0;i--)
	{
		total=c[i];
		while(j<m && total+d[j]<=k)
			j++;
		ans=max(i+j+1,ans);
	}
	i=0;
	while(i<m && d[i]<=k)
		i++;
	ans=max(ans,i);
	cout<<ans<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 9868
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Dec  2 21:35:07 2018
//
package main

import "fmt"

var n int

func num(n int, arr []int) int {
	ret := 0
	for i := range arr {
		if n <= arr[i] {
			ret++
		}
	}
	return ret
}

func main() {
	fmt.Scan(&n)

	d := map[int]int{}

	for i := 1; i <= n; i++ {
		val := i
		for j := 2; j <= i; j++ {
			for val%j == 0 {
				val /= j
				d[j]++
			}
		}
	}
	var arr []int
	for _, v := range d {
		arr = append(arr, v+1)
	}

	ans := num(75, arr) + num(25, arr)*(num(3, arr)-1) + num(15, arr)*(num(5, arr)-1) + num(5, arr)*(num(5, arr)-1)*(num(3, arr)-2)/2
	fmt.Println(ans)
}


Measured memory_bytes: 512