akhauriyash/Code-Regression huggingface dataset:
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
const int N=105;
//Code begin...

int dp[N][N];
char s[N], ans[N<<1];

int dfs(int l, int r){
    if (~dp[l][r]) return dp[l][r];
    if (l==r) return dp[l][r]=1;
    if (l>r) return dp[l][r]=0;
    int ans=INF;
    if (s[l]=='('&&s[r]==')')  ans=dfs(l+1,r-1);
    FO(i,l,r) ans=min(ans,dfs(l,i)+dfs(i+1,r));
    return dp[l][r]=ans;
}
int main ()
{
    int n, sum1=0, sum2=0, pos=0;
    scanf("%d",&n); mem(dp,-1);
    scanf("%s",s+1);
    FOR(i,1,n) {
        if (s[i]=='(') ++sum1;
        else ++sum2;
    }
    int res=dfs(1,n), x=(res+sum2-sum1)/2;
    FOR(i,1,x) ans[pos++]='(';
    FOR(i,1,n) ans[pos++]=s[i];
    FOR(i,1,res-x) ans[pos++]=')';
    ans[pos++]='\0';
    puts(ans);
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
A = []
B = []
for a in map(int, input().split()):
    A.append(a)
    B.append( a if a > 0 else 0)
S = [0]+list(accumulate(A))
T = [0]+list(accumulate(B))
res = 0
for i in range(N-K+1):
    res = max(T[i] + max(S[i+K] - S[i], 0) + T[N]-T[i+K], res)
print(res)

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

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d});

	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

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

constexpr ll INF = 1e18+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int m = n/2;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    vector<vector<ll>> dp(m,vector<ll>(2));
    ll ans = -INF;
    if(n%2==0){
        rep(i,0,2) dp[0][i] = a[i];
        rep(i,1,m){
            dp[i][0] = dp[i-1][0]+a[2*i];
            dp[i][1] = max(dp[i-1][0],dp[i-1][1]) + a[2*i+1];
        }
        ans = max(dp[m-1][0],dp[m-1][1]);
    }
    else{
        rep(i,0,3) dp[0][i] = a[i];
        rep(i,1,m){
            dp[i][0] = dp[i-1][0] + a[2*i];
            dp[i][1] = max(dp[i-1][0],dp[i-1][1]) + a[2*i+1];
            dp[i][2] = max(dp[i-1][1],dp[i-1][2]) + a[2*i+2];
        }
        rep(i,0,3){
            chmax(ans,dp[m-1][i]);
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i =0; i < n; i ++) cin >> a[i];

  for (int i = 1; i <= m; i ++) {
    for (int j = 0; j < n-1; j ++) {
      if (a[j]%i > a[j+1]%i) {
        int tmp = a[j];
        a[j] = a[j+1];
        a[j+1] = tmp;
      }
    }
  }

  for (int i = 0; i < n; i ++) {
    cout << a[i] << endl;
  }
}


Measured memory_bytes: 3104
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int H, W, K;
	std::cin >> H >> W >> K;
	boost::multi_array<bool, 2> cake(boost::extents[H][W]);
	boost::multi_array<int, 2> result(boost::extents[H][W]);
	for (auto i : boost::irange(0, H))
	{
		std::string str;
		std::cin >> str;
		for (auto j : boost::irange(0, W))
		{
			cake[i][j] = str[j] == '#';
		}
	}
	int start = 0;
	int number = 1;
	for (auto i : boost::irange(0, H))
	{
		int count = 0;
		std::vector<int>strawberry = { -1 };
		for (auto j : boost::irange(0, W))
		{
			if (cake[i][j])
			{
				strawberry.emplace_back(j);
				++count;
			}
		}
		if (count == 0)
		{
			continue;
		}
		else
		{
			for (auto ind : boost::irange(0, count - 1))
			{
				for (auto y : boost::irange(strawberry[ind] + 1, strawberry[ind + 1] + 1))
				{
					for (auto x : boost::irange(start, i + 1))
					{
						result[x][y] = number;
					}
				}
				++number;
			}
			for (auto y : boost::irange(strawberry[count - 1] + 1, W))
			{
				for (auto x : boost::irange(start, i + 1))
				{
					result[x][y] = number;
				}
			}
			++number;
			start = i + 1;
		}
	}
	if (start != H)
	{
		for (auto j : boost::irange(0, W))
		{
			for (auto i : boost::irange(start, H))
			{
				result[i][j] = result[start - 1][j];
			}
		}
	}
	for (auto i : boost::irange(0, H))
	{
		for (auto j : boost::irange(0, W))
		{
			std::cout << result[i][j] << " ";
		}
		std::cout << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >>a>>b>>c;
    int ab=a-b, bc=b-c, ca=c-a;
    ab = (ab*ab + 9999)/10000;
    bc = (bc*bc + 9999)/10000;
    ca = (ca*ca + 9999)/10000;
    cout << 1+ ab*bc + bc*ca + ca*ab -ab*bc*ca<<endl;
    return 0;
}

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

int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c) <= d){
    cout << "Yes" << endl;
  } else if(abs(a-b) <= d && abs(c-b) <= d ){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

while True:
    n=int(input())
        
    if n==0:
        break
    l=list(map(int,input().split()))
    m=sum(l)/len(l)
    
    s=[]
    for i in range(n):
        k=(l[i]-m)**2
        s.append(k)
    
    print(math.sqrt(sum(s)/n))
        


Measured memory_bytes: 5708
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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 = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
//using pb = push_back;
//

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
#define pq = priority_queue;
#define pb = push_back;
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 


signed main() {
  db w,h,x,y;
    cin>>w>>h>>x>>y;
  db t =2;

  if(w/2==x&&h/2==y){
    cout<<w*h/t<<" "<<1<<endl;
  }
  else{
    cout<<w*h/t<<" "<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;

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

	Mint ans = 0;
	rep(i, N) {
		if(i == 0) ans += K;
		else ans *= (K - 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
cum_a = [0]
cum_b = [0]
here_a = 0
here_b = 0
for i in range(n):
    cum_a.append(abs(here_a-a[i]) + cum_a[i])
    here_a = a[i]
    cum_b.append(abs(here_b - a[n-1-i]) + cum_b[i])
    here_b = a[n-1-i]
cum_a.append(abs(a[-1])+cum_a[-1])
cum_b.append(abs(a[0]) + cum_b[-1])
here = 0
a.append(0)
for i in range(n):
    l = cum_a[i]
    r = cum_b[n-1-i]
    move = abs(here-a[i+1])
    here = a[i]
    print(l+r+move)


Measured memory_bytes: 17324
ans = 0
last_v = 0
for i in range(5):
    tmp = int(input())
    if tmp % 10 == 0:
        tmp_v = 0
    else:
        tmp_v = 10 - tmp % 10 
    if tmp_v> last_v:
        last_v = tmp_v
    ans += tmp + tmp_v
print(ans - last_v)

Measured memory_bytes: 38256
#include <stdio.h>
#include <algorithm>

const int N_MAX = 100;
const int W_MAX = 10000;

int dp[N_MAX+1][W_MAX+1];

int main(){
  int N,W;
  scanf("%d %d",&N,&W);
  int v[N],w[N];
  for(int i=0;i<N;i++){
    scanf("%d %d",&v[i],&w[i]);
  }
  // dp table
  // dp[i][j] は、i番目(idx==i-1)までの品物でj以下の重さになるような最大value
  // dp[N][W] が解
  for(int i=1;i<=N;i++){
    for(int j=1;j<=W;j++){
      if(j<w[i-1]){
        dp[i][j] = dp[i-1][j];
      } else {
        dp[i][j] = std::max(dp[i-1][j],dp[i][j-w[i-1]]+v[i-1]);
      }
    }
  }
  /*
  for(int i=0;i<=N;i++){
    for(int j=0;j<=W;j++){
      printf("%3d", dp[i][j]);
    }
    printf("\n");
  }*/
  printf("%d\n", dp[N][W]);
  return 0;
}


Measured memory_bytes: 6672
#include<stdio.h>
int main(void)
{
	int h,w,i,j;
	char s[101][101];
	scanf("%d %d", &h, &w);
	for(i=0; i<h; i++)
	scanf("%s", &s[i]);
	for(i=0; i<h+2; i++)
	{
		for(j=0; j<w+2; j++)
		{
			if(i==0||i==h+1||j==0||j==w+1)
			printf("#");
			else
			printf("%c", s[i-1][j-1]);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int k, a, b; cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i%k == 0) {
			cout << "OK";
			return;
		}
	}
	cout << "NG";
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

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

int main(void) {
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    string u;
    double x;
    cin >> x >> u;
    ans += (u == "BTC") ? x * 380000.0 : x;
  }
  cout << fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from functools import lru_cache


@lru_cache(None)
def dp(i, cur):
    if cur > W:
        return float('-inf')
    elif i < 0:
        return 0
    else:
        v, w = VW[i]
        return max(dp(i - 1, cur), dp(i - 1, cur + w) + v)


N, W = map(int, input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
print(dp(N - 1, 0))


Measured memory_bytes: 137036
object Main extends App {

  import scala.io.StdIn._


  val n = readLine.trim.toInt
  println(
    if (n == 3 || n == 5 || n == 7) "YES" else "NO"
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}

Measured memory_bytes: 25420
/*

  _    _ _      _ _      _ _     _____ ____________ 
 | |__| | | _ _| | | _ _| | | __|__ / |__ /__ /__  |
 | '_ \_  _| ' \_  _| ' \_  _(_-<|_ \ ||_ \|_ \ / / 
 |_.__/ |_||_||_||_||_||_||_|/__/___/_|___/___//_/  

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define db1(x) cout << #x << "=" << x << '\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << '\n'
#define rep(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(x) scanf("%s", x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", x)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define F first
#define S second
#define pb push_back
#define ll long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mpow(int base, int exp);
void ipgraph(int n,int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 2e5+7, M = N, OO = 1e9 + 7;
const ll LLOO = 1e18 + 7;
//=======================

vi g[N];
ll a[N];
int n;

void solve()
{
    si(n);
    ll sum = 0;
    rep(i,0,n) {sl(a[i]);sum = (sum+a[i])%mod;}
    ll ans = 0;
    rep(i,0,n)
    {
		sum = (sum-a[i]+mod)%mod;
		ans = (ans+(sum*a[i])%mod)%mod;
	}
	
	pl(ans);
    
}

int main()
{
    // uncomment if file :
    // freopen("in","r",stdin);
    // freopen("out","w",stdout);
    int t = 1;
    // si(t); // uncomment if testcases
    while (t--)
        solve();
    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int u, v;
    while (m--)
    {
        scanf("%d %d", &u, &v);
        g[u - 1].pb(v - 1);
        g[v - 1].pb(u - 1);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10072
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;

const int mxl=100;
const int mx=1e3+10;
map<string,int>mp;
char s[mxl];
int lyr[mx],p[mx];
char sx[mxl],sy[mxl],rel[mxl],op[mxl];
int main(){
   int n,m;
   lyr[0]=0;
   while(scanf("%d %d",&n,&m)){
      if(n==0 && m==0)break;
      mp.clear();
      int u=0;
      lyr[u]=p[u]=0;
      gets(s);
      gets(s);
      mp[string(s)]=0;
      for(int i=1;i<n;i++){
         gets(s);
         int l=strlen(s);
         int dep=0;
         while(dep<l && s[dep]==' ')dep++;
         string x(s+dep);
         mp[x]=i;         
         while(lyr[u]!=dep-1)u=p[u];
         p[i]=u;
         lyr[i]=lyr[u]+1;
         u=i;
      }
      for(int i=0;i<m;i++){
         scanf("%s is %s %s of %s",sx,op,rel,sy);
         string y=string(sy);
         y=y.substr(0,int(y.size())-1);
         int ix=mp[string(sx)];
         int iy=mp[y];
         bool ans=false;
         if(rel[0]=='c'){
            if(p[ix]==iy)ans=1;
         }
         else if(rel[0]=='p'){
            if(p[iy]==ix)ans=1;
         }
         else if(rel[0]=='s'){
            if(p[ix]==p[iy] && lyr[ix]==lyr[iy])ans=1;
         }
         else if(rel[0]=='d' || rel[0]=='a'){            
            if(rel[0]=='a')swap(ix,iy);
            ix=p[ix];
            while(!ans){
               if(ix==iy) ans=true;
               if(ix==p[ix])break;
               ix=p[ix];
            }
         }
         if(ans)puts("True");
         else puts("False");
      }
      puts("");
   }
   return 0;
}

Measured memory_bytes: 1336
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int Mod=998244353;
const int N=400000;
int n;
#define Maxn 400010
char str[Maxn];
int ch[Maxn];
int F[Maxn],two[Maxn];
vector<int> vec[Maxn];

int head[Maxn],v[Maxn<<1],nxt[Maxn<<1],w[Maxn<<1],tot=0;
int col[Maxn],bel[Maxn],cnt;
vector<int> seq[Maxn];
inline void add_edge(int s,int e,int t){
	tot++;v[tot]=e;w[tot]=t;nxt[tot]=head[s];head[s]=tot;
}

bool flag=true;
void dfs(int u,int c){
	col[u]=c;
	bel[u]=cnt;
	seq[cnt].push_back(u);
    for(int i=head[u];i;i=nxt[i])
        if(col[v[i]]==-1)
        	dfs(v[i],(c+w[i])&1);
        else if((col[u]^col[v[i]])!=w[i])flag=false;
}
bool vis[Maxn];
char num[Maxn];
inline int solve(int x){
	cnt=0;
	tot=0;memset(head,0,sizeof(int)*(n+1));
	flag=true;
	for(register int i=1;i<=n;++i){
		int to=(i-x+n)%n;
		if(to==0)add_edge(i,n,0);
		else add_edge(i,to,0);
	}
	for(register int i=1;i<=n/2;++i){
		add_edge(i,i+n/2,1);
		add_edge(i+n/2,i,1);
	}
	memset(col,-1,sizeof(int)*(n+1));
	for(register int i=1;i<=n;++i)
	    if(col[i]==-1){
	    	cnt++;
	    	seq[cnt].clear();
	    	dfs(i,0);
	    	if(!flag)return 0;
		}
	memset(vis,false,sizeof(bool)*(n+1));
	int tmp=0,res=0;
	bool z=false;
    for(register int i=1;i<=n;++i)
        if(!vis[i]){
        	if(ch[i]==1)res=(res+two[cnt-tmp-1])%Mod;
        	int t=bel[i];
        	for(int j=0;j<seq[t].size();++j){
        		vis[seq[t][j]]=true;
        		num[seq[t][j]]=(ch[i]^col[seq[t][j]]);
			}
			tmp++;
		}else{
			if(num[i]>ch[i])break;
			if(num[i]<ch[i]){
				res=(res+two[cnt-tmp]);
				break;
			}
			if(i==n)z=true;
		}
	if(z)res++;
	return res;
}

int main(){
	two[0]=1;
	for(register int i=1;i<=N;++i)two[i]=(two[i-1]+two[i-1])%Mod;
	for(register int i=1;i<=N;++i)
	    for(register int j=i;j<=N;j+=i)
	        vec[j].push_back(i);
    scanf("%d",&n);
    scanf("%s",str+1);
    for(register int i=1;i<=n;++i)ch[i]=str[i]-'0';
    for(register int i=n+1;i<=2*n;++i)ch[i]=1;
    int ans=0;
    n<<=1;
    for(register int i=0;i<vec[n].size();++i){
    	F[i]=solve(vec[n][i]);
    	for(register int j=0;j<i;++j)
    	    if(vec[n][i]%vec[n][j]==0)F[i]=(F[i]-F[j]+Mod)%Mod;
	    ans=(ans+1ll*vec[n][i]*F[i])%Mod;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 115824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int red = 0;
  rep(i, n) {
    if (s[i] == 'R')
      red++;
  }
  int sum = 0, ans = red;
  for (int i = 1; i <= n; i++) {
    if (s[i-1] == 'R')
      sum++;
    if (red >= i)
      chmin(ans, red-sum);
    else
      chmin(ans, i-sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (100000L)

int main(int argc, char *argv[]) {
  // read inputs
  long N, as[MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // xs[i] : the number of times the box i is chosen.
  //    N       xs[0] + (N - 1) xs[1] + ... + 1       xs[N - 1] = as[0]
  //    1       xs[0] + N       xs[1] + ... + 2       xs[N - 1] = as[1]
  //    ...
  //    (N - 1) xs[0] + (N - 2) xs[1] + ... + N       xs[N - 1] = as[N - 1]
  long xs[MAX_N];

  // calculate sum_a, sum_x, and sum_i
  long sum_a = 0, sum_i = N * (N + 1) / 2;
  for (long i = 0; i < N; i++) {
    sum_a += as[i];
  }
  if (sum_a % sum_i != 0) {
    printf("NO\n");
    return 0;
  }
  const long sum_x = sum_a / sum_i;
  
  // calculate xs[i]
  for (long i = 0; i < N; i++) {
    const long Nx = sum_x + as[i] - as[(i + 1) % N];
    if (Nx % N != 0) {
      printf("NO\n");
      return 0;
    }
    const long x = Nx / N;
    if (x < 0) {
      printf("NO\n");
      return 0;
    }
    xs[i] = x;
  }
  printf("YES\n");
  
  return 0;
}


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

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

const int Maxn = 100005;

int n;
int P[Maxn];
ii seq[Maxn];
set <int> S;
ll res;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &P[i]);
        seq[i - 1] = ii(P[i], i);
    }
    sort(seq, seq + n);
    S.insert(0); S.insert(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        int v = seq[i].second;
        set <int>::iterator rig = S.upper_bound(v);
        set <int>::iterator lef = rig; lef--;
        set <int>::iterator it1, it2;
        if (*lef == 0)
            if (*rig == n + 1) ;
            else {
                it2 = rig; it2++;
                res += ll(P[v]) * v * (*it2 - *rig);
            }
        else if (*rig == n + 1) {
            it1 = lef; it1--;
            res += ll(P[v]) * (n + 1 - v) * (*lef - *it1);
        } else {
            it1 = lef; it1--;
            it2 = rig; it2++;
            res += ll(P[v]) * (ll(v - *lef) * (*it2 - *rig) + ll(*lef - *it1) * (*rig - v));
        }
        S.insert(v);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int p, q, r;
  cin >> p >> q >> r;

  cout << min(p+q, min(q+r, r+p)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <bits/stdc++.h> 
using namespace std;
 
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) 
\
 
int main()
{
  unsigned long int n,a,b,k=0;
  cin>>n>>a>>b;
  k=std::min(n%(a+b),a);
  cout<<(n/(a+b))*a + k;
  
  return 0;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next(), a = next(), b = next();
  var v = nexts(n);
  v.sort((a,b)=>b-a);
  var tot = 0;
  for(var i = 0; i < a; i++)tot += v[i];
  console.log(tot/a);
  var cnt = 0;
  if(v[0] === v[a-1]){
    var x = a;
    for(var i = a; i < n; i++){
      if(v[i] === v[a-1])x++;
    }
    for(var i = a; i <= b && i <= x; i++)cnt += ncr(x,i);
  }else{
    var x = 0;
    for(var i = 0; i < n; i++){
      if(v[i] === v[a-1])cnt++;
      else if(v[i] > v[a-1])x++;
    }
    cnt = ncr(cnt,a-x);
  }
  return cnt;
}
function ncr(n,r){
  var res = 1;
  if(r > n-r)r = n-r;
  for(var i = 1; i <= r; i++)res *= n-r+i, res /= i;
  return res;
}

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

int a[100005], pay[100005];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	int sum = abs(a[1]) + abs(a[n]);
	for(int i = 1; i < n; i++){
		pay[i] = abs(a[i] - a[i+1]);
		sum += pay[i];
	}
	printf("%d\n", sum - abs(a[1]) - pay[1] + abs(a[2]));
	for(int i = 2; i < n; i++){
		printf("%d\n", sum - pay[i] - pay[i-1] + abs(a[i-1] - a[i+1]));
	}
	printf("%d\n", sum - abs(a[n]) - pay[n-1] + abs(a[n-1]));
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 11;
int n, m, p, c;
ii a[N];
int gain[N];

int main() {
    cin >> n >> m;
    m /= 100;
    int ans = 1e9;
    for (int i = 0; i < n; ++i) {
        cin >> p >> c;
        a[i] = {p, c};
        gain[i] = p * (i + 1) + c / 100;
    }
    for (int i = 0; i < (1 << n); ++i) {
        int sum = 0;
        int cnt = 0;
        int mi = 0;
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)) {
                sum += gain[j];
                cnt += a[j].first;
            } else {
                mi = j;
            }
        }
        if (sum < m) {
            int d = m - sum;
            if (a[mi].first * (mi + 1) < d)
                continue;
            cnt += (d + mi) / (mi + 1);
        }

        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int mn[200005], mx[200005];
int main () {
  int n;
  scanf("%d", &n);
  FOR(i, 1, n) {
    int x, y;
    scanf("%d %d", &x, &y);
    mn[i] = x; mx[i] = y;
  }
  sort(mn + 1, mn + n + 1);
  sort(mx + 1, mx + n + 1);
  if (n & 1) {
    int l = mn[(n + 1) / 2];
    int r = mx[(n + 1) / 2];
    printf("%d\n", r - l + 1);
  } else {
    int l = mn[n / 2] + mn[n / 2 + 1];
    int r = mx[n / 2] + mx[n / 2 + 1];
    printf("%d\n", r - l + 1);
  }
  return 0;
}

Measured memory_bytes: 5328
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        char[][] base = new char[n][n];
        char[][] child = new char[m][m];
     
        for(int x=0; x<n; x++){
                base[x] = sc.next().toCharArray();
        }
        for(int x=0; x<m; x++){
                child[x] = sc.next().toCharArray();
        }
        
        String ans = "No";
        
        for(int x=0; x<n; x++){
            for(int y=0; y<n; y++){
                if((y+m-1 >= n) || (x+m-1 >= n)){
                    continue;
                }
                
                boolean match = true;
                for(int p=0; p<m; p++){
                    for(int q=0; q<m; q++){
                        if(base[x+p][y+q] != child[p][q]){
                            match = false;
                        }
                    }
                }
                if(match){
                    ans = "Yes";
                }
            }
        }
       
        System.out.println(ans);
	}
}

Measured memory_bytes: 21332
#include <stdio.h>
#include <string.h>

void addstr(char *str1,char *str2)
{
	char temp[1000];
	int max;
	int i;

	if(strlen(str1)>strlen(str2)){
		max=strlen(str1);
	}
	else{
		max=strlen(str2);
	}

	memset(temp,'\0',1000);
	strcpy(&temp[max-strlen(str1)+1],str1);
	i=0;

	while(temp[i]=='\0'){
		temp[i]='0';
		i++;
	}
	strcpy(str1,temp);

	memset(temp,'\0',1000);
	strcpy(&temp[max-strlen(str2)+1],str2);
	i = 0;
	
	while (temp[i]=='\0'){
		temp[i]='0';
		i++;
	}
	
	strcpy(str2,temp);
	
	for(i=max;i>=0;i--){
		str1[i]+=str2[i]-'0';
		if (str1[i]>'9'){
			str1[i]-=10;
			str1[i-1]+=1;
		}
	}
	if(str1[0]=='0'){
		memset(temp,'\0',1000);
		strcpy(temp,&str1[1]);
		memset(str1,'\0',1000);
		strcpy(str1,temp);
	}
}

int main()
{
	char str[1000],str2[1000];
	int n;

	scanf("%d", &n);

	while (n-- != 0){
		memset(str,'\0',1000);
		memset(str2,'\0',1000);
		scanf("%s",str);
		getchar();
		scanf("%s",str2);
		getchar();
		addstr(str,str2);
		if (strlen(str)<81){
			printf("%s\n",str);
		}
		else {
			printf("overflow\n");
		}
	}
	return 0;
}

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

flag = False

inf = 10 ** 6

while flag == False:
  for i in range(N,inf):
    L = str(i)
    for j in L:
      if int(j) in D:
        break
    else:
      print(i)
      flag = True
      break

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;
if(W<(x+r)){
	cout<<"No"<<endl;
}
else if(H<(y+r)){
	cout<<"No"<<endl;
}
else if(x<r){
	cout<<"No"<<endl;
}
else if(y<r){
	cout<<"No"<<endl;
}
else{cout<<"Yes"<<endl;}
return 0;
}


Measured memory_bytes: 3092
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define all(x) x.begin(),x.end()
ld pie=3.141592653589793238462643383279;
int mod=1e9+7;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};


int fact[2000005];
int infact[2000005];

int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}

int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}

void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}

int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}

int n,m;

vector<int> adj[1000005];
bool vis[1000005];
bool vis2[1000005];
int ans[1000005];

bool poss=1;

int dfs(int c,int p){
  bool lp=1;
  int leaf=0;
  for(auto it : adj[c]){
    if(it!=p){
      lp=0;
      leaf+=dfs(it,c);
    }
  }
  if(lp) return 1;
  else{
    if(leaf<3) poss=0;
    return 0;
  }
  
}

void dfs2(int s,int val){
  if(vis2[s]) return ;
  vis2[s]=1; ans[s]=val;
  for(auto it : adj[s])
    dfs2(it,val);
}

int rev(int a){
  int r=0;
  while(a!=0){
    r+=a%10;
    r*=10;
    a/=10;
  }
  return r/10;
}
int32_t main(){ 

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int ans=0;
  string s,t; cin>>s>>t;
  for(int i=0;i<s.size();++i) if(s[i]!=t[i]) ++ans;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 27268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

signed main(){
  int n;
  cin>>n;
  for(int i=n; i<=999; i++){
    string str=to_string(i);
    if(str[0]==str[1]&&str[1]==str[2]){
      cout<<i<<en;
      RE;
    }
  }
}


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

namespace D___Megalomania
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var AiBi = new int[N].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x[1]).ToArray();
            int time = 0;

            for (int i = 0; i < N; i++)
            {
                time += AiBi[i][0];

                if (time > AiBi[i][1])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 35604
while True:
    h,w = map(int, input().split())
    if h==0 and w==0:
        break
    
    for i in range(w):
        print("#", end="")
    
    print()
    
    for i in range(1,h-1):
        print("#",end = "")
        for j in range(1,w-1):
            print(".",end="")
        print("#")
    
    for i in range(w):
        print("#",end = "")
    print("\n")


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int yes(){
	cout << "YES" << endl;
	return 0;
}

int no(){
	cout << "NO" << endl;
	return 0;
}

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	ll acc = accumulate( a.begin(), a.end(), 0ll );
	ll sum = (n*(n+1))/2;
	if( acc % sum != 0 ) return no();
	ll k = acc / sum;
	vector<ll> d(n);
	for( int i = 0; i < n; ++i ){
		if( i == n-1 ){
			d[i] = a[0] - a[i];
		} else {
			d[i] = a[i+1] - a[i];
		}
	}
	ll ycnt = 0;
	for( auto p : d ){
		if(
			(k-p)%n != 0 || ((n-1)*k+p)%n != 0
			||
			(k-p)/n < 0 || ((n-1)*k+p)/n < 0
			||
			(k-p)/n + ((n-1)*k+p)/n != k
		){
			return no();
		}
		ycnt += (k-p)/n;
	}
	( ycnt == k ) ? yes() : no();
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int c0=0,c1=0,c2=0,c3=0;
	int n;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="AC")
		c0++;
		else if(s=="WA")
		c1++;
		else if(s=="TLE")
		c2++;
		else 
		c3++;
	}
	cout<<"AC x "<<c0<<endl
	    <<"WA x "<<c1<<endl
	    <<"TLE x "<<c2<<endl
	    <<"RE x "<<c3<<endl;
	return 0;
}

Measured memory_bytes: 3564
/*
 * Since g++10 is released, some characters is not valid inside #if 0 :(
 * So, why not using clang++? :D

 * Date:
  2020.07.17

 * Solution:
  不难发现 D 最小的数就是重心，把它作为根。
  把所有点按 D 降序，一个个考虑其父亲节点，并维护每个点的 size 即可。

 * Digression:

 * CopyRight:
          ▁▃▄▄▄▃▃▃▃▄▶
        ▗▇▀▔    ▔▔▔▔
       ▄▛   ▃▅━━■▄▂
      ▟▊   ▐▘     ▀▙
     ▟▜▌   ▐▖   ▋  ▐▍
    ▟▘ ▜   ▝▀▇▆●▘  ▐▌
  ▗▟▘   ▜▃       ▁▅▛
  ▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔
        ▔▔▔▔▔▔
 */

#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
typedef std::pair<ll, int> par;

struct _ {
    inline operator int () { int x; return scanf("%d", &x), x; }
    inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 100005;
par p[maxn];
int fa[maxn], size[maxn], dis[maxn];

int main () {
	int n = read;
	if (n < 7) return puts("-1"), 0;

	for (int i = 1; i <= n; i ++) p[i] = par(read, i);
	std::sort(p + 1, p + n + 1);

	for (int i = 1; i <= n; i ++) size[i] = 1;

	for (int i = n; i > 1; i --) {
		int u = p[i].second;
		ll x = p[i].first - n + size[u] * 2;
		int j = int(std::lower_bound(p + 1, p + n + 1, par(x, 0)) - p);
		if (j > n or p[j].first != x) return puts("-1"), 0;
		fa[u] = p[j].second;
		size[fa[u]] += size[u];
	}

	ll test = 0;
	for (int i = 2; i <= n; i ++) {
		int u = p[i].second;
		dis[u] = dis[fa[u]] + 1;
		test += dis[u];
	}

	if (test != p[1].first) return puts("-1"), 0;

	for (int u = 1; u <= n; u ++)
		if (fa[u])
			printf("%d %d\n", fa[u], u);
}


Measured memory_bytes: 5964
class BinaryIndexedTree:
    def __init__(self, size):
        self.data = [0] * (size+1)
        self.size = size+1
        self.msb = 1 << (size.bit_length()-1)
    
    def _add(self, i, w):
        i += 1
        while i < self.size:
            self.data[i] += w
            i += i & -i
    
    def _get_sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    def __getitem__(self, i):
        """
        [0,i)
        """
        if isinstance(i, slice):
            if i.start is None:
                return self._get_sum(i.stop)
            else:
                return self._get_sum(i.stop) - self._get_sum(i.start)
        else:
            return 0 # fake value
    
    __setitem__ = _add
    
    def bisect_left(self, v):
        """
        return smallest i s.t v <= sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] < v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    def bisect_right(self, v):
        """
        return smallest i s.t v < sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] <= v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    bisect = bisect_right



def solve(C, queries):
    N = len(C)
    Q = len(queries)
    bit = BinaryIndexedTree(N)

    last_ind = [None]*(N + 1)
    res = [None]*Q
    pr = 0
    temp = 0

    MASK = (1<<20)-1
    for ri in sorted((r << 20)|i for i,(l,r) in enumerate(queries)):
        qi = ri&MASK
        l,r = queries[qi]
        for j in range(pr,r):
            c = C[j]
            if last_ind[c] is not None:
                bit._add(last_ind[c], -1)
            else:
                temp += 1
            last_ind[c] = j
            bit._add(j, 1)

        pr = r
        res[qi] = temp - bit._get_sum(l-1)

    return res

# from random import randrange, seed
# from time import perf_counter

# def test():
#     seed(1234)
#     N = 5*10**5
#     C = [randrange(N) for _ in range(N)]
#     queries = [tuple(sorted((randrange(1,N+1),randrange(1,N+1)))) for _ in range(N)]
#     start = perf_counter()
#     solve(C,queries)
#     stop = perf_counter()
#     print(stop-start)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

if __name__ == '__main__':
    N,Q = map(int,readline().split())
    C = list(map(int,readline().split()))

    m = map(int,read().split())
    queries = list(zip(m,m))

    print(*solve(C,queries), sep='\n')
    # test()


Measured memory_bytes: 238472
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int t = 1;
    for (int i = 0; i < d; i++) {
        t *= 100;
    }

    if (n == 100) n++;

    cout << t * n << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();
		int m = ni();
		int x = ni();

		out((10 * m + x) % 4 == 0 ? "YES" : "NO");

	}

	/*
	 * 以下メソッド集
	 */

	public static long[] kousokusoinnsuubunkaihairetsu(long n2) {
		long[] d = new long[(int) n2];
		for (int i = 0; i < n2; i++) {
			d[i] = i;
		}
		for (int i = 2; i * i < n2; i++) {
			for (int j = i * i; j < n2; j += i) {
				if (d[j] == j)
					d[j] = i;
			}

		}

		return d;
	}

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "2";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static long kaijo(long n) {

		debug(n);

		if (n == 0l || n == 1l) {
			return 1l;
		} else {
			return n * kaijo(n - 1l);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}


Measured memory_bytes: 35668