akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector> 
using namespace std;
const long long inf=(1ll<<60);
long long n,ans;
struct node{
	long long x,y;
	node(long long u,long long v)
	{
		x=u,y=v;
	}
};
vector <node> c[4],bin;
inline bool cmp1(node x,node y)
{
	return x.x+x.y > y.x+y.y;
}
inline bool cmp2(node x,node y)
{
	return -x.x+x.y > -y.x+y.y;
}
inline bool cmp3(node x,node y)
{
	return -x.x-x.y > -y.x-y.y;
}
inline bool cmp4(node x,node y)
{
	return x.x-x.y > y.x-y.y;
}
inline long long read()
{
	long long 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<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	n=read();
	long long u,v;
	u=v=inf;
	for(long long i=1;i<=n;++i)
	{
		long long x=read(),y=read();
		bin.push_back(node(x,y));
		u=min(u,x),v=min(v,y);
	}
	u=-u,v=-v;
	for(long long i=0;i<n;++i)
	{
		bin[i].x+=u,bin[i].y+=v;
		long long x=(bin[i].x),y=(bin[i].y);
		c[0].push_back(node(x,y));
		c[1].push_back(node(x,y));
		c[2].push_back(node(x,y));
		c[3].push_back(node(x,y));
	}
	sort(c[0].begin(),c[0].end(),cmp1);
	sort(c[1].begin(),c[1].end(),cmp2);
	sort(c[2].begin(),c[2].end(),cmp3);
	sort(c[3].begin(),c[3].end(),cmp4);
	for(long long i=0;i<n;++i)
	{
		long long x=c[0][i].x,y=c[0][i].y;
		for(long long j=0;j<4;++j)
		{
			u=c[j][0].x,v=c[j][0].y;
			ans=max(ans,abs(x-u)+abs(y-v));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 24664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Possible":"Impossible");
}
int main() {
  int a,b;cin>>a>>b;
  cout<<btos(a%3==0||b%3==0||(a+b)%3==0)<<endl;
  return 0;
}


Measured memory_bytes: 256
n, m = (int(_) for _ in input().split())
currs = 0
currg = 100000000
for i in range(m):
    s, g = (int(_) for _ in input().split())
    if s > currs:
        currs = s
    if g < currg:
        currg = g
if currg < currs:
    print(0)
else:
    print(currg - currs + 1)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
from collections import Counter

d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()

N = d_in()
A_list = np.array(ds_in())
A_list.sort()
EPSILON = 10**(-6)

cand_A = 2 ** (np.log2(A_list + EPSILON).astype(int) + 1) - A_list
idx = np.searchsorted(A_list, cand_A)
A_count = dict(Counter(A_list))

ans = 0
for i in range(N-1, -1, -1):
    if A_count[A_list[i]] <= 0:
        continue
    A_count[A_list[i]] -= 1
    if (A_list[idx[i]] == cand_A[i]) and (A_count[cand_A[i]] > 0):
        ans += 1
        A_count[cand_A[i]] -= 1

print(ans)


Measured memory_bytes: 48448
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> p(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> p.at(i);
    }
    p.push_back(0);

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(p.at(i) == i+1) {
            swap(p.at(i), p.at(i+1));
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int64_t n, k; cin >> n >> k;
  int64_t h[n], dp[n];
  for(int64_t& i: h) cin >> i;
  memset(dp, 0, sizeof dp);
  for(int i = 1; i < n; ++i) {
    dp[i] = numeric_limits<int>::max();
  	for(int j = 1; (i - j) >= 0 and (j <= k); ++j) {
    	dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }
  cout << dp[n - 1];
  return 0;
}

Measured memory_bytes: 1792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int num, honsu;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.honsu != t.honsu)
		return s.honsu < t.honsu; // 昇順
	return s.num > t.num;
}



int main() {
	int a, b, k;
	cin >> a >> b >> k;

	int sum = 0;
	for(int i=100;i>=1;i--) {
		if (a%i == 0 && b%i == 0) {
			sum++;
		}

		if (sum == k) {
			ANS(i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
int main()
{
    ll h,w;
    cin >>h>>w;
    char arr[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        cin >>arr[i][j];
    
    ll ans=0;
   ll dp[h+1][w+1];
   memset(dp,0,sizeof(dp));
    for(int i=0;i<=h;i++)
    {
        for(int j=0;j<=w;j++)
        {
         if(i==0||j==0)
         dp[i][j]=0;
         else
         {
             if(i==1&&j==1)
             dp[i][j]=1;
            else if(arr[i-1][j-1]=='.')
             {
                 dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
             }
             else
             dp[i][j]=0;
         }
            
        }
    }
    // for(int i=0;i<=h;i++){
    // for(int j=0;j<=w;j++)
    // {
    //     cout<<dp[i][j];
    // }
    //     cout<<endl;
    // }
    cout<<dp[h][w];
    
}



Measured memory_bytes: 9088
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    int n;
    cin >> n;
    int zero = 0;
    map<pair<ll, ll>, P> mp;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0)
        {
            zero++;
            continue;
        }
        ll g = gcd(x, y);
        x /= g;
        y /= g;
        if (y < 0)
            x = -x, y = -y;
        if (y == 0 && x < 0)
            x = -x, y = -y;
        bool rot90 = (x <= 0);
        if (rot90)
        {
            ll tmp = x;
            x = y;
            y = -tmp;
        }
        if (rot90)
            mp[{x, y}].first++;
        else
            mp[{x, y}].second++;
    }

    mint ans = 1;
    for (auto p : mp)
    {
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1;
        now += mint(2).pow(s) - 1;
        now += mint(2).pow(t) - 1;
        ans *= now;
    }
    ans -= 1;

    ans += zero;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16084
#include<stdio.h>

int main(){
	int a;
	scanf("%d", &a);
	while (a>0){
		if (a%10==7){
			printf("Yes\n");
			break;
		} else{
			if (a<10){
				printf("No\n");
			}
		}
		a/=10;
	}
	return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
double pre[1005];

int main()
{
  int T;
  int t,xx;
  scanf("%d",&T);
  scanf("%d%d",&t,&xx);
  for(int i=0;i<T;i++){
    scanf("%lf",&pre[i]);
    pre[i] = t - (pre[i] * 0.006);
  }
  int flag = 0;
  double ans = 0x3f3f3f3f * 1.0;
  for(int i=0;i<T;i++){
    if(fabs(pre[i] - xx) < ans){
      flag = i;
      ans = fabs(pre[i] - xx);
    }
  }
  printf("%d\n",flag + 1);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int top,stack[101];
  char input[8];
 
  top = 0;
  while( scanf("%s",input) != EOF ){
    if( '+' == input[0] ){
      top--;
      stack[top] += stack[top+1];
    }
    else if( '-' == input[0] ){
      top--;
      stack[top] -= stack[top+1];
    }
    else if( '*' == input[0] ){
      top--;
      stack[top] *= stack[top+1];
    }
    else{
      top++;
      stack[top] = atoi(input);
    }
  }
  printf("%d\n",stack[top]);
  return 0;
}

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

using namespace std;

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

typedef complex<double> P;

namespace std {
  bool operator < (P const& a, P const& b) {
    if(real(a) != real(b)) return real(a) < real(b);
    return imag(a) < imag(b);
  }
}

double const EPS = 1e-8;

#define prev(G, i) ( G[((i-1)+G.size())%G.size()] )
#define curr(G, i) ( G[i%G.size()] )
#define next(G, i) ( G[(i+1)%G.size()] )

double dot(P const& a, P const& b) {
  return real(conj(a)*b);
}

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

typedef vector<P> Polygon;
/*
Polygon convex_hull(vector<P> ps) {
  sort(ps.begin(), ps.end());
  int N = ps.size(), k = 0;
  vector<P> qs(N*2);
  rep(i, N) {
    while(k > 1 && cross(qs[k-1]-qs[k-2], ps[i]-ps[k-1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  for(int i=N-2, t=k; i>=0; i--) {
    while(k > t && cross(qs[k-1]-qs[k-2], ps[i]-qs[k-1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  qs.resize(k-1);
  return qs;
}
*/

enum { counter_clock_wise=+1, clockwise=-1, cab_online=+2, abc_online=-2, on_segment = 0 };
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return counter_clock_wise;
  if(cross(b, c) < 0) return clockwise;
  if(dot(b, c) < 0) return cab_online;
  if(norm(b) < norm(c)) return abc_online;
  return on_segment;
}

Polygon convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

struct Line : public vector<P>
{
  Line(P const& a, P const& b) {
    push_back(a), push_back(b);
  }
};

typedef Line Segment;

bool is_intersect_ss(Segment const& s, Segment const& t) {
  return ( ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) < EPS )
    && ( ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) < EPS );
}

// contain: 2, on segment: 1, the other case: 0
int contains(Polygon const& G, P const& p) {
  bool x = false;
  for(int i=0; i<(int)G.size(); i++) {
    P v1 = curr(G, i)-p, v2 = next(G, i) - p;
    if( v1.imag() > v2.imag() ) swap(v1, v2);
    if( v1.imag() <= 0 && 0 < v2.imag() && cross(v1, v2) > 0 ) x = !x;
    if( cross(v1, v2) == 0 && dot(v1, v2) <= 0 ) return 1;
  }
  return (x?2:0);
}

int main() {

  int N, M;
  while(cin >> N >> M && (N|M)) {
    Polygon G1(N), G2(M);
    rep(i, N) cin >> G1[i].real() >> G1[i].imag(); 
    rep(i, M) cin >> G2[i].real() >> G2[i].imag(); 
    
    G1 = convex_hull(G1); N = G1.size();
    G2 = convex_hull(G2); M = G2.size();
    //    cout << "convex hull\n";
    bool ok = (!contains(G1, G2[0])) && (!contains(G2, G1[0]));
    rep(i, N) {
      rep(j, M) {
	Segment s1 = Segment(curr(G1, i), next(G1, i));
	Segment s2 = Segment(curr(G2, j), next(G2, j));
	if(is_intersect_ss(s1, s2)) { ok = 0; }
      }
    }
    
    cout << (ok ? "YES\n" : "NO\n");
  }
  
  return 0;
}

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

int main() {
  int n; cin >> n;
  pair<int, int> p[n];
  rep(i, n) {
    cin >> p[i].first;
    p[i].second = i;
  }

  sort(p, p + n);
  int ans = 0;
  rep(i, n) {
    if (i % 2 != p[i].second % 2) ans ++;
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i <= n; i++)
#define EPS 1e-9
#define ff first
#define ss second
#define pb push_back
#define sortx(x) sort(x.begin(), x.end())

int main()
{
    ios::sync_with_stdio(0);

    ll N, X, soma = 0, menor=1000000;
    cin >> N >> X;
    ll vezes = N;
    vector<ll> custo(N);
    forn(i, N)
    {
        cin >> custo[i];
        soma+=custo[i];
        if(menor>custo[i]){
            menor=custo[i];
        }
    }
    vezes += (X-soma)/menor;
    cout << vezes << endl;

    return 0;
}

Measured memory_bytes: 3628
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

var memo = {};

function Main(input) {

    var employed = 0;
    for (var i = 0; i < input[0].length; i++) {
        if (input[0][i] == '1') {
            employed++;
        }
    }

    console.log(employed);

    return 0;
}

Measured memory_bytes: 7500
ss = input()
for n, s in enumerate(ss):
  if s == 'R':
    if (n + 1) % 2 == 0:
      print('No')
      exit()
  elif s == 'L':
    if (n + 1) % 2 == 1:
      print('No')
      exit()
print('Yes')  

Measured memory_bytes: 2940
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable ulong MOD = 1000000007;


auto solve(ulong N, ulong[] A) {
    ulong ans;

    foreach (ulong i; 0 .. 60) {
        ulong bits = A.count!(a => ((a >> i) & 1) == 1);
        ans += (1uL << i) % MOD * (N - bits) % MOD * bits % MOD;
        ans %= MOD;
    }

    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    ulong N;
    N = input.front.to!ulong;
    input.popFront;

    ulong[] A = new ulong[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!ulong;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A);
    else {
        auto ans = solve(N, A);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


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

int main(){
	
	long long int a,b,t,x,y;
	while(0<=scanf("%lld%lld",&a,&b)){
	
		if(a>b){
			x=a;
			y=b;
		}else{
			y=a;
			x=b;
		}

		while(x%y !=0){
			t=x%y;
			x=y;
			y=t;
		}
		printf("%lld %lld\n",y,a*b/y);
	}

	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
using namespace std;

vector<vector<int>> v;
int w, h;

void dfs(int y, int x) {
	if (v[y][x] == 1)v[y][x] = 0;

	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			int nx = x + i, ny = y + j;

			if (!(nx < 0 || ny < 0 || nx >= w||ny >= h)&&v[ny][nx] == 1) dfs(ny, nx);
		}
	}
	
	return;
}

int main(){
	while (1) {
		int ans=0;
		cin >> w >> h;
		if (w == 0 && h == 0)break;
		v.resize(h, vector<int>(w));
		rep(i, 0, h) {
			rep(j, 0, w) {
				cin >> v[i][j];
			}
		}

		rep(i, 0, h) {
			rep(j, 0, w) {
				if (v[i][j] == 1) {
					ans++;
					dfs(i, j);
				}
			}
		}
		cout << ans << endl;
		v.clear();
	}
	
	return 0;
}

Measured memory_bytes: 3244
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<	 #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }
#define p   200005

vec<int> v;
void gen()
{  
	  queue<int> q;
	  for(int i=1;i<=9;i++)
	  	  q.push(i);
	  	while(!q.empty() and sz(v)<100006)
	  		  {  
                 int x=q.front();
                 q.pop();
                 v.pb(x);

                 if(x%10>=1)
                 	 {
                 	 	q.push(x*10+x%10-1);

                 	 }
                 	 if(x%10>=0)
                 	 	 {
                 	 	 	q.push(x*10+x%10);

                 	 	 }
                 	 	 if(x%10<=8)
                 	 	 	 {
                                q.push(x*10+x%10+1);
                 	 	 	 }
                  






	  		  }



}
  
void solve()
{   
int k;
cin>>k;
gen();
cout<<v[k-1];








}
signed main()
{fast
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
solve();}
  
}












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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;

  ll ans = 0;
  if (n * 2 <= m) {
    ans += n;
    m -= n * 2;
  } else {
    ans += m / 2;
    m = m % 2;
  }

  ans += m / 4;
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

l_r = ["AC","WA","TLE","RE"]

ac,wa,tle,re = 0,0,0,0
l_s = [ac,wa,tle,re]

for i in range(n):
  x = str(input())
  if x == l_r[0]:
    ac += 1
    l_s[0] = ac
  if x == l_r[1]:
    wa += 1
    l_s[1] = wa
  if x == l_r[2]:
    tle += 1
    l_s[2] = tle
  if x == l_r[3]:
    re += 1
    l_s[3] = re

for j in range(4):
  print(l_r[j]," x ",l_s[j])

Measured memory_bytes: 9236
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
int a[100]={0,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};
int main(){
	// in;
	// out;
	int n;
	while(cin>>n)
	cout<<a[n]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int w,h,n;
    cin>>w>>h>>n;
    int a[200][200]={};
    for(int i=0;i<n;i++){
        int x,y,z;
        cin>>x>>y>>z;
        if(z==1){
            for(int i=0;i<x;i++){
                for(int j=0;j<h;j++){
                    a[j][i]=1;
                }
            }
        }
        if(z==2){
            for(int i=x;i<w;i++){
                for(int j=0;j<h;j++){
                    a[j][i]=1;
                }
            }
        }
        if(z==3){
            for(int i=0;i<y;i++){
                for(int j=0;j<w;j++){
                    a[i][j]=1;
                }
            }
        }
        if(z==4){
            for(int i=y;i<h;i++){
                for(int j=0;j<w;j++){
                    a[i][j]=1;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(a[j][i]==0)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, a[1010], q, b, e, k;
signed main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> b >> e >> k;
		int ans = 0;
		for (int j = b; j < e; j++)ans += (a[j] == k);
		cout << ans << endl;
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

int main(){
	int k, a, b; cin >> k >> a >> b;
	bool f = false;
	for(int i = a; i <= b; i++){
		if(i % k == 0) f = true;
	}
	if(f) cout << "OK" << endl;
	else cout << "NG" << endl;
}

Measured memory_bytes: 3596
while 1:
	x = int(input())
	if x == 0:
		break
	else:
		a = 0
		b = 0
		for i in range(x):
			abStr = input().split(" ")
			ab = (int(abStr[0]), int(abStr[1]))
			if ab[0] < ab[1]:
				b += ab[0] + ab[1]
			elif ab[0] > ab[1]:
				a += ab[0] + ab[1]
			else:
				a += ab[0]
				b += ab[1]
		print(str(a) + " " + str(b))

Measured memory_bytes: 7576
#include<iostream>
#include<stdio.h>
using namespace std;

const int x[] = {-1,0,1,0};
const int y[] = {0,1,0,-1};
char m[14][14];
	
int a (int i,int j) {
	if (m[i][j] == '0') return 0;
	
	m[i][j]='0';
	for (int k=0;k<4;k++){
		int l = i - x[k],n = j - y[k];
		a (l,n);
	}
	
}

int main () {
	while(cin>>m[1][1]){
		int dummy = m[1][1];
		for (int i=0;i<14;i++){
			for (int j=0;j<14;j++){
				m[i][j] = '0';
			}
		}
		m[1][1] = dummy;
		
		for (int i=1;i<13;i++){
			for (int j=1;j<13;j++){
				if(!(i==1&&j==1)){
				cin>>m[j][i];
				}
			}
		}
		
		int count=0;
		for (int i=1;i<13;i++){
			for (int j=1;j<13;j++){
				if (m[i][j]=='1'){
					count++;
					a(i,j);
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1140
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
using namespace std;

struct point{
	double x;
	double y;
};

void koch(int n, point p1, point p2){
	if (n == 0) return;

	point s = { (2.0 * p1.x + p2.x) / 3, (2.0 * p1.y + p2.y) / 3 };
	point t = { (p1.x + 2.0 * p2.x) / 3, (p1.y + 2.0 * p2.y) / 3 };
	point u = { (t.x - s.x) * (1.0 / 2) - (t.y - s.y) * (sqrt(3) / 2) + s.x,
		(t.x - s.x) * (sqrt(3) / 2) + (t.y - s.y) * (1.0 / 2) + s.y };
	koch(n - 1, p1, s);
	cout << s.x << " " << s.y << endl;
	koch(n - 1, s, u);
	cout << u.x << " " << u.y << endl;
	koch(n - 1, u, t);
	cout << t.x << " " << t.y << endl;
	koch(n - 1, t, p2);
}

int main(){

	int n;
	cin >> n;
	cout << fixed << setprecision(8);
	point p1 = { 0.0, 0.0 };
	point p2 = { 100.0, 0.0 };
	cout << p1.x << " " << p1.y << endl;
	koch(n, p1, p2);
	cout << p2.x << " " << p2.y << endl;

	return 0;
}


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }


int ans = MOD;

void dfs(int f, int e){

}

int main() {
ll K, A, B;
cin >> K >> A >> B;


if(3 > B - A){
  print(K + 1);
  return 0;
}

ll biscuit = 1;

biscuit += A - 1;
K -= A - 1;

biscuit += K / 2 *(B - A);
K = K % 2;
biscuit += K;

print(biscuit);



}



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector<vector<long long int>>dp(N + 1, vector<long long int>(N*N + 1));
	dp[N][0] = 1;
	vector<vector<long long int>>ans(N + 1, vector<long long int>(N*N + 1));
	for (int i = N; i > 0; i--) {
		for (int j = 0; j <= N * N; j++) {
			for (int k = 0; k <= K; k++) {
				int nxj = j;
				long long int amari = 0;
				if (k > i) {
					amari = k+j;
				}
				else {
					amari = (k + j) % i;
					nxj += (k + j) / i;
				}
				if (nxj > N*N)continue;
				dp[i - 1][nxj] += dp[i][j];
				dp[i - 1][nxj] %= MOD;
				ans[i - 1][nxj] += ans[i][j] + amari * dp[i][j];
				ans[i - 1][nxj] %= MOD;
			}
		}
	}
	M = accumulate(ans.front().begin(), ans.front().end(), 0LL);
	cout << M % MOD << endl;
}

Measured memory_bytes: 17664
# -*- coding: utf-8 -*-

h, w = map(int, input().split())
a = []

for i in range(h):
    a.append(input())
#print(a)

print("#"*(w+2))
for i in range(h):
    print("#", end="")
    print(a[i], end="")
    print("#")
print("#"*(w+2))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  int p=0,w=0,g=0,y=0;
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> S;
    if (S=="P"){
      p++;
    }else if(S=="W"){
      w++;
    }else if(S=="G"){
      g++;
    }else if(S=="Y"){
      y++;
    }
  }
  if (y!=0){
    cout << "Four" << endl;
  }else if(y==0){
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
import java.awt.*;
import java.io.*;
import java.net.StandardSocketOptions;
import java.util.*;

public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main();
    }
    public Main(){
        new TestC().doIt();
    }
    class TestC{
        void doIt() {
            long X = sc.nextLong();
            long K = sc.nextLong();
            long D = sc.nextLong();
            X = Math.abs(X);
            long Straight = Math.min(K, X/D);
            K -= Straight;
            X -= Straight * D;

            if(K % 2 == 0){
                System.out.println(X);
            }else{
                System.out.println(D - X);
            }
        }
    }
}

Measured memory_bytes: 35896
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int mm[8][2] = { {0, 1}, {0, -1}, {1, 1}, {1, 0}, {1, -1}, {-1, 1}, {-1, 0}, {-1, -1} };

int main(int argc, char *argv[])
{
  int H, W;
  vector<string> ss;

  cin >> H >> W;

  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    ss.push_back(s);
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (ss[i][j] == '#') {
        cout << '#';
      } else {
        int ans = 0;
        for (int k = 0; k < 8; k++) {
          if ((j + mm[k][0] >= 0) && (j + mm[k][0] < W) && (i + mm[k][1] >= 0) && (i + mm[k][1] < H)) {
            if (ss[i + mm[k][1]][j + mm[k][0]] == '#') {
              ans++;
            }
          }
        }
        cout << ans;
      }
    }
    cout << endl;
  }

  return 0;
}


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

int func (int num) {
    if (num % 2 == 1) {
        return 0;
    }
    int sum = 0;
    while (num % 2 == 0) {
        num /= 2;
        sum++;
    }
    return sum;
}

int main() 
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int ans = 1e9;
    for (int i = 0; i < N; i++) {
        int sum = 0;
        sum = func(A[i]);
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    if (a >= 13)
        cout << b;
    if (a >= 6 && a <= 12)
        cout << b / 2;
    if (a <= 5)
        cout << "0";
    return 0;
}


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

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

using namespace std;

const int INF=1<<29;

int main(){
	for(int lim,n,m,x;scanf("%d%d%d%d",&lim,&n,&m,&x),lim;){
		int e_sec[100],s_sec[100];
		rep(i,n) scanf("%*s%d%d",e_sec+i,s_sec+i);
		int e[100],s[100];
		rep(i,m) scanf("%*s%d%d",e+i,s+i);

		int dp[101][1001]; // dp[i][j] := i ツ人, j ツ円ツ使ツづつスツづつォツづ個催妥・ツ鳴楪堕ォツ度
		rep(i,m+1) rep(j,lim+1) dp[i][j]=-INF;
		dp[0][0]=0;
		rep(i,m) for(int k=i;k>=0;k--) for(int j=e[i];j<=lim;j++) {
			dp[k+1][j]=max(dp[k+1][j],dp[k][j-e[i]]+s[i]);
		}

		int ans=-INF;
		for(int i=x;i<=m;i++) rep(j,lim+1) if(dp[i][j]>=0) {
			int tmp=-INF;
			rep(k,n){
				if(j+e_sec[k]<=lim) tmp=max(tmp,s_sec[k]);
				rep(l,k) if(j+e_sec[k]+e_sec[l]<=lim) tmp=max(tmp,s_sec[k]+s_sec[l]);
			}
			ans=max(ans,dp[i][j]+tmp);
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
struct edge{ ll to, cost; };//　一つ目は結んでいるノード,二つ目はその辺の重みを指す
#define sort(a) sort(a.begin(),a.end())
using Graph = vector<vector<edge>>;  //隣接リスト
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int MOD = 1e9+7;
const ll INF =1e18;
ll data1[100][100],data2[100][100],data[100][100];
bool dp[100][100][7000];
int main(){
  int h,w;cin>>h>>w;
  fr(i,h){
    fr(j,w)cin>>data1[i][j];
  }
  fr(i,h){
    fr(j,w)cin>>data2[i][j];
  }
  fr(i,h){
    fr(j,w)data[i][j]=data1[i][j]-data2[i][j];
  }
  fr(i,100){
    fr(j,100){
      fr(k,7000)dp[i][j][k]=false;
    }
  }
  dp[0][0][abs(data[0][0])]=true;
  fr(i,h){
    fr(j,w){
      if(i==0 && j==0)continue;
      if(i>0){
        fr(k,7000){
          if(dp[i-1][j][k]){
            if(abs(k-abs(data[i][j]))<7000){
              dp[i][j][abs(k-abs(data[i][j]))] = true;
            }
            if(dp[i-1][j][k]){
            if(abs(k+abs(data[i][j]))<7000){
              dp[i][j][abs(k+abs(data[i][j]))] = true;
          }
        }
      }
    }
  }
  if(j>0){
        fr(k,7000){
          if(dp[i][j-1][k]){
            if(abs(k-abs(data[i][j]))<7000){
              dp[i][j][abs(k-abs(data[i][j]))] = true;
            }
            if(dp[i][j-1][k]){
            if(abs(k+abs(data[i][j]))<7000){
              dp[i][j][abs(k+abs(data[i][j]))] = true;
          }
        }
      }
    }
  }
}
  }
  fr(k,7000){
    if(dp[h-1][w-1][k]){
      cout << k << endl;
      break;
    }
  }
}

Measured memory_bytes: 68736
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int cnt=0;
  for(int i=0;i<s.size();i++)
  {
      if(s[i]!=t[i])
      cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3856
#include <stdio.h>

int a[100000];

int main(void)
{
	int n, q, k, i, lb, ub, m;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &k);
		lb = -1; ub = n;
		while (ub - lb > 1) {
			m = (lb + ub) >> 1;
			if (a[m] < k) {
				lb = m;
			}
			else {
				ub = m;
			}
		}
		printf("%d\n", ub);
	}
	return 0;
}



Measured memory_bytes: 2184
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
    int N, K;
    cin >> N >> K;
    int l[N];
    for(int i=0; i<N; i++) cin >> l[i];
    sort(l,l+N);
    int sum=0;
    for(int i=1; i<=K; i++) sum += l[N-i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())

ans = []

alpha_dict = {}
for i, c in enumerate(range(ord("A"), ord("Z") + 1)):
    alpha_dict[chr(c)] = i + 1

for alpha in s:
    now_alpha_num = alpha_dict[alpha]
    if (now_alpha_num + n) <= 26:
        return_alpha = [k for k, v in alpha_dict.items() if v == now_alpha_num + n]
    else:
        return_alpha = [k for k, v in alpha_dict.items() if v == now_alpha_num + n - 26]

    ans.append("".join(return_alpha))

print("".join(ans))


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> F(h);
    rep(i, h) cin >> F[i];
    //削除される行と列のインデックスを記録
    set<int> G, R;
    //行チェック
    rep(i, h)
    {
        int ok = 1;
        rep(j, w)
        {
            if (F[i][j] == '#')
                ok = 0;
        }
        if (ok)
            G.insert(i);
    }
    //列チェック
    rep(j, w)
    {
        int ok = 1;
        rep(i, h)
        {
            if (F[i][j] == '#')
                ok = 0;
        }
        if (ok)
            R.insert(j);
    }
    //再構成
    rep(i, h)
    {
        if (G.count(i))
            continue;
        rep(j, w)
        {
            if (R.count(j))
                continue;
            cout << F[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

//パスカルの三角形を使用してCOMを求める
//MODしないバージョン
ll COM[51][51];

void COMinit(int n){
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            if(j == 0 || j == i) COM[i][j] = 1;
            else COM[i][j] = (COM[i-1][j-1] + COM[i-1][j]);
        }
    }
}


int main(){
    COMinit(50);

    int n, a, b;
    cin >> n >> a >> b;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    sort(rall(v));

    double maxv = 0;
    rep(i, a) maxv += v[i];
    maxv /= a;

    cout << fixed << setprecision(9) << maxv << endl;

    ll ans = 0;
    double va = v[a-1];
    
    if(v[0] != va){
        int y = 0, x = 0, idx = 0;
        while(idx < n){
            if(idx < a && va == v[idx]) x++;
            if(va == v[idx]) y++;
            idx++;
        }
        ans += COM[y][x];
    }
    else if(v[0] == va){
        int y = 0;
        rep(i, n) y += (va == v[i]);
        for(int x = a; x <= min(y, b); x++) ans += COM[y][x];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
local S={}
for k,_ in io.read():gmatch("%l") do
    S[k]=(S[k] or 0)+1
end
local s={}
for _,v in pairs(S) do
    table.insert(s,v)
end
table.sort(s)

local T={}
for k,_ in io.read():gmatch("%l") do
    T[k]=(T[k] or 0)+1
end
local t={}
for _,v in pairs(T) do
    table.insert(t,v)
end
table.sort(t)

local flag=true
if #s==#t then
    for i=1,#s do
        if s[i]~=t[i] then
            flag=false
            break
        end
    end
else
    flag=false
end

print(flag and "Yes" or "No")

Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

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

template <typename T>
int indexOf(vector<T> v, T elem)
{
  auto iter = find(v.begin(), v.end(), elem);
  size_t idx = distance(v.begin(), iter);
  if (idx == v.size()) return -1;
  return idx;
}

int n;
vector<int> a;
int result;

void input()
{
  cin>> n;
  a=vector<int>(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
}

void calc()
{
  vector<int> v; // 押したことがあるボタン
  result=0;
  int i=0;
  v.push_back(i);
  for(int j=0;j<n;j++){
    i=a[i]-1;
    result++;
    if(i==1){
      return;
    }
    // if(indexOf(v,i)!=-1){
    //   result=-1;
    //   return;
    // }
    v.push_back(i);
  }
  result=-1;
}

void output()
{
  cout << result << endl;
}

int main(int argc, char const* argv[])
{
  input();
  calc();
  output();
  return 0;
}


Measured memory_bytes: 1276
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=10005;
int n,k;
char mi,mx,s[N],t[N],ans[N];
void ckmin(){
	bool flag=false;
	for(int i=1;i<=n;i++){
		if(t[i]>ans[i]){
			break;
		}else if(t[i]<ans[i]){
			flag=true;
			break;
		}
	}
	if(flag){
		for(int i=1;i<=n;i++){
			ans[i]=t[i];
		}
	}
}
void gao(char s[],int k){
	int len=1;
	while(len<n&&s[n-len]==mi){
		len++;
	}
	int now=n-len+1;
	while(k&&len<n){
		len*=2;
		k--;
	}
	if(len>=n){
		for(int i=1;i<=n;i++){
			t[i]=mi;
		}
		ckmin();
	}else{
		for(int i=1;i<=len;i++){
			t[i]=mi;
		}
		for(int i=len+1;i<=n;i++){
			t[i]=s[--now];
		}
		ckmin();
	}
}
int main(){
	scanf("%d%d%s",&n,&k,s+1);
	mi='z',mx='a';
	for(int i=1;i<=n;i++){
		s[2*n-i+1]=s[i];
		mi=min(mi,s[i]);
		mx=max(mx,s[i]);
		ans[i]='z';
	}
	if(mx==mi){
		puts(s+1);
		return 0;
	}
	if(s[n]==mi){
		gao(s,k);
	}
	for(int i=n+1;i<=2*n;i++){
		if(s[i]==mi){
			gao(s+i-n,k-1);
		}
	}
	puts(ans+1);
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
  int n;cin>>n;
  string s; cin>>s;
  map<char, int> logger;
  rep(i,n)logger[s[i]]++;

  ll result=0;
  for(char i='a'; i<='z'; i++)if(logger[i]>0){
    result+=(logger[i] + result * logger[i]);
    result%=MOD;
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 512
R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B])

i = 0
for r in range(N // R + 1):
    for g in range((N - r) // G + 1):
        bb = (N - r*R - g*G)
        if bb >= 0 and bb % B == 0:
            i += 1

print(i)

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

K, S = map(int, input().split())

ans = 0
for z in range(K+1):
    for y in range(K+1):
        x = S - (z + y)
        if 0 <= x <= K:
            ans += 1
print(ans)

Measured memory_bytes: 40684
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int N,i,j,M=0;
	scanf("%d", &N);
	for (i = 0; i <= 25; i++) {
		for (j = 0; j <= 14; j++) {
			if (N - 4 * i - 7 * j == 0) {
				M = 1;
			}
		}
	}
	if (M == 0)printf("No\n");
	else printf("Yes\n");
	return 0;
}
 

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

var w1 = "Sunny"
var w2 = "Cloudy"
var w3 = "Rainy"

func solve(s string) string {
	switch s {
	case w1:
		return w2
	case w2:
		return w3
	case w3:
		return w1
	default:
		return ""
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	s := next()
	res := solve(s)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 640
s = input()
t = input()

n = len(s)
m = len(t)

dp = [[0] * (m+1) for _ in range(n+1)]

for i in range(n+1):
    for j in range(m+1):
        if i < n and j < m and s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        if i < n:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j < m:
            dp[i][j+1] = max(dp[i][j+1], dp[i][j])

i = n
j = m
ans = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
        continue
    if dp[i][j] == dp[i][j-1]:
        j -= 1
        continue
    i -= 1
    j -= 1
    ans += s[i]

print(ans[::-1])

Measured memory_bytes: 116700
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define Max 1000
using namespace std;
const int N=1e5+5;
int dp[N];
int w[105],val[105];
void solve()
{
    int n,wt,ans=0; cin>>n>>wt;
    for(int i=0;i<n;i++)cin>>w[i]>>val[i];
    for(int i=1;i<N;i++)dp[i]=wt+1;
    for(int i=0;i<n;i++)
    {
        for(int j=1e5;j>=0;j--)
        {
            if(j-val[i]<0)continue;
            dp[j]=min(dp[j],dp[j-val[i]]+w[i]);
            if(dp[j]<=wt)ans=max(ans,j);
        }
    }
    cout<<ans;
    return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    while(t--)solve();
    return 0;
}


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

int main() {
	int N;
    cin >> N;
    if(N % 2 == 1) {
    cout << N / 2 + 1 << endl;
    }
    
    else if(N % 2 == 0) {
    cout << N / 2 << endl;
    }
}


Measured memory_bytes: 256
main = do
    s <- getLine
    putStrLn . show $ solve s

solve :: String -> Int
solve s = let (_,_,score) = foldl maximizer (0,0,0) s in score

maximizer :: (Int, Int, Int) -> Char -> (Int, Int, Int)
maximizer (p, g, score) hand
    | hand == 'g' && p < g = (p+1, g, score+1)
    | hand == 'g' && p >= g = (p, g+1, score)
    | hand == 'p' && p < g = (p+1, g, score)
    | hand == 'p' && p >= g = (p, g+1, score-1)


Measured memory_bytes: 6140