akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005, inf=1e9+5;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n,W;cin>>n>>W;
    ll w[n],v[n];
    repn(i,n){
        cin>>w[i]>>v[i];
    }
    ll vv[N];
    repn(i,N){
        vv[i]=1e18;
    }
    vv[0]=0;
    repn(i,n){
        // if(i==1){
        //     cout<<vv[30]<<endl;
        // }
        bac(j,N-1,0){
            if(j+v[i]<N and vv[j]!=1e18){
                // cout<<"YES ";
                vv[j+v[i]]=min(vv[j]+w[i],vv[j+v[i]]);
            }  
        }
    }
    // repn(i,W+1){
    //     cout<<vv[i]<<" ";
    // }
    // cout<<endl;
    // cout<<vv[30]<<" "<<vv[60]<<" "<<vv[50]<<" "<<vv[90]<<endl;
    ll ans = 0;
    bac(i,N-1,0){
        if(vv[i]<=W){
            ans = i;
            break;
        }
    }
    cout<<ans;
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(i<(s.size()+1)/2){
            if(s[i]=='p')ans--;
        } else {
            if(s[i]=='g')ans++;
        }
    }
    fin(ans);

}



Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	while(1) {
		int n, x, ans = 0;
		cin >> n >> x;
		if (n == 0 && x == 0)
			break;
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				for (int k = j + 1; k <= n; k++)
					if (i + j + k == x)
						ans++;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cassert>
#include <queue>
#include <set>
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

template<int m>
class Prime{
  std::vector<bool> p;
  std::vector<int> ps;
public:
  Prime(){
    p = std::vector<bool>(m,true);
    assert(m>1);
    p[0]=p[1]=false;
    for(int i=4;i<m;i+=2)
      p[i]=false;
    ps.push_back(2);
    for(int i=3;i<m;i+=2){
      if(p[i]){
        ps.push_back(i);
        for(int j=i+i;j<m;j+=i)
          p[j]=false;
      }
    }
  }

  bool isPrime(int n){
    assert(m>n);
    return p[n];
  }

  int operator [] (int n){
    if(n<ps.size()) return ps[n];
    else return 0;
  }

  int size(){
    return ps.size();
  }
};


using namespace std;

int main(){
  Prime<10001> prime;
  int n;

  while(cin >> n){
    int ans = 0;
    REP(i,n){
      if(prime.isPrime(i + 1) && prime.isPrime(n - i)){
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


void solve() {
	int k;
	string a;
	cin >> k >> a;
	int length = a.size();

	if(length > k) {
		for (int i = 0; i < k; i++) {
			cout << a[i];
		}
		cout << "...\n";
	} else {
		cout << a << "\n";
	}
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	FastInput;
	solve();

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3592
S = list(str(input()))
ini0,ini1 = 0,0
for i,s in enumerate(S):
    if i%2 == 0:
        if s == '0':
            ini1 += 1
        else:
            ini0 += 1
    else:
        if s == '0':
            ini0 += 1
        else:
            ini1 += 1
print(min(ini0,ini1))


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    const ll mod=1e9+7;
    int n;
    cin>>n;
    vector<int>a(1001,1);
    for(int i=2; i<=n; ++i){
        for(int j=i,k=2; j>1;){
            if(j%k==0)j/=k,a[k]++;
            else k++;
        }
    }
    ll ans=1;
    for(int i=2; i<=n; ++i){
        ans*=a[i];
        ans%=mod;
    }
    cout<<ans<<endl;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min(a, min(b, min(c, min(d, e))));
    ll ans = (n + m - 1) / m + 4;
    out(ans);
}


Measured memory_bytes: 384
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	q := nextInt()
	set := make(map[int]struct{})
	for i := 0; i < q; i++ {
		switch nextInt() {
		case 0:
			x := nextInt()
			set[x] = struct{}{}
			fmt.Println(len(set))
		case 1:
			x := nextInt()
			if _, ok := set[x]; ok {
				fmt.Println(1)
			} else {
				fmt.Println(0)
			}
		case 2:
			x := nextInt()
			delete(set, x)
		default:
			panic("no such operation!")
		}
	}
}


Measured memory_bytes: 9104
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, Y = MAP()

for i in range(N+1):
	for j in range(N+1):
		if i+j > N: continue
		k = N - (i+j)
		if i*10000 + j*5000 + k*1000 == Y:
			print("{} {} {}".format(i, j, k))
			sys.exit()
print('-1 -1 -1')

Measured memory_bytes: 41324
package main

import (
	"fmt"
)

func main() {

	var a,b,c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	var count int 
	if a == b {
		count ++
	}
	if a == c {
		count ++
	}
	if b == c {
		count ++
	}
	if count == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
char s[30],w[30];
int main() {
    cin>>s;
    int n=strlen(s);
    for(int i=0;i<n;i++) w[s[i]-'a']=1;
    for(int i=n;~i;i--) {
	for(int j=max(97,s[i]+1);j<='z';j++)
	    if(!w[j-'a']) return s[i]=j,puts(s),0;
	if(i<n) w[s[i]-'a']=s[i]=0;
    }
    puts("-1");
    return 0;
}

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;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	string a, b;
	cin >> a >> b;

	for(int i = 0; i < a.length(); ++i) {
		if(a[i] != b[i]) {
			cout << "No\n";
			return;
		}
	}

	cout << "Yes\n";
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 3616
#! /usr/bin/perl

use strict;
use warnings;

chomp(my $line = <>);
my($h, $w) = split(/\s+/, $line);

my @canvas;
foreach my $i (1..$h) {
    chomp(my $line = <>);
    push(@canvas, [ split(//, $line)]);
}

for(my $y = 0;$y < $h;$y ++) {
    for(my $x = 0;$x < $w;$x ++) {
        next if($canvas[$y][$x] eq '.');
        my $c = countn(\@canvas, $w, $h, $x, $y);
        if($c == 0) {
            print "No\n";
            exit;
        }
    }
}

print "Yes\n";

sub countn {
    my($canvas, $w, $h, $x, $y) = @_;
    my $count = 0;
    foreach my $n ([-1, 0], [1, 0], [0, -1], [0, 1]) {
        my $nx = $x + $n->[0];
        my $ny = $y + $n->[1];
        if(0 <= $nx && $nx < $w &&
           0 <= $ny && $ny < $h &&
           $canvas->[$ny][$nx] eq '#') {
            $count ++;
        }
    }
    return $count;
}


Measured memory_bytes: 896
/*
 * main.cpp
 *
 *  Created on: 2020/04/10
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

int main(){
	int A, B, C;
	int X;
	cin >> A >> B >> C;
	cin >> X;

	int count = 0;
	for(int i = 0; i <= A; i++){
		for(int j = 0; j  <= B; j++){
			for(int k = 0; k <= C; k++){
				int sum = i * 500 + j * 100 + k * 50;
				if(sum == X){
					count++;
					break;
				}
			}
		}
	}

	cout << count << endl;

	return 0;
}




Measured memory_bytes: 256
N = int(input())
D = []
for i in range(N):
  D.append(list(map(int, input().split())))
D.sort(key = lambda x:x[2], reverse = True)
for i in range(101):
  for j in range(101):
    F = True
    H = abs(i - D[0][0]) + abs(j-D[0][1]) + D[0][2]
    for k in range(1,N):
      if D[k][2] != 0:
        if H != abs(i - D[k][0]) + abs(j-D[k][1]) + D[k][2]:
          F = False
          break
      else:
        if H > abs(i - D[k][0]) + abs(j-D[k][1]) + D[k][2]:
          F = False
          break
    if F == True:
      print(str(i) + " " + str(j) + " " + str(H))
      exit()

Measured memory_bytes: 3064
unittest
{
	assert( [ "9" ].solve == 0 );
	assert( [ "10" ].solve == 1 );
	assert( [ "100" ].solve == 543 );
}



import std.conv;
import std.range;
import std.stdio;

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

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	long[ long ] fs;
	auto ps = ( cast( long ) n ^^ 0.5L ).primes;
	foreach_reverse( i; 2L .. n + 1 )
	{
		foreach( f; i.primefactorize( ps ) )
		{
			fs[ f ]++;
		}
	}
	return solve2( fs.values, 1 );
}

long solve2( long[] fs, long m )
{
	if( fs.empty || 75 <= m ) return ( m == 75 );
	
	auto c = 0L;
	foreach( i; 1L .. fs.front + 2 )
	{
		c += solve2( fs[ 1 .. $ ], m * i );
	}
	return c;
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}

// 素因数分解
auto primefactorize( long x, long[] ps )
{
	Appender!( long[] ) fs;
	if( x < 2 ) return fs.data;
	
	auto s = cast( long ) x ^^ 0.5L;
	foreach( p; ps )
	{
		if( s < p ) break;
		while( x % p == 0 )
		{
			x /= p;
			fs ~= p;
		}
		if( x < 2 ) break;
	}
	if( 2 <= x ) fs ~= x;
	return fs.data;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    repi(i, N / 4) {
        repi(j, N / 7) {
            if(4 * i + j * 7 == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3568
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    T = [[None]*n for _ in range(n)]

    try:
        it = iter(args[1:])
        a = next(it)
        i = 1
        while a:
            for _ in range(int(a)):
                x, y = map(int, next(it).split())
                T[i-1][x-1] = y == 1
            a = next(it)
            i += 1
    except StopIteration:
        pass

    ret = 0
    for hypo in range(2**n):
        consistent = True
        truth = [None]*n
        count = 0
        i = 0
        while consistent and i < n:
            if (hypo >> i) & 1:
                count += 1
                j = 0
                while consistent and j < n:
                    t = T[i][j]
                    if t is not None:
                        if truth[j] is None:
                            truth[j] = t
                        elif truth[j] != t:
                            consistent = False

                        consistent = (hypo >> j) & 1 == t
                    j += 1
            i += 1

        if consistent:
            ret = max(ret, count)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3064
a,b,c = map(int,input().split())
k = int(input())
ans = 0
for i in range(k+1):
    for j in range(k+1-i):
        n = k - (i + j)
        res = a * 2 ** i + b * 2 ** j + c * 2 ** n
        ans = max(ans,res)
print(ans)

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

const ll MOD = 998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<vector<ll>> m(c + 1, vector<ll>(d + 1, 0));
    
    m[a][b] = 1;
    for (int i = a + 1; i <= c; ++i) {
        m[i][b] = (m[i - 1][b] * b) % MOD;
    }
    for (int j = b + 1; j <= d; ++j) {
        m[a][j] = (m[a][j - 1] * a) % MOD;
    }
    
    for (int i = a + 1; i <= c; ++i) {
        for (int j = b + 1; j <= d; ++j) {
            m[i][j] = m[i - 1][j] * j + m[i][j - 1] * i;
            m[i][j] -= (m[i - 1][j - 1] * (i - 1) * (j - 1)) % MOD;
            m[i][j] = (m[i][j] + MOD) % MOD;
        }
    }
    cout << m[c][d] << "\n";
    
    return 0;
}


Measured memory_bytes: 73584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll N;
ll D1[110],D2[110];

int main(){
   cin >> N;
   rep(i,N) cin >> D1[i] >> D2[i];
   rep(i,N-2){
      if(D1[i] == D2[i] && D1[i+1] == D2[i+1] && D1[i+2] == D2[i+2]){
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AtCoder.ABC173
{
    public class Problem2
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var S = new List<string>();

            for (var i = 0; i < N; i++)
            {
                S.Add(Console.ReadLine());
            }

            var res = S.GroupBy(x => x).Select(c => new { Result = c.Key, Count = c.Count() });

            var AC = S.Contains("AC") ? (res.FirstOrDefault(x => x.Result == "AC")?.Count).ToString() : "0";
            var WA = S.Contains("WA") ? (res.FirstOrDefault(x => x.Result == "WA")?.Count).ToString() : "0";
            var TLE = S.Contains("TLE") ? (res.FirstOrDefault(x => x.Result == "TLE")?.Count).ToString() : "0";
            var RE = S.Contains("RE") ? (res.FirstOrDefault(x => x.Result == "RE")?.Count).ToString() : "0";


            Console.WriteLine("AC x " + AC);
            Console.WriteLine("WA x " + WA);
            Console.WriteLine("TLE x " + TLE);
            Console.WriteLine("RE x " + RE);
        }
    }
}


Measured memory_bytes: 37548
n,k=map(int,input().split())
a=[0]+[int(input())-k for i in range(n)]
for i in range(1,n+1):
	a[i]+=a[i-1]
b=sorted(a)+[-2e9-1]
c,d=0,dict()
for i in range(n+1):
	if b[i]!=b[i-1]:
		c+=1
		d[b[i]]=c
bit=[0]*(n+5)
def sum(i):
	res=0
	while i>0:
		res+=bit[i]
		i-=i&-i
	return res
def add(i):
	while i<=c:
		bit[i]+=1
		i+=i&-i
ans=0
for i in range(n+1):
	ans+=sum(d[a[i]])
	add(d[a[i]])
print(ans)

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,K;
    cin >> N >> K;
    ll H = (N / 2) + (N % 2);
    YES(H >= K);
}

Measured memory_bytes: 3640
from sys import stdin

def main():
    input = stdin.readline

    n,a,b = map(int,input().split())

    P = 10**9 + 7

    print((pow(2,n,P) - comb(n,a,P) - comb(n,b,P) - 1) %P)

def comb(n,k,p):
    min_k = min(k,n-k)

    n_kaijyo = 1
    k_kaijyo = 1
    for i in range(min_k):
        n_kaijyo = n_kaijyo * (n - i) % p
        k_kaijyo = k_kaijyo * (i + 1) % p

    return n_kaijyo * pow(k_kaijyo,p-2,p) % p
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

void print(int h,int w)
{
    for(int j=0;j<h/2;j++){
        for(int i=0;i<w/2;i++){
            cout<<"#.";
        }
        if(w%2==1)  cout<<'#';
        cout<<'\n'; 
        
        for(int i=0;i<w/2;i++){
            cout<<".#";
        }
        if(w%2==1)  cout<<'.';
        cout<<'\n'; 
    }
    if(h%2==1){
        for(int i=0;i<w/2;i++){
            cout<<"#.";
        }
        if(w%2==1)  cout<<'#';
        cout<<'\n'; 
    }
}

int main()
{
    int H[1000],W[1000];

    for(int i=0;;i++){
        cin>>H[i]>>W[i];
        if(H[i]==0 && W[i]==0)  break;
    }

    for(int i=0;;i++){
        if(H[i]==0 && W[i]==0)  break;
        print(H[i],W[i]);
        cout<<'\n';
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main() {
  int n, d;
  cin >> n >> d;
  int x, y;
  int cnt = 0;
  rep(i,n){
    cin >> x >> y;
    ll p = pow(x,2);
    ll q = pow(y,2);
    double dist = pow(p+q,0.5);
    if(d >= dist)cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 4292
def mpow(x, n):
    result = 1
    while n != 0:
        if n & 1 == 1:
            result *= x
            result %= 1000000007
        x *= x
        x %= 1000000007
        n >>= 1

    return result

def mcomb(n, k):
    a = 1
    b = 1
    for i in range(k):
        a *= n - i
        a %= 1000000007
        b *= i + 1
        b %= 1000000007

    return a * mpow(b, 1000000005) % 1000000007

def main():
    n, a, b = map(int, input().split())
    
    ans = mpow(2, n) - mcomb(n, a) - mcomb(n, b) - 1

    print(ans%1000000007)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N);
    rep(n,0,N) cin>>A.at(n);

    int64_t allXor=0;
    rep(i,0,N) allXor^=A.at(i);

    rep(i,0,N){
        int64_t ans=allXor^A.at(i);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4700
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string S;
	cin >> S;
	if (S.size() % 2) cout << "No";
	else {
		for (int i = 0; i < S.size(); ++i) {
			if (i % 2 && S[i] != 'i') {
				cout << "No";
				return 0;
			} else if (i % 2 == 0 && S[i] != 'h') {
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> d(n);
  for(auto & a: d) cin>>a;
  sort(d.begin(),d.end());
  d[n-1] /=2;
  cout << accumulate(d.begin(),d.end(),0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int N,M; cin >> N >> M;
    vector<pair<int,int > > LR(M);
    int left=-INF, right=INF;
    REP(i,M){
        cin >> LR[i].first >> LR[i].second;
        if(left<LR[i].first) left = LR[i].first;
        if(right>LR[i].second) right = LR[i].second;
    }

    if(right - left >= 0) cout << right - left + 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static string S { get; private set; }
        public static long K { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            S = CR.GetText();
            K = CR.GetLong();

            // すべて同じ文字列の場合
            if (S.All(x => S[0] == x))
            {
                if (S.Length % 2 == 0)
                {
                    return S.Length / 2 * K;
                }
                else
                {
                    return Math.Floor((double)K / 2) + Math.Floor((double)S.Length / 2) * K;
                }
            }

            if (S[0] != S[S.Length - 1] || K == 1)
            {
                var count = GetSingleCount(S);
                return count * K;
            }

            var prefix = GetPrefix(S);
            var sufix = GetSufix(S);
            var middle = S.Substring(prefix.Length, S.Length - prefix.Length - sufix.Length);

            return GetSingleCount(prefix)
                + GetSingleCount(middle) * K 
                + GetSingleCount(prefix + sufix) * (K - 1)
                + GetSingleCount(sufix);
        }

        private static string GetPrefix(string s)
        {
            var count = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[0] == s[i])
                {
                    count++;
                    continue;
                }
                break;
            }

            return new string(Enumerable.Range(0, count).Select(x => s[0]).ToArray());
        }
        private static string GetSufix(string s)
        {
            var count = 0;
            for (int i = s.Length - 1; i > -1; i--)
            {
                if (s[s.Length - 1] == s[i])
                {
                    count++;
                    continue;
                }
                break;
            }

            return new string(Enumerable.Range(0, count).Select(x => s[s.Length - 1]).ToArray());
        }

        private static int GetSingleCount(string s)
        {
            var count = 0;
            var pre = '\0';
            for (int i = 0; i < s.Length; i++)
            {
                var current = s[i];
                if (current == pre)
                {
                    count++;
                    pre = '\0';
                }
                else
                {
                    pre = current;
                }
            }

            return count;
        }
    }
}


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

int main() {
	long long n, m;
	cin >> n >> m;
	long long sum = 0;
	for (int i = 1;i < n;i++) {
		sum += i;
	}
	for (int i = 1;i < m;i++) {
		sum += i;
	}
	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
import collections
c = collections.Counter(prime_factorize(int(input())))
num = 0

for k in c.values():
    temp_num = 1
    k_values = k
    while k_values > 0:
        if k_values - temp_num >= 0:
            k_values -= temp_num
            num += 1
            temp_num += 1
        else:
            k_values = 0
print(num)

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

int main() {
  int a, b, c, k;
  cin >>a >>b >>c >>k;
  string ret = "No";

  while (k>0 && b<=a) {k--; b*=2;}
  while (k>0 && c<=b) {k--; c*=2;}

  if (c>b && b>a) ret = "Yes";

  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3624
from heapq import heapify, heappop, heappush
N,*A=map(int, open(0).read().split())
A=sorted(A, reverse=True)
L=[0]*N
R=[0]*N
ans=0
L[0]=0
R[0]=0
H=[(-A[0],0,0)]
heapify(H)
for i in range(1,N):
    a=A[i]
    p,pl,pr=heappop(H)
    ans+=-p
    L[pr]=i
    R[pl]=i
    L[i]=pl
    R[i]=pr
    heappush(H,(-min(A[pl],a),pl,i))
    heappush(H,(-min(A[pr],a),i,pr))
print(ans)

Measured memory_bytes: 145672
import java.util.*;
class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        while(true)
        {
            int n = sc.nextInt();
            if(n==0)
            {
                break;
            }
            int avg = 0;
            int s[] = new int[n];
            for (int i = 0; i < n; i++)
            {
                s[i] = sc.nextInt();
            }
            //??????????????????
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n - 1; j++)
                {
                    if(s[j]<=s[j+1])
                    {
                        int temp = s[j];
                        s[j] = s[j+1];
                        s[j+1]=temp;
                    }
                }
            }
            for(int i=1; i<n-1; i++)
            {
                avg+=s[i];
            }
            avg/=(n-2);
            System.out.println(avg);
        }
        sc.close();
    }
}

Measured memory_bytes: 29268
#include <iostream>
#include <string>

using namespace std;

int K;
string S;

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

    if ((int)S.length() <= K)
    {
        cout << S << "\n";
    }
    else
    {
        cout << S.substr(0, (size_t)K) << "...\n";
    }
    return 0;
}

Measured memory_bytes: 3628
def getGrundyNumber(x):
    ans = 1
    while x % (ans * 2) == 0:
        ans *= 2
    return ans


N, L = map(int, input().split())
Ss = [input() for i in range(N)]

# トライ木を作成する
Trie = [[-1, -1]]
for S in Ss:
    iT = 0
    for c in map(int, S):
        if Trie[iT][c] == -1:
            Trie += [[-1, -1]]
            Trie[iT][c] = len(Trie) - 1
        iT = Trie[iT][c]

# 子が１つの頂点を探す
Hgts = {}
stack = [(0, L + 1)]
while stack:
    iT, Hgt = stack.pop()
    num = 0
    for c in Trie[iT]:
        if c != -1:
            stack.append((c, Hgt - 1))
            num += 1

    if num == 1:
        Hgts[Hgt - 1] = Hgts.get(Hgt - 1, 0) + 1

# Grundy数のXORを求める
ans = 0
for Hgt, num in Hgts.items():
    if num % 2:
        ans ^= getGrundyNumber(Hgt)

if ans:
    print('Alice')
else:
    print('Bob')


Measured memory_bytes: 28600
#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)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

#define OK { cout << "POSSIBLE\n"; exit(0); }
#define NG { cout << "IMPOSSIBLE\n"; exit(0); }

int main() {
  int N, K; cin >> N >> K;
  vector<int> a(N); cin >> a;
  if (N == 1 && a[0] == K) OK;
  int g = a[0];
  REP(i, 1, N) {
    if (a[i] == K) OK;
    g = __gcd(g, a[i]);
  }
  if (*max_element(a.begin(), a.end()) > K && K % g == 0) OK;
  NG;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  vector<int> vec(A);
  int C=0,D=0;
  for(int i=0;i<A;i++){
    cin >> vec.at(i);
    C += vec.at(i);
    if(C<=B){
      D++;
    }
  }
  cout << D+1 << endl;
}

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

using namespace std;

int main()
{
    char ch;

    scanf("%c",&ch);

    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
        printf("vowel\n");

    else
        printf("consonant\n");


    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
const int MN=100000;
int N;
ll a[MN];
vector<int> G[MN];
void NO(){
	puts("NO");
	exit(0);
}
ll dfs(int v,int p=-1){
	ll S=0;
	vector<ll> vs;
	for(int u:G[v]) if(u!=p){
		ll tmp=dfs(u,v);
		S+=tmp;
		vs.pb(tmp);
	}
	if(G[v].size()==1){	//leaf
		return a[v];
	}
	ll x=a[v];
	ll t=S-x;
	ll y=2*x-S;
	if(t<0||y<0) NO();
	sort(all(vs));
	int K=vs.size();
	ll mn=0;
	rep(i,K-1) mn+=vs[i];
	if(mn<t) NO();

//	printf("v=%d : S=%d\n",v,(int)S);
	return y;
}
bool can(){
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N-1){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	if(N==2){
		return a[0]==a[1];
	}
	int root=-1;
	rep(i,N) if(G[i].size()>1) root=i;
	return dfs(root)==0;
}
int main(){
	if(can()) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\



int modPow(int a, int b);           

                
void solve(){
    int n,k ;
    cin >> n >> k ;
    int a[n];
    rep(i,0,n)cin >> a[i];
    sort(a,a+n);
    int ans =0;
    rep(i,0,k)ans+=a[i];
    cout << ans;
    
}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
   // int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N);
    REP(i,N){
        ll p;
        cin >> p;
        P[i] = p;
    }

    double ans = 0;
    ll sum = 0;
    REP(i,N){
        ll p = P[i];
        sum += p;
        if(i >= K-1){
            chmax(ans, (sum+K)/2.0);
            sum -= P[i-K+1];
        }
    }

    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

const ll MAXNUM = 1000000000;

int main(){
    ll s;
    cin >> s;
    if(s == MAXNUM * MAXNUM){
        cout << 0 << ' ' << 0 << ' ' <<
            MAXNUM << ' ' << 1 << ' ' <<
            0 << ' ' << MAXNUM << endl;
    }else{
        cout << 0 << ' ' << 0 << ' ' <<
            MAXNUM << ' ' << 1 << ' ' <<
            (MAXNUM - s % MAXNUM) << ' ' << (s / MAXNUM + 1) << endl;
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, n) cin >> a[i + 1];
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        if (i % 2 != 0 && a[i] % 2 != 0)
            ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3624
N = 12
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]

def dfs(i, j):
    field[i][j] = '0'
    for k in xrange(4):
        ni = i + di[k]
        nj = j + dj[k]
        if 0 <= ni < N and 0 <= nj < N and field[ni][nj] == '1':
            dfs(ni, nj)
    return;

while True:
    try:
        field = []
        for i in xrange(N):
            field.append(list(raw_input()))
        cnt = 0
        for i in xrange(N):
            for j in xrange(N):
                if field[i][j] == '1':
                    dfs(i, j)
                    cnt += 1
        print cnt
        raw_input()
    except:
        break

Measured memory_bytes: 6384
N=int(input())
A=list(map(int,input().split()))
A.sort()
for i in range(N):
  A[i]=list(format(A[i],'320b'))
A=list(map(list,zip(*A)))
B=['0']*N
ret=0
A.reverse()
for i in A:
  if i==B:
    ret+=1
  else:
    break
print(ret)

Measured memory_bytes: 4212
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    if N == 0:
        return False
    P = [list(map(int, readline().split())) for i in range(N)]
    L = 2000
    Q = [[] for i in range(2*L+1)]
    LS = []
    for i in range(N):
        x0, y0 = P[i-1]; x1, y1 = P[i]
        if y0 != y1:
            Q[y0].append(i); Q[y1].append(i)
        LS.append((P[i-1], P[i]) if y0 < y1 else (P[i], P[i-1]))
    U = [0]*N
    s = set()
    ans = 0
    for y in range(-L, L):
        for i in Q[y]:
            if U[i]:
                s.remove(i)
            else:
                s.add(i)
                U[i] = 1
        *js, = s
        def f(i):
            (x0, y0), (x1, y1) = LS[i]
            dx = x1 - x0; dy = y1 - y0
            if dx < 0:
                return (x0 + dx*((y+1) - y0)/dy, x0 + (dx*(y - y0) + dy-1)//dy)
            return (x0 + dx*(y - y0)/dy, x0 + (dx*((y+1) - y0) + dy-1)//dy)
        js.sort(key = f)
        l = r = -5000

        for k, i in enumerate(js):
            (x0, y0), (x1, y1) = LS[i]
            dx = x1 - x0; dy = y1 - y0
            if k & 1:
                if dx >= 0:
                    x = x0 + (dx*((y+1) - y0) + dy-1) // dy
                else:
                    x = x0 + (dx*(y - y0) + dy-1) // dy
                r = x
            else:
                if dx >= 0:
                    x = x0 + dx*(y - y0) // dy
                else:
                    x = x0 + dx*((y+1) - y0) // dy
                if r < x:
                    ans += r-l
                    l = x
        ans += r-l
    write("%d\n" % ans)
    return True
while solve():
    ...


Measured memory_bytes: 5924
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        int N, R;
        intReadLine(out N, out R);
        if(N < 10)
        {
            WriteLine(R + (100 * (10 - N)));
        }
        else
        {
            WriteLine(R);
        }
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
    
    public static int[] intArrayReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static long[] longArrayReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static List<int> intListReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToList();
    }

    public static List<long> longListReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToList();
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

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

int ans = 0, N, M;
vector<int> E[9];
bool seen[9];

void dfs(int u = 1, int d = 0){
    if(d == N - 1){
        ans++;
    }
    vector<int>::iterator it;
    for(it = E[u].begin(); it != E[u].end(); it++){
        int v = *it;
        if(!seen[v]){
            seen[v] = true;
            dfs(v, d + 1);
            seen[v] = false;
        }
    }
    return;
}

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    fill(seen, seen + N + 1, false);
    seen[1] = true;
    dfs();
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main()
{
    char s[105];
    while(scanf("%s",&s)!=EOF)
    {
        int len=strlen(s),i;
        for(i=0;;i++)
        {
            if(s[i]=='\0')
                break;
        }
        printf("%c%d%c\n",s[0],len-2,s[i-1]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;  // X[0] に空白を挿入
  Y = ' ' + Y;  // Y[0] に空白を挿入
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7060
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll n,d;
	cin>>n>>d;
	d=d*d;
	int ans=0;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		if(a*a+b*b<=d){
			ans++;
		}
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3616