akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	H, W, _ := ReadInt(), ReadInt(), ReadInt()
	grid := make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = ReadString()
	}
	ans := make([][]int, H)
	for i := 0; i < H; i++ {
		ans[i] = make([]int, W)
	}

	nextK := 1
	var lastStrawBerryRow []int
	for y := 0; y < H; y++ {
		foundStrawBerry := 0
		for x := 0; x < W; x++ {
			if grid[y][x] == '#' {
				foundStrawBerry++
				for i := x; i >= 0; i-- {
					if ans[y][i] > 0 {
						break
					}
					ans[y][i] = nextK + foundStrawBerry - 1
				}
			}
		}
		if foundStrawBerry == 0 {
			continue
		}
		if ans[y][W-1] == 0 {
			for i := W - 1; i >= 0; i-- {
				if ans[y][i] > 0 {
					break
				}
				ans[y][i] = nextK + foundStrawBerry - 1
			}
		}
		for i := y - 1; i >= 0; i-- {
			if ans[i][0] > 0 {
				break
			}
			ans[i] = ans[y]
		}
		lastStrawBerryRow = ans[y]
		nextK += foundStrawBerry
	}
	for i := H - 1; i >= 0; i-- {
		if ans[i][0] > 0 {
			break
		}
		ans[i] = lastStrawBerryRow
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%d ", ans[i][j])
		}
		fmt.Println()
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void) {
	
	string S, T;
	int A, B;
	string U;

	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if (U == S) A--;
	if (U == T) B--;

	cout << A << " " << B;
	return 0;
}

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

int main() {
  int n, a, b;
  int na;
  int ans;

  cin >> n >> a >> b;

  na = n*a;
  if(na < b){ ans = na;}
  else {ans = b;}

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
    ///"In the name of Allah,most gracious and most merciful"///

    ll i,j,x,y,z,count=0,sum=0,n;
    cin>>n;
    if(n%1000==0)
        cout<<"0"<<endl;
    else
    {
        x=1000-(n%1000);
        cout<<x<<endl;
    }



    return 0;
}





Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
bool p[MAX];
int b[MAX];

void setprime(){
  p[1] = false; p[2] = true;
  for(int i = 3; i <= MAX; i += 2){
    int sq = sqrt((double)i);
    p[i] = true; p[i+1] = false;
    for(int j = 3; j <= sq; j += 2){
      if(!(i%j)) p[i] = false;
    }
  }
}

void set2017like(){
  b[1] = 0; b[3] = 0;
  for(int i = 3; i <= MAX; i += 2){
    b[i+2] = b[i] + (p[i] && p[(i+1)/2] ? 1 : 0);
  }
}

int main(){
  int q, r, l;
  scanf("%d", &q);
  setprime();
  set2017like();
  for(int i = 0; i < q; i++){
    scanf("%d%d", &l, &r);
    printf("%d\n", b[r+2] - b[l]);
  }
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        sc.close();

        int ans = 0;

        if (K == 1) {

            System.out.println(1+N);
        } else if (K > 1 && K <= 3) {

            if ( N > 2) {

                ans = 4 + K*(N-2);
            } else {

                ans = (int) Math.pow(2,N);
            }

            System.out.println(ans);
        } else if (K > 3 && K <= 7) {

            if ( N > 3) {

                ans = 8 + K*(N-3);
            } else {

                ans = (int) Math.pow(2,N);
            }
            System.out.println(ans);
        } else {

            if ( N > 4) {

                ans = 16 + K*(N-4);
            } else {

                ans = (int) Math.pow(2,N);
            }
            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>

int main() {
	int a, b, c, d; std::cin >> a >> b >> c >> d;
	std::cout << std::max(0, std::min(b, d) - std::max(a, c)) << std::endl;
}



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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<pair<ll, pair<ll, ll>>> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll x, y, h;
        cin >> x >> y >> h;
        A.push_back(make_pair(h, make_pair(x, y)));
    }
    sort(A.begin(), A.end());
    pair<ll, pair<ll, ll>> pp = A.back();
    for(int x1=0;x1<=100;x1++) {
        for(int y1=0;y1<=100;y1++) {
            ll flag=0;
            ll h = pp.first+abs(x1-pp.second.first)+abs(y1-pp.second.second);
            for(int i=0;i<N-1;i++) {
                pair<ll, pair<ll, ll>> pp1 = A[i];
                if(pp1.first==0) {
                    if(h - abs(x1-pp1.second.first) - abs(y1-pp1.second.second)>0) flag=1;
                } 
                else {
                    if(h - abs(x1-pp1.second.first) - abs(y1-pp1.second.second)!=pp1.first) flag=1;
                }
            }
            if(!flag) cout << x1 << " " << y1 << " " << h << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 1123456;
const double pi = 3.14159265359;
const double eps = 0.00000001;

li arr[MAXN];

int32_t main() {

    $
    
    int n, k;

    cin >> n >> k;

    double ans = 0;

    int x;
    forn (1, n + 1) {
        if (i >= k) ans += (1 / (double)n);
        else {
            x = ceil(log2(k / (double)i));
            ans += (1 / (double)(1 << x)) * (1 / (double)n);
        }
    }
    
    cout << fixed;
    cout.precision(15);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, q;
    char k;
    cin >> n;
    int S[14] = {0}, H[14] = {0}, C[14] = {0}, D[14] = {0};

    for(int i = 0; i < n; i++) {
        cin >> k >> q;
        switch (k)
        {
        case 'S':
            S[q] = 1;
            break;
        case 'H':
            H[q] = 1;
            break;
        case 'C':
            C[q] = 1;
            break;
        case 'D':
            D[q] = 1;
            break;
        }
    }

        for(int j = 1; j < 14; j++) {
            if(S[j] == 0) {
                cout << 'S' << ' ' << j << endl;
            }
            // cout << S[j];
        }
        for(int j = 1; j < 14; j++) {
            if(H[j] == 0) {
                cout << 'H' << ' ' << j << endl;
            }
            // cout << H[j];
        }
        for(int j = 1; j < 14; j++) {
            if(C[j] == 0) {
                cout << 'C' << ' ' << j << endl;
            }
            // cout << C[j];
        }
        for(int j = 1; j < 14; j++) {
            if(D[j] == 0) {
                cout << 'D' << ' ' << j << endl;
            }
            // cout << D[j];
        }

    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL s[100005];
LL powd(LL a,LL b,LL c)
{
	LL ans=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
			ans=(ans*a)%c;
		b/=2;
		a=(a*a)%c;
	}
	return ans;
}
int main()
{
	LL n,a;
	cin>>n;
	for(LL i=0;i<n;i++)
	{
		scanf("%lld",&a);
		s[a]++;
	}
	if(n%2==0)
	{
		LL k=n/2;
		for(LL i=1;i<=k;i++)
			if(s[2*i-1]!=2)
			{
				puts("0");
				return 0;
			}
		printf("%lld\n",powd(2,k,1000000007));
	}
	else
	{
		LL u=n/2;
		for(LL i=1;i<=u;i++)
			if(s[2*i]!=2||s[0]!=1)
			{
				puts("0");
				return 0;
			}
		printf("%lld\n",powd(2,u,1000000007));
	}
	return 0;
}

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

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

    cout<<(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


template<typename T, const T&(*f)(const T&, const T&) = std::min<T> >
struct rmq {
	vector<T> t;
	size_t d;
	
	rmq(size_t sz = 0, const T &val = T()): t(sz*2,val), d(sz) {}
	rmq(const vector<T> &vals){
		d = size(vals);
		t.resize(d*2);
		copy(begin(vals), end(vals), begin(t)+d);
		for(int i=d-1;i>0;--i) t[i] = f(t[i*2], t[i*2+1]);
	}
	
	void set_value(size_t i, const T& val){
		for(t[i+=d]=val; i>1; i>>=1) t[i>>1] = f(t[i], t[i^1]);
	}
	
	void update(size_t i, const T& val){
		set_value(i, f(t[i+d],val));
	}
	
	struct reference {
		rmq<T,f> *daddy;
		size_t position;
		reference(rmq<T,f> *t, size_t i): daddy(t), position(i) {}
		void operator=(const T &val){
			daddy->update(position, val);
		}
		operator T() {
			return daddy->t[position+d]; 
		}
	};
	
	reference operator[](size_t i){
		return reference(this, i);
	}
	
	T operator()(size_t l, size_t r){
		T res = t[l+=d];
		for(++l,r+=d; l<r; l>>=1,r>>=1){
			if(l&1) res = f(res, t[l]), ++l;
			if(r&1) --r, res = f(res, t[r]);
		}
		return res;
	}
	
	T operator()(){ return t[1]; }
};

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	vector<ll> x(n), y(n);
	for(int i=0;i<n;++i) cin>>x[i]>>y[i];
	
	ll ans = -9e18;
	
	for(int it=0;it<4;++it){
		
		vector<int> p(n); iota(ALL(p),0);
		sort(ALL(p), [&](int i, int j){return pair(y[i],x[i]) < pair(y[j],x[j]);});
		
		vector<ll> xs;
		for(int i=0;i<n;++i) xs.push_back(x[i]);
		sort(ALL(xs));
		
		rmq<ll,min> q(n,9e18);
		
		for(int i : p){
			//cout<<"?"<<i<<": "<<x[i]<<' '<<y[i]<<endl;
			int k = lower_bound(ALL(xs), x[i]) - begin(xs);
			ll s = q(0,k+1);
			ans = max(ans, x[i]+y[i] - s);
			q[k] = x[i]+y[i];
		}
		
		
		for(int i=0;i<n;++i){
			ll tx = x[i], ty = y[i];
			
			x[i] = ty;
			y[i] = -tx;
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 13928
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use { sc ->
        val n = sc.nextInt()
        val (a, b) = sc.asSequence().take(n).map { it.toInt() }.sortedDescending().withIndex().partition { it.index % 2 == 0 }
        println(a.map { it.value }.sum() - b.map { it.value }.sum())
    }
}


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

int main()
{
  int n ;
  cin >> n ;
  for(int i = 1 ; i <= 50000 ; i++)
  {
    int judge = i * 1.08 ;
    if(judge == n)
    {
      cout << i << endl ;
      break ;
    }
    else if(judge > n)
    {
      cout << ":(" << endl ;
      break ;
    }
  }
}


Measured memory_bytes: 256
def balls(ball_a, ball_b, a, b, u)
  if ball_a == u
    a = a - 1
  elsif ball_b == u
    b = b - 1
  end
  puts "#{a} #{b}"
end

ball_a, ball_b = gets.chomp.split(" ")
a, b = gets.chomp.split(" ").map(&:to_i)
u = gets.chomp
balls(ball_a, ball_b, a, b, u)

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

int main() {
	int n;
	cin>>n;
	vector<int> h(n);
	int m=0;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	for(int i=0;i<n;i++){
		if(h[i]>=m){
			m = h[i];
			ans++;
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;

const long long MOD = 1000000007;

int main() {
    int N;
    cin>>N;
    vector<int>L;
    L.push_back(0);
    //L.push_back(1e+9);
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        L.push_back(a);
    }
    int ans=0;
    sort(L.begin(),L.end());
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int d=abs(L[i]-L[j]);
            int e=L[i]+L[j];
            ans+=max((int)(lower_bound(L.begin(),L.end(),e)-L.begin())-(j+1),0);


        }
    }
    cout<<ans<<endl;



}













Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
string str;
cin>>str;
int n=str.length();
int i;
int count=0;
if(str[0]=='1')
{
  for(i=1; i<n; i++)
  {
    if(i%2!=0)
    { if(str[i]=='1')
      count++;

    }
    else
    {
      if(str[i]=='0')
      count++;
    }
  }
}
if(str[0]=='0')
{
  for(i=1; i<n; i++)
  {
    if(i%2!=0)
    { if(str[i]=='0')
      count++;

    }
    else
    {
      if(str[i]=='1')
      count++;
    }
  }
}
cout<<count;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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


	int n, S;
	cin >> n >> S;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	

	int ans = 0;
	for (auto &&x : a) {
		if (S >= x) {
			S -= x;
			ans++;
		}
	}
	if (ans == n && S > 0)
		ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
X,K,D = map(int, input().split())
X = abs(X)
q, mod = divmod(X, D)
#print(q,mod)
if q >= K :
    print(X - K*D)
else:
    if (K - q)%2 == 0:
        print(mod)
    else:
        print(D-mod)

Measured memory_bytes: 9116
#include <iostream>
//#include <iomanip>
using namespace std;

int main(){

	int a, b;
	char op;

	while(cin){
		cin >> a>> op >> b;
		if(op == '+'){
			cout << a + b << endl;
		}else if(op == '-'){
			cout << a - b << endl;
		}else if(op == '*'){
			cout << a * b << endl;
		}else if(op == '/'){
			cout << a / b << endl;
		}else if(op == '?'){
			break;
		}
	}

return 0;
}

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

using namespace std;

int main(int argc, char **argv)
{
    int A, B, K;
    cin >> A >> B >> K;
    int res = 0;
    int MINAB = min(A, B);
    for(int g = MINAB; K > 0; g--){
        if((A % g) == 0 && (B % g) == 0){
            K--;
            res = g;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n,k;cin>>n>>k;
	ll v1,v2;
	rep(i,0,n){
		ll x;cin>>x;
		if(x==1)v1=i;
	}
	k--;
	ll cnt=0,ans=0;
	while(1){
		cnt+=k,ans++;
		if(cnt>=n-1)break;
	}
	cout<<ans;
	return 0;
}



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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n, m;
  cin >> n >> m;

  vector<bool> acs(n + 1, false);
  vector<int> was(n + 1, 0);
  int ac = 0;
  int wa = 0;
  for(int i=0; i<m; i++) {
    int p;
    string s;
    cin >> p >> s;
    if(s == "AC" && !acs[p]) {
      acs[p] = true;
      ac++;
      wa += was[p];
    }
    else {
      if(!acs[p]) {
        was[p]++;
      }
    }
  }

  cout << ac << ' ' << wa << endl;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

    map<int, int> mp;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        ++mp[a];
    }
    int cnt = 0;
    for(auto p : mp) {
        cnt += (p.second%2);
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int ans = (n + (2 - 1)) / 2;

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

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()


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

template<i64 M>
struct modint {
  i64 a;
  constexpr modint(const i64 x = 0) noexcept: a((x % M + M) % M) {}
  constexpr i64 value() const noexcept { return a; }
  constexpr modint pow(i64 r) const noexcept {
    modint ans(1);
    modint aa = *this;
    while(r) {
      if(r & 1) {
        ans *= aa;
      }
      aa *= aa;
      r >>= 1;
    }
    return ans;
  }
  constexpr modint& operator+=(const modint r) noexcept {
    a += r.a;
    if(a >= M) a -= M;
    return *this;
  }
  constexpr modint& operator=(const i64 r) {
    a = (r % M + M) % M;
    return *this;
  }
  constexpr modint& operator-=(const modint r) noexcept {
    a -= r.a;
    if(a < 0) a += M;
    return *this;
  }
  constexpr modint& operator*=(const modint r) noexcept {
    a = a * r.a % M;
    return *this;
  }
  constexpr modint& operator/=(modint r) noexcept {
    i64 ex = M - 2;
    while(ex) {
      if(ex & 1) {
        *this *= r;
      }
      r *= r;
      ex >>= 1;
    }
    return *this;
  }

  constexpr modint operator+(const modint r) const {
    return modint(*this) += r;
  }
  constexpr modint operator-(const modint r) const {
    return modint(*this) -= r;
  }
  constexpr modint operator*(const modint r) const {
    return modint(*this) *= r;
  }
  constexpr modint operator/(const modint r) const {
    return modint(*this) /= r;
  }
};

using fp = modint<(i64)(1e9 + 7)>;

int main() {

  vector<fp> fact(2020);
  vector<fp> inv(2020);
  fact[0] = fp(1);
  rep(i,1,2020) fact[i] = fact[i - 1] * fp(i);
  inv[2020 - 1] = fp(1) / fact[2020 - 1];
  rev(i, 2020 - 1, 0) inv[i] = inv[i + 1] * fp(i + 1);

  auto binom = [&](i64 n, i64 k) {
    if(k < 0 || n < k) return fp(0);
    else return fact[n] * inv[k] * inv[n - k];
  };

  auto H = [&](i64 n, i64 k) {
    return binom(n + k - 1, k);
  };

  i64 N, K;
  cin >> N >> K;
  rep(i,1,K + 1) {
    cout << (H(i, K - i) * H(i + 1, (N - K) - (i - 1))).value() << endl;
  }
}


Measured memory_bytes: 256
from collections import Counter
from itertools import combinations
 
n = int(input())
l = [input()[0] for _ in range(n)]
lc = Counter(l)
 
con = []
for c in 'MARCH':
  if c in lc:
    con.append(lc[c])
 
ans = 0
for a, b, c in combinations(con, 3):
  ans += a * b * c
 
print(ans)

Measured memory_bytes: 4224
using System;
using System.Linq;
 
public class Test
{
	public static void Main()
	{
		
		int n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(y => long.Parse(y)).ToArray();
		int counter = 0;
		long ans = 1;
		long atcoder = 1000000000000000000;
		
		for(int i=0;i!=n;i++){
			if(a[i]==0){
				counter++;
				break;
			}
		}
		if(counter!=0){
			Console.WriteLine("0");
		}else{
			for(int j=0;j!=n;j++){
					if(ans>atcoder/a[j]){
						ans = -1;
						break;
					}
					ans *= a[j];
			}
			Console.WriteLine(ans);
		}
		
	}
}

Measured memory_bytes: 41456
#include <iostream>
using namespace std;
int ppl[4][2];

int c(double n){
	if(n>=1.1)return 0;
	if(n>=0.6)return 1;
	if(n>=0.2)return 2;
	return 3;
}

int main(){
	double t,t2;
	while(cin >> t >> t2){	
		ppl[c(t)][0]++;
		ppl[c(t2)][1]++;
	}
	for(int i=0;i<4;i++){
			cout << ppl[i][0] << " " << ppl[i][1] << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int maps[305][305];
bool flag[305][305];
int main()
{
    int n;
    //memset(maps,INF,sizeof(maps));
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&maps[i][j]);
        }
    }

    bool ok = true;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                if(i==j) continue;
                if(i==k) continue;
                if(j==k) continue;
                if(maps[i][k]+maps[k][j] < maps[i][j]) ok = false;
                if(maps[i][k]+maps[k][j] == maps[i][j]) flag[i][j] = flag[j][i] = 1;
            }
        }
    }

    if(!ok){
        puts("-1");
        return 0;
    }

    long long ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            if(flag[i][j]) continue;
            ans += maps[i][j];
        }
    }
    printf("%lld\n",ans/2);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
//#define lb lower_bound
//#define ub upper_bound
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>
#define mvl map<lli, vl>
#define vt vector<pair<ll, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
int main()
{
 //	ios::sync_with_stdio(0);
 //   cin.tie(0);
    lli n,k;
    cin>>n>>k;
    if(k<=(n+1)/2)
    cout<<"YES";
    else cout<<"NO";
    
    return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef struct ListKey {
    int num;
} ListKey;
bool listkey__equal(ListKey *a, ListKey *b) {
    return a->num == b->num;
}
typedef struct ListDat {
    ListKey key;
    struct ListDat *prev;
    struct ListDat *next;
} ListDat;
typedef struct List {
    size_t len;
    ListDat *hdr;
} List;
#define list_init(l) ((l) ? ((l)->len = 0, (l)->hdr = NULL) : 0)
#define list_len(l) ((l) ? (l)->len : 0)
#define list_delete_first(l) ((l)->len ? list__delete((l), (l)->hdr->next) : 0)
#define list_delete_last(l) ((l)->len ? list__delete((l), (l)->hdr->prev) : 0)
void list_insert(List *l, ListKey x) {
    ListDat *new_dat = malloc(sizeof(ListDat));
    if(l->len) {
        new_dat->next = l->hdr->next;
        l->hdr->next->prev = new_dat;
        l->hdr->next = new_dat;
    } else {
        l->hdr = malloc(sizeof(ListDat));
        l->hdr->prev = l->hdr->next = new_dat;
        new_dat->next = l->hdr;
    }
    new_dat->key = x;
    new_dat->prev = l->hdr;
    l->len++;
}
void list__delete(List *l, ListDat *a) {
    a->prev->next = a->next;
    a->next->prev = a->prev;
    free(a);
    l->len--;
}
void list_delete(List *l, ListKey x) {
    for(ListDat *it = l->hdr->next; it != l->hdr; it = it->next) {
        if(listkey__equal(&x, &it->key)) {
            list__delete(l, it);
            break;
        }
    }
}
void list_print(List *l) {
    for(ListDat *it = l->hdr->next; it != l->hdr; it = it->next) {
        printf(it->next == l->hdr ? "%d\n" : "%d ", it->key);
    }
}
int main(int argc, char **argv) {
    int n;
    scanf("%d", &n);
    List l;
    list_init(&l);
    for(int i = 0; i < n; ++i) {
        char str[16];
        scanf("%s", str);
        if(strlen(str) == 6 && strncmp(str, "insert", 6) == 0) {
            ListKey key;
            scanf("%d", &key.num);
            list_insert(&l, key);
        } else if(strlen(str) == 6 && strncmp(str, "delete", 6) == 0) {
            ListKey key;
            scanf("%d", &key.num);
            list_delete(&l, key);
        } else if(strlen(str) == 11 && strncmp(str, "deleteFirst", 11) == 0) {
            list_delete_first(&l);
        } else if(strlen(str) == 10 && strncmp(str, "deleteLast", 10) == 0) {
            list_delete_last(&l);
        }
    }
    list_print(&l);
    return 0;
}



Measured memory_bytes: 33036
import std.array;
import std.algorithm;
import std.range;
import std.stdio;
import std.c.stdio : scanf;

void main() {
  int n, y;
  scanf("%d %d", &n, &y);
  for (int i = 0; i <= y / 10000 && i <= n; ++i) {
    for (int j = 0; j <= y / 5000 && i + j <= n; ++j) {
      int k = n - i - j;
      if (i * 10000 + j * 5000 + k * 1000 == y) {
        writef("%d %d %d", i, j, k);
        return;
      }      
    }
  }
  write("-1 -1 -1");
}

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

int n, a[100005], sa[100005], b[100005], d[100005], e[100005], sgt[800005];
long long c;

bool cmp(int x, int y) {
	return b[x] < b[y];
}

bool cmp2(int x, int y) {
	return d[x] > d[y];
}

void build(int l, int r, int i) {
	sgt[i] = 0;
	if (l == r) {
		return;
	}
	int mid = (l + r) / 2;
	build(l, mid, i * 2);
	build(mid + 1, r, i * 2 + 1);
}

int query(int l, int r, int i, int x, int y) {
	int z = 0;
	if (x <= l && r <= y) return sgt[i];
	int mid = (l + r) / 2;
	if (l <= x && x <= mid || l <= y && y <= mid || x <= l && mid <= y) z += query(l, mid, i * 2, x, y);
	if (mid + 1 <= x && x <= r || mid + 1 <= y && y <= r || x <= mid + 1 && r <= y) z += query(mid + 1, r, i * 2 + 1, x, y);
	return z;
}

void update(int l, int r, int i, int x, int y) {
	int mid = (l + r) / 2;
	if (l == r) {
		sgt[i] = y;
		return;
	}
	if (x <= mid) update(l, mid, i * 2, x, y);
	else update(mid + 1, r, i * 2 + 1, x, y);
	sgt[i] = sgt[i * 2] + sgt[i * 2 + 1];
}

long long count(int m) {
	e[0] = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= sa[m]) d[i] = d[i - 1] - 1;
		else d[i] = d[i - 1] + 1;
		e[i] = i;
	}
	std::sort(e, e + n + 1, cmp2);
	long long ans = 0;
	build(0, n, 1);
	for (int i = 0; i <= n; ) {
		int j = i;
		while (j <= n && d[e[i]] == d[e[j]]) j++;
		for (int k = i; k < j; k++) {
			ans += query(0, n, 1, 0, e[k]);
		}
		for (; i < j; i++) {
			update(0, n, 1, e[i], 1);
		}
	}
	return ans;
}

int search(int x, int y) {
	int l = x, r = y;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (l == r) {
			return mid;
		} else if (count(mid) > c) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
}

int main() {
	scanf("%d", &n);
	c = 1ll * n * (n + 1) / 4;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		b[i] = i;
		sa[i] = a[i];
	}
	std::sort(sa + 1, sa + n + 1);
	std::sort(b + 1, b + n + 1);
	printf("%d\n", sa[b[search(1, n)]]);
}

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

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

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

const ll mod = 998244353L;

void write(const VB &x) {
  for(bool b: x) {
    cout << b;
  }
  cout << endl;
}

void addAssign(VB &x, const VB &y, int offset) {
  int n = x.size();
  REP(i,offset,n) {
    x[i] = x[i] != y[i - offset];
  }
  while(!x.empty()) {
    if(x.back()) break;
    x.pop_back();
  }
}

void gcd(VB &x, VB &y) {
  if(x.size() < y.size()) {
    x.swap(y);
  }
  while(y.size() > 0) {
    addAssign(x, y, x.size() - y.size());
    if(x.size() < y.size()) {
      x.swap(y);
    }
  }
}

ll solve(const VB &x, const VB &g) {
  int xl = x.size();
  int gl = g.size();
  if(xl < gl) {
    return 1;
  }
  ll ans = 0;
  for(int i=xl-1; i>=gl-1; i--) {
    ans = (ans * 2) % mod;
    if(x[i]) {
      ans = (ans + 1) % mod;
    }
  }
  VB y(xl);
  copy(g.begin(), g.end(), y.begin() + (xl - gl));
  for(int i=xl-1; i>=gl-1; i--) {
    if(x[i] != y[i]) {
      addAssign(y, g, i - gl + 1);
    }
  }
  ans++;
  for(int i=gl-1; i>=0; i--) {
    if(x[i] < y[i]) {
      ans--;
      break;
    }
    if(x[i] > y[i]) {
      break;
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string str;
  cin >> str;
  VB x;
  transform(str.rbegin(), str.rend(), back_inserter(x), [](char c){return c == '1';});
  vector<VB> as(N);
  FOR(a,as) {
    cin >> str;
    transform(str.rbegin(), str.rend(), back_inserter(a), [](char c){return c == '1';});
  }
  VB g;
  FOR(a,as) {
    gcd(g, a);
  }
  cout << solve(x, g) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
string S;
bool isKaibun(string s) {
	int n = s.length();
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n - 1 - i]) {
			return false;
		}
	}
	return true;
}
int main() {
	cin >> S;
	string sub = S.substr(0, S.length() / 2);
	bool F = isKaibun(S) && isKaibun(sub);
	if (F) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
import math

inps = [int(i) for i in input().split()] # A B H M
A = inps[0]
B = inps[1]
H = inps[2]
M = inps[3]

H %= 12
M %= 60

hour = (H + M / 60) * 30
mins = M * 6

angle = abs(hour - mins)

angle = min(360 - angle, angle)

angle = math.radians(angle)

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle)))

Measured memory_bytes: 9468
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: String,
        b: String
    };
    let arr = ["H", "D", "H"];
    let rs = arr[((a == "H") as i32 + (b == "H") as i32) as usize];
    println!("{}", rs);
}


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

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

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


    for(int i = 0; i < m; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            if(j == x[i][0]-1){
                sum += x[i][1];
            }
            else {
                sum  += t[j];
            }
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

ll calc(string s){
	ll ans = 0;
	ll x,y;
	FOR(i,1,s.size()){
		x = stoi(s.substr(0,i));
		y = stoi(s.substr(i,s.size()-i));
		ans = max(ans,x*y);
	}
	return ans;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll Q;
	cin >> Q;
	FOR(t,0,Q){
		ll R;
		cin >> R;
		ll ans = 0;
		while(R>=10){
			R = calc(to_string(R));
			++ans;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define MOD 1000000007
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	int n;
	cin >> n;
	
	vector<ll> v(n);
	rep(i, n) cin >> v[i];
	
	ll ans = 0;
	
	rep(i, n){
		if(i != 0){
			if(v[i-1] > 0 && v[i] > 0){
				ans++;
				v[i-1]--;
				v[i]--;
			}
		}
		if(v[i] > 1){
			ll tmp = v[i] / 2;
			ans += tmp;
			v[i] -= (2 * tmp);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = 2000005, MOD = 1000000007;
int f[N], finv[N], act[N];

int mul(int a, int b) {
    return (ll)a * b % MOD;
}

void precalc() {
    f[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = mul(f[i - 1], i);
    }
    finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
        finv[i] = (MOD - mul(MOD / i, finv[MOD % i])) % MOD;
    }
    for (int i = 2; i < N; i++) {
        finv[i] = mul(finv[i - 1], finv[i]);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    precalc();
    int n;
    cin >> n;
    for (int k = (n + 1) / 2; k < n; k++) {
        act[k] = mul(mul(f[k - 1], f[k]), finv[2 * k - n]);
    }
    ll res = 0;
    for (int k = (n + 1) / 2; k < n; k++) {
        res = (res + mul(k, MOD + act[k] - act[k - 1])) % MOD;
    }
    cout << res << "\n";
}


Measured memory_bytes: 20352
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=1000000007,n=Number(t[0]),o=t[1].split(""),u=t[2].split(""),i=1,f=0,l=0;l<n;l++)o[l]==u[l]?(0==f&&(i*=3),1==f&&(i*=2),2==f&&(i*=1),f=1,i%=r):(0==f&&(i*=6),1==f&&(i*=2),2==f&&(i*=3),i%=r,f=2,l+=1);console.log(i)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 7372
unittest
{
	assert( [ "4", "2 3 5", "2 1 5", "1 2 5", "3 2 5" ].solve == "2 2 6" );
	assert( [ "2", "0 0 100", "1 1 98" ].solve == "0 0 100" );
	assert( [ "3", "99 1 191", "100 1 192", "99 0 192" ].solve == "100 0 193" );
	
	assert( [ "5", "100 100 0", "2 3 5", "2 1 5", "1 2 5", "3 2 5" ].solve == "2 2 6" );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xyhs = new long[ 3 ][ n ];
	foreach( ref xyh; xyhs )
	{
		input.popFront;
		xyh = input.front.split.to!( long[] );
	}
	
	xyhs.sort!( ( a, b ) => b[ 2 ] < a[ 2 ] );
	foreach( cx; 0L .. 101L )
	{
		LOOP: foreach( cy; 0L .. 101L )
		{
			auto ch = max( abs( xyhs.front[ 0 ] - cx ) + abs( xyhs.front[ 1 ] - cy ) + xyhs.front[ 2 ], 0 );
			foreach( xyh; xyhs )
			{
				if( max( ch - abs( xyh[ 0 ] - cx ) - abs( xyh[ 1 ] - cy ), 0 ) != xyh[ 2 ] ) continue LOOP;
			}
			return format( "%s %s %s", cx, cy, ch );
		}
	}
	
	assert( false );
}


Measured memory_bytes: 2980
import itertools
from collections import deque

N,M = map(int,input().split())
table = [[0]*N for _ in range(N)]
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    table[a][b] = 1
    table[b][a] = 1

p = [i for i in range(1,N)]
q = list(itertools.permutations(p))

s = deque()
for i in range(len(q)):
    x = 0
    flag = 0
    for y in q[i]:
        if table[x][y] == 0:
            flag = 1
            break
        x = y
    if flag == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


int main()
{
int r,g,b;
cin>>r>>g>>b;
int l=r*100+g*10+b;
if(l%4)
    cout<<"NO"<<endl;
else
    cout<<"YES"<<endl;
 return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	ll a[100];
	a[0]=2;a[1]=1;
	for(int i=2;i<=n;i++)
		a[i]=a[i-1]+a[i-2];
	cout<<a[n]<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v (n);
  for(int i=0;i<n;i++)
    cin >> v[i];
  bool flag= false;
  for(int a: v){
    if(a%2==0){
      if(a%3!=0 && a%5!=0){
        flag=true;
        break;
        }
      }
    }
    if(flag)
      cout << "DENIED\n";
    else
      cout << "APPROVED\n";
  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 21

using namespace std;

const int mod = 1000000007;
int v[maxn+5][maxn+5];
int d[(1<<maxn)+5];
///nr combinatii daca folosesti fetele din conf cu primii bpop(conf) baieti
int bpop (int x) { return __builtin_popcount(x); }

void mad (int &a, int b) {
  a += b;
  while (a >= mod) a -= mod;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, m; cin >> n;
  int i, j, z;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) cin >> v[i][j];
  int conf, bit;
  d[0] = 1;
  for (conf = 0; conf < (1<<n); conf++) {
    m = bpop(conf);
    for (bit = 0; bit < n; bit++)
      if ((conf & (1<<bit)) == 0 && v[m][bit] == 1) mad(d[conf|(1<<bit)], d[conf]);
  }
  cout << d[(1<<n)-1];
  return 0;
}


Measured memory_bytes: 8448
N,*as=$<.read.split.map(&:to_i)

h = {}
ret = 0

as.each.with_index do |a,i|
    if h[i-a]
        ret += h[i-a]
    end
    h[a+i] ||= 0
    h[a+i] += 1
end

puts ret


Measured memory_bytes: 38692
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $ans = 0;
  for($i=0;$i<$n;$i++){
    list($x, $u) = explode(" ", trim(fgets(STDIN)));
    if($u == 'JPY'){
      $ans += $x;
    }else{
      $ans += $x*380000;
    }
  }
  echo $ans;

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

using namespace std;
set<int>st[30];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        st[s[i]-'a'].insert(i);
    int m;cin>>m;
    for(int i=0;i<m;i++)
    {
        int c;cin>>c;
        if(c==1)
        {
            int idx;
            char x;
            cin>>idx>>x;
            idx--;
            st[s[idx]-'a'].erase(idx);
            st[x-'a'].insert(idx);
            s[idx]=x;
        }
        else
        {
            int l,r;cin>>l>>r;
            l--;r--;
            int cnt=0;
            for(int j=0;j<26;j++)
            {
                auto it=st[j].lower_bound(l);
                if(it!=st[j].end()&&*it<=r) cnt++;
            }
            cout<<cnt<<'\n';
        }
    }
    return 0;
}


Measured memory_bytes: 24220
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef complex<ld> PT;
typedef pair<PT, PT> LS;
#define F first
#define S second
#define X real()
#define Y imag()

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;
const ld EPS = 1e-12;

bool eq(ld a, ld b){
	return abs(a-b) < EPS;
}

istream& operator>> (istream& is, complex<ld>& p){
	ld val;
	is >> val;
	p.real(val);
	is >> val;
	p.imag(val);
	return is;
}

ld dot(PT a, PT b){ return real(conj(a)*b); }
ld cross(PT a, PT b){ return imag(conj(a)*b); }
ld sqlen(PT a){ return dot(a, a); }
ld len(PT a){ return sqrt(sqlen(a)); }

PT proj(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + b*real(c/b);
}

PT reflect(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + conj(c/b)*b;
}

PT rotate(PT a, PT b, ld theta){
	return (b-a)*polar<ld>(1, theta) + a;
}

string pos(PT a, PT b, PT c){
	b -= a, c -= a;
	c /= b;
	if (c.imag() > EPS) return "COUNTER_CLOCKWISE";
	if (c.imag() + EPS < 0) return "CLOCKWISE";
	if (c.real() + EPS < 0) return "ONLINE_BACK";
	if (c.real() > 1 + EPS) return "ONLINE_FRONT";
	return "ON_SEGMENT";
}

int side(PT a, PT b, PT c){
	b -= a, c -= a;
	ld cr = (c/b).Y;
	return cr > EPS ? 1 : (cr + EPS < 0 ? -1 : 0);
}

bool intersect(PT a, PT b, PT c, PT d){
	int as = side(c, d, a), bs = side(c, d, b), cs = side(a, b, c), ds = side(a, b, d);
	if (as && as == bs || cs && cs == ds) return false;
	else if (as || bs || cs || ds) return true;
	for (int j = 0; j < 2; j++, swap(a, c), swap(b, d)){
		ld mx = min(a.X, b.X), Mx = max(a.X, b.X), my = min(a.Y, b.Y), My = max(a.Y, b.Y);
		for (int k = 0; k < 2; k++, swap(c, d))
			if (c.X + EPS > mx && c.X < Mx + EPS && c.Y + EPS > my && c.Y < My + EPS)
				return true;
	}
	return false;
}

PT intersection(PT a, PT b, PT c, PT d){
	ld c1 = cross(b-a, c-a), c2 = cross(b-a, d-a);
	return (c1*d - c2*c)/(c1-c2);
}

int main(){	
	cout << setprecision(10) << fixed;
	for (int i = in(); i; i--){
		PT a, b, c, d;
		cin >> a >> b >> c >> d;
		PT p = intersection(a, b, c, d);
		cout << p.X << ' ' << p.Y << endl;
	}
	return 0;
}


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

#改行入力 X,Y
L = [[0,0,0,0] for i in range(N)]
t=-1*(10**9)
s=0
for i in range(N):
    L[i][0],L[i][1] = map(int,input().split())
    L[i][2]=L[i][0]+L[i][1]
    L[i][3]=L[i][0]-L[i][1]

L=sorted(L,key=lambda x: x[2])

for i in range(N):
    if(t<=L[i][3]):
        s+=1
        t=L[i][2]

print(s)

Measured memory_bytes: 29992
N = gets.to_i
S = gets.chomp

["SS","WW","SW","WS"].each{ |t|
  (2..N+1).each{ |i|
    t << ((t[-2] == "W") ^ (t[-1] == "W") ^ (S[(i-1)%N] == "x") ? "W" : "S")
  }
  if t[0...2] == t[-2..-1]
    puts t[0...N]; exit
  end
}

p -1

Measured memory_bytes: 2556