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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI p(n);
    REP(i, n) cin >> p[i];
    int ans = 0;
    FOR(i, 1, n - 2) {
        if (p[i - 1] < p[i] and p[i] < p[i + 1])
            ans++;
        else if (p[i - 1] > p[i] and p[i] > p[i + 1])
            ans++;
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	for (int loop = 2; (long long)loop * (long long)loop <= N; loop++) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop--;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination(int, int);
};
int Combination::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination::Combination(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

void A_Black_Jack(void) {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
	cout << ((A1 + A2 + A3 >= 22) ? "bust" : "win") << flush;
	return;
}

int main(void) {

	A_Black_Jack();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int x = N * 800;
    int y = (N / 15) * 200;

    cout << x - y << endl;

    return 0;
}


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

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	int ans = 0;
	int ba=0,bx=0,xa=0;
	for(int i = 0; i < n; i++){
		int m = s[i].size();
		if(s[i][0] == 'B'){
			if(s[i][m-1] == 'A') ba++;
			else bx++;
		}else if(s[i][m-1] == 'A') xa++;

		for(int j = 1; j < m; j++){
			if(s[i][j] == 'B' && s[i][j-1] == 'A') ans++;
		}
	}
	// cout << ans << endl;
	// cout << ba << " " << bx << " " << xa << endl;
	if(ba == 0){
		ans += min(bx,xa);
	}else{
		ans += ba + (bx+xa>0?min(bx,xa):-1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
//rankaleeさんのをこぴぺさせていただきました...

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	long MOD = (int)(1e8)+7;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		int[] pow = new int[w+1];
		pow[0] = 1;
		for(int i=1;i<=w;i++) pow[i] = (int)(pow[i-1]*3%MOD);
		long[][][] dp = new long[2][3][pow[w]];
		dp[0][0][0] = 1;
		String[] map = new String[h];
		for(int i=0;i<h;i++) map[i] = sc.next();
		int p = 1;
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) {
			for(long[] a: dp[p]) fill(a, 0);
			for(int k=0;k<3;k++) for(int u=0;u<pow[w];u++) if(dp[1-p][k][u] != 0){
				
				int tu = u/pow[j]%3;
//				debug(p, k , u, i, j, tu);
				if(map[i].charAt(j) == '.') {
					if(tu * k > 0) continue;
					if(k == 0 || j < w-1) dp[p][k][u] = ( dp[p][k][u] + dp[1-p][k][u] ) % MOD;
					continue;
				}
				int r = map[i].charAt(j) - '0' - tu - k;
				for(int nk=0;nk<3;nk++) {
					int nu = r - nk;
					if(nu < 0 || nu > 2) continue;
					if(nk == 0 || j < w-1 ) {
						dp[p][nk][u + pow[j]*(nu-tu)] = (dp[p][nk][u + pow[j]*(nu-tu)] + dp[1-p][k][u]) % MOD;
					}
				}
			}
//			debug(dp[p]);
			p = 1-p;
		}
		System.out.println(dp[1-p][0][0]);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26252
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;



int main(void) {
    ll N;
    cin >> N;
    vector<ll> c;
    ll i;
    ll dp[MAX*2]={};
    ll pre[MAX*2];
    
    
    for(i=0; i<N; i++) {
        ll t;
        cin >> t;
        t--;
        if(i==0)
            c.pb(t);
        else if(c[c.size()-1]!=t)
            c.pb(t);
    }
    
    memset(pre, -1, sizeof(pre));
    for(i=0; i<c.size(); i++) {
        if(i==0) {
            dp[i]=1;
            pre[c[i]]=i;
        }else {
            if(pre[c[i]]!=-1) {
                dp[i]=(dp[i-1]+dp[pre[c[i]]])%MOD;
                pre[c[i]]=i;
            }else {
                dp[i]=dp[i-1];
                pre[c[i]]=i;
            }
        }
    }
    
    pt(dp[c.size()-1]);
    
    
}


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

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
//int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			//depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

#define int long long //change int main to int32_t main

const int N = 1e5 + 5;

int dp[105][N];

void solve()
{
	int n, fw; cin >> n >> fw;
	int w[105], v[105];
	fr0(i, n) cin >> w[i + 1] >> v[i + 1];
	
	fr(j, 1, n + 1) fr0(i, fw + 1)
	{
		if (i - w[j] >= 0)
			dp[j][i] = max(dp[j - 1][i], dp[j - 1][i - w[j]] + v[j]);
		else
			dp[j][i] = dp[j - 1][i];
	}
	cout << dp[n][fw] << nl;

}





int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 81684
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    for (int i = 0; i < N; i++) {
        A[i] -= (i+1);
    }

    std::sort(A.begin(), A.end());
    
    ll b = 0;
    if (N % 2 == 0) {
        b = (A[N/2-1] + A[N/2]) / 2;
    } else {
        b = A[N/2];
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += std::abs(A[i] - b);
    }

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

Measured memory_bytes: 1792
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, m;
  cin >> n >> m;
  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  long double r;
  cin >> r;
  long double ans = r * (long double)2 * 3.14159265358979323846;
  cout << std::fixed << std::setprecision(20) << ans << endl;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,ans,last;
    scanf("%lld%lld",&n,&last);
    if (last) {
        printf("-1");
        return 0;
    }
    for (long long i = 1,x;i < n;i++) {
        scanf("%lld",&x);
        if (x == last+1) ans++;
        else ans += x;
        if (x-last > 1 && last < x) {
            printf("-1");
            return 0;
        }
        last = x;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
/*A - Password*/

#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;

	int ans = 1;

	ans = n * n * n;

	cout << ans;

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  int N,i,ans=0;
  scanf("%d",&N);
  ans=N*100/108;
  if(ans*108/100!=N){
    ans++;
    if(ans*108/100!=N){
      printf(":(");
      return 0;
    }
  }

  printf("%d\n",ans);
	return 0;
}


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

// 'r'  " 
int main(){
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n),b(200003,0);
  for(auto &&x:a)cin>>x;
  for(auto &&x:a)b[x]++;
  for(auto x:b)ans+=x*(x-1)/2;
  for(auto &&x:a){
    ll res = (b[x]-1)*(b[x]-2)/2;
    res -= b[x]*(b[x]-1)/2;
    cout << ans+res << endl;
  }
}


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

namespace ABC
{
    class ABC165C
    {
        const bool TESTING = false;
        const string FILE = "/tmp/data.txt";

        static int n;
        static int m;
        static int q;
        static int[] aa;
        static int[] ba;
        static int[] ca;
        static int[] da;

        static long result = 0;

        static void Main(string[] args)
        {
            if (TESTING)
            {
                Console.SetIn(new StreamReader(FILE));
            }
            var line = Console.ReadLine();
            var sa = line.Split(' ');
            n = int.Parse(sa[0]);
            m = int.Parse(sa[1]);
            q = int.Parse(sa[2]);

             aa = new int[q];
             ba = new int[q];
             ca = new int[q];
             da = new int[q];

            for (int i = 0; i < q; ++i)
            {
                line = Console.ReadLine();
                sa = line.Split(' ');
                aa[i] = int.Parse(sa[0]) - 1;
                ba[i] = int.Parse(sa[1]) - 1;
                ca[i] = int.Parse(sa[2]);
                da[i] = int.Parse(sa[3]);
            }

            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = 1;
            }

            proc(la, 0);
            Console.WriteLine(result);
#if DEBUG
            Console.WriteLine();
#endif
        }

        private static void proc(int[] la, int depth)
        {
            if (depth == n)
            {
                // check
                long res = 0;
                for (int i = 0; i < q; ++i)
                {
                    if (la[ba[i]] - la[aa[i]] == ca[i])
                    {
                        res += da[i];
                    }
                }
                if (res > result)
                {
                    result = res;
                }

                return;
            }
            while (la[depth] <= m)
            {
                proc(la, depth + 1);
                la[depth] += 1;
                for (int i = depth + 1; i < n; ++i)
                {
                    la[i] = la[depth];
                }

            }
        }
    }
}


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

int main(){
  int x;
  cin >> x;
  int ans=0;
  int mid = x/500;
  ans += mid*1000;
  x -= mid*500;
  ans += (x/5)*5;
  cout << ans;
}


Measured memory_bytes: 256
def dfs(X,Y,ch):
	stack.append([X,Y])
	field[X][Y] = '.'
	while len(stack) > 0:
		x,y = stack.pop()
		for i in range(4):
				nx = x+moveY[i]
				ny = y+moveX[i]
				if nx < 0 or ny < 0 or nx >= H or ny >= W or field[nx][ny] != ch:
					continue
				if field[nx][ny] == '#' or field[nx][ny] == '*'or field[nx][ny] == '@':
					field[nx][ny] = '.'
					stack.append([nx,ny])
stack = []
moveY = [-1,0,1,0]
moveX = [0,1,0,-1]
while True:
	H,W = map(int,raw_input().split(' '))
	if H == 0 and W == 0:
		break
	field = [list(raw_input()) for i in range(H)]
	correct =0
	for i in range(H):
		for j in range(W):
			if field[i][j] == '@' or field[i][j] == '#'or field[i][j] == '*':
				dfs(i,j,field[i][j])
				correct += 1
	print correct

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    ll ans = 1, max = h[0];
    frep(i, 1, n-1) {
        if(h[i] >= max) {
            ans++;
            max = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

int main()
{
    fast
    // test
    {
        lli row,col,k,ct=0;
        cin>>row>>col>>k;
        vector<string> v(row,"SEX");
        for(lli i=0;i<row;i++)
        cin>>v[i];
        
        lli ans=0;
        lli total=(1LL)<<(row+col);
        
        for(lli i=0;i<(total);i++)
        {
            ct=0;
            for(lli r=0;r<row;r++)
            {
                if(i>>(r)&1)
                {
                    for(lli c=0;c<col;c++)
                    {
                        if((i>>(row+c))&1)
                        {
                            
                            if(v[r][c]=='#')
                            ct++;
                        }
                    }
                }
            }
            
            if(ct==k)
            ans++;
        }
        
        cout<<ans;
      
        
        
    }
}
//a+b=a?b+2?(a&b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";




Measured memory_bytes: 3648
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

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

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

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	n, m := nextInt(), nextInt()
	a := make([]float64, n)
	sum := 0.0
	for i := 0; i < n; i++ {
		a[i] = nextFloat()
		sum += a[i]
	}

	cnt := 0
	for _, v := range a {
		if v < sum/float64((4*m)) {
			continue
		}
		cnt++
		if cnt >= m {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

void Find(int a,int b,int t,int n){
    //cerr<<a<<' '<<b<<endl;
    
 
        int i=0,j=0;
        while((t&(1<<i))||((a&(1<<i)) == (b&(1<<i))))i++;
        while(n>j&&(t&(1<<j)||i==j))j++;
        if(j!=n){
        Find(a,a^(1<<j),t^(1<<i),n);
        Find((a^(1<<j))^(1<<i),b,t^(1<<i),n);
        }else{
            cout <<a<<' ';
            cout<<b<<' ';
        }
    
    

    
}


signed main(){
    int n,a,b,k=0;
    cin >>n>>a>>b;
    for(int i=0;i<n;i++)if((a^b)&(1<<i))k++;
    if(k%2==0)cout<<" NO ";
    else{
        cout<<" YES "<<endl;
        Find(a,b,0,n);
    }
   
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;

  int l = S.length(), ans = 0;
  for(int i=0; i<l/2; i++){
    if(S[i] != S[l-i-1]){
      ans++;
    } 
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    sum_list = [0 for _ in range(n)]
    sum_list[0] = sum(a_list)
    ans = 0

    for i in range(1, n):
        sum_list[i] = sum_list[i - 1] - a_list[i - 1]

    for i in range(n - 1):
        ans += a_list[i] * sum_list[i + 1] % (10 ** 9 + 7)

    print(ans % (10 ** 9 + 7))


if __name__ == "__main__":
    main()


Measured memory_bytes: 102000
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}
//dp[i][j] : i個目まで選んだ時価値の総和がvであるような重さの最小値
long long dp[105][100005];

int main() {
    int N;cin >> N;
    long long maxiW;cin >> maxiW;
    vector<long long> W(N);
    vector<long long> V(N);
    for(int i = 0;i<N;i++) cin >> W.at(i) >> V.at(i);
    for(int i = 0;i<105;i++)for(int j = 0;j<100005;j++)dp[i][j] = INF;
    dp[0][0] = 0;
    for(int i = 0;i<N;i++){
        for(int j = 0;j<100005;j++){
            if(j < V.at(i)){
                chmin(dp[i+1][j],dp[i][j]);
            }
            else{
                dp[i+1][j] = min(dp[i][j],dp[i][j-V.at(i)]+W.at(i));
            }
        }
    }
    int ans = 0;
    for(int i = 0;i<100005;i++){
        if(dp[N][i] <= maxiW) ans = max(ans,i);
    }
    cout << ans << endl;

}


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

int main(void) {
  string s;
  cin >> s;

  int gp = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'p') gp--;
    else gp++;
  }
  cout << gp / 2<< endl;

  return 0;
}

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

long long int dp[404][404];
int n;
long long int a[404];

long long int fn(int i, int j) {
    if (i == j) return 0;
    if (~dp[i][j]) return dp[i][j];
    dp[i][j] = LLONG_MAX;
    for (int k = i; k < j; ++k) {
        dp[i][j] = min(dp[i][j], fn(i, k) + fn(k + 1, j) + (a[j] - (i > 0? a[i - 1] : 0))); 
    }
    return dp[i][j];
}

int main() {
    scanf("%d", &n);
    scanf("%lld", &a[0]);
    for (int i = 1; i < n; ++i) {
        scanf("%lld", &a[i]);
        a[i] += a[i - 1];
    }
    memset(dp, -1, sizeof dp);
    cout << fn(0, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define RE return
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    int s500=n/500;
    int y500=n%500;
    int s5=y500/5;
    cout<<s500*1000+s5*5; 
    RE 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
a=[0]*N
b=[0]*N
c=[0]*M
d=[0]*M
for i in range(N):
        a[i],b[i]=map(int,input().split())
for i in range(M):
        c[i],d[i]=map(int,input().split())
for i in range(N):
        ans=0
        tmp=300000000
        for j in range(M):
                l=abs(a[i]-c[j])+abs(b[i]-d[j])
                if tmp>l:
                        ans=j+1
                        tmp=l
        print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int[][] a = new int [3][3];
      	for(int i = 0; i < 3; i++){
        	for(int j = 0; j < 3; j++){
            	a[i][j] = sc.nextInt();
            }
        }
      	int N = sc.nextInt();
      	int[] b = new int [N];
      	for(int i = 0; i < N; i++){
        	b[i] = sc.nextInt();
        }
      	
      	for(int i = 0; i < N; i++){
        	for(int j = 0; j < 3; j++){
            	for(int k = 0; k < 3; k++){
                	if(b[i] == a[j][k]) a[j][k] = 0;
                }
            }
        }
    	String ans = "No";
      	for(int i = 0; i < 3; i++){
      		if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) ans = "Yes";
      	}
     	for(int i = 0; i < 3; i++){
      		if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) ans = "Yes";
      	}
      	if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) ans = "Yes";
      	if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) ans = "Yes";
      
      	System.out.println(ans);
   }
}

Measured memory_bytes: 35804
#import sys
from collections import deque
#def input():
#    return sys.stdin.readline()[:-1]

S = deque(map(int, list(input())))
num = 0
dict = {}
dict[0] = 1
ans = 0

for i in range(len(S)):
    num += S.pop() * pow(10,i,2019)
    cand = num % 2019
    if cand in dict.keys():
        dict[cand] += 1
    else:
        dict[cand] = 1

for key in dict.keys():
    ans += dict[key] * (dict[key] - 1) // 2
print(ans)


Measured memory_bytes: 81464
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll b=0,s=0,n,c=0,a;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"Yes\n";
    }
    else if((a==1 || a==3 ||a==5 ||a==7 ||a==8 ||a==10 ||a== 12)  &&
    (b== 1|| b== 3||b== 5||b== 7||b== 8||b== 10||b== 12))
    {
        cout<<"Yes\n";
    }
    else if((a==4 || a==6 ||a==9 ||a==11)  &&
    (b== 4|| b== 6||b== 9||b== 11))
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }



}


Measured memory_bytes: 256
// デバッグ実行：Ctrl+F5

using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        int N = int.Parse(line);
        List<int> A = new List<int>();
        for (int i = 0; i < N; i++)
        {
            line = Console.ReadLine();
            A.Add(int.Parse(line));
        }
        A.Sort();

        long result = 0;
        if (N % 2 == 0)
        {
            // 偶数の場合
            result += A[N / 2];
            for(int i = N / 2 + 1; i < N; i++)
            {
                result += A[i] * 2;
            }
            result -= A[N / 2 - 1];
            for (int i = 0; i < N / 2 - 1; i++)
            {
                result -= A[i] * 2;
            }
        }
        else
        {
            // 奇数の場合
            // 高いものを端っこに並べる場合
            long result_high = 0;
            result_high += A[(N - 1) / 2];
            result_high += A[(N + 1) / 2];
            for (int i = (N+1) / 2 + 1; i < N; i++)
            {
                result_high += A[i] * 2;
            }
            for (int i = 0; i < (N - 1) / 2; i++)
            {
                result_high -= A[i] * 2;
            }
            // 低いものを端っこに並べる場合
            long result_low = 0;
            result_low -= A[(N - 1) / 2];
            result_low -= A[(N - 3) / 2];
            for (int i = (N - 1) / 2 + 1; i < N; i++)
            {
                result_low += A[i] * 2;
            }
            for (int i = 0; i < (N - 3) / 2; i++)
            {
                result_low -= A[i] * 2;
            }
            if (result_low < result_high) result = result_high;
            else result = result_low;
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 16096
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node{
  int data;
 struct Node *parent, *left, *right;
};

struct Node *root;

void insert(int x){
  struct Node *root_tmp = root;
  struct Node *elem;
  struct  Node *prev = NULL;
  elem = (struct Node *)malloc(sizeof(struct Node));
  elem->data = x;
  elem->left = NULL;
  elem->right = NULL;
  

  while(root_tmp != NULL){
    prev = root_tmp;
    if(elem->data < root_tmp->data){
      root_tmp = root_tmp->left;
    }else{
      root_tmp = root_tmp->right;
    }
  }

  elem->parent = prev;

  if(elem->parent == NULL){
    root = elem;
  }else{
    if(elem->parent->data < elem->data){
      elem->parent->right = elem;
    }else{
      elem->parent->left = elem;
    }
  }
}
int Preorder(struct Node *root){
  if(root == NULL) return -1; 
  printf(" %d",root->data);
  Preorder(root->left);
  Preorder(root->right);
  return 0;
}

int Inorder(struct Node *root){
  if(root==NULL) return -1;
  Inorder(root->left);
  printf(" %d",root->data);
  Inorder(root->right);
  return 0;
}

int main(){
  int n,elem,i;
  char c[10];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&elem);
      insert(elem);
    }else{
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24044
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	int n,m,x,y;
	cin >> n >> m >> x >> y;
	
	syc(n,1,100);
	syc(m,1,100);
	syc(x,-100,100);
	syc(y,-100,100);
	
	int a[n],b[m];
	int temp;
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<m;i++){
		cin >> b[i];
	}
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
	
	for(int i=0;i<m-1;i++){
		for(int j=i+1;j<m;j++){
			if(b[i]>b[j]){
				temp=b[i];
				b[i]=b[j];
				b[j]=temp;
			}
		}
	}
	
	if(a[n-1]<b[0] && x<b[0] && b[0]<=y){
		cout << "No War" << endl;
	}else{
		cout << "War" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=100005;
LL s;
int A[N],i,j,k,n,m,l,T,x;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

int main()
{
	n=read(),l=read(),T=read();
	for (i=0;i<n;++i)
	{
		x=read(),
		x+=read()==1?T:-T,
		s+=x/l,x%=l;
		if (x<0) x+=l,--s;
		A[i]=x;
	}
	sort(A,A+n);
	s=(s%n+n)%n;
	for (i=0;i<n;++i) printf("%d\n",A[(i+s)%n]);
	return 0;
}

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


void solve(long long L){
	printf("%f\n",(pow(L/3.0,3.0)));

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  //double a=0.123456789;
  //printf("%.10f\n",a);return 0;
  int n;cin>>n;
  double p[n];
  for(int i=0;i<n;i++)cin>>p[i];
  double dp[2][n+1];
  for(int i=0;i<=n;i++){
    dp[1][i]=0;
    dp[0][i]=0;
  }
  dp[1][0]=1-p[0];
  dp[1][1]=p[0];
  for(int i=1;i<n;i++){
    int d=i%2;
    int e=(i+1)%2;
    for(int j=0;j<=i;j++){
      dp[e][j]+=dp[d][j]*(1-p[i]);
      dp[e][j+1]+=dp[d][j]*p[i];
    }
    fill(dp[d],dp[d]+n+1,0);
  }
  double ans=0;
  for(int i=n/2+1;i<=n;i++)ans+=dp[1][i];
  //cout<<ans<<endl;
  printf("%.10f\n",ans);
}

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

int main() {
    lint n, k;
    cin >> n >> k;

    vector<double> p(n);
    for(auto& elem : p)  cin >> elem;
    for(auto& elem : p)  elem = (elem + 1) / 2;

    partial_sum(p.begin(), p.end(), p.begin());
    p.insert(p.begin(), 0);
    
    double ans = -1e18;
    for(lint i=0; i+k<=n; i++) {
        ans = max(ans, p[i+k] - p[i]);
    }

    cout << setprecision(12) << fixed << ans << endl;
}

Measured memory_bytes: 4608
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int total = 0;
        for(int i = 1;i <= N;i++){
            if(i == 1){
                total += K;
            }else{
                total *= K - 1;
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 23764
package main

import (
	"fmt"
)

func COM(n, k int64) int64 {
	r := int64(1)
	for i := int64(0); i < k; i++ {
		r = ModMul(r, n-i)
		r = ModDiv(r, i+1)
	}

	return r
}

const (
	MOD = 1000000000 + 7
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)
	S := make([][]int, M)
	P := make([]int, M)

	for i := 0; i < M; i++ {
		var k int
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var s int
			fmt.Scan(&s)
			S[i] = append(S[i], s)
		}
	}
	for i := 0; i < M; i++ {
		var p int
		fmt.Scan(&p)
		P[i] = p
	}

	ans := 0
	for i := 0; i < (1 << uint(N)); i++ {
		sum := 0
		for j := 0; j < M; j++ {
			cnt := 0
			for _, s := range S[j] {
				if i&(1<<uint(s-1)) > 0 {
					cnt++
				}
			}
			//fmt.Println("R", i, j, cnt, P[j])
			if P[j] == cnt%2 {
				sum++
			}
		}
		if sum == len(P) {
			ans++
		}
	}
	fmt.Println(ans)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


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

int main() {
  int a,b;
 
  cin >> a >>b  ;
  
  int c = 1;
  
  for (int i = 0; i <a-1 ;i++)
    c *= (b-1);
  
  cout << b*c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=110;
int n,b[maxn],a[maxn],ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<n;i++)
		read(b[i]);
	a[1]=b[1]; a[n]=b[n-1];
	for (int i=2;i<n;i++) a[i]=min(b[i-1],b[i]);
	for (int i=1;i<=n;i++) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

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


Measured memory_bytes: 1024
while(True):
  height,width = map(int,input().split())
  if height == 0 and width == 0:
    break
  else:
    for i in range(height):
      for j in range(width):
        if i == 0 or i == height-1:
          print("#",end="")
        else:
          if j == 0 or j == width -1:
            print("#",end="")
          else:
            print(".",end ="")
      print()
    print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    bool c = a%2,d = b%2;
    if(!(c xor d)){
        cout << (b-a)/2 << endl;
    }
    else {
        cout << min(a-1,n-b)+1+(b-a-1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
string s;
int main()
{
	cin>>s;
	if(s=="AAA"||s=="BBB") cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	string s;
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='7') {
			cout<<"Yes"<<endl;
			return  0;
		}
	}
	cout<<"No"<<endl;
	return  0;

}

Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int A = GetInt();
		int B = GetInt();
		if(A == 1)
			A += 13;
		if(B == 1)
			B+= 13;
		Console.WriteLine((A > B) ? "Alice" : (A < B) ? "Bob" : "Draw");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long s,x1,y1,x2,y2;
    scanf("%lld",&s);
    x1=1000000000;
    y2=s/1000000000+(s%1000000000!=0);
    x2=1;
    y1=1000000000-s%1000000000-(s%1000000000==0)*1000000000;
    printf("0 0 %lld %lld %lld %lld\n",x1,y1,x2,y2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;

    if (N%((D*2)+1) == 0) {
        cout << N/((D*2)+1) << endl;
    } else {
        cout << N/((D*2)+1) + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstring>
#include <map>

using namespace std;

const int N = 110;
int dp[N][5][5][5];
const long long mod = 1e9 + 7;

map<int, string> cm;

bool CheckLegal(int a, int b, int c, int d) {
    if(cm[a] + cm[b] + cm[c] == "AGC") { return 0; }
    if(cm[a] + cm[b] + cm[d] == "AGC") { return 0; }
    if(cm[a] + cm[c] + cm[d] == "AGC") { return 0; }
    if(cm[a] + cm[c] + cm[b] == "AGC") { return 0; }
    if(cm[b] + cm[a] + cm[c] == "AGC") { return 0; }
    if(cm[b] + cm[c] + cm[d] == "AGC") { return 0; }
    if(cm[b] + cm[d] + cm[c] == "AGC") { return 0; }
    if(cm[c] + cm[b] + cm[d] == "AGC") { return 0; }
    return 1;
}

int main() {
    cm[0] = "O";
    cm[1] = "A";
    cm[2] = "G";
    cm[3] = "C";
    cm[4] = "T";
    
    int N = 100;
    cin >> N;
    
    dp[0][0][0][0] = 1;
    for(int i = 1; i <= N; ++i) {
        for(int c1 = 1; c1 <= 4; ++c1) {
            for(int c2 = 0; c2 <= 4; ++c2) {
                for(int c3 = 0; c3 <= 4; ++c3) {
                    for(int c4 = 0; c4 <= 4; ++c4) {
                        if(CheckLegal(c4, c3, c2, c1)) {
                            dp[i][c1][c2][c3] = (dp[i][c1][c2][c3] + dp[i - 1][c2][c3][c4]) % mod;
                        }
                    }
                }
            }
        }
    }
    
    int ans = 0;
    for(int i = 1; i <= 4; ++i) {
        for(int j = 1; j <= 4; ++j) {
            for(int k = 1; k <= 4; ++k) {
                ans = (ans + dp[N][i][j][k]) % mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    N = int(input())
    c = input()

    white, red = 0, c.count('R')
    ans = red
    for i in range(N):
        if c[i] == 'W':
            white += 1
        else:
            red -= 1
        res = max(white, red)
        ans = min(ans, res)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
s = input()
x,y = map(int,input().split())

XY = [[],[]]
i = 0
xy = 0
for c in s+"T":
    if c == "T":
        XY[xy].append(i)
        i = 0
        xy = 1-xy
    else:
        i+=1

xset = set((XY[0][0],))
yset = set((0,))
for X in XY[0][1:]:
    xset = set(i + X for i in xset) | set(i - X for i in xset)
for Y in XY[1]:
    yset = set(i + Y for i in yset) | set(i - Y for i in yset)
if x in xset and y in yset:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 94684
func readInt() -> Int {
    Int(readLine()!)!
}
 
func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func main() {
    let (n, d) = *readInts()

    let ans = (0..<n).map { _ in
        let (x, y) = *readInts()
        return x * x + y * y
    }.filter {
        $0 <= d * d
    }.count

    print(ans)
}

main()

Measured memory_bytes: 11556
#include <iostream>
#include <algorithm>    // std::sort
#include <vector>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256