akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int h,w;
vector<string> s;
int dx[8] = {1,1,1,0,0,-1,-1,-1};
int dy[8] = {1,0,-1,1,-1,1,0,-1};

int main(int argc, char const* argv[])
{
    cin >> h >> w;
    s.resize(h);
    rep(i,h) cin >> s[i];
    vector<string> ans;
    rep(y,h){
        string ad="";
        rep(x,w){
            if(s[y][x] == '#'){
                ad += "#";
                continue;
            }
            int num = 0;
            rep(i,8){
                int nx = x+dx[i];
                int ny = y+dy[i];
                if(nx < 0 || nx > w-1 || ny < 0 || ny > h-1) continue;
                else{
                    if(s[ny][nx] == '#') num++;
                }
            }
            ad += to_string(num);
        }
        ans.pb(ad);
    }
    rep(i,h) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read::<usize>();
    if n % 500 <= a {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  string s,t; cin >> s >> t;
  ll count = 0;
  
  rep(i,s.size()) {
    if(s.at(i) != t.at(i)) count++;
  }

  cout << count << endl;
}


Measured memory_bytes: 3920
#include<stdio.h>
#define N 200000
int partition(int *,int ,int );

int main(){
    int a,b,i,A[N];

    scanf("%d",&a);
    for(i = 0;i < a;i++){
        scanf("%d",&A[i]);
    }

    b = partition(A,0,a - 1);

    for(i = 0;i < a;i++){
        if(i == a - 1)printf("%d\n",A[i]);
        else if(i == b)printf("[%d] ",A[i]);
        else printf("%d ",A[i]);
    }
    return 0;
}
int partition(int *A,int p,int r)
{
    int x,i,j,a;
    x = A[r];
    i = p - 1;
    for(j = p;j <= r - 1;j++){
        if(A[j] <= x){
            i = i + 1;
            a = A[i];
            A[i] = A[j];
            A[j] = a;
        }
    }
    a = A[i+1];
    A[i+1] = A[r];
    A[r] = a;

    return i+1;
}


Measured memory_bytes: 2252
#include <cstdio>
using namespace std;

int main(){
    int H, W;
    while(true){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                char ch;
                if( (i + j) % 2 == 0) ch = '#';
                else ch = '.';
                printf("%c", ch);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1000
#include <iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	string s="";
	while(n>0){
		 n--;
		 s+=('a'+ (n%26));
		 n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}


Measured memory_bytes: 3608
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int n, m, q;
vector<int> a, b, c, d;
ll ans = 0;

void dfs(vector<int> v){
  if(v.size()==n+1){
    ll sum = 0;
    rep(i, q){
      if(v[b[i]] - v[a[i]]==c[i]) sum += d[i];
    }
    chmax(ans, sum);
    return;
  }

  v.pb(v.back());
  while(v.back()<=m){
    dfs(v);
    ++(v.back());
  }
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i]; --b[i];
  }

  vector<int> v(1, 1);
  dfs(v);
  cout << ans << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
const int table[6][20] = {{},
  {1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 36, 108, 220, 334, 384, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 976, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001}};
int G[105];
inline void Init(){G[1]=0;Rep(n,2,100)for(int k=1;k<n;k++)if((1<<k)>=n&&(1<<k)-n>=G[k]){G[n]=k;break;}}
inline int g(ll n){
	if(n<=100)return G[n];
	for(int k=1;;k++)if((1ll<<k)>=n&&(1ll<<k)-n>=g(k))
		return k;
}
ll n;
inline int Solve(ll n,ll k){
	if(n<k)swap(n,k);
	if(k<63&&(1ll<<k)-n<n)return Solve((1ll<<k)-n,k);
	if(k>5)return 1001;return k==0?1:table[k][n];
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),Init();
	int ans=Solve(n,g(n));ans+=(n==4)+(n==7)*2;
	cout<<(ans>1000?-1:ans);
	return 0;
}




Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
	ll n;ll k;
	scanf("%lld%lld",&n,&k);
	ll ans=0;
	for(ll i=k;i<=n+1;i++){
		ans=(ans+i*(n-i)+i+1)%mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3828
import java.io.*;
import java.util.Scanner;

public class Main{
               public static void main(String args[]) throws IOException{
                     int a = 0;
                     int b = 0;
                     int c = 0;
                   
                     Scanner in = new Scanner(System.in);
                     
                     String buf1 = in.next();
                     String buf2 = in.next();
                     String buf3 = in.next();
                     
                     a = Integer.parseInt(buf1);
                     b = Integer.parseInt(buf2);
                     c = Integer.parseInt(buf3);

                        if(a < b && b < c){
                          System.out.println("Yes");
                       }else{
                          System.out.println("No");
                       }

              }
      }

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

const int MXN = 13, INF = 1e9;
int n, m, x, c[MXN], a[MXN][MXN];

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> x;
  for (int i = 0; i < n; ++i){
    cin >> c[i];
    for (int j = 0; j < m; ++j){
      cin >> a[i][j];
    }
  }
  int done[m];
  int ans = INF;
  for (int i = 1; i <= (1<<n); ++i){
    bitset<14> bt(i);
    fill(done, done+m, 0);
    int cost = 0;
    for (int j = 0; j < n; ++j){
      if(bt[j]){
        cost += c[j];
        for (int k = 0; k < m; ++k){
          done[k] += a[j][k];
        }
      }
    }
    bool yes = true;
    for (int j = 0; j < m; ++j){
      if(done[j] < x) yes = false;
    }
    if(yes) ans = min(ans, cost);
  }
  if(ans!=INF) cout << ans << endl;
  else  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author @MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DolphinPath solver = new DolphinPath();
        solver.solve(1, in, out);
        out.close();
    }

    static class DolphinPath {
        public void solve(int testNumber, FastReader fs, PrintWriter pw) {
            int sx = fs.nextInt(), sy = fs.nextInt(), tx = fs.nextInt(), ty = fs.nextInt();
            StringBuilder ans = new StringBuilder();
            int px = sx, py = sy;
            while (py++ < ty) {
                ans.append("U");
            }
            while (px++ < tx) {
                ans.append("R");
            }
            while (py-- > sy + 1) {
                ans.append("D");
            }
            while (px-- > sx + 1) {
                ans.append("L");
            }
            px--;
            ans.append("L");
            while (py++ < ty + 1) {
                ans.append("U");
            }
            while (px++ < tx) {
                ans.append("R");
            }
            py--;
            ans.append("D");
            px++;
            ans.append("R");
            while (py-- > sy) {
                ans.append("D");
            }
            while (px-- > sx + 1) {
                ans.append("L");
            }
            ans.append("U");
            pw.println(ans.toString().trim());
        }

    }

    static class FastReader {
        BufferedReader bf;
        StringTokenizer st;

        public FastReader(InputStream is) {
            bf = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

        public String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    String line = bf.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
            } catch (Exception e) {
            }

            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 8528
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
int main(){
  int n,ans=0,x=0;
  cin>>n;
  int num[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  for(int i=0;i<n;i++){
    if(x>=n){
      break;
    }
    if(num[x]-1==x){
      ans++;
      x+=2;
    }
    else
      x++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main() {
  int N ; cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  sort(a.begin(),a.end());
  bool can = true;
  
  int ans = 0;
  int cnt = 1;
  int num = a[0];
  if(N==1){
    if(num == 1) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
  }
  rep(i,N-1){ 
    if(a[i] == a[i+1]){
      cnt++;
    }
    else{
      if(cnt>num) ans += cnt-num;
      else if(cnt == num){
        cnt = 1;
        num = a[i+1];
      }
      else ans += cnt;
      cnt = 1;
      num = a[i+1];
    }  
    if(i==N-2){
      if(cnt > num) ans += cnt-num;
      else if(cnt < num) ans += cnt;
    }
  }
  cout << ans << endl;
  
  
}

  



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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int maxpizza, minpizza;
  
  if(X > Y){
    maxpizza = X; minpizza = Y;
  } else {
    maxpizza = Y; minpizza = X;
  }
  
  int ans = 0;
  
  if(2 * C <= A && 2 * C <= B) {
    ans += 2 * C * maxpizza;
  } else if (2 * C <= A + B) {
    ans += minpizza * 2 * C;
    if (X > Y) {
      if (2 * C < A) {
        ans += 2 * C * (maxpizza - minpizza);
      } else {
        ans += A * (maxpizza - minpizza);
      } 
    } else {
      if (2 * C < B) {
        ans += 2 * C * (maxpizza - minpizza);
      } else {
        ans += B * (maxpizza - minpizza); 
      }
    }
  } else {
    ans += A * X + B * Y;
  }
  cout << ans << endl;  
}  

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];

	int x2 = 0;
	for(int i = 0; i < n; ++i)
	{
		if(i%2) x2 -= a[i];
		else x2 += a[i];
	}
	vector<int> ans(n);
	ans[0] = x2/2;
	for(int i = 0; i < n-1; ++i)
	{
		ans[i+1] = a[i] - ans[i];
	}
	for(int i = 0; i < n; ++i){
		ans[i] *= 2;
	}
	for(int i = 0; i < n; ++i){
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 2176
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


T = int(input())
a = []
for i in range(T):
    a.append(list(map(int, input().split())))
for r in a:
    s, b, c, d = r[0], r[1], r[2], r[3]
    mod_list = []
    if (s < b) or (b>d):
        print('No')
        continue
    if (c>b):
        print('Yes')
        continue

    g = gcd(b,d)

    if b- g + s%g > c:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, ans = 0;
    cin >> n;
    vi A(n);
    rep(i, n){
        cin >> A[i];
    }
    rep(i, n){
        FOR(j, i + 1, n){
            ans = max(ans, abs(A[i] - A[j]));
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
LEN, QES = gets.chomp.split(" ").map(&:to_i)
STRING = gets.chomp

RES = [0, 0]
(2..LEN).each do |i|
  if STRING.slice(i-2, 2) == "AC"
    RES[i] = RES[i-1] + 1
  else
    RES[i] = RES[i-1]
  end
end

(0...QES).each do |i|
  l, r = gets.chomp.split(" ").map(&:to_i)
  puts (RES[r] - RES[l])
end

Measured memory_bytes: 3452
n, d = gets.chomp.split(" ").map(&:to_i)
arr = []
count = 0
n.times do
    row = gets.chomp.split(" ").map(&:to_i)

    arr.each do |r|
        expr = (0...r.length).map { |j| (r[j] - row[j]) ** 2 }.sum
        rt = Math.sqrt(expr)
        count += 1 if rt.to_i == rt
    end

    arr << row
end
puts count

Measured memory_bytes: 14340
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repab(i,a,b) for(ll i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define pr1(x) cout<<fixed<<setprecision(15)<<x<<'\n'
#define mod 1000000007
#define mod1 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getvec(v,n) vector<ll> v(n);for(ll i=0;i<n;i++) cin>>v[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(h);get(w);get(n);
  if(h<w){
    h=h+w;
    w=h-w;
    h=h-w;
  }
  ll ans=0;
  while(n>0){
    ans++;
    n-=h;
  }
  p1(ans);
  return 0;
}


Measured memory_bytes: 256
def fifty_fifty(s):

    count = set(s)
    return "Yes" if len(count) == 2 and s.count(list(count)[0]) == 2 and s.count(list(count)[1]) == 2 else "No"
def main():
    s = list(str(input()))
    print(fifty_fifty(s))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9052
import math
N = int(input())
keta = math.floor(math.log10(N))+1
if keta<1:
  result = 0
elif keta == 1:
  result = N
elif keta == 2:
  result = 9
elif keta%2==1:
  result = 9
  a = (keta-2)//2
  for i in range(1,a+1):
    result += 9*10**(2*i)
  result += N - 10**(keta-1) + 1
else:
  result = 9
  a = (keta-2)//2
  for i in range(1,a+1):
    result += 9*10**(2*i)
print(result)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 1e5 + 5;
const int maxk = 1005;
int k;
int W[2*maxk][2*maxk], B[2*maxk][2*maxk];
int sw[2*maxk][2*maxk],sb[2*maxk][2*maxk];
int dp[2*maxk][2*maxk];
inline int cntb(int t,int i,int j){
    if(j < 0)return 0;
    if(i == 0)return B[t][j];
    return B[t][j] - B[t][i - 1];
}
inline int cntw(int t,int i,int j){
    if(j < 0)return 0;
    if(i == 0)return W[t][j];
    return W[t][j] - W[t][i - 1];
}
int cnt(int t,int i,int j){
    if(j < 0)return 0;
//    cout<<cntb(t,i,j)<<' '<<cntw(t,i,j);
    return cntb(t,i,j) - cntw(t,i,j);
}
int main(){
//    freopen("e:\\in.txt","r",stdin);
    memset(sw,0,sizeof(sw));
    memset(sb,0,sizeof(sb));
    int n;
    cin>>n>>k;
    for(int i = 0; i < n; i++){
        int a,b;
        char c;
        cin>>a>>b>>c;
        a %= 2*k;
        b %= 2*k;
        if(c == 'W')sw[a][b]++;
        else sb[a][b]++;
    }
    memset(dp,0,sizeof(dp));
    for(int j = 0; j < 2*k; j++){
        W[j][0] = sw[0][j];
        B[j][0] = sb[0][j];
        for(int i = 1; i < 2*k; i++){
            W[j][i] = W[j][i - 1] + sw[i][j];
            B[j][i] = B[j][i - 1] + sb[i][j];
        }
    }
    int ans = 0;
    for(int s = 0; s < k; s++){
        for(int t = 0;t<k;t++){
            dp[s][0] += cntb(t,s,s+k-1) + cntw(t,0,s-1) + cntw(t,s+k,2*k-1)
                        +cntw(t+k,s,s+k-1) + cntb(t+k,0,s-1) + cntb(t+k,s+k,2*k-1);
        }
        //cout<<dp[s][0]<<endl;
        ans = max(ans,dp[s][0]);
//        cout<<dp[s][0]<<endl;
        for(int t = 1; t < 2*k; t++){
//            cout<<cnt(t-1,s+k,2*k-1)<<' '<<cnt(t-1,s,s+k-1)<< ' '<<cnt(t-1,0,s - 1)
//                    <<' '<<cnt((t+k-1)%(2*k),s,s+k-1)<<' '<<cnt((t+k-1)%(2*k),s+k,2*k-1)<<' '<<cnt((t+k-1)%(2*k),0,s-1)<<endl;
            dp[s][t] = dp[s][t - 1] + cnt(t-1,s+k,2*k-1) - cnt(t-1,s,s+k-1) + cnt(t-1,0,s - 1)
                    + cnt((t+k-1)%(2*k),s,s+k-1) - cnt((t+k-1)%(2*k),s+k,2*k-1) - cnt((t+k-1)%(2*k),0,s-1);
            ans = max(ans,dp[s][t]);
//            cout<<dp[s][t]<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,pe;
	cin>>a>>b>>c;
	pe=1;
	if(a>b||a<b){
		pe++;
	}
	if(a>c||a<c){
		if(b<c||b>c){
			pe++;
		}
	}
	cout<<pe<<endl;
}


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

using namespace std;

#define int long long
#define ll long long
//#define int unsigned long long

const int mod = 1e9 + 7;


signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //------<<<<>>>>-----//
    // freopen("C:\\Users\\Andrey\\CLionProjects\\untitled1\\input.txt","r",stdin);
    // freopen("C:\\Users\\Andrey\\CLionProjects\\untitled1\\output.txt","w",stdout);
    //freopen("huffman.in","r",stdin);
    //  freopen("huffman.out","w",stdout);
    double a,b,x;
    cin>> a>> b>>x;
    x /= a;
    double y = x / a * 2 - b;
    if(y >= 0){
        cout << setprecision(20) << atan2(b - y, a) * 180 / M_PI;
    }
    else{
        y = 2 * x / b;
        cout << setprecision(20) << atan2(b, y) * 180 / M_PI;
    }




}

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

int main (){
    string S;
    cin>>S;
  	vector<char> num(10);
  num = {'0','1', '2', '3','4','5','6', '7', '8', '9'};
  int num5, num6;
    for (int i=0;i<10;i ++){
        if(num.at(i)==S.at(5)){
            num5 = i;
        }
    }
    for (int i=0;i<10;i ++){
        if(num.at(i)==S.at(6)){
            num6 = i;
        }
    }
    int month=num5*10 +num6;
    cout<<(month>4?"TBD":"Heisei")<<endl;
}

Measured memory_bytes: 256
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   string str;
   cin >> str;
   if(str[1] == 'R') cout << "ABC";
   else cout << "ARC";
}

int main(){
    fastio;
    int t;
    t = 1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;

const int MAXN=0;

int cnt=0,d;
ll N,m;

int main() {
	cin>>N;
	m=0;
	while(N > 0) {
		m += N%10;
		d = N%10;
		N /= 10;
		cnt++;
	}
	d--;
	cout<<max(m,1ll*(cnt-1)*9+d)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    char S[4],T[4];
    cin >> S;
    cin >> T;
    int total=0;
    for(int i=0;i<3;i++){
        if(S[i]==T[i]){
            total++;
        }
    }
    cout << total << endl;
    return 0;
}


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

signed main() {
	string s, p, tmp;
	cin >> s >> p;

	for (int i = 0; i < s.size(); ++i) {
		tmp = s.substr(i) + s.substr(0, i);
		if (tmp.find(p) != string::npos) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}
		


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;

int main() {
    int A,B,K;
    cin >> A >> B >> K;
    for (int i = 100; i > 0; --i) {
        if(A % i == 0 && B % i == 0){
            K--;
            if(K == 0){
                cout << i;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
int main(){
  string s;cin>>s;
  transform(s.begin(),s.end(),s.begin(),::toupper);
  int ret = 0;
  while(1){
    string ss;cin>>ss;
    if(ss == "END_OF_TEXT")break;
    transform(ss.begin(),ss.end(),ss.begin(),::toupper);
    if(s == ss)ret++;
  }
  cout << ret << endl;
}


Measured memory_bytes: 3128
#include <iostream>

using namespace std;

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

	int i = 1;
	long long sum = 0;
	while (true)
	{
		sum += i;
		if (sum >= X)
		{
			cout << i << endl;
			break;
		}

		i++;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define usll                    unordered_set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

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

int main()
{
	fastIO
//	inp_out();
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c-=b;
		if(c<=0)	
		{
			cout<<"Yes";
			break;
		}
		a-=d;
		if(a<=0)
		{
			cout<<"No";
			break;
		}
	}

	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
  int n,x,y,sum = 0;
  cin>>n>>x;
  vector<ll> a(n);
  REP(i,n){
    cin >> a.at(i);
    sum += a.at(i);
    if(sum > x){cout<<i+1<<endl;return 0;}
  }
  cout<<n+1<<endl;
}

Measured memory_bytes: 256
#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 FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define pb push_back

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	ll n, i, k, j; cin >> n >> k;
	vl v(n), dp(n, LLONG_MAX);
	for (i = 0; i < n; i++) cin >> v[i];
	dp[0] = 0;
	for (i = 0; i < n; i++) {
		// if ((i + 1) < n) dp[i + 1] = min(dp[i + 1], (dp[i] + abs(v[i + 1] - v[i])));
		// if ((i + 2) < n) dp[i + 2] = min(dp[i + 2], (dp[i] + abs(v[i + 2] - v[i])));
		for (j = 1; j <= k; j++) {
			if ((i + j) < n) dp[i + j] = min(dp[i + j], (dp[i] + abs(v[i + j] - v[i])));
		}
	}
	cout << dp[n - 1] << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

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



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

  bool ans = false;
  rep(i, 100) {
    rep(j, 100) {
      if(i * 4 + j * 7 == n) ans = true;
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#define int long long int
int32_t main()
{
    int n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    int answer=0;
    vector<int> v;
    map<int,int> mp1,mp2;
    int count=0;
    int j;
    for(j=0;j<n;j++)
    {
		if(str[j]=='0')
		{
			mp1[j]=count;
			mp2[count]=j;
			count++;
			while(j<n&&str[j]=='0')
			{
				j++;
			}
	    }
	}
    for(j=0;j<n;j++)
    {
		if(str[j]=='0')
		{
			int i=mp1[j];
			auto it=mp2.find(i+k);
			int end;
			if(it==mp2.end())
			  end=n-1;
			else
			  end=it->second-1;
			answer=max(answer,end-j+1);
		}
		else
		{
			int val=0;
			while(j<n&&str[j]=='1')
			{
				val++;
				j++;
			}
			if(j==n)
			{
				answer=max(answer,val);
				break;
			}
			else
			{
				int i=mp1[j];
				auto it=mp2.find(i+k);
				int end;
				if(it==mp2.end())
				   end=n-1;
				else
				   end=it->second-1;
				answer=max(answer,end-j+1+val);
			}
		}
	}
	cout<<answer<<endl;
}


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

int main() {
	string s;
  	cin >> s;
  	sort(s.begin(), s.end());
  	if (s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) {
      	cout << "Yes" << endl;
      	return 0;
    }
  	cout << "No" << endl;
  	return 0;
}

Measured memory_bytes: 256
/*
	dp[i][j] = min. wt. of items from a[i, i+1, .... N] with j value left to add
	dp[i][j] = min(dp[i+1][j], dp[i+1][j-v[i]]+w[i])

	Base Cases
	-----------
	dp[N-1][v[N-1]] = w[N-1]
	dp[N-1][0] = 0
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1<<30;

ll dp[105][100005];

int main(){
	int N, W;
	vector<ll> w, v;
	//vector<vector<ll> > dp;
	cin>>N>>W;
	w.assign(N+1, 0);
	v.assign(N+1, 0);
	for(int i=0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	
	dp[N][0] = 0;
	for(int i=1;i<100005;i++){
		dp[N][i] = INF;
	}

	for(int i=N-1;i>=0;i--){
		dp[i][0] = 0;
		for(int j=100000;j>=1;j--){
			dp[i][j] = dp[i+1][j];
			if(j>=v[i])
				dp[i][j] = min(dp[i][j], w[i]+dp[i+1][j-v[i]]);
		}
	}

	for(int i=100000;i>=0;i--){
		if(dp[0][i] <= W){
			cout<<i<<"\n";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 80128
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
const i64 MOD = 1e9+7;
const i64 INF = 1e18+7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <typename T>
struct Dinic{
    struct Edge{
        int to, rev;
        T cap;
        Edge(int to, T cap, int rev) : to(to), rev(rev), cap(cap){}
    };

    vector<vector<Edge>> edges;
    T _inf;
    vector<T> min_cost;
    vector<int> cnt;

    Dinic(int n) : edges(n), _inf(numeric_limits<T>::max()){}

    void add(int from, int to, T cap){
        edges[from].emplace_back(to, cap, static_cast<int>(edges[to].size()));
        edges[to].emplace_back(from, 0, static_cast<int>(edges[from].size()) - 1);
    }

    bool bfs(int s, int t){
        min_cost.assign(edges.size(), -1);
        queue<int> que;
        min_cost[s] = 0;
        que.emplace(s);
        while(!que.empty() && min_cost[t] == -1){
            int x = que.front();
            que.pop();
            for(auto& ed : edges[x])
                if(ed.cap > 0 && min_cost[ed.to] == -1){
                    min_cost[ed.to] = min_cost[x] + 1;
                    que.emplace(ed.to);
                }
        }
        return min_cost[t] != -1;
    }

    T dfs(int idx, int t, T flow){
        if(idx == t)
            return flow;
        T ret = 0;
        while(cnt[idx] < edges[idx].size()){
            auto& ed = edges[idx][cnt[idx]];
            if(ed.cap > 0 && min_cost[idx] < min_cost[ed.to]){
                T d = dfs(ed.to, t, min(flow, ed.cap));
                ed.cap -= d;
                edges[ed.to][ed.rev].cap += d;
                ret += d;
                flow -= d;
                if(flow == 0)
                    break;
            }
            ++cnt[idx];
        }
        return ret;
    }

    T solve(int s, int t){
        T flow = 0;
        while(bfs(s, t)){
            cnt.assign(edges.size(), 0);
            T f = 0;
            while((f = dfs(s, t, _inf)) > 0)
                flow += f;
        }
        return flow;
    }

};


signed main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(auto& x : s)
        cin >> x;
    unordered_map<string, int> m;
    for(int i = 0; i < n; ++i)
        m[s[i]] = i;

    Dinic<int> d(n + 2);
    for(int i = 0; i < n; ++i){
        if(s[i].size() % 2 == 0)
            d.add(n, i, 1);
        else
            d.add(i, n + 1, 1);
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < s[i].size(); ++j){
            string t = s[i].substr(0, j) + s[i].substr(j + 1);
            if(m.find(t) != m.end()){
                int i1 = i, i2 = m[t];
                if(s[i].size() % 2)
                    swap(i1, i2);
                d.add(i1, i2, 1);
            }
        }
    }
    cout << d.solve(n, n + 1) << endl;
}



Measured memory_bytes: 55712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,k;
signed main()
{
	n=read(),k=read();
	cout<<n-k+1;
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
typedef pair<ll, ll> pll;
ll dp[3005][3005];
int main(){
    int n,t; cin >> n >> t;
    vector<pll> d(n);
    rep(i,n) cin >> d[i].first >> d[i].second;
    sort(ALL(d));
    ll ans = 0;
    rep(i,n){
        rep(j,t){
           dp[i+1][j] = dp[i][j];
           ans = max(ans, dp[i+1][j] + d[i].second);
           if(j >= d[i].first) dp[i+1][j] = max(dp[i+1][j], dp[i][j - d[i].first] + d[i].second); 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int a,b;
int main(){
    string s;
    cin >> a >> b >> s;
    int n = s.size();
    if(n!=(a+b+1)){
        printf("No\n");
        return 0;
    }
    for(int i=0;i<a;i++){
        if(s[i]>='0' && s[i]<='9') continue;
        else {
            printf("No\n");
            return 0;
        }
    }
    if(s[a]!='-'){
        printf("No\n");
        return 0;
    }
    for(int i=a+1;i<n;i++){
        if(s[i]>='0' && s[i]<='9') continue;
        else {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
# solution

data = int(input())

data1 = [input(), input()]

mod = 10**9+7

i = 1 + (data1[0][0] != data1[1][0])

ans = 3 * i

while i < data:
    p = data1[0][i-1] == data1[1][i-1]
    if data1[0][i] == data1[1][i]:
        ans *= 1 + p
        i += 1
    else:
        ans *= 3 - p
        i += 2
    ans %= mod

print(ans)

Measured memory_bytes: 3064
a,b,c,d = map(int, input().split())
t = list()
ac = a*c
bc = b*c
ad = a*d
bd = b*d
t.append(ac)
t.append(bc)
t.append(ad)
t.append(bd)
ans = -1 * 10**18
for i in range(4):
  ans = max(t[i],ans)
print(ans)

Measured memory_bytes: 9184
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const long long int mod=1e9+7;
typedef long long ll;

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

bool issq(int n){
    int i=1;
    while(i*i<=n){
        if(i*i==n){
            return true;
        }
        i++;
    }
    return false;
}
int main(){
    int a;
    cin >>a;
    int ans=3*a*a;
    
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  vector<int> A(N);
  map<int, int> s;
  rep(i,N) {
    cin >> A[i];
    s[A[i]]++;
  }
 
  sort(all(A),greater<int>());
  if (N==1){
    cout << 1 << endl;
    return 0;
  }
  if (s[1]==1){
    cout << 1 << endl;
    return 0;
  }
  else if (s[1]>1){
    cout << 0 << endl;
    return 0;
  } 
  
  int retval = 0;
  rep(i,N){
    bool flag = false;
    if (s[1]>0 || s[A[i]]>1) flag = true;

    for (int j=2;j<=(int)sqrt(A[i]);j++){
      if (A[i]%j==0){
        if (s[j]>0 || s[A[i]/j]>0) flag = true;
      }
    }
    if (flag==false) retval++;
  }
  cout << retval << endl;






  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 32628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = (char)(s[k - 1] + ('a' - 'A'));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 500000

int n;

void maxHeapify(int A[], int i){
  int l,r,largest,temp;
  l = left(i);
  r = right(i);
  if(l <= n && A[l] > A[i]){
    largest = l;
  }
  else 
    largest = i;
  if(r <= n && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    int tmp;
    temp = A[largest];
    A[largest] = A[i];
    A[i] = temp;
    maxHeapify(A, largest);
  }
}

void BuildMaxHeap(int A[]){
  int i;
  for(i=n/2;i >= 1;i--){
    maxHeapify(A,i);
  }
}

/*int parent(int i){
  return i/2;
  }*/

int left(int i){
  if( i > n )return N;
  
  else return 2*i;
}

int right(int i){
  if( i > n )return N;
  
  else return 2*i+1;
}

main(){
  int i,a[N];
  
  scanf("%d",&n);
  for( i = 1 ; i < n+1 ; i++ ){
    scanf("%d",&a[i]);
  }
  
  BuildMaxHeap(a);
  
  for(i=1; i<=n; i++){
    printf(" %d",a[i]);  
  }
  
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;


int main(){
  int r;
  cin >> r;
  if(0<=r&&r<1200){
    cout << "ABC" << endl;
  }
  if(1200<=r&&r<2800){
    cout << "ARC" << endl;
  }
  if(2800<=r){
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

k_subset = [k]
for i in range(len(bin(k)) - 2):
    if (k >> i) & 1:
        x = k & ~(1 << i)  # remove i-th bit
        x = x | ((1 << i) - 1)  # add 1 to j-th bit (j<i)
        k_subset.append(x)

ans = max(sum(b for a, b in ab if a | x == x) for x in k_subset)

print(ans)


Measured memory_bytes: 27300
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int h, w;
     cin >> h >> w;
     vector<string> a(h);
     vector<bool> row(h, false);
     vector<bool> col(w, false);
     rep(i,0,h) cin >> a[i];
    
     rep(i,0,h){
       rep(j,0,w){
         if(a[i][j] == '#'){
           row[i] = true;
           col[j] = true;
         }
       }
     }

     rep(i,0,h){
       if(row[i]){
         rep(j,0,w){
           if(col[j]){
             cout << a[i][j];
           }
         }
         cout << endl;
       }
     }
    
     return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back
#define MP make_pair

using namespace std;

int main(){
	vector<int> v;
	lint n,c,k;
	cin>>n>>c>>k;
	lint l;
	rep(i,0,n){
		cin>>l;
		v.push_back(l);
	}
	sort(v.begin(),v.end());
	lint st,count=0;
	bool TF=true;
	st=v[0];
	lint i=0,ans=1;
	while(i<n){
		if(st<=v[i]&&st+k>=v[i]&&count<c){
			i++;
			count++;
		}
		else{
			st=v[i];
			ans++;
			i++;
			count=1;
		}
	}
	cout<<ans;
return 0;
}

Measured memory_bytes: 892
using System;

namespace AtCoder_1223_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int a = int.Parse(input[1]);
            int b = int.Parse(input[2]);
            int sum = 0;
            int total = 0;

            for (int i = 0; i <= n; i++){
                int tmp = i;
                for (int k = 0; k <= 4; k++){
                    sum += tmp % 10;
                    tmp /= 10;
                }
                if (sum >= a && sum <= b)
                {
                    total += i;
                }
                sum = 0;
            }

            Console.WriteLine(total);
        }
    }
}


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

using namespace std;

constexpr int MOD = 1e9 + 7;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i=0; i<h; i++) cin >> s.at(i);
  
  vector<vector<int>> dp(h, vector<int>(w));
  dp.at(0).at(0) = 1;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s.at(i).at(j) == '#') continue;
      if (i != 0) dp.at(i).at(j) += dp.at(i-1).at(j);
      if (j != 0) dp.at(i).at(j) += dp.at(i).at(j-1);
      dp.at(i).at(j) %= MOD;
    }
  }
  
  cout << dp.at(h-1).at(w-1) << endl;
  return 0;
}


Measured memory_bytes: 5248
n, m = list(map(int, input().split()))
ps = [input().split() for _ in range(m)]

re = [[] for _ in range(n)]

for p, s in ps:
  p = int(p) - 1
  re[p].append(s)

po = 0
pe = 0

for r in re:
  temp_pe = 0
  for x in r:
    if x == 'AC':
      po += 1
      pe += temp_pe
      break
    else:
      temp_pe += 1

print(po, pe)


Measured memory_bytes: 44004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int count = b / a;
			if (count > c) {
				System.out.println(c);
			} else {
				System.out.println(count);
			}
		}
	}
}

Measured memory_bytes: 23636
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let S = readLine()!.split("/")
let y = S[0]
let m = S[1]
let d = S[2]

var result = "TBD"
if y < 2019 {
    result = "Heisei"
} else if y == 2019 {
    if m < 4 {
        result = "Heisei"
    } else if m == 4 {
        if d <= 30 {
            result = "Heisei"
        }
    }
}

print(result)

Measured memory_bytes: 7904
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;

int main(){
    ll n, p;
    cin >> n >> p;

    map<ll,ll> cnt;
    for(ll i = 2; i*i <= p; i++){
        while(p%i == 0) p /= i, cnt[i]++;
    }
    if(p != 1)  cnt[p]++;

    ll ans = 1;
    for(auto p : cnt){
        if(p.second >= n){
            ll times = p.second/n;
            while(times-- > 0)  ans *= p.first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256