akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

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

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int h, a;
    read(h, a);
    print((h + a - 1) / a);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;
int edge[30][2];

bool check(int m,int begin,int end){

  REP(i,m){
    if ((edge[i][0] == begin && edge[i][1] == end) || (edge[i][1] == begin && edge[i][0] == end)) {
      return true;
    }
  }
  return false;

}

int solve(int n,int m){
  vector<int> node(n);
  REP(i,n){
    node[i] = i + 1;
  }

  int ans = 0;

  do {
    if (node[0] != 1) {
      continue;
    }
    REP(j,n){
      if (j == n-1) {
        ans++;
      }
      if (check(m,node[j],node[j+1]) == false) {
        break;
      }
    }
  } while (next_permutation(node.begin(),node.end()));
  return ans;
}

int main(){
  int n,m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> edge[i][0] >> edge[i][1];
  }

  int ans = solve(n,m);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		boolean key = true;
		int[] ans = new int[N];
		for (int i = 0; i < N; i++) ans[i] = 10;
		int res = 0;
		List<int[]> in = new ArrayList<>();
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < M; i++) {
			int[] stock = new int[2];
			stock[0] = sc.nextInt();
			stock[1] = sc.nextInt();
			in.add(stock);
		}
		
		for (int i = 0; i < in.size(); i++) {
			int si = in.get(i)[0];
			int ci = in.get(i)[1];
			if ((N < si) 
					|| (N != 1 && si == 1 && ci == 0)
					|| (ans[si-1] != 10 && ans[si-1] != ci)) {
				key = false;
				break;
			} else {
				ans[si-1] = ci;
			}
		}
		if (key) {
			for (int i = 0; i < ans.length; i++) {
				if (N == 1 && ans[0] == 10) {
					res = 0;
					System.out.println(0);
					System.exit(0);
				}
				if (ans[0] == 10) {
					ans[0] = 1;
				}
				if (ans[i] != 10) {
					sb.append(ans[i]);
				} else {
					sb.append("0");
				}
			}
			res = Integer.parseInt(sb.toString());
			System.out.println(res);
		} else {
			System.out.println(-1);
		}
		
	}
}

Measured memory_bytes: 21844
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        S: chars,
    }
    let mut buff = 0;
    let mut ans = 1 << 29;
    for i in 0..S.len() - 2 {
        for j in 0..3 {
            buff += S[i + j] as i32 - 48;
            buff *= 10;
        }
        buff /= 10;
        ans = std::cmp::min(ans, (buff - 753).abs());
        buff = 0;
    }
    println!("{}", ans);
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 305;
int n;
int d[N][N];
ii dist[N];
ll ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> d[i][j];
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            bool ok = true;
            for (int k = 0; k < n; ++k) {
                if (k == i || k == j) continue;
                if (d[i][j] > d[i][k] + d[k][j]) {
                    cout << -1 << endl;
                    exit(0);
                }
                if (d[i][j] == d[i][k] + d[k][j]) {
                    ok = false;
                    break;
                }
            }
            if (ok)
                ans += d[i][j];
        }
    }
    cout << ans / 2 << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a > mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
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 << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/
ll n, a[25][25], dp[25][1 << 21];
ll fn(ll i, ll msk) {
  if(i == n) return 1;
  ll &res = dp[i][msk];
  if(res != -1) return res;
  res = 0;
  for(ll j = 0; j < n; j++) 
  if(!(msk >> j & 1) && a[i][j])
  mod_add(res, fn(i + 1, msk | (1 << j)));
  return res;
}
int main()
{
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  
  ll t, m, i, j, k, q, u, v;
  // cin >> t;
  // ll tc = t;
  t = 1;
  while (t--)
  {
    cin >> n;
    for(i = 0; i < n; i++)
    for(j = 0; j < n; j++)
    cin >> a[i][j];
    memset(dp, -1, sizeof(dp));
    cout << fn(0, 0);
    // cout << "Case #" << tc - t << ": ";

    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 409856
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n, m;
    cin >> n >> m;
    // graph[i - n]がi番目の言語, 0-indexed
    vector<vector<int>> graph(m + n);
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int l;
            cin >> l;
            graph[i].push_back(l + n - 1);
            graph[l + n - 1].push_back(i);
        }
    }
    vector<bool> visited(m + n);
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int from = que.front();
        que.pop();

        if (visited[from])
            continue;
        visited[from] = true;
        for (int to : graph[from]) {
            que.push(to);
        }
    }
    bool ans = true;
    for (int i = 0; i < n; ++i) {
        ans = ans && visited[i];
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 8952
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2333;
Pii ans; ll res=1;
int a[N],b[N],len,dis[N],A[N],B[N];
int n,head[N],to[N],nxt[N],edgenum,deg[N];
void add(int u, int v) {
	to[++edgenum]=v; nxt[edgenum]=head[u]; head[u]=edgenum;
}
void DFS(int s, int u, int fa, int Dis) {
	dis[s]=max(dis[s],Dis);
	L(i,u) if (to[i]!=fa) DFS(s,to[i],u,Dis+1);
}
void solve() {
	int mx=0; rep(i,1,len) mx=max(mx,deg[a[i]]);
	if (mx<=1) {res=1; return;}
	int Len=0;
	rep(k,1,len) L(i,a[k]) if (to[i]!=b[k]) A[++Len]=to[i],B[Len]=a[k];
	len=Len; rep(i,1,len) a[i]=A[i],b[i]=B[i]; solve(); res*=mx-1;
	//*(mx-1)
}
int main() { int x,y;
	read(n); rep(i,2,n) {read(x);read(y);add(x,y);add(y,x);deg[x]++;deg[y]++;}
	rep(i,1,n) DFS(i,i,0,1);
	ans.fi=7e18;
	rep(u,1,n) {
		len=0; L(i,u) a[++len]=to[i],b[len]=u; res=1;
		solve(); if (deg[u]==1) res++; else res*=deg[u]; ans=min(ans,Pii(dis[u],res));
	}
	rep(u,1,n) L(i,u) {
		int v=to[i];
		dis[u]=dis[v]=0; DFS(u,u,v,1); DFS(v,v,u,1);
		res=1; len=2; a[1]=u; b[1]=v; a[2]=v; b[2]=u; solve(); res*=2;
		ans=min(ans,Pii(max(dis[u],dis[v]),res));
	}
	cout<<ans.fi<<' '<<ans.se;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  vi v(n);
  vi c(n);
  scan(v);
  scan(c);
  ll ans = 0;
  rep (i, n) {
    ans += max(0, v[i] - c[i]);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std ;
long long int a[1200000];
long long int b[1200000];
long long int n,m;
int cmp(int a ,int b){
	return a>b;
}
inline void read(int &x){
   int s = 0, w = 1; char ch = getchar();
   while(ch < '0' || ch > '9'){ if(ch == '-') w = -1; ch = getchar(); }
   while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
   x = s*w;
}
long long int check(long long int t){
	long long int sum=0;
	for(int i=0;i<n;i++){
		if(t/b[i]==0){
			sum+=a[i];
		}
		else {
			if(a[i]>=t/b[i]){
				sum+=a[i]-(t/b[i]);
			}
			else{
				sum+=0;
			}
		}
	}
	if(sum<=m){
		return 1;
	}
	else{
		return 0;
	}
}
int main()
{
	long long int ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	if(m>=ans){
		printf("0\n");
		return 0;
	}
	sort(a,a+n);
	sort(b,b+n,cmp);
	long long int l=0,r=12000000000000;
	long long int daan=0; 
    while(l<=r) 
    {	
        long long int mid = (l + r) / 2;
        if(check(mid)) {
        daan=mid;
		r = mid-1;}
		 //检查mid是否符合题目要求
        else l = mid+1;
        
    }
    printf("%lld\n",daan);
	return 0;
}

Measured memory_bytes: 5888
K = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[K-1])

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n,d,x,y;
    scanf("%d%d",&n,&d);
    int c=0;
    while (n--)
    {
        scanf("%d%d",&x,&y);
        double val=1.0*sqrt(pow(x,2)+pow(y,2));
        if (val<=d)
        c++;
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;



int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int m = 0;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        if(m+1 < v[i]){
            ans += (v[i]-1)/(m+1);
            v[i] = max(1, m);
        }
        m = max(m, v[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 768
x = int(input())

a = [i**5 for i in range(0, 300)]

for i in range(300):
    flag = 0
    for j in range(300):
        if a[i] - a[j] == x:
            print(i,j)
            flag = 1
            break
            
        if a[i] + a[j] == x:
            print(i,-j)
            flag = 1
            break
    if flag == 1:
        break

Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int[] h = new int[N];
		int hi = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
			if (h[i] != 0) {
				hi = i;
			}
		}
		int height;
		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++) {
				height = h[hi] + Math.abs(x[hi] - i) + Math.abs(y[hi] - j);
				for (int k = 0; k < N; k++) {
					if (h[k] != Math.max(height - Math.abs(x[k] - i) - Math.abs(y[k] - j), 0)) {
						break;
					}
					if (k == N - 1) {
						System.out.println(i + " " + j + " " + height);
						sc.close();
						return;
					}
				}
			}
		}

		sc.close();
	}

}


Measured memory_bytes: 22868
n, m = map(int, input().split())
# xの根を求める


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


# 初期化
# 根なら-size,子なら親の頂点
par = [-1] * (n + 1)
for _ in range(m):
    a, b = map(int, input().split())
    unite(a, b)
ans = 0
for i in range(1, n + 1):
    ans = max(ans, size(i))
print(ans)


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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 1e2 + 5;

char a[N][N];
int f[N][N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    rf(i, 1, h) rf(j, 1, w) cin >> a[i][j];
    f[0][1] = 0;
    f[1][0] = 0;
    rf(i, 1, h) f[i][1] = f[i - 1][1] + (a[i][1] == '#' && a[i - 1][1] != '#');
    rf(i, 1, w) f[1][i] = f[1][i - 1] + (a[1][i] == '#' && a[1][i - 1] != '#');
    rf(i, 2, h) rf(j, 2, w) {
        int res1 = f[i - 1][j];
        int res2 = f[i][j - 1];
        if (a[i][j] == '#' && a[i - 1][j] != '#') {
            res1++;
        }
        if (a[i][j] == '#' && a[i][j - 1] != '#') {
            res2++;
        }
        f[i][j] = min(res1, res2);
    }
    cout << f[h][w] << "\n";
    // cout << f[2][2] << "\n";
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [0] + list(map(int, input().split())) + [0]

    dist = 0
    for i in range(1, N+2):
        dist += abs(A[i] - A[i-1])
    
    for i in range(1, N+1):
        ans = dist - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1])
        print(ans)

main()

Measured memory_bytes: 64876
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,X;
  X=0;
  cin>>N;
  for(int i=0;i<N+1;i+=7){
    if((N-i)%4==0&&X==0){
      cout<<"Yes"<<endl;
      X++;
    }
  }
  if(X==0)cout<<"No"<<endl;
}


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

int main(void) {
  int n;

  std::string str;
  std::cin >> str;
  n = std::stoi(str);

  int count = 0;
  int sosuu[10000] = {0};
  //int index[55555]  = {0};

  for (int i = 2; i <= 55555; ++i) {
    bool is_sosuu = true;
    for (int j = 0; j < count; ++j) {
      if (sosuu[j] > (int)std::sqrt(i)) {
        break;
      }
      if (i % sosuu[j] == 0) {
        is_sosuu = false;
      }
    }
    if (is_sosuu) {
      sosuu[count++] = i;
      //index[i] = 1;
    }
  }

  //for (int i = 0; i < count; i++) {
  //  std::cout << i << " : " << sosuu[i] << std::endl;
  //}

  size_t ncount = 0;
  int result[n] = {0};
  for (size_t i = 0; i < count; i++) {
    if (sosuu[i] % 5 == 1) {
      result[ncount] = sosuu[i];
      ncount++;

      if (ncount == n) {
        break;
      }
    }
  }

  std::cout << result[0];
  for (size_t i = 1; i < n; i++) {
    std::cout << " " << result[i];
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	string s;
	int k;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++) {
		if (i + 1 == s.size()) {
			k %= 26;
			s[i] = (s[i] - 'a' + k) % 26 + 'a';
		} else {

			int to = 'z' - s[i] + 1;
			to %= 26;
			if (to <= k) {
				s[i] = 'a';
				k -= to;
			}
		}	
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc126/tasks/abc126_b

def month?(num)
  num > 0 && num < 13
end


S = gets.to_i

x = S / 100
y = S % 100

ans = if month?(x) && month?(y)
         'AMBIGUOUS'
      elsif month?(y)
        'YYMM'
      elsif month?(x)
        'MMYY'
      else
        'NA'
      end
puts ans


Measured memory_bytes: 1788
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        int result = s.replace("0", "").length();

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


Measured memory_bytes: 21844
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()

module IntMap = Map.Make (struct 
  type t = int 
  let compare = compare
end)

let rec loop map i ans =
  if i = n then ans
  else
    let ans = ans + try IntMap.find (i - a.(i)) map with _ -> 0 in
    let k = i + a.(i) in
    let map = IntMap.add k (1 + try IntMap.find k map with _ -> 0) map in
    loop map (i + 1) ans

let () = Printf.printf "%d\n" @@ loop IntMap.empty 0 0

Measured memory_bytes: 31444
import java.util.Scanner;

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

        int n = Integer.parseInt(scanner.nextLine());
        int tScore = 0;
        int hScore = 0;

        for(int i = 0; i < n; i++){
            String taro = scanner.next().toLowerCase();
            String hana = scanner.next().toLowerCase();

            if(taro.equals(hana)){
                tScore++;
                hScore++;
            }else{
                char[] tCh = taro.toCharArray();
                char[] hCh = hana.toCharArray();

                int min = tCh.length < hCh.length ? tCh.length : hCh.length;
                int index = 0;
               do{
                   if(index == min){
                       if(tCh.length > hCh.length){
                           tScore += 3;
                       }else {
                           hScore += 3;
                       }
                       break;
                   }else if(tCh[index] == hCh[index]){
                        index++;
                    }else if(tCh[index] > hCh[index]){
                        tScore += 3;
                        break;
                    } else if (tCh[index] < hCh[index]) {
                        hScore += 3;
                        break;
                    }


                }while(index <= min);
            }

        }

        System.out.printf("%d %d\n", tScore, hScore);

        scanner.close();
    }
}



Measured memory_bytes: 32616
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using LL = long long ;
const int kN = 100000 + 5;
int n;
std::vector<int> edges[kN];
LL a[kN];

void bad()
{
    puts("NO");
    exit(0);
}

LL dfs(int u, int fa)
{
    if (edges[u].size() == 1) return a[u];
    LL sum = 0, vmax = 0;
    for (int v : edges[u]) if (v != fa) {
        LL cnt = dfs(v, u);
        sum += cnt;
        vmax = std::max(vmax, cnt);
    }
    LL up = 0, pair = 0;
    if (vmax * 2 > sum) {
        up = vmax - (sum - vmax);
        sum -= up;
    }
    pair += sum / 2;
    up += sum & 1;
    if (up + 2 * pair < a[u] || up + pair > a[u]) {
        bad();
    }
    do {
        LL tmp = a[u] - up - pair;
        up += tmp * 2;
        pair -= tmp;
    } while (false);
    return up;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) scanf("%lld", a + i);
    for (int i = 0; i < n - 1; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b); a --; b --;
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }
    if (n == 2) {
        puts(a[0] == a[1] ? "YES" : "NO");
        return 0;
    }
    int root = 0;
    for (int i = 0; i < n; ++ i) if (edges[i].size() > 1) root = i;
    puts(0 == dfs(root, -1) ? "YES" : "NO");
}


Measured memory_bytes: 13568
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

# ここから処理
s = ns()
k = ni()

chl = list(s)
res = k

for i, c in enumerate(chl):
    if c == "a":
        continue
    
    elif res >= ord("z") - ord(c) + 1:
        chl[i] = "a"
        res -= (ord("z") - ord(c) + 1)

chl[-1] = chr(ord(chl[-1]) + res%26)

print("".join(chl))

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=1000001 ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;
   ///Mission-500
   ll n,k ;
   cin>>n>>k ;
   vector<ll>v(n) ;
   for(ll i=0;i<n;i++)
    cin>>v[i] ;

   sort(all(v)) ;

   ll ans=0 ;
    ll c=1 ;

   for(ll i=n-k;i>=0;i--)
   {
       ll x=c*v[i] ;
       x%=maa ;
       ans-=x+maa ;
       ans%=maa ;
       ans+=maa ;
       ans%=maa ;
       ll cur=n-1-i ;
      c=(c*(cur+1))%maa ;
      c=(c*power(cur+1-k+1,maa-2))%maa ;

   }

   c=1 ;

//   cout<<ans<<endl ;

   for(ll i=k-1;i<n;i++)
   {
        ll x=c*v[i] ;
       x%=maa ;
       ans+=x ;
       ans%=maa ;
       ans+=maa ;
       ans%=maa ;
       ll cur=i ;
      c=(c*(cur+1))%maa ;
      c=(c*power(cur+1-k+1,maa-2))%maa ;

   }

   cout<<ans ;




}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(), c.end()

using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

const int INF = 1e9;
const double EPS = 1e-6;
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> using heap = priority_queue<T, vector<T>, greater<T>>;

using Point = complex<double>;

struct Circle {
    Point c;
    double r;
};

// 円と円の交点
pair<Point, Point> get_cross_points(Circle c1, Circle c2) {
    double d = abs(c1.c - c2.c);
    double a = acos((c1.r * c1.r - c2.r * c2.r + d * d) / (2 * c1.r * d));
    double t = arg(c2.c - c1.c);
    return {c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)};
}

void solve(int N) {
    vector<Circle> C(N);
    rep(i, 0, N) {
        double x, y;
        cin >> x >> y;
        C[i] = {Point(x, y), 1};
    }

    auto check_intersect = [&](int i, int j) {
        return abs(C[i].c - C[j].c) < C[i].r + C[j].r;
    };

    auto check_inner = [&](Circle c, Point p) {
        return abs(c.c - p) <= c.r + EPS;
    };

    int ans = 0;
    rep(i, 0, N) {
        rep(j, i + 1, N) {
            if (check_intersect(i, j)) {
                auto cps = get_cross_points(C[i], C[j]);
                int cnt = 0;
                rep(k, 0, N) {
                    if (check_inner(C[k], cps.first)) {
                        cnt++;
                    }
                }
                chmax(ans, cnt);
                cnt = 0;
                rep(k, 0, N) {
                    if (check_inner(C[k], cps.second)) {
                        cnt++;
                    }
                }
                chmax(ans, cnt);
            }
        }
    }
    rep(i, 0, N) {
        int cnt = 0;
        rep(k, 0, N) {
            if (check_inner(C[k], C[i].c)) {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

signed main() {
    while (1) {
        int N;
        cin >> N;
        if (N == 0) break;
        solve(N);
    }
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

int main() {
  int r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,flag,sum,m,n,left,mid,right,S[100000],T[50000];
  scanf("%d",&m);
  for(i=0;i<m;i++)scanf("%d",&S[i]);
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&T[i]);
  
  for(i=0;i<n;i++){
    left = 0;
    right = m;
    flag = 0;
    while(left < right){
      mid = (left + right) / 2;
      if(S[mid] == T[i]){
	flag = 1;
	break;
      }
      else if(T[i] < S[mid])right = mid;
      else left = mid + 1;
    }
    if(flag==1)sum++;
  }
  printf("%d\n",sum);
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    if (A[0] == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll LIM = 1000000000000000000LL;
    ll ans = 1;
    rep(i, N) {
        ans *= A[i];
        if (ans <= 0 || LIM < ans) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4048
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const Arr = (input.trim()).split("\n");
const N1 = Number(Arr[0]);
const arr1 = Arr[1].split(" ").map(Number);
const arr2 = Arr[3].split(" ").map(Number);

const summing = (a, b) => a + b;
console.log(arr2.map((function(arr, N) {
  return (key) => {   
    let mid;
    let left = 0;
    let right = N;
    if (key < arr[0] || arr[N-1] < key) return 0;
    while (left < right) {
      mid = Math.floor((left + right) / 2);
      if (key < arr[mid]) right = mid;
      else if (key > arr[mid]) left = mid + 1;
      else return 1;
    }
    return 0;
  }
})(arr1, N1)).reduce((a, b) => a + b, 0));



Measured memory_bytes: 34964
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if v <= w:
    print('NO')
else:
    if (v-w) * t >= abs(a - b):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 65480
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long A, long long B, long long C) {
    ll ans = 0;
    ll tmp_a, tmp_b, tmp_c;

    if (A == B && B == C && C == A && A%2 == 0) {
        ans = -1;
    } else {
        while (A%2 == 0 && B%2 == 0 && C%2 == 0) {
            tmp_a = B/2 + C/2;
            tmp_b = C/2 + A/2;
            tmp_c = A/2 + B/2;

            A = tmp_a;
            B = tmp_b;
            C = tmp_c;

            ans++;
        }
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long A;
  cin >> A;
  long long B;
  cin >> B;
  long long C;
  cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1ll << 60;
     
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
     
constexpr ll MAX = 100100;
ll happy[MAX][3];
ll table[MAX][3];
ll n;
     
int main(int argc, char **argv)
{
	cin >> n;
     
	for (ll i = 0; i < n; ++i)
		for (ll j = 0; j < 3; ++j)
			cin >> happy[i][j];
     
    	
	for (ll i = 0; i < n; ++i)
	{
		for (ll j = 0; j < 3; ++j)
		{
			for (ll k = 0; k < 3; ++k)
			{
				if (j == k) continue;
				chmax(table[i+1][j] , table[i][k]+happy[i][j]);
			}
		}
	}

	
	std::cout << *max_element(begin(table[n]), end(table[n]))<< std::endl;
}


Measured memory_bytes: 4992
s = input()

n = len(s)
s1 = s[:(n-1)//2]
s2 = s[(n+3) // 2 - 1:]

s_reversed = ''.join(list(reversed(s)))
s1_reversed = ''.join(list(reversed(s1)))
s2_reversed = ''.join(list(reversed(s2)))

if s == s_reversed and s1 == s1_reversed and s2 == s2_reversed:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> d(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    d[a]++, d[b]++;
  }
  for (int i = 0; i < N; i++) {
    cout << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 29);
ll k, m, n,h,w,v;
const ll MOD= 1000000007;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    cin >> n; ll sum = 1;
    vector<int> a(n + 1), c(3, 0);
    req(i, n) cin >> a[i];
    req(i, n) {
        ll cnt = 0, id = -1;
        if (a[i] == c[0]) { cnt++; id = 0; }
        if (a[i] == c[1]) { cnt++; id = 1; }
        if (a[i] == c[2]) { cnt++; id = 2; }
        if (id == -1) {
            cout << 0 << endl;
            return 0;
        }sum *= cnt; c[id]++;
        sum %= MOD;
    }cout << sum << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
int N, K, A, B;

int main(int argc, char ** argv) {
	scanf("%d%d%d%d", &N, &K, &A, &B);
	printf("%d\n", min(N, K)*A + max(0, N-K)*B);
	return 0;
}


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

#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back

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

template<typename T> using V = vector<T>;

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int a; cin >> a;
	string s; cin >> s;
	cout << (a >= 3200 ? s : "red") << '\n';
}

Measured memory_bytes: 256
/*
 * @Author: Kaizyn
 * @Date: 2020-05-10 19:57:14
 * @LastEditTime: 2020-05-10 21:34:44
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 1e6+7;

int n;
int minv[N], endv[N];
string s[N];
vector<int> neg, pos;

inline void solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> s[i];
  int sum = 0, val = 0;
  for (int i = 1; i <= n; ++i) {
    for (const char &c : s[i]) {
      endv[i] += (c == '(' ? 1 : -1);
      minv[i] = min(minv[i], endv[i]);
    }
    sum += endv[i];
    if (minv[i] >= 0) {
      val += endv[i];
    } else if (endv[i] >= 0) {
      pos.emplace_back(i);
    } else if (minv[i] < endv[i]) {
      neg.emplace_back(i);
    }
  }
  if (sum != 0) return void(cout << "No" << endl);
  sort(pos.begin(), pos.end(), [&](const int &x, const int &y) {
      return minv[x] > minv[y];
  });
  for (const int &i : pos) {
    if (val < -minv[i]) return void(cout << "No" << endl);
    val += endv[i];
  }
  sort(neg.begin(), neg.end(), [&](const int &x, const int &y) {
      return minv[x] < minv[y];
  });
  for (const int &i : neg) {
    if (val < -minv[i]) return void(cout << "No" << endl);
    val += endv[i];
  }
  cout << "Yes" << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long n = long.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        long ans = 1;
        for (int i = 0; i < n - 1; i++)
        {
            if (s[i] != s[i + 1])
            {
                ans += 1;
            }

        }

        //出力
        Console.WriteLine(ans);
    }
}

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

int N;
vector<int> numS(110);
vector<int> sumS(110);
int mochi = 0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> numS.at(i);
	}
	for (int i = 0; i < N; i++) {
		sumS.at(numS.at(i))++;
	}
	for (int x : sumS) {
		if (x != 0)mochi++;
	}
	cout << mochi << endl;
}

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

int main()
{
  unsigned long long a;
  long double b;
  cin >> a >> b;

  unsigned long long ans = a * round(b * 100) / 100;
  cout << ans << endl;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n, k;

int main() {

	FAST;

	cin >> n >> k;
	vector <int> a(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	int ans = *max_element(a.begin(), a.end());
	int l = 1, r = *max_element(a.begin(), a.end());
	while (l <= r) {
		int midd = (l + r) / 2;
		// cout << l << ' ' << r << ' ' << midd << '\n';
		int cuts = 0;
		for (int i = 1; i <= n; i ++) {
			cuts += (a[i] + midd - 1) / midd - 1;
		}
		if (cuts <= k) {
			ans = min(ans, midd);
			r = midd - 1;
		}
		else {
			l = midd + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    ans += power(2, n) - 1;
    int tmp1 = 1, tmp2 = 1;
    RREP(i, n, n - a + 1) {
        tmp1 = (tmp1 * i) % mod;
    }
    rep(i, a) {
        tmp1 = Div(tmp1, i + 1);
    }
    RREP(i, n, n - b + 1) {
        tmp2 = (tmp2 * i) % mod;
    }
    rep(i, b) {
        tmp2 = Div(tmp2, i + 1);
    }
    ans = ans - tmp1 - tmp2 + mod + mod + mod + mod;
    cout << ans % mod << endl;


    return 0;
}


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

const ll MOD = 1e9 + 7;
const int N = (1e2) + 5;
int memo[N][4][4][4];

int DP(int n, int c, int b, int a) {
  if (n == 3) return 1;
  int& ret = memo[n][c][b][a];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 0; i < 4; ++i) {
    if (i == 0 and c == 1 and b == 2 and a == 1) continue;
    if (i == 0 and c == 2 and b == 2 and a == 1) continue;
    if (i == 0 and c == 3 and b == 2 and a == 1) continue;
    if (i == 0 and c == 2 and b == 0 and a == 1) continue;
    if (i == 0 and c == 2 and b == 2 and a == 1) continue;
    if (i == 0 and c == 2 and b == 3 and a == 1) continue;
    if (i == 0 and c == 2 and b == 1) continue;
    if (i == 0 and c == 1 and b == 2) continue;
    if (i == 2 and c == 0 and b == 1) continue;
    ret += DP(n - 1, i, c, b);
    ret %= MOD;
  }
  return ret;
}

int main() { // claudio van
  int n; cin >> n;
  memset(memo, -1, sizeof memo);
  int ans = 0;
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      for (int k = 0; k < 4; ++k) {
        if (i == 0 and j == 2 and k == 1) continue;
        if (i == 0 and j == 1 and k == 2) continue;
        if (i == 2 and j == 0 and k == 1) continue;
        ans += DP(n, i, j, k);
        ans %= MOD;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val S = (1..H).map { readLine()!!.map { it=='.' } }
    val L = Array(H+2){ IntArray(W+2){0} }
    val R = Array(H+2){ IntArray(W+2){0} }
    val U = Array(H+2){ IntArray(W+2){0} }
    val D = Array(H+2){ IntArray(W+2){0} }
    val ans = Array(H+2){ IntArray(W+2){0} }

    for (i in 1..H) for (j in 1..W) {
        if(S[i-1][j-1]) {
            L[i][j] = L[i][j-1]+1
            U[i][j] = U[i-1][j]+1
            ans[i][j] += L[i][j] + U[i][j]
        }
    }
    for (i in H downTo 1) for (j in W downTo 1) {
        if(S[i-1][j-1]) {
            R[i][j] = R[i][j+1]+1
            D[i][j] = D[i+1][j]+1
            ans[i][j] += R[i][j] + D[i][j]
        }
    }
    println( ans.map { it.max()!! }.max()!!-3 )


}

Measured memory_bytes: 179228
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <queue>
#include <functional> 

using namespace std;
typedef long long ll;

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

int main(){
    //制約に注意 
    //AとBを必ず１つ使うこと
    ll N, A, B;
    cin >> N >> A >> B;

    if(A > B){
        cout << "0" << endl;
        return 0;
    }else if(N == 1 && B - A >= 1){
        cout << "0" << endl;
        return 0;     
    }

    cout << (N - 2) * (B - A) + 1 << endl;



} 

Measured memory_bytes: 256
import java.util.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	static ArrayList<Integer> G = new ArrayList<Integer>();
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0; i < n; ++i)
			a[i] = Integer.parseInt(sc.next());
		sc.close();
		long cnt = shellSort(a);
		System.out.println(G.size());
		revPrintArrayList(G);
		System.out.println(cnt);
		for(int i = 0; i < n; ++i)
			System.out.println(a[i]);
	}

	public static void printArray(int[] a){
		int n = a.length;
		for(int i = 0; i < n; ++i){
			if(i != 0) System.out.print(" ");
			System.out.print(a[i]);
		}

	}

	public static void revPrintArrayList(ArrayList<Integer> a){
		int n = a.size();
		for(int i = n-1; i >= 0; --i){
			System.out.print(a.get(i).intValue());
			if(i != 0)  System.out.print(" ");
		}
		System.out.println();
	}

	public static int insertionSort(int[] a, int g){
		int n = a.length, ret = 0;
		for(int i = g; i < n; ++i){
			int instnum = a[i], j;
			for(j = i - g; j >= 0 && a[j] > instnum; j -= g){
				a[j+g] = a[j]; ++ret;
			}
			a[j+g] = instnum;
		}
		return ret;
	}
	
	public static long shellSort(int[] a){
		long cnt = 0;
		int n = a.length;
		for(int h = 1;;){
			if(h > n) break;
			G.add(h);
			h = 3 * h + 1;
		}
		
		for(int i = G.size()-1; i >= 0; --i){
			cnt += insertionSort(a, G.get(i));
		}
		return cnt;
	}
}


Measured memory_bytes: 179300