akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 1e9 + 9;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) (LONG_LONG_MAX - 3ll) / 2ll;
const ld EPS = (ld) 1e-8;
const ll P = 104107;

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

ll pw(ll b, ll p){
	if(p == 0) return 1;
	if(p & 1) return mul(b, pw(b, p - 1));
	return pw(mul(b, b), p / 2);
}
ll inv(ll x){
	return pw(x, MOD - 2);
}

bitset<2000010> knap;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll v, s = 0;
	knap[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> v;
		s += v;
		knap |= (knap << v);
	}
	ll mx = 0;
	for(int i = 1; i <= s/2; i++) if(knap[i]) mx = i;
	cout << s - mx;
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    REP(i, N) { cin >> S[i]; }
    sort(S.begin(), S.end());
    string ans;
    REP(i, N) { ans += S[i]; }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		int tmp_a = a;
		int tmp_b = b;
		int tmp_c = c;

		int ans = 0;
		sc.close();

		for (int i = 0; i < tmp_a; i++) {
			if (k == 0 || a == 0) {
				break;
			} else {
				ans ++;
				k --;
				a --;
			}
		}


		for (int i = 0; i < tmp_b; i++) {
			if (k == 0 || b == 0) {
				break;
			} else {
				k --;
				b --;
			}
		}


		for (int i = 0; i < tmp_c; i++) {
			if (k == 0 || c == 0) {
				break;
			} else {
				ans --;
				k --;
				c --;
			}
		}
		System.out.println(ans);


	}

}

Measured memory_bytes: 27356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

ll mod = 1e9 + 7;
long long fac[2500], finv[2500], inv[2500];

void cinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 2500; i++)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

    ll k, n;
    cin >> n >> k;
    cinit();

    for (ll i = 1; i <= k; i++)
    {
        ll x = com(k - 1, i - 1);
        x = x * com(n - k + 1, i) % mod;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 != 0 && b % 2 != 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int h = sc.nextInt();
		int a = sc.nextInt();
		
		int ans = h / a;
		if (h % a != 0) ans++;
		out.println(ans);

		out.close();
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static System.Math;

namespace Same_Integers
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var abc = GetArray<int>();
                var max = abc.Max();
                var sum = abc.Sum();
                if (max % 2 ==  sum % 2)
                {
                    CWrite((3 * max - sum) / 2);
                }
                else
                {
                    CWrite((3 * ++max - sum) / 2);
                }
            }
        }

        static void CWrite<T>(T str) => Console.WriteLine(str);
        static string GetString() => Console.ReadLine();
        static T[] GetArray<T>()
        {
            var t = typeof(T);
            var str = Console.ReadLine();
            if (t == typeof(string))
            {
                return (T[])(object)str.Split();
            }
            if (t == typeof(int))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            throw new NotSupportedException($"{t} is not supported.");
        }
    }



    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static T[] ToNumArray<T>(this string str)
        {
            var t = typeof(T);
            if (t == typeof(int))
            {
                return (T[])(object)str.Split().Select(int.Parse).ToArray();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.Split().Select(long.Parse).ToArray();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.Split().Select(double.Parse).ToArray();
            }
            throw new NotSupportedException();
        }
        public static int ToInt(this string str) => int.Parse(str);
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
    int N;
    int main (void){
      if(scanf("%d",&N) == 1);
      int x[N][2];
      for(int i = 0;i < N;i++){
        if(scanf("%d",&x[i][1]) == 1);
      }
      x[0][2] = 0;
      for (int i = 0;i < N;i++){
        if(i % 2 == 0){
            x[0][2] = x[0][2] + x[i][1];
          }
          if(i % 2 == 1){
            x[0][2] = x[0][2] - x[i][1];
          }
      }
      for(int i = 1;i < N;i++){
       x[i][2] = 2 * x[i-1][1] - x[i-1][2];
      }
      for(int n = 0;n < N;n++){
        printf("%d ",x[n][2]);
      }
      return 0;
    }

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

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

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

function Main(input) {

    var r = parseInt(input[0], 10);
    var g = parseInt(input[1], 10);

    var ans = 2 * g - r;
    console.log(ans);

    return 0;
}


Measured memory_bytes: 15948
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

struct xydata {
    int x; int y; int r; int c;
};

bool judge(xydata c1, xydata c2) {
    ll xy = pow(c1.x-c2.x, 2) + pow(c1.y-c2.y, 2);
    ll cr = pow(c1.r+c2.r, 2);
    return xy < cr;
}

int n;
int dp[(1<<25)];

int main() {
    while(1) {
        cin >> n;
        if(n == 0) break;
        vector<xydata> circle(n);
        for(int bit = 0; bit < (1<<n); ++bit) dp[bit] = -1;
        vector<int> overlap(n, 0);  // 上に載っているところに1を立てる
        for(int i = 0; i < n; ++i) {
            xydata indata;
            cin >> indata.x >> indata.y >> indata.r >> indata.c;
            circle.at(i) = indata;
            for(int j = 0; j < i; ++j) {
                if(judge(circle.at(i), circle.at(j))) {
                    overlap.at(i) |= (1<<j);
                }
            }
        }

        dp[0] = 0;
        int ans = 0;
        for(int bit = 0; bit < (1<<n); ++bit) {
            if(dp[bit] == -1) continue;
            chmax(ans, dp[bit]);
            for(int i = 0; i < n; ++i) {
                if((bit&(1<<i)) || (bit&overlap.at(i)) != overlap.at(i)) continue;
                for(int j = i+1; j < n; ++j) {
                    if(circle.at(i).c != circle.at(j).c || (bit&(1<<j)) || (bit&overlap.at(j)) != overlap.at(j)) continue;
                    chmax(dp[bit|(1<<i)|(1<<j)], dp[bit]+2);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 68644
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e3 + 5, inf = 1e18, mod = 1e9 + 7;

int H, W, dp[N][N];
char mat[N][N];

bool inside(int x, int y){
    return x >= 1 && y >= 1 && x <= H && y <= W;
}

int go(int x, int y){
    if(!inside(x,y)) return 0;
    if(mat[x][y] == '#')    return 0;
    if(x == H && y == W)
        return 1;
    int &ans = dp[x][y];
    if(~ans)
        return ans;
    ans = 0;
    ans = (ans + go(x + 1, y)) % mod;
    ans = (ans + go(x, y + 1)) % mod;
    return ans;
}

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


    memset(dp, -1, sizeof(dp));
    cin >> H >> W;
    for(int i = 1; i <= H; i++)
        for(int j = 1; j <= W; j++)
            cin >> mat[i][j];
    cout << go(1,1);
}

Measured memory_bytes: 9216
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int m,n;
int grid[100][100];
bool arv[100][100];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int dfs(int x, int y, int time){
  int ret = time;
  REP(i,4){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(0<=nx&&nx<m&&0<=ny&&ny<n&&grid[ny][nx]&&!arv[ny][nx]){
      arv[ny][nx] = true;
      ret = max(ret,dfs(nx,ny,time+1));
      arv[ny][nx] = false;
    }
  }
  return ret;
}
int main(void){
  while(cin>>m>>n,m){
    REP(y,n)REP(x,m)cin>>grid[y][x];
    memset(arv,0,sizeof(arv));
    int ans = 0;
    REP(y,n)REP(x,m){
      if(grid[y][x]){
        arv[y][x] = true;
        ans = max(ans, dfs(x,y,1));
        arv[y][x] = false;
      }
    }
    cout<<ans<<endl;
  }
   
  return 0;
}

Measured memory_bytes: 0
N = int(input())
A_s = list(map(int, input().split()))

sunuke = A_s[0]
kuma = sum(A_s[1:])
mini = abs(sunuke - kuma)


for i in range(1, N - 1):
    sunuke += A_s[i]
    kuma -= A_s[i]
    
    mini = min(mini, abs(sunuke - kuma))

print(mini)

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

int main(){
	int s;
	int h, m;
	cin >> s;
	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;

namespace AtCoder {
    class Program {
        static void Main() {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int r = s.Count(x => x == 'R');
            int g = s.Count(x => x == 'G');
            int b = s.Count(x => x == 'B');
            int count = 0;
            for(int i = 0; i < n; i++) {
                if(s[i] != 'R') continue;
                for(int j = 0; j < n; j++) {
                    if(s[j] != 'G') continue;
                    int i2, j2;
                    if(i > j) {
                        i2 = i;
                        j2 = j;
                    } else {
                        j2 = i;
                        i2 = j;
                    }
                    int d = i2 - j2;
                    int c1 = j2 - d;
                    int c2 = i2 + d;
                    int c3 = (i2 + j2) / 2;
                    if(c1 >= 0 && s[c1] == 'B') count++;
                    if(c2 < n && s[c2] == 'B') count++;
                    if(d % 2 == 0 && s[c3] == 'B') count++;
                }
            }
            Console.WriteLine((long) r * g * b - count);
        }
    }
}

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

int main() {
	int n, x;cin >> n >> x;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	sort(v.begin(), v.end());
	int sum = accumulate(v.begin(), v.end(), 0);
	int h = (x - sum) / v[0];
	
	cout << n + h << endl;
	return 0;
}

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

const int N = 505;

using namespace std;

int n, m, x, y, a[N][N];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	scanf("%d%d%d%d", &n, &m, &x, &y);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			a[i][j] = 2011;
	for (int i = x; i <= n; i += x)
	{
		for (int j = y; j <= m; j += y)
			a[i][j] = -x * y * 2011 + 2010;
	}
	long long cnt = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cnt += a[i][j];
	if (cnt <= 0)
		cout << "No" << endl;
	else
	{
		cout << "Yes" << endl;
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
				printf("%d ", a[i][j]);
			printf("\n");
		}
	}

	return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	while(b !=1) {
		if (a > b) swap(a,b);
		b = b % a;
		if (b==0){
			cout << a << endl;
			break;
		}
		if (b==1){
			cout << b << endl;
			break;
		}
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    ll s = 0;
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        int cnt = 0;
        while(tmp%2==0) {
            tmp /= 2; cnt++;
        }
        s = s + cnt;
    }
    printf("%lld\n", s);
    

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d%d", &T, &B);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100001
using namespace std;
int n;
double pw,vw[N],pf[N],vf[N],th[N];
const double EPS = 1e-8;

double f(double x){
  double cost=x*pw;
  for(int i=0;i<n;i++){
    double v = th[i]-x*vw[i];
    if(v>0)cost+=pf[i]*(v/vf[i]);
  }
  return cost;
}

double search(){
  double L=0,R=101;
  while(abs(L-R)>EPS){
    double M1=(L+(R-L)/3);
    double M2=(L+2*(R-L)/3);
    if(f(M1)<f(M2))R=M2-EPS;
    else L=M1+EPS;
  }
  return L;
}


int main(){
  while(cin>>n,n){
    cin>>pw;
    for(int i=0;i<n;i++)scanf("%lf%lf%lf%lf",&vw[i],&pf[i],&vf[i],&th[i]);
    printf("%.10f\n",f(search()));
  }
  return 0;
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    SORT(a);
    int ans = 0;
    REP(l, n - 1) FOR(r, l + 1, n) {
        auto p = lower_bound(ALL(a), a[l] + a[r]);
        if (p == a.end()) ans += n - 1 - r;
        else {
            int d = distance(a.begin(), p);
            ans += max(0, d - 1 - r);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
using namespace std;
long long x[100010], y[100010];
int a[100010], p[62][100010], q[2][100010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &x[i]);
	}
	int m;
	long long k;
	scanf("%d%lld", &m, &k);
	for (int i = 0; i < m; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n - 1; i++) {
		y[i] = x[i+1] - x[i];
	}
	int t = 0;
	for (int i = 0; i < n - 1; i++) {
		p[0][i] = i;
		q[0][i] = i;
	}
	for (int i = 0; i < m; i++) {
		swap(p[0][a[i]-2], p[0][a[i]-1]);
	}
	for (int i = 0; i < 61; i++) {
		for (int j = 0; j < n - 1; j++) {
			p[i+1][j] = p[i][p[i][j]];
		}
		if (k >> i & 1) {
			for (int j = 0; j < n - 1; j++) {
				q[t^1][j] = p[i][q[t][j]];
			}
			t ^= 1;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		x[i+1] = x[i] + y[q[t][i]];
	}
	for (int i = 0; i < n; i++) {
		printf("%lld\n", x[i]);
	}
	return 0;
}


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

int main() {
	ll k, d, ans = 0;
	cin >> k >> d;
	for (ll i = 0; i < k; i++) {
		ll x, y; cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;	
	}
	cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    int check = 0;
    for(int i = 0; i < N; i++){
        int D1, D2;
        cin >> D1 >> D2;
        if(D1 == D2)
            check++;
        else
            check = 0;
        if(check == 3)
            break;
    }
    cout << (check == 3 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int H, W, K; cin >> H >> W >> K;
    vector<vector<char>> grids(H, vector<char>(W));
    for (int r = 0; r < H; ++r) for (int c = 0; c < W; ++c) cin >> grids[r][c];
    int ans = 0;
    for (int rBit = 0; rBit < (1 << H); ++rBit)
    {
        for (int cBit = 0; cBit < (1 << W); ++cBit)
        {
            int blackNum = 0;   
            for (int r = 0; r < H; ++r) for (int c = 0; c < W; ++c)
                if (rBit & (1 << r) && cBit & (1 << c) && grids[r][c] == '#')
                {
                    ++blackNum;
                }
            if (blackNum == K) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
////must check out geeks for geeks may be help :) but no.... no.....may be whole solution 
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string S1 ,S2;
    cin>>S1>>S2;

    int n = S2.size(), m = S1.size();

    int ans = INT_MAX;


    for (int i = 0; i < m - n + 1; i++) {
        int minRemovedChar = 0;
        for (int j = 0; j < n; j++) {
            if (S2[j] != S1[i + j]) {
                minRemovedChar++;
            }
        }
        ans = min(minRemovedChar, ans);



}
cout<<ans;
}


Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a := r.nextStringArray().toInts()


	fmt.Fprintln(stdout, []string{"bust", "win"}[b2i(a[0]+a[1]+a[2]<=21)])
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
#define MAXN (200000 + 5)
#define MAXL (32 + 5)
using namespace std;
LL n, a[MAXN], b[MAXN], ak[MAXL][MAXN], bk[MAXL][MAXN], k = 29, ans[MAXL];
int main()
{
//	freopen("in.in", "r", stdin);
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		for (int j = 1; j <= k; j++)
			ak[j][i] = a[i] & ((1 << j) - 1);
	}
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &b[i]);
		for (int j = 1; j <= k; j++)
			bk[j][i] = b[i] & ((1 << j) - 1);
	}
	for (int i = 1; i <= k; i++)
		sort(bk[i] + 1, bk[i] + n + 1);
	/*for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= n; j++)
			printf("%d ", ak[i][j]);
		puts("");
	}
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= n; j++)
			printf("%d ", bk[i][j]);
		puts("");
	}*/
	for (int i = 1; i <= n; i++) // ai + bj >= (1 << (k - 1)) && ai + bj < (1 << (k))
	{
		for (int j = 1; j <= k; j++)
		{
			int to = upper_bound(bk[j] + 1, bk[j] + n + 1, (1 << j) - ak[j][i] - 1) - bk[j];
			int to1 = upper_bound(bk[j] + 1, bk[j] + n + 1, (1 << (j + 1)) - 1 - ak[j][i]) - bk[j];
			int from = lower_bound(bk[j] + 1, bk[j] + n + 1, (1 <<(j - 1)) - ak[j][i]) - bk[j];
			int from1 = lower_bound(bk[j] + 1, bk[j] + n + 1, (1 << j) + (1 << (j - 1)) - ak[j][i]) - bk[j];
			ans[j] += to - from + to1 - from1;
		}
	}
	LL outp = 0;
	for (int i = 1; i <= k; i++)
		outp += (ans[i] & 1) << (i - 1);
	printf("%lld", outp);
	return 0;
}

/*
2
1 2
3 4
*/

Measured memory_bytes: 99072
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int A, B, C;

int main() {
	read(A), read(B), read(C);
	std::swap(A, B), std::swap(A, C);
	print(A, ' '), print(B, ' '), print(C);
}


Measured memory_bytes: 2304
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
#define ARRAY_MAX 110

int main(void){

  int i = 0;
  int n;
  stack<int> Stack;
  vector<int>array(ARRAY_MAX,0);

  while(cin >> n){
    if(n){
      Stack.push(n);
    }else{
      cout << Stack.top() << endl;
      Stack.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 3112
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

ll  N, M, x[1234], y[1234], z[1234];

int main() {

	scanf("%lld%lld", &N, &M);
	rep(i, N) scanf("%lld%lld%lld", &x[i], &y[i], &z[i]);

	ll sign[8][3] = { { 1, 1, 1 },
	{ 1, 1, -1 },{ 1, -1, 1 },{ -1, 1, 1 },
	{ -1, -1, 1 },{ -1, 1, -1 },{ 1, -1, -1 },
	{ -1, -1, -1 } };

	ll ans = -1;

	rep(t, 8) {
		ll c = 0;
		vector<ll> v;
		rep(i, N) {
			v.push_back(x[i] * sign[t][0] + y[i] * sign[t][1] + z[i] * sign[t][2]);
		}
		sort(v.begin(), v.end());
		rep(i, M) {
			c += v[N - 1 - i];
		}
		ans = max(ans, c);
	}



	printf("%lld\n", ans);

	return 0;
}


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

using namespace std;
char arr[3] = {'A', 'B', 'C'};

string conv(string s, int idx)
{
    string res = "";
    int i = 0;
    for (; i < (int)s.length() - 2; i++)
    {
        string sub = s.substr(i, 3);
        if (sub == "ABC")
        {
            res += arr[idx];
            i += 2;
        }
        else
            res += s[i];
    }
    res += s.substr(i);
    return res;
}

string reconv(string s, int idx)
{
    string res = "";
    for (int i = 0; i < (int)s.length(); i++)
    {
        if (s[i] == arr[idx])
            res += "ABC";
        else
            res += s[i];
    }
    return res;
}

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

    string s;
    cin >> s;
    if (s == "ABC")
    {
        cout << "Yes" << endl;
        return 0;
    }
    queue<string> que;
    que.push(s);
    while (!que.empty())
    {
        string now = que.front();
        que.pop();
        for (int i = 0; i < 3; i++)
        {
            string tmp = conv(now, i);
            if (tmp == now)
                break;
            if (now != reconv(tmp, i))
                continue;
            if (tmp == "ABC")
            {
                cout << "Yes" << endl;
                return 0;
            }
            que.push(tmp);
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3268
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N) :
    print (" ".join(map(str, A)))
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v :
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
print (" ".join(map(str,A)))


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;



int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
  int n, m;
  cin >> n >> m;
  vector<int> sort(n+1, false), arribada(n+1, false);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (a == 1) sort[b] = true;
    if (b == n) arribada[a] = true;
  }
  bool pos = false;
  for (int i = 2; i < n; i++)
    if (sort[i] and arribada[i]) pos = true;
  if (pos) cout << "POSSIBLE\n";
  else cout << "IMPOSSIBLE\n";
  
  return 0;
}



Measured memory_bytes: 1792
//コピペ…
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=3000000,ans=mzint;
  while(M--){
    int d=rand()%D,q=rand()%26,ans2=ans;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    if(ans2<ans)
      t[d]=q+1;
    else
      ans=ans2;
  }
  for(int i:t)
    cout<<i<<endl;
}


Measured memory_bytes: 3728
/*
Author : N_o_o_B
Created : March 22 2020 17:33:06 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

bool ok(string s){
    string t = s;
    reverse(all(t));
    return s == t;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    string s;
    cin >> s;
    int n = sz(s);
    bool res = 1;

    res &= ok(s);

    string s1 = "",s2 = "";
    fori(i,n/2){
        s1 += s[i];
        s2 += s[n-1-i];
    }

    res &= ok(s1);
    res &= ok(s2);

    cout << (res ? "Yes":"No") << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
string s;
cin>>s;
int ans=0;
int flag=1;
if(s=="RSR"){
    cout<<1<<endl;
    return 0;
}
rep(i,3){
    
    if(s[i]=='R'){
        ans++;
    }    

}

cout<<ans<<endl;

return 0;
 }


Measured memory_bytes: 3624
s = input()

if s[0] == s[1] and s[0] != s[2]and s[2] == s[3]:
    print('Yes')
elif s[0] == s[2] and s[0] != s[1] and s[1] == s[3]:
    print('Yes')
elif s[0] == s[3] and s[0] != s[1] and s[1] == s[2]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<functional>
#include<unordered_set>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
#define endl "\n";


void run_case() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> G(n+1, vector<int>());
    vector<unordered_set<int>>a(n+1);
    vector<int> fa(n+1), siz(n+1), son(n+1), ans(n+1);
    for(int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
        son[x]++, son[y]++;
        a[x].insert(y), a[y].insert(x);
    }
    function<void(int,int,int&)> dfs = [&](int u, int f, int& cnt) {
        fa[u] = f; cnt++;
        for(auto v: G[u])
            if(!fa[v]) dfs(v, f, cnt);
    };
    for(int i = 1; i <= n; ++i) {
        if(!fa[i]) {
            int cnt = 0;
            dfs(i, i, cnt);
            siz[i] = cnt;
        }
    }
    for(int i = 1; i <= n; ++i)
        ans[i] = siz[fa[i]] - son[i] - 1;
    for(int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y;
        if(fa[x] == fa[y] && !a[x].count(y)) ans[x]--, ans[y]--;
    }
    for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 24704
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
vector<int> vertexs[200000];
int bad = 0;
int grid[200000] = {};
int dfs(int now,int back) {
	int a = 0, b = 0;
	for (int i = 0;i < vertexs[now].size();++i) {
		if (vertexs[now][i] != back) {
			int hoge = dfs(vertexs[now][i], now);
			if (hoge == 1) {
				a++;
			}
			else b++;
		}
	}
	if (a >= 2) {
		bad = 1;
		return 0;
	}
	if (a == 1) {
		grid[now] = 2;
		return 2;
	}
	if (a == 0) {
		grid[now] = 1;
		if (now == 1) bad = 1;
		return 1;
	}
}
int main() {
	int n;
	cin >> n;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	dfs(1, -1);
	if (bad == 1) {
		cout << "First" << endl;
	}
	else cout << "Second" << endl;
	return 0;
}

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

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(x) x.begin(), x.end()
#define print(x) cout << x << "\n"

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, n; 
	vector<int> buf, arr;
	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		arr.push_back(x);
	}
	sort(all(arr));
	for (int i = 0; i <= n-1; i++) {
		if (i == n-1) {
			int diff = k-arr[i];
			diff += arr[0];
			buf.push_back(diff);
		} else {
			buf.push_back(arr[i+1]-arr[i]);	
		}
	}
	int sum = 0, ma = -1;
	for (int i : buf) {
		sum += i;
		ma = max(ma, i);
	}
	cout << sum-ma << endl;
}


Measured memory_bytes: 2548
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
using namespace std;



int main() {
  vector<vector<long long>> graph(10, vector<long long>(10)); // = to_adjacency_matrix(edges, num_vertex);
  int num_vertex = 10, H, W;
  long long LL_INF = numeric_limits<long long>::max();


  cin >> H >> W;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> graph[i][j];
    }
  }

  // DPで距離を更新する
  for (int k = 0; k < num_vertex; ++k) {
    for (int i = 0; i < num_vertex; ++i) {
      for (int j = 0; j < num_vertex; ++j) {
        if(graph[i][k] != LL_INF && graph[k][j] != LL_INF)
          graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j]);
      }
    }
  }

  long long a, ans = 0;
  for (int i = 0; i < H * W; ++i) {
    cin >> a;
    if(a != -1){
      ans += graph[a][1];
    }
  }

//  for (int i = 0; i < 10; ++i) {
//    for (int j = 0; j < 10; ++j) {
//      cout << graph[i][j] << " ";
//    }
//    cout << endl;
//  }
//
//  cout << graph[8][1] << endl;

  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int inf = 1e9 +5;
using namespace std;

void max_self(ll &a, ll b){
    a = max(a,b);
}

int main() {
	fastio;
	int n, W;
	cin>>n>>W;
	vector<ll> dp(W+1);     // 0...W
	// dp[i] - the maximum total weight of items with 
	//total weight exactly 'i'
    for(int item = 0 ; item < n ; item++){
        int w{},v{};
        cin>>w>>v;
        for(int weight_already = W - w; weight_already >=0; weight_already--)
            max_self(dp[weight_already+w], dp[weight_already ]+ v);
    }
    ll ans{0};
    for(int i=0; i<=W;i++)
        max_self(ans,dp[i]);
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/


signed main(){
	ll a,r;
	cin >> r;
	cout << 3 * r * r << endl;
	
	return 0;
}


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

using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
} 
string str,z;
long long j=0,y,x,a,b;
bool flag=0;
int main()
{ init();
   cin>>x;
    cin>>a >>b;
    for(int i=a;i<=b;i++) {
      if(i%x==0){
        flag=1;
      }
    }
     if(flag==1){
       cout<<"OK"<<endl;
     }else {
       cout<<"NG"<<endl;
     }
       
  
  
  
  
   }

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>

char a[10],b[10];
int main(){
    for(;;){
        scanf("%s %s\n",a,b);
        if(strlen(a)==1&&strlen(b)==1) break;
        int h=0,bl=0;
        for(int i=0;i<4;i++){
            if(a[i]==b[i]) h++;
        }
        for(int i=0;i<10;i++){
            bool isa=false,isb=false;
            for(int j=0;j<4;j++){
                if(a[j]=='0'+i) isa=true;
                if(b[j]=='0'+i) isb=true;
            }
            if(isa&&isb) bl++;
        }
        bl-=h;
        printf("%d %d\n",h,bl);
    }
}

Measured memory_bytes: 980
a = []
 
def dfs(x):
    if x > 3234566667:
        return
    a.append(x)
    for i in range(10):
        if abs(x%10-i) <= 1:
            dfs(x*10+i)

for i in range(1, 10):
  dfs(i)
a = sorted(a)
k = int(input())
print(a[k-1])


Measured memory_bytes: 8512
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]
tate = [[int(i) for i in readline().split()] for _ in range(n)]
yoko = [[int(i) for i in readline().split()] for _ in range(m)]

INF = 10**9+5
hcoord = {-INF,0,INF}
wcoord = {-INF,0,INF}

for a,b,c in tate: # (a,c) to (b,c)
    hcoord.add(a)
    hcoord.add(b)
    wcoord.add(c)
for d,e,f in yoko: # (d,e) to (d,f)
    hcoord.add(d)
    wcoord.add(e)
    wcoord.add(f)

hcoord = list(sorted(hcoord))
wcoord = list(sorted(wcoord))

zaatu_x = {a:i for i,a in enumerate(sorted(hcoord))}
zaatu_y = {a:i for i,a in enumerate(sorted(wcoord))}

P = len(hcoord)
Q = len(wcoord)

ok_h = [[1 for y in range(Q-1)] for x in range(P-1)] #縦に移動できるか？
ok_w = [[1 for y in range(Q-1)] for x in range(P-1)] #横に移動できるか？

for y in range(Q-1):
    ok_h[P-2][y] = 0
for x in range(P-1):
    ok_w[x][Q-2] = 0

for a,b,c in tate: # (a,c) to (b,c)
    xa = zaatu_x[a]
    xb = zaatu_x[b]
    yc = zaatu_y[c]
    for i in range(xa,xb):
        ok_w[i][yc-1] = 0

for d,e,f in yoko: # (d,e) to (d,f)
    ye = zaatu_y[e]
    yf = zaatu_y[f]
    xd = zaatu_x[d]
    for i in range(ye,yf):
        ok_h[xd-1][i] = 0

dx = [1,0,-1,0]
dy = [0,1,0,-1]

x0 = zaatu_x[0]
y0 = zaatu_y[0]
used = [[0 for y in range(Q-1)] for x in range(P-1)]

from collections import deque
q = deque([(x0,y0)])
used[x0][y0] = 1
while q:
    x,y = q.popleft()
    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if nx < 0 or ny < 0 or nx >= P-1 or ny >= Q-1: continue #枠外
        #4方向
        if i==0 and ok_h[x][y]==0: continue
        if i==2 and ok_h[nx][ny]==0: continue
        if i==1 and ok_w[x][y]==0: continue
        if i==3 and ok_w[nx][ny]==0: continue
        
        if used[nx][ny] == 0:
            used[nx][ny] = 1
            q.append((nx,ny))


#print(used)

if used[0][0] == 1:
    print("INF")
else:
    ans = 0
    for i in range(P-1):
        for j in range(Q-1):
            if used[i][j] == 1:
                ans += (hcoord[i+1]-hcoord[i])*(wcoord[j+1]-wcoord[j])
    print(ans)



Measured memory_bytes: 367916