akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
int main(){
	int n;
	cin>>n;
	int a[n];
	in(a,n);
	int q;
	cin>>q;
	int b[q],c[q];
	rep(i,q)cin>>b[i]>>c[i];
	ll num[100001];
	init(num,100001);
	rep(i,n)num[a[i]]++;
	ll sum=0;
	rep(i,100001)sum+=i*num[i];
	rep(i,q){
		num[c[i]]+=num[b[i]];
		sum+=(c[i]-b[i])*num[b[i]];
		num[b[i]]=0;
		cout<<sum<<"\n";
	}
	return 0;
}

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

int main(){
	int n,m,t;
	while(cin >> n >> m && n || m){
		int now = 0,ret = -1;
		int data[1006]={0};
		for(int i=0;i<n;i++){
			cin >> data[i];
		}
		
		for(int i=0;i<m;i++){
			cin >> t;
			if(ret == -1){
				now += t;
				now += data[now];
				if(now >= n-1){
					ret = i;
				}
			}
		}
		cout << ret+1 << endl;
	}
}

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

int main() {
  string s;
  cin >> s;
  string ans = "Good";
  for (int i = 0; i < s.size() - 1; i++) {
    if (s.at(i) == s.at(i + 1)) {
      ans = "Bad";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
'use strict';

const testcase = null;

function main(input) {
    const n = parseInt(input.shift());
    const m = parseInt(input.shift());
    const b = new BinaryHeap();
    for (var i = 0; i < n; i++) {
        b.push(parseInt(input.shift()));
    }
    for (var i = 0; i < m; i++) {
        b.push(b.pop() / 2);
    }
    var sum = 0;
    for (var i = 0; i < n; i++) {
        sum += Math.trunc(b.pop());
    }
    console.log(sum);
}

class BinaryHeap {
    constructor() {
        // HACK: first is unused
        this.heap = new Array(1);
    }
    push(data) {
        const index = this.heap.push(data) - 1;
        BinaryHeap.upHeap(this.heap, index);
    }
    static upHeap(heap, idx) {
        const parent = Math.trunc(idx / 2);
        if (heap[parent] < heap[idx]) {
            const tmp = heap[idx];
            heap[idx] = heap[parent];
            heap[parent] = tmp;
            BinaryHeap.upHeap(heap, parent);
        }
    }
    pop() {
        const index = 1;
        const data = this.heap[index];
        const last = this.heap.pop();
        if (1 < this.heap.length) {
            this.heap[index] = last;
            BinaryHeap.downHeap(this.heap, index);
        }
        return data;
    }
    static downHeap(heap, idx) {
        const childL = idx * 2, childR = idx * 2 + 1;
        var target = idx;
        target = heap[target] < heap[childL] ? childL : target;
        target = heap[target] < heap[childR] ? childR : target;
        if (target != idx) {
            const tmp = heap[target];
            heap[target] = heap[idx];
            heap[idx] = tmp;
            BinaryHeap.downHeap(heap, target);
        }
    }
}

// as python, if __name__ == '__main__':
if (process.argv[1] == __filename) {
    const input = testcase
        || require('fs')
            .readFileSync('/dev/stdin', 'utf-8');
    main(input.split(/\s/));
}


Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, M, X;

int main(void){
    
    scanf("%d %d %d", &N, &M, &X);
    int a = 0, b = 0;
    for(int i = 0; i < M; ++i){
        int A; scanf("%d", &A);
        if(A < X) ++a;
        if(A > X) ++b;
    }
    printf("%d\n", min(a, b));
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc_055_A
{
    class Program
    {
        static void Main(string[] args)
        {

            int a = int.Parse(Console.ReadLine());
            int morau = 0;
            if (a % 15 == 0) { morau = a / 15*200; }
            else { morau = ((a / 15) ) * 200; }
            Console.WriteLine(a*800-morau);
        }
    }
}


Measured memory_bytes: 13140
N, M = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(N)]
checkpoints = [list(map(int, input().split())) for _ in range(M)]

for student in students:
    nearst_index = 0
    _min = 10**10
    for point_index in range(len(checkpoints)):
        diff = abs(student[0] - checkpoints[point_index][0])+abs(student[1] - checkpoints[point_index][1])
        if diff < _min:
            _min = diff
            nearst_index = point_index+1
    print(nearst_index)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int N, i, max, cnt;
    int H[20];
    
    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &H[i]);
    }
    
    max = 0;
    cnt = 0;
    for(i = 0; i < N; i++){
        if(max <= H[i]){
            max = H[i];
            cnt = cnt + 1;
            
        }
    }

    printf("%d", cnt);
    
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int h,w,i,j;

	while(1){
		scanf("%d %d",&h,&w);

		if(h==0 && w == 0){
			return 0;
		}

		for(j=0;j<h;j++){

			switch(j%2){

				case 0:
				for(i=0;i<w;i++){

					switch(i%2){

						case 0:
						printf("#");
						break;

						case 1:
						printf(".");
						break;
					}
				}
				break;

				case 1:
				for(i=0;i<w;i++){

					switch(i%2){

						case 0:
						printf(".");
						break;

						case 1:
						printf("#");
						break;
					}
				}
				break;
			}
			printf("\n");
		}
		printf("\n");

	}
}


Measured memory_bytes: 2052
n = int(input())
a = list(map(int, input().split()))
dp = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]
for w in range(1, n):
    for l in range(n - w):
        dp[l][l+w] = max(a[l] - dp[l+1][l+w], a[l+w] - dp[l][l+w-1])
print(dp[0][n-1])

Measured memory_bytes: 119900
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,k,l,m,ans;
  cin>>n>>k;
  l=n/k;
  ans=l*l*l;
  if(k%2==0){
    m=n/(k/2)-l;
    ans+=m*m*m;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 M = 0;
	SINT32 ANS = 0;

	
	cin >> N >> M;
	vector<SINT32> DATA(M+1);

	for (SINT32 i = 0; i < M+1; i++) {
		DATA[i] = 0;
	}

	for (SINT32 i = 0; i < N; i++) {
		SINT32 BUF;
		cin >> BUF;
		for (SINT32 j = 0; j < BUF; j++) {
			SINT32 BUF2;
			cin >> BUF2;
			DATA[BUF2] = DATA[BUF2]+1;
		}
	}

	for (SINT32 i = 0; i < M+1; i++) {
		if (DATA[i] == N) {
			ANS = ANS + 1;
		}
	}


//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());

	
	cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,i,j,k;
    cin >> n >> k;
    int h[n],dp[n];
    for(i=0;i<n;++i) cin >> h[i];
    dp[0] = 0;
    for(i=1;i<n;++i) {
        dp[i] = abs(h[i] - h[i-1]) + dp[i-1];
        for(j=1;j<=min(k,i);++j) 
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout << dp[n-1];
    return 0;
}

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

#define ff first
#define ss second
#define all(abcc) (abcc).begin(), (abcc).end()
#define endl '\n'
#define left aba
#define right abc

using namespace std;

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

const int N=103, W=100003;

int n, maxw;

int w[N], v[N];
ll dp[N][W];

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

    cin>>n>>maxw;
    for(int i=0; i<n; ++i) {
        cin>>w[i]>>v[i];
    }

    dp[0][w[0]]=(ll)v[0];

    for(int i=1; i<n; ++i) {
        for(int j=0; j<=maxw; ++j) {
            if(j>=w[i]) {
                dp[i][j]=max(dp[i-1][j], (ll)dp[i-1][j-w[i]]+(ll)v[i]);
            } else {
                dp[i][j]=dp[i-1][j];
            }
        }
    }

    cout<<*max_element(dp[n-1], dp[n-1]+(maxw+1))<<endl;

    //cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<"s"<<'\n';
    return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n, k;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i <= n; ++i) {
        if(s.substr(n-i, i) == t.substr(0, i)){
            k = i;
        }
    }
    cout << 2*n-k << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[200010],b[200010];
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){
		if(a[i]==0)b[i]=0;
		else{
			b[i]=1;
			for(int j=1;j<=sqrt(i);j++){
				if(i%j==0){
					a[j]=1-a[j];
					if(j*j!=i)a[i/j]=1-a[i/j];
				}
			}
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++)if(b[i]==1)cnt++;
	cout<<cnt<<endl;
	for(int i=1;i<=n;i++){
		if(b[i]==1)cout<<i<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC082
{
    class Derangement
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine().Trim());
            var p = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_)).Where((num, i) => num == i + 1).OrderBy(_ => _).ToArray();
            for (var i = 1; i < p.Length; ++i) {
                p[i - 1] = p[i] - p[i - 1];
            }
            var sum = p.Count();
            for (var i = 1; i < p.Length; ++i) {
                if (p[i - 1] == 1) {
                    --sum;
                    if (p[i] == 1) {
                        p[i] = 0;
                    }
                }
            }
            WriteLine(sum);
        }
    }
}


Measured memory_bytes: 22240
#include <stdio.h>
void sortArraySmall(int array[],int size);
void swap (int *pa, int *pb);
int main(int argc, const char * argv[]) {
    
    int n,k;
    
    scanf("%d%d",&n,&k);
    
    int a[n];
    
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sortArraySmall(a,n);
    
    int sum=0;
    
    for(int i=0;i<k;i++){
        sum+=a[i];
    }
    
    printf("%d",sum);
    
    
    return 0;
}
void sortArraySmall(int array[], int size)
{
    for( int i = 1; i < size; size--)
    {
        for( int j = 1; j < size; j++ )
        {
            if( array[j-1] > array[j] )
            {
                swap( &array[j-1], &array[j] );
            }
        }
    }
}
void swap(int *pa, int *pb)
{
    int temp = *pa;
    *pa = *pb;
    *pb = temp;
}


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

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

    vector<int> x(n);
    rep(i, n)
        cin >> x.at(i);

    int s = 0;
    rep(i, n)
        s += x.at(i);

    double a = ((double) s) / n;
    int aa = round(a);

    int sd = 0;
    rep(i, n)
        sd += (x.at(i) - aa) * (x.at(i) - aa);

    cout << sd << endl;
}

Measured memory_bytes: 3580
//include
//------------------------------------------
#include <string>
#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 <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

int solve() {
	ll a;
	cin >> a;

	cout << 10 - a / 200 << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0;i<N;i++){
    cin >>A.at(i);
  }
  
  sort(A.begin(),A.end());
  cout << A.at(N-1)-A.at(0) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define lnode node*2,start,mid
#define rnode node*2+1,mid+1,end
#define rep(i,a,b) for(ll i=a;i<=(b);i+=1)
#define input freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
#define To_string(num,str) {stringstream ss;ss<<num;ss>>str;}
#define To_num(str,num) {stringstream ss;ss<<str;ss>>num;}
const double pi=acos(-1.0);
const int maxn=(1e6+10);
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
using namespace std;
bool pd[maxn];
int num=0,prime[maxn];
void getprime()
{  memset(pd,true,sizeof(pd));
   for(int i=2;i<=1e6;i++)
     if(pd[i])
     {
         for(int j=i*2;j<=1e6;j+=i)
            pd[j]=false;
     }
   for(int i=2;i<=1e6;i++)
     if(pd[i])
     {
        num+=1;
        prime[num]=i;
     }
}
int main()
{   cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,ans=0;
    cin>>a>>b;
    getprime();
    ll now=__gcd(a,b);
    for(int i=1;i<=num;i++)
    {
        if(now%prime[i]==0)
        {
            ans+=1;
            while(now%prime[i]==0)
            {
                now/=prime[i];
            }
        }
    }

    if(now!=1) ans+=1;
    ans+=1;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
   int n,m;cin>>n>>m;
   if(n-2*m>0)cout<<n-2*m<<endl;
   else cout<<0<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

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

  int ans_a, ans_a_max;
  ans_a = ceil(a * (1 / 0.08));
  ans_a_max = ceil((a + 0.9) * (1 / 0.08));
  int ans_b, ans_b_max;
  ans_b = ceil(b * (1 / 0.1));
  ans_b_max = ceil((b + 0.9) * (1 / 0.1));

  int ans = max(ans_a, ans_b);

  if (ans == ans_a)
  {
    if (ans_b_max > ans)
    {
      cout << ans << endl;
      return 0;
    };
  }
  else
  {
    if (ans_a_max > ans)
    {
      cout << ans << endl;
      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}


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

using namespace std;

long long ans;

int main()
{
    int k,a,b;
    ans = 1;
    scanf("%d%d%d",&k,&a,&b);
    if(b-a<=2){
        ans += k;
    }else{
        if(k+1 >= a){
            ans = a;
            k = k - (a-1);
        }else{
            ans += k;
            cout << ans << endl;
            return 0;
        }
        long long kk = k /2;
        k = k % 2;
        ans += kk*(b-a);
        ans+=k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  readln;
  readln.chomp.split.map!(a=>a.to!int - 1).sum.writeln;
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
map<string,int> S;
map<P,int> D;
string s;
int p;

int getNum(){
  if('0'<=s[p]&&s[p]<='9'){
    int res=0;
    while('0'<=s[p]&&s[p]<='9')
      res=res*10+s[p++]-'0';
    return res;
  }
  string str;
  while(s[p]!='[')str+=s[p++];
  p++;
  int r=getNum();
  if(r<0||S[str]<=r)return -1;
  if(!D.count(P(str,r)))return -1;
  return D[P(str,r)];
}

bool check(){
  for(int i=0;i<s.size();i++)
    if(s[i]=='='){
      string t;
      p=i+1;
      int num1,num2=getNum();
      for(int j=0;j<i;j++)
	if(s[j]=='['){
	  t=s.substr(0,j);
	  p=j+1;
	  num1=getNum();
	  if(S[t]<=num1)num1=-1;
	  break;
	}
      if(num1<0||num2<0)return false;
      D[P(t,num1)]=num2;
      return true;
    }
  int idx;
  for(int i=0;i<s.size();i++)
    if(s[i]=='[')idx=i;
  string A=s.substr(0,idx);
  p=idx+1;
  S[A]=getNum();
  return true;
}

int main(){
  while(1){
    cin>>s;
    if(s==".")break;
    int ans=1,flag=0;
    while(1){
      if(!flag&&!check())flag=1;
      if(!flag)ans++;
      cin>>s;
      if(s==".")break;
    }
    cout<<(flag?ans:0)<<endl;
    S.clear();
    D.clear();
  }
  return 0;
}

Measured memory_bytes: 3292
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        char[] c = new char[1200];
        int lsum = 0;
        String str;

        while((str = br.readLine()) != null){
           
            
            int l = str.length();
            

            for(int j=0; j<l; j++){
                c[j+lsum] = str.charAt(j);
            }

            lsum += l;
        }


        for(int i = 97; i<123; i++){
            char N = (char)i;
            int cou=0;
            for(int j=0; j<lsum; j++){
                if(c[j] == i || c[j] == i-32){
                    cou++;
                }
            }
            System.out.println(N + " : " + cou);
        }
       

    }
} 


Measured memory_bytes: 24184
#include<iostream>
#include<cstring>
using namespace std;
const int N = 2*1e5+10;
char str[N];
int pre[N];
int r,l,length, ans;
bool jud;

int main()
{
    scanf("%s",str);
    length = strlen(str);
    for(int i = 0; i < length; i++)pre[i] = i - 1;
    r = 1;
    while(r < length)
    {
        jud = false;
        while(str[l]=='S' && str[r]=='T')
        {
            ans += 2;
            if(pre[l] < 0 || r + 1 > length)
            {
                jud = true;
                break;
            }
            l = pre[l];
            r++;
            pre[r] = l;
        }
        if(pre[l] < 0 && jud)l = r + 1, r += 2;
        else l = r, r++;
    }
    printf("%d",length - ans);
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main() {
	int n;

	scanf("%d", &n);

	if (400 <= n && n <= 599) {
		puts("8");
	}
	else if (600 <= n && n <= 799) {
		puts("7");
	}
	else if (800 <= n && n <= 999) {
		puts("6");
	}
	else if (1000 <= n && n <= 1199) {
		puts("5");
	}
	else if (1200 <= n && n <= 1399) {
		puts("4");
	}
	else if (1400 <= n && n <= 1599) {
		puts("3");
	}
	else if (1600 <= n && n <= 1799) {
		puts("2");
	}
	else if (1800 <= n && n <= 1999) {
		puts("1");
	}

	return 0;
}

Measured memory_bytes: 1616
import java.util.Scanner;

public class Main {

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

        String num = sc.next();
        int numi = Integer.parseInt(num);

        int count = 0;
        for (int i = 1; i <=numi; i++) {
            if (i % 2 != 0) {
                count++;
            }
        }

        double result = (double)count/numi;
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
h, w = list(map(int, input().split()))
a = [list(input()) for i in range(h)]
cnt = 0
for i in range(h):
  for j in range(w):
    if a[i][j]=='#':
      cnt += 1
if cnt==(h+w)-1:
  print("Possible")
else:
  print("Impossible")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll ans = min(N%K, K - N%K);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int a = Integer.parseInt(sa[1]);

		sa = br.readLine().split(" ");
		int[] x = new int[n + 1];
		for (int i = 0; i < n; i++) {
			x[i + 1] = Integer.parseInt(sa[i]);
		}
		br.close();

		long[][][] dp = new long[n + 1][n + 1][n * 50 + 1];
		dp[0][0][0] = 1;
		for (int i = 1; i <= n; i++) {
			dp[i][0][0] = 1;
			for (int j = 1; j <= i; j++) {
				for (int k = 0; k <= j * 50; k++) {
					dp[i][j][k] = dp[i - 1][j][k];
					int pre = k - x[i];
					if (0 <= pre && pre <= (j - 1) * 50) {
						dp[i][j][k] += dp[i - 1][j - 1][pre];
					}
				}
			}
		}

		long ans = 0;
		for (int j = 1; j <= n; j++) {
			ans += dp[n][j][j * a];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 83260
use proconio::input;

fn main() {
    input!(n: usize, mut a: [u64; n], mut b: [u64; n], mut c: [u64; n]);
    a.sort();
    b.sort();
    c.sort();
    let mut ans = 0u64;
    let mut i = 0;
    let mut k = 0;
    for j in 0..n {
        while i < n && a[i] < b[j] {
            i += 1;
        }
        while k < n && c[k] <= b[j] {
            k += 1;
        }
        ans += i as u64 * (n as u64 - k as u64);
    }
    println!("{}", ans);
}


Measured memory_bytes: 7772
import copy
import math
n,m = map(int,input().split())

#取得
scores = list()
for i in range(n):
    score = list(map(int,input().split()))
    scores.append(score)

smax=None
for p in range(8):
    x=math.floor((p/4)%2)
    y=math.floor((p/2)%2)
    z=math.floor((p/1)%2)
    
    scores_=copy.deepcopy(scores)
    sumlist=list()

    for i in range(n):
        scores_[i][0] = pow(-1,x)*scores[i][0]
        scores_[i][1] = pow(-1,y)*scores[i][1]
        scores_[i][2] = pow(-1,z)*scores[i][2]
        sumlist.append(sum(scores_[i]))
    sumlist.sort()
    
    tmp=0
    for eat in range(m):
        tmp+=sumlist[-1]
        sumlist.pop()
    if smax==None or tmp>smax:
        smax=tmp
print(smax)

Measured memory_bytes: 4212
//This disgusting code is wriiten by Juruo D0zingbear
//Please don't hack me! 0v0 <3
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: ｌｌｄ
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int Maxn=105;
char a[Maxn][Maxn];
int cnt[26];
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for (int i=0;i<n;i++){
		scanf("%s",a[i]);
		for (int j=0;j<m;j++) cnt[a[i][j]-'a']++;
	}
	if (n%2==0 && m%2==0){
		for (int i=0;i<26;i++){
			if (cnt[i]%4!=0){
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
		return 0;
	}
	else if (n%2==0 || m%2==0){
		int cr=0,cc=0;
		for (int i=0;i<26;i++){
			if (cnt[i]&1){
				printf("No\n");
				return 0;
			}
			if (cnt[i]%2==0 && cnt[i]%4!=0) cc++;
		}
		int dd=((n%2==0)?n/2:m/2);
		if (dd<cc || (dd-cc)&1){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}
		return 0;
	}
	else{
		int cr=0,cc=0;
		for (int i=0;i<26;i++){
			if (cnt[i]&1) cr++;
			if (cnt[i]%2==0 && cnt[i]%4!=0) cc++;
		}
		if (cr!=1){
			printf("No\n");
			return 0;
		}
		int dd=(n/2+m/2);
		if (dd<cc || (dd-cc)&1){
			printf("No\n");
		}
		else{
			printf("Yes\n"); 
		}
		return 0;
	}
}

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

int main()
{
	int a,b;
	cin>>a>>b;
	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)
		cout<<"Possible"<<endl;
	else
		cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace program
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);

            string[] ng = Console.ReadLine().Split(' ');
            int result = 0;
            for(int i = n; n<100000;i++)
            {
                bool query = ng
                    .Any(x => i.ToString().Contains(x));

                if(query == false)
                {
                    result = i;
                    break;
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    ll N,K; cin>>N>>K;
    // N = pb + q
    // 0,1,2,...,b-1,0,1,...,b-1,0,1,..,b-1,0,1,...,q
    ll ans = 0;
    for(ll b=1;b<=N;++b){
        ll p = N/b;
        ll q = N%b;
        ans += p*max(b-K,0LL);
        ans += max(q-K+1,0LL);
    }
    if(K==0){ ans -= N; }
    cout << ans << "\n";
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

struct union_find{
    vector<int> par;
    vector<int> rank;

    union_find(int n) : par(n), rank(n){
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    void init(int n){
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    int G[100][2] = {};
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b; a--; b--;
        G[i][0] = a;
        G[i][1] = b;
    }
    union_find u(n);
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            if(j == i) continue;
            u.unite(G[j][0], G[j][1]);
        }

        bool flag = false;
        int root = u.root(0);
        for (int j = 0; j < n; ++j) {
            if(u.root(j) != root){
                flag = true;
                break;
            }
        }
        if(flag) ans++;
        u.init(n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    string s;
    
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
    
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

ll dp[100005][13];

int main()
{
    int a[5];
    int n = 5;
    rep(i,n) cin >> a[i];
    int ans = inf;
    rep(i,n){
        int tmp = 0;
        rep(j,n){
            if(i == j) tmp += a[j];
            else{
                tmp += ((a[j]-1)/10 + 1) * 10;
            }
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

template <ll mod>
struct modular {
    ll value;
    modular(ll x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }

    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        ll a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            ll t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular& operator^=(modular other) {
        ll r = 1, x = value, n = other.value;
        while (n > 0) {
            if (n & 1) r = r * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        value = r;
        return *this;
    }
    modular operator+(modular rhs) {
        return modular(*this) += rhs;
    }
    modular operator-(modular rhs) {
        return modular(*this) -= rhs;
    }
    modular operator*(modular rhs) {
        return modular(*this) *= rhs;
    }
    modular operator/(modular rhs) {
        return modular(*this) /= rhs;
    }
    modular operator^(modular rhs) {
        return modular(*this) ^= rhs;
    }
    bool operator==(modular rhs) {
        return value == rhs.value;
    };
    bool operator!=(modular rhs) {
        return value != rhs.value;
    };
    bool operator<(modular rhs) {
        return value < rhs.value;
    }
};
template <ll mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <ll mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <ll mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
}
const ll mod = 1e9 + 7;
using mint = modular<mod>;

vector<mint> fac, finv;
inline void cinit(int n) {
    fac.resize(n, 1);
    finv.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fac[i] = fac[i - 1] * i;
        finv[i] = finv[i - 1] / i;
    }
}
inline mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
inline mint H(int n, int k) {
    return C(n + k - 1, k);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    cinit(300000);
    mint ans;
    rep(i, 0, min(n, k + 1)) {
        mint res = C(n, i) * C(n - 1, i);
        ans += res;
        debug(i, res);
    }
    cout << ans << endl;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int count=0;
    int A,B,C;
    
  
  for(int i=1; i<=1000; i++){
    if(a%2 == 1 || b%2 == 1 || c%2 == 1){
      cout << count << endl;
      break;
    }
    
    else if(a == b && b == c){
      count = -1;
      cout << count << endl;
      break;
    }
    
    else{
      A=(b+c)/2;
      B=(c+a)/2;
      C=(a+b)/2;
      a=A;
      b=B;
      c=C;
      count++;
    }
    
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define ld long double
using namespace std;
int32_t main()
{
    IOS;
    int n,a=0,w=0,t=0,r=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	string s;
    	cin>>s;
    	if(s=="AC")
    		a++;
    	else if(s=="WA")
    		w++;
    	else if(s=="TLE")
    		t++;
    	else
    		r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>
#include <functional>

int n;
int S[1<<18];
int Q[19];


int main(){
  scanf("%d",&n);
  for(int i=0;i<(1<<n);i++) scanf("%d",S+i);
  std::sort(S, S+(1<<n), std::greater<int>());
  int k = 0;
  for(int i=0;i<(1<<n);){
    int j = i;
    for(i++; S[i] == S[j]; i++) ;
    S[k++] = i-j;
  }
  Q[n] = 1;
  for(int i=0;i<k;i++){
    int l;
    int a=0;
    for(l=n;l>=0 && a < S[i];l--) a += Q[l];
    if(a<S[i]){
      puts("No");
      return 0;
    }
    l++;
    for(int t=0;t<l;t++) Q[t] += S[i];
    int b = a-Q[l];
    Q[l] = a-S[i]+b;
    for(int t=l+1;b;t++){
      b -= Q[t];
      Q[t] = b;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1152
##いくつかの人の回答を参考に、メモしながら学習
H, W = map(int, input().split())
Field = [list(input()) for _ in range(H)]

# 10 37
# .....................................
# ...#...####...####..###...###...###..
# ..#.#..#...#.##....#...#.#...#.#...#.
# ..#.#..#...#.#.....#...#.#...#.#...#.
# .#...#.#..##.#.....#...#.#.###.#.###.
# .#####.####..#.....#...#..##....##...
# .#...#.#...#.#.....#...#.#...#.#...#.
# .#...#.#...#.##....#...#.#...#.#...#.
# .#...#.####...####..###...###...###..
# .....................................

# 出力するスコアは「全白マス数」-「最短距離のマス数」なので、まず白マスの数を数える。
white = 0
for i in range(H):
    for j in range(W):
        if Field[i][j] == '.':
            white += 1

# 移動する4方向
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

# HxWの行列を作る。初期値は全部"None"。ここにスタートからゴールまでの歩数を入れていく。
    # Field_map[H-1][W-1]がゴールまでの「最短距離のマス数」になる。
Field_cost =[[None]*W for i in range(H)]
Field_cost[0][0] = 0

# whileでゴールまでの最短距離を幅優先探索
from collections import deque
que = deque([])     # デックリストqueに、最短距離を通る際の(i,j)が入っていく。
que.append((0, 0))  # まず(0,0)は通るので。

while que:
    i, j = que.popleft()       # (i,j)が今いるマス
    if i == H-1 and j == W-1:  # (i,j)がゴールマスになったらやめ
        break
    for d in range(4):
        new_i = i + dx[d]
        new_j = j + dy[d]
        if 0 <= new_i and new_i < H and \
           0 <= new_j and new_j < W and \
           Field[new_i][new_j] != '#' and \
           Field_cost[new_i][new_j] == None:  # 1,2は道を外れてないこと。3はちゃんと白マス。4はまだ通ってないこと。
            que.append((new_i, new_j))     # このマス
            Field_cost[new_i][new_j] = Field_cost[i][j] + 1  # 前のマス+1。何マス歩いてきたか。

# 出力するスコアは「全白マス数」-「最短距離のマス数」
if Field_cost[H-1][W-1] is None:
    print("-1")
else:
    print(white - Field_cost[H-1][W-1]-1)


Measured memory_bytes: 9488
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	var A, a, B, b int
	fmt.Scan(&A, &B)
	a = A
	b = B
	for a != b {
		if a < b {
			a += A
		} else {
			b += B
		}
	}
	fmt.Println(a)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), "")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func smallest(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

class Combination {
 public:
  vector<vector<ll>> dp;
  ll n;

  explicit Combination(ll n) {
    this->n = n;
    this->dp = vector<vector<ll>>(n + 1, vector<ll>(n + 1, 0));
    comb_table();
  }

  inline ll calc(ll n, ll r) {
    return dp[n][r];
  }

  void comb_table() {
    rep(i, n + 1) {
      rep(j, n + 1) {
        if (j == 0 or j == i) {
          dp[i][j] = 1LL;
        } else {
          if (i != 0)
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
        }
      }
    }
  }
};

void solve(istream &ccin = cin, ostream &ccout = cout) {

  ll n, a, b;
  ccin >> n >> a >> b;
  ll1d v(n);
  rep(i, n) {
    ccin >> v.at(i);
  }
  sort(v.rbegin(), v.rend());

  ll sum = 0;
  rep(i, a) {
    sum += v.at(i);
  }
  double mean = double(sum) / a;

  ccout << fixed;
  ccout << setprecision(6) << mean << endl;

  ll va_1 = v.at(a - 1);
  Combination cmb(51);
  ll cnt1 = 0, cnt2 = 0;
  rep(i, n) {
    if (v[i] == va_1) {
      ++cnt1;
      if (i < a) {
        ++cnt2;
      }

    }

  }

  ll ans = 0;
  if (a == cnt2) {
    REP(i, a, b + 1) {
      ans += cmb.calc(cnt1, i);
    }
  } else {
    ans += cmb.calc(cnt1, cnt2);
  }

  ccout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, m, a[105], b[105], x, s_a, s_b, A, B, min, i, j;
    n=1; m=1;
    while (1) {
        scanf("%d %d", &n, &m);
        if (n==0 && m==0) break;
        s_a=0; s_b=0;
        for (i=1; i<=n; i++) {
            scanf("%d", &a[i]);
            s_a+=a[i];
        }
        for (i=1; i<=m; i++) {
            scanf("%d", &b[i]);
            s_b+=b[i];
        }
        if ((s_a+s_b)%2==1) {
            printf("-1\n");
            continue;
        }
        x=(s_a-s_b)/2; min=1000;
        for (i=1; i<=n; i++) {
            for (j=1; j<=m; j++) {
                if (a[i]-b[j]==x && a[i]+b[j]<min) {
                    A=a[i]; B=b[j];
                    min=a[i]+b[j];
                }
            }
        }
        if (min!=1000) printf("%d %d\n", A, B);
        else printf("-1\n");
    }
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

// Radix r;
//     // 10 進数を n 進文字列に
//     std::cout << r.to(255, 10) << std::endl; // => "255"
//     std::cout << r.to(255, 12) << std::endl; // => "193"
//     std::cout << r.to(255, 16) << std::endl; // => "FF"
//
//     // n 進文字列を 10 進数に
//     std::cout << r.to("255", 10) << std::endl; // => 255
//     std::cout << r.to("255", 14) << std::endl; // => 467
//
//     // n 進文字列を m 進文字列に
//     std::cout << r.to("255", 7, 11) << std::endl; // => "116"
//     std::cout << r.to("255", 11, 7) << std::endl; // => "611"


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

	int n, k;
	cin >> n >> k;
	Radix r;
	string s = r.to(n, k);
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
#define ll long long
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,k;
    while(cin>>n>>k){
        n==k?cout<<"Yes"<<endl:cout<<"No"<<endl;
    }
    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{

    int n;
    cin >> n;
    string s,t;cin >> s>>t;
    int ans=2*n;
    int x=0;
    FOR(i,1,n+1){//i文字
        REP(j,i){
            if(s[n-1-i+1+j]!=t[j]){
                break;
            }
            if(j==i-1){
                x = max(x, i);
            }
        }
    }
    ans -= x;
    //if(s==t){ans = n;//cout <<" a" << "\n"; }

    cout << ans <<"\n";

    return 0;
}

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

int main() {
  int n,m;cin>>n>>m;
  vector<vector<char>>a(100,vector<char>(100));
  vector<vector<char>>b(100,vector<char>(100));
  rep(i,n)rep(j,n)cin>>a[i][j];
  rep(i,m)rep(j,m)cin>>b[i][j];
  bool ans=false;
  rep(i,n)rep(j,n){
    if(a[i][j]==b[0][0]){
      int cnt=0;
      rep(k,m)rep(l,m){
        if(a[i+k][j+l]==b[k][l])cnt++;
        }
        if(cnt==m*m)ans=true;
    }
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3656