akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {

	int c[9];
	for(int i=0;i<9;i++) cin>>c[i];

	for(int a1 = 0; a1 <= 100; a1++) {
		int b1 = c[0] - a1;
		int b2 = c[1] - a1;
		int b3 = c[2] - a1;
		int a2 = c[3] - b1;
		int a3 = c[6] - b1;
		if(c[4] != a2 + b2) continue;
		if(c[5] != a2 + b3) continue;
		if(c[7] != a3 + b2) continue;
		if(c[8] != a3 + b3) continue;
		cout<<"Yes"<<endl;
		return 0;
	}

	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

n, d = list(map(int, input().split()))
x_list = [list(map(int, input().split())) for _ in range(n)]


def calc_distance(x_list1, x_list2):
    return math.sqrt(sum([(x1 - x2)**2 for x1, x2 in zip(x_list1, x_list2)]))


ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tmp = calc_distance(x_list[i], x_list[j])
        if tmp == int(tmp):
            ans += 1

print(ans)


Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x1, y1, x2, y2 = MAP()

dx = x2 - x1
dy = y2 - y1

x3, y3 = x2 - dy, y2 + dx
x4, y4 = x3 - dx, y3 - dy


print(x3, y3, x4, y4) 



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

#define INFTY (1 << 30);
typedef long long ll;

int main(void) {
  int H, W;
  cin >> H >> W;
  int h, w;
  cin >> h >> w;

  cout << H*W-W*h-w*H+h*w << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,ans=0;
    cin>>N;
    vector<vector<ll>> v(N,vector<ll> (N));
    vector<vector<bool>> f(N,vector<bool> (N));
    for(ll i=0;i<N;i++){
        for(ll j=0;j<N;j++){
            cin>>v[i][j];
            f[i][j]=true;
        }
    }
    for(ll k=0;k<N;k++){
        for(ll i=0;i<N;i++){
            for(ll j=0;j<N;j++){
                if(v[i][j]>v[i][k]+v[k][j]){
                    cout<<"-1"<<endl;
                    return 0;
                }
                if(i==k||j==k) continue;
                if(v[i][j]==v[i][k]+v[k][j]){
                    f[i][j]=false;
                }
            }
        }
    }
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<N;j++){
            if(f[i][j]) ans+=v[i][j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        
        if(a < b  && a < c && b < c){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int n;
vector<int> prime;
bool is_prime[100000];
vector<int> ans;
int main(){
  cin >> n;
  fill(is_prime, is_prime + 100000, true);
  
  for(int i = 2; i < 100000; i++){
    if(is_prime[i]){
      prime.push_back(i);
      int j = 2;
      while(i * j < 100000){
        is_prime[i*j] = false;
        j++;
      }
    }
  }
  for(int x : prime){
    if(x%5==1 && x <= 55555) ans.push_back(x);
  }
  rep(i, n) printf("%d%c", ans[i], i == n-1 ? '\n': ' ');
}
    
    
  

Measured memory_bytes: 3932
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

lint rangecount(lint X,lint Y,lint* A,lint N){
  if(X>Y) swap(X,Y);
  return upper_bound(A,A+N,Y)-lower_bound(A,A+N,X);
}

int main(void){
  lint N;
  cin >> N;
  lint L[N];
  rep(i,N) cin >> L[i];
  sort(L,L+N);
  lint ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      lint sum=L[i]+L[j],dis=L[j]-L[i];
      lint add=rangecount(dis+1,sum-1,L,N);
      if(L[i]>dis && L[i]<sum) add--;
      if(L[j]>dis && L[j]<sum) add--;
      ans+=max(0LL,add);
    }
  }
  cout << ans/3 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int n = Integer.parseInt(strArr[0]) - 1;
            int m = Integer.parseInt(strArr[1]) - 1;
            System.out.println(n * m);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}


Measured memory_bytes: 21076
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;

    int x = b / k * k;
    if(a <= x)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;

    return 0;
}


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

int main(void)
{
    int x, n; cin >> x >> n;
    vector<int> cnt(102, 0);
    int p;
    for (int i = 0; i < n; i++)
    {
        cin >> p;
        cnt[p]++;
    }
    int ans;
    for (int i = 0; i < 51; i++)
    {
        if (cnt[x - i] == 0) 
        {
            ans = x - i; break;
        }
        if (cnt[x + i] == 0) 
        {
            ans = x + i; break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
int main(){
  long long int a[5];
  for(int i=0;i<4;i++){
  	cin >> a[i];
 }

long long int x,b,c,d;

x = a[0] * a[2];
b = a[0] * a[3];
c = a[1] * a[2];
d = a[1] * a[3];

if( x > b & x > c & x >d){
	cout << x << endl;
}else if( b > x & b > c & b > d){
	cout << b << endl;
}else if(c > x & c > b & c > d){
	cout << c << endl;	
}else{
	cout << d << endl;
}
 
return 0;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, m, c[N], idx[N], p[N];
V<int> e[N], re[N], v;
void tsort(){
  queue<int> q;
  FOR(i, 0, n) if(!c[i]) q.push(i);
  while(!q.empty()){
    int a = q.front(); q.pop();
    v.pb(a);
    for(int b:e[a]){
      c[b]--;
      if(!c[b]) q.push(b);
    }
  }
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n+m-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[a].pb(b);
    re[b].pb(a);
    c[b]++;
  }
  tsort();
  reverse(all(v));
  FOR(i, 0, n) idx[v[i]] = i;
  FOR(i, 0, n){
    int mi = IINF;
    for(int a:re[v[i]]){
      if(idx[a] < mi){
        mi = idx[a];
        p[v[i]] = a+1;
      }
    }
  }
  FOR(i, 0, n) printf("%d\n", p[i]);
}


Measured memory_bytes: 13436
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll k,n;
    cin>>k>>n;
    V a(n);
    rep(i,n)cin>>a[i];
    V d;
    rep(i,n-1)d.push_back(a[i+1]-a[i]);
    d.push_back(a[0]+k-a[n-1]);
    sort(d.begin(), d.end());
    cout<<accumulate(d.begin(), d.end()-1, 0LL)<<endl;
}


Measured memory_bytes: 3956
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

long double dist (int x1, int y1, int x2, int y2) {
    long double a = (x1 - x2) * (x1 - x2);
    long double b = (y1 - y2) * (y1 - y2);

    return sqrt(a + b);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    vi v(N);
    REP(i, N) v[i] = i;

    long double ans = 0;
    ll cnt = 0;
    do {
        REP(i, N - 1) {
            ans += dist(x[v[i]], y[v[i]], x[v[i + 1]],  y[v[i + 1]]);
        }
        cnt++;

    } while(next_permutation(ALL(v)));


    print(ans / cnt);
}


Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

string str;

bool c (map<char,int> m) {
    for (auto i = m.begin(); i !=  m.end(); i++) {
        if (i->second != 0) return false;
    }
    return true;
}

bool dfs(map<char,int> m) {
    if (c(m)) return true;
    for (char i = '1'; i <= '9'; i++) {
        if (m[i] >= 3) {
            m[i] -= 3;
            if (dfs (m)) return true;;
            m[i] += 3;
        }
        if (i + 2 <= '9' && m[i] > 0 && m[i+1] > 0 &&  m[i+2] > 0) {
            m[i]--; m[i + 1]--; m[i + 2]--;
            if (dfs(m)) return true;
            m[i]++; m[i + 1]++; m[i + 2]++;
        }
    }
    return false;
}

int main ()
{
    while (cin >> str) {
        map<char,int> m;
        for (char i = '1' ; i <= '9'; i++) m[i] = 0;
        for (int i = 0; i < str.size(); i++) {
            m[str[i]]++;
        }

        vector<char> res;
        for (char i = '1'; i <= '9'; i++) {
            if (m[i] >= 4) continue;
            m[i]++;
            for (char j = '1'; j <= '9'; j++) {
                if (m[j] >= 2) {
                    m[j] -= 2;
                    if (dfs(m)) {
                        res.push_back(i);
                        m[j] += 2;
                        break;
                    }
                    m[j] += 2;
                }
            }
            m[i]--;
        }
        if (res.size()) {
            cout << res[0];
            for (int i = 1; i < res.size(); i++) cout << " " << res[i];
        } else cout << 0;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  return b==0?a:gcd(b,a%b);
}
int main(){
  int x,y;
  cin>>x>>y;
  cout<<x+y+1-gcd(x,y)<<endl;
  return 0;
}



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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

const int N = 105;

int n, m;
char a[N][N];
int dp[N][N];

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            dp[i][j] = inf;

    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i + 1 < n) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (a[i][j] != a[i + 1][j]));
            }
            if (j + 1 < m) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (a[i][j] != a[i][j + 1]));
            }
        }
    }

    int w = dp[n - 1][m - 1];

    if (a[0][0] == a[n - 1][m - 1]) {
        cout << w / 2 + (a[0][0] == '#') << "\n";
    } else {
        cout << (w + 1) / 2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

int main(){

    int n,soma=0,a,b;

    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        soma=soma+(b-a);
    }
    soma+=n;

    printf("%d\n",soma);


    return 0;
}

Measured memory_bytes: 128
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();

    LL t,n,i,j,k,x,y,c,m;
    string str, str1;
    cin >> str >> str1;
    c = 0;
    REP(i, str.size()){
        if(str[i] == str1[i]){
            ++c;
        }
    }
    cout << c;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;

  int ans = a + b;
  if (a-b > ans) ans = a-b;
  if (a*b > ans) ans = a*b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main () {
  int a, b, c, n;
  scanf("%d %d %d",&a, &b, &c);
  if(a > b) {
    n = a;
    a = b;
    b = n;
  }
  if(a>c){
    n = a;
    a = c;
    c = n;
  }
  if(b>c){
    n = b;
    b = c;
    c = n;
  }
  printf("%d %d %d\n",a, b, c);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        string o, t;
        in >> o >> t;
        out << (o[0] == t[0] ? '=' : o[0] > t[0] ? '>' : '<') << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<iostream>
#include<unordered_map>

using namespace std;

 int a[30];

int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++)
  {
    a[(int)(s[i]-'a')]++;
  }
  for(int i=0;i<30;i++){
    if(a[i]>1){
      cout<<"no"<<endl;
      return 0;
    }
  }
  cout<<"yes"<<endl;
  
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int ddy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    vstr s(h);
    rep(i, h)
        cin >> s[i];

    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#')  continue;

            int cnt=0;
            rep(k, 8){
                int dY = i+ddy[k];
                int dX = j+ddx[k];
                if(dY<0 or dX<0 or h<=dY or w<=dX) continue;
                if(s[dY][dX] == '#') cnt++;
            }
            s[i][j] = char(cnt + '0');
        }
    }

    rep(i, h){
        ppp(s[i]);
    }




    return 0;
}


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

int main(int argc, const char * argv[]) {
    int X;
    
    cin >> X;
    
    if (X == 7 || X == 5 || X == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c,i,num=0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for(i=a;i<=b;i++){
		if(c%i==0) num+=1;
		else num+=0;
	}
	printf("%d\n", num);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    char f;
    int w[51],b[51],r[51];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int a=0,d=0,c=0;
        for(int j=0;j<m;j++){
            cin>>f;
            if(f!='W')a++;
            if(f!='B')d++;
            if(f!='R')c++;
        }
        w[i]=a,b[i]=d,r[i]=c;
    }
    for(int i=1;i<n;i++){
        w[i]+=w[i-1];
        b[i]+=b[i-1];
    }
    for(int i=n-2;i>=0;i--){
        r[i]+=r[i+1];
    }
    int ans=10000;
    for(int i=1;i<n-1;i++){
        for(int j=i;j<n-1;j++){
            ans=min(ans,w[i-1]+b[j]-b[i-1]+r[j+1]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1160
import math

a, b, x = map(int, input().split())
s = a*a*b

if x*2 <= s:
    tan = (a * b * b) / (2 * x)
else:
    tan = (2 * (a * a * b - x)) / (a * a * a)

sita = math.degrees(math.atan(tan))
print(sita)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
inc = 1
dec = 1
ans = 1
for i in range(N-1):
    if A[i] > A[i+1]:
        inc = 0
    elif A[i] < A[i+1]:
        dec = 0
    if inc == 0 and dec == 0:
        ans += 1
        inc = 1
        dec = 1
print(str(ans))

Measured memory_bytes: 62840
type obj = Op of string | Num of int

let rev_split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  doit str []

let str_fold_left f init str =
  let n = String.length str - 1 in
  let rec doit i acc =
    if i > n then acc
    else doit (i + 1) (f acc str.[i])
  in
  doit 0 init

let num_p s =
  str_fold_left (fun acc c -> acc && (c >= '0' && c <= '9')) true s

let read lst =
  let rec doit acc = function
    | [] -> acc
    | n :: tl when num_p n -> doit (Num (int_of_string n) :: acc) tl
    | op :: tl -> doit (Op op :: acc) tl
  in
  doit [] lst

let calc lst =
  let rec doit acc = function
    | [] -> acc
    | Op op :: tl -> begin
        match acc with
        | Num x :: Num y :: z -> begin
            if op = "+" then doit (Num (y + x) :: z) tl
            else if op = "-" then doit (Num (y - x) :: z) tl
            else doit (Num (y * x) :: z) tl
          end
        | _ -> exit 1
      end
    | Num n :: tl -> doit (Num n :: acc) tl
  in
  match doit [] lst with
  | [Num n] -> n
  | _ -> exit 1

let _ =
  let lst = read (rev_split (read_line ()) ' ') in
  Printf.printf "%d\n" (calc lst)

Measured memory_bytes: 2364
#include <algorithm>
#include <cstdio>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int X, Y, Z, K;
  scanf("%d %d %d %d", &X, &Y, &Z, &K);
  long long A[X], B[Y], C[Z];
  for (int i=0; i<X; i++) scanf("%lld", &A[i]);
  for (int i=0; i<Y; i++) scanf("%lld", &B[i]);
  for (int i=0; i<Z; i++) scanf("%lld", &C[i]);

  sort(A, A+X, greater<long long>());
  sort(B, B+Y, greater<long long>());
  sort(C, C+Z, greater<long long>());

  vector<long long> v;
  for (int i=0; i<X; i++) {
    for (int j=0; j<Y; j++) {
      for (int k=0; k<Z; k++) {
          if ((i+1) * (j+1) * (k+1) > K) break;
          v.push_back(A[i] + B[j] + C[k]);
      }
    }
  }
  sort(v.begin(), v.end(), greater<long long>());
  for (int i=0; i<K; i++) {
    printf("%lld\n", v[i]);
  }
}


Measured memory_bytes: 1400
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a)
{
    for(LL i=2; i*i<=a; i++)
    {
        if(a%i==0)
            return false;
    }
    return true;
}
bool palin(string a)
{
    for(int i=0; i<a.sz; i++)
    {
        if(a.at(i)!=a.at(a.sz-i-1))
            return 0;
    }
    return 1;
}
bool isVowel(char ch)
{
    ch=toupper(ch);
    if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E')
        return true;
    return false;
}
int toInt(string s)
{
    int sm;
    stringstream ss(s);
    ss>>sm;
    return sm;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)
        return gcd(-a,b);
    if(b<0)
        return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)
        return lcm(-a,b);
    if(b<0)
        return lcm(a,-b);
    return a*(b/gcd(a,b));
}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n>>m)
    {
        vi a[n];
        rep(i,n)
        {
            rep(j,m)
            {
                cin>>x;
                a[i].pb(x);
            }
        }
        s=0;
        double d;
        rep(k,n)
        {
            for(i=k+1; i<n; i++)
            {
                d=0;
                rep(j,m)
                {
                    x=abs(a[i][j]-a[k][j]);
                    x=x*x;
                    d+=x;
                }
                d=sqrt(d);
                x=floor(d),y=ceil(d);
                if(x==y)
                {
                    s++;
                }
            }
        }
        cout<<s<<en;
    }
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int x,i,max=1;
  scanf("%d",&x);
  for(i=2;i<=sqrt(x);i++){
    int a=i*i;
    while(a*i<=x)
      a=a*i;
    if(a>max)
      max=a;
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

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

	vector<LL> v(26, 0);

	REP(i, s.size()) {
		v[s[i] - 'a']++;
	}

	LL sum = 1 + s.size()*(s.size() - 1) / 2;

	REP(i, 26) {
		sum -= v[i] * (v[i] - 1) / 2;
	}

	cout << sum << endl;
}

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

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s;
    char a;
    int cnt[];
    cnt=new int[26];
    while(true){
      s=sc.next();
      s=s.toLowerCase();
      for(int i=0;i<s.length();i++){
        a=s.charAt(i);
        if(a>='a' && a<='z') cnt[a-'a']++;
      }
      if(!(sc.hasNext())) break;
    }
    char abc='a';
    for(int i=0;i<26;i++){
      System.out.println((char)(abc+i)+" : "+cnt[i]);
    }
  }
}



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

#define print cout <<
#define printl(s) cout << s << endl;
#define prif(s) cout << s << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

const string yes = "Yes";
const string no = "No";

string S;
int N, cnt;

int main(){
  cin >> N;
  rep2(i, 9){
    rep2(j,9){
      if(i*j==N){
        prif(yes);
      }
      }
    }
  prif(no);
}


Measured memory_bytes: 3640
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    h,w = LI()
    a = SR(h)
    d = [(1,0),(0,1)]
    bfs = [[1]*w for i in range(h)]
    for y in range(h):
        for x in range(w):
            if a[y][x] == "#":
                bfs[y][x] = 0
                q = deque([(y,x)])
                while q:
                    i,j = q.popleft()
                    k = 0
                    for dy,dx in d:
                        ni = i+dy
                        nj = j+dx
                        if 0 <= ni < h and 0 <= nj < w:
                            if a[ni][nj] == "#":
                                if k:
                                    print("Impossible")
                                    return
                                k = 1
                                bfs[ni][nj] = 0
                                q.append((ni,nj))
                for i in range(h):
                    for j in range(w):
                        if a[i][j] == "#" and bfs[i][j]:
                            print("Impossible")
                            return
                print("Possible")
                return
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39024
kr :: [Int] -> [Int] -> Int
kr [x] _ = 0
kr a c = if a!!0 + 1 == a!!1 then c !! (a!!0 - 1) + kr (tail a) c else kr (tail a) c

main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    b <- map read . words <$> getLine :: IO [Int]
    c <- map read . words <$> getLine :: IO [Int]
    print $ sum b + kr a c


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool check(vector<int>& d, int n) {
    while (n > 0) {
        int digit = n % 10;
        n /= 10;
        if (find(d.begin(), d.end(), digit) != d.end()) {
            return true;
        }
    }
    return false;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    for (int& dd : d) {
        cin >> dd;
    }
    int nn = n;
    while (check(d, nn)) {
        nn += 1;
    }
    cout << nn << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++)
      A[i] = sc.nextInt();
    sc.close();

    int k = 0;
    for (int i = 0; i < N; i++)
      k += A[i] == k + 1 ? 1 : 0;

    int ans = k == 0 ? -1 : N - k;
    System.out.println(ans);
  }
}

Measured memory_bytes: 64700
import java.util.Scanner;

public class Main {
	//static Map<Long,Long>map=new TreeMap<>();
	static int k;
	static String ans="NO";
    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int a=sc.nextInt();
       int b=sc.nextInt();
       int c=sc.nextInt();
       for(int i=1;i<=b;i++) {
    	   if(a*i%b==c)ans="YES";
       }
       System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include<stdio.h>

int main()
{
  int H,i,A[100001];//１オリジンだから＋１

  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if( i/2 >= 1 ) printf("parent key = %d, ",A[i/2]);
    if( 2*i <= H ) printf("left key = %d, ",A[2*i]);
    if( 2*i + 1 <= H ) printf("right key = %d, ",A[2*i + 1]);

    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2108
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 7;
//-------head---------
const int dx[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
const int dy[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
int h, w, n;
set<pii> S;
set<pii>::iterator it;
ll ans[10];
int calc(int sx, int sy) {
	int ret = 0;
	rep(i, 0, 9) {
		int x, y;
		x = sx + dx[i];
		y = sy + dy[i];
		if (S.find(mp(x, y)) != S.end())
			++ret;
	}
	return ret;
}
void solve() {
	for (it = S.begin(); it != S.end(); ++it) {
		rep(i, 0, 9) {
			int x, y;
			x = it->first + dx[i];
			y = it->second + dy[i];
			if (x < 2 || x > h - 1 || y < 2 || y > w - 1)
				continue;
			++ans[calc(x, y)];
		}
	}
	ans[0] = 1ll * (h -2) * (w - 2);
	rep(i, 1, 10) {
		ans[i] /= i;
		ans[0] -= ans[i];
	}
}
int main() {
	cin >> h >> w >> n;
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		S.insert(mp(a, b));
	}
	solve();
	rep(i, 0, 10)
		cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#define maxn 100010
struct node{
	int to,next;
}e[maxn<<1];
int h[maxn],head[maxn],tot,cnt;
void add_edge(int u,int v){
	tot++,e[tot].to=v,e[tot].next=head[u],head[u]=tot;
}
int main(){
	int n,m,u,v,i,b,flag1,flag2;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",&h[i]);
	for(i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
	for(i=1;i<=n;i++){
		flag1=0,flag2=0;
		for(b=head[i];b;b=e[b].next){
			flag1=1,v=e[b].to;
			if(h[i]<=h[v]){flag2=1;break;}
		}
		if(!flag1)cnt++;
		else if(!flag2)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll k,a,b;

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

  cin>>k>>a>>b;
  ll res=0;
  if(b-a>2&&k>=a-1){
    ll rest=(k-(a-1));
    res=a+(rest/2)*(b-a)+(rest%2);
  }else{
    res=k+1;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

using namespace std;

#ifdef superset
  #include <ext/pb_ds/assoc_container.hpp>
  #include <ext/pb_ds/tree_policy.hpp>
  #include <ext/pb_ds/detail/standard_policies.hpp>

  using namespace __gnu_pbds;
  typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 5e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int get_int() {
  char x = getchar();
  bool mns = 0;
  while (!isdigit(x)) mns |= x == '-', x = getchar();
  int res = 0;
  while (isdigit(x)) res = res * 10 + x - '0', x = getchar();
  if (mns) res = -res;
  return res;
}
void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
int mult(int x, int y) {
  return x * 1ll * y % mod;
}
int sum(int x, int y) {
  add(x, y);
  return x;
}

int a, b, c, d, e, f;
ld need;
ld calc(int x, int y) {
  return (100 * y) / (ld)(x + y);
}
map <ll, bool> g1, g2;
ld mx = -1;
int ax, ay;
void solve() {
  cin >> a >> b >> c >> d >> e >> f;
  a *= 100;
  b *= 100;
  ax = a;
  rep(i, 0, inf) {
    if (i * a > f) break;
    rep(j, 0, inf) {
      if (i * a + j * b <= f) g1[i * a + j * b] = 1;
      else break;
    }
  }
  rep(i, 0, inf) {
    if (i * c > f) break;
    rep(j, 0, inf) {
      if (i * c + j *d <= f) g2[i * c + j * d] = 1;
      else break;
    }
  }
  need = (ld)100 / e;
  rep(i, 1, f) {
    rep(j, 1, i) {
      if (i + j <= f && (j <= (i / 100) * e) && g1[i] && g2[j]) {
        if (calc(i, j) > mx) {
          mx = calc(i, j);
          ax = i, ay = j;
        }
      }
    }
  }
  cout << ax + ay << ' ' << ay;
}
int main() {
  #ifdef IOI2018
    #define Toktama ""
    freopen (Toktama".in", "r", stdin);
    //freopen (Toktama".out", "w", stdout);
  #endif
  int T = 1;
  while (T--)
    solve();
  ioi
}


Measured memory_bytes: 640
from math import gcd
n = int(input())
a = list(map(int,input().split()))
l,r = [a[0]]*n,[a[n-1]]*n
for i in range(1,n-1):
  l[i] = gcd(l[i-1],a[i])
  r[n-i-1] = gcd(r[n-i],a[n-i-1])
ans = [0]*n
ans[0] = r[1]
ans[n-1] = l[n-2]
for i in range(1,n-1):
  ans[i] = gcd(l[i-1],r[i+1])
print(max(ans))

Measured memory_bytes: 24812
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[][] w = new int[2 * k][2 * k];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            char c = sc.next().charAt(0);
            if (c == 'W') {
                w[x % (2 * k)][y % (2 * k)]++;
            } else {
                w[(x + k) % (2 * k)][y % (2 * k)]++;
            }
        }
        sc.close();

        // 累積和
        int[][] s = new int[2 * k + 1][2 * k + 1];
        for (int i = 1; i <= 2 * k; i++) {
            for (int j = 1; j <= 2 * k; j++) {
                s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + w[i - 1][j - 1];
            }
        }

        // 塗り方を全通り試す
        int max = 0;
        for (int i = 0; i < k; i++) {
            for (int j = 0; j < k; j++) {
                int m = sum(s, k, i, j);
                max = Math.max(Math.max(max, m), n - m);
            }
        }
        System.out.println(max);
    }

    // 矩形領域 
    // x \in [x1, x2), y \in [y1, y2) 
    // でのw[x][y]の和
    public static int rectSum(int[][] s, int x1, int y1, int x2, int y2) {
        return s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1];
    }

    // 矩形領域 
    // D1: x \in [0, i),         y \in [0, j)
    // D2: x \in [i, i + k),     y \in [j, j + k)
    // D3: x \in [0, i),         y \in [j + k, 2 * k)
    // D4: x \in [i + k, 2 * k), y \in [0, j)
    // D5: x \in [i + k, 2 * k), y \in [j + k, 2 * k)
    // のそれぞれでのw[x][y]の和を足し合わせる
    public static int sum(int[][] s, int k, int i, int j) {
        int sum = 0;
        sum += rectSum(s, 0, 0, i, j);
        sum += rectSum(s, i, j, i + k, j + k);
        sum += rectSum(s, 0, j + k, i, 2 * k);
        sum += rectSum(s, i + k, 0, 2 * k, j);
        sum += rectSum(s, i + k, j + k, 2 * k, 2 * k);
        return sum;
    }
}


Measured memory_bytes: 105932
import numpy as np
N, K = [int(i) for i  in input().split()]
A= [int(i) for i  in input().split()]
A=np.array(A)
ans =0
for i in range(N):
    ans += np.count_nonzero(A[:i]<A[i])*K*(K-1)//2
    ans += np.count_nonzero(A[i+1:]<A[i])*K*(K+1)//2

print(ans%1000000007)

Measured memory_bytes: 12504
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int n,m;
char a;
int main()
{
	cin>>a;
	cout<<char(a+1)<<endl;
}

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    int x, y, z;
    cin >> x >> y >> z;

    cout << z  << " " << x << " " << y << endl;


    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String ans = "No";
		if(N == M){
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
console.log((args=>{
  let N = args.trim()|0;
  if ( !N ) return '0';
  let s = [];
  while ( N ) {
    s.push(N&1);
    N = (N&~1) / -2;
  }
  return s.reverse().join``;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 29556
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = n;
    REP(i,1,n) {
        if (s[i] == s[i-1]) continue;
        ans = min(ans, max(i, n - i));
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
typedef pair<ll,P> lP;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

template <class T>struct PairingHeap{
    struct node{
        T key;
        node *head,*next;
        explicit node(T key):key(key),head(nullptr),next(nullptr){}
    };
    node *r;
    PairingHeap():r(nullptr){}
    PairingHeap(node* r):r(r){}
    node* merge(node *a,node *b){
        if(!a||!b) return a?a:b;
        if(a->key<b->key){
            b->next=a->head,a->head=b;
            return a;
        }
        else{
            a->next=b->head,b->head=a;
            return b;
        }
    }
    node* mergelist(node *s){
        if(!s) return nullptr;
        node h((T()));
        while(s){
            node *a=s,*b=nullptr;
            s=s->next;a->next=nullptr;
            if(s) b=s,s=s->next,b->next=nullptr;
            a=merge(a,b);a->next=h.next;
            h.next=a;
        }
        node *t=h.next;
        s=t;
        t=t->next;
        while(t){
            node *u=t;
            t=t->next;
            s=merge(s,u);
        }
        return s;
    }
    T top(){
        if(!r) return numeric_limits<T>::min();
        return r->key;
    }
    void pop(){
        if(!r) return;
        r=mergelist(r->head);
    }
    void push(T k){r=merge(r,new node(k));}
    bool empty(){return !r;}
};

int main(){
    ll x,y,z,k,a[1010],b[1010],c[1010],ans,S,X,Y,Z,cnt=0;
    cin>>x>>y>>z>>k;
    fr(i,x) cin>>a[i];
    fr(i,y) cin>>b[i];
    fr(i,z) cin>>c[i];
    sort(a,a+x);
    sort(b,b+y);
    sort(c,c+z);
    reverse(a,a+x);
    reverse(b,b+y);
    reverse(c,c+z);
    ans=a[0]+b[0]+c[0];
    ifr(i,x) a[i]=a[0]-a[i];
    ifr(i,y) b[i]=b[0]-b[i];
    ifr(i,z) c[i]=c[0]-c[i];
    PairingHeap<PP> pq;
    pq.push(mp(mp(0,0),mp(0,0)));
    map<lP,bool> lPb;
    while(cnt<k){
        PP pp=pq.top();
        pq.pop();
        if(lPb[mp(pp.ft.sd,pp.sd)]) continue;
        cout<<ans-pp.ft.ft<<endl;
        cnt++;
        lPb[mp(pp.ft.sd,pp.sd)]=1;
        S=pp.ft.ft;X=pp.ft.sd;Y=pp.sd.ft;Z=pp.sd.sd;
        if(X<x-1) pq.push(mp(mp(a[X+1]+b[Y]+c[Z],X+1),mp(Y,Z)));
        if(Y<y-1) pq.push(mp(mp(a[X]+b[Y+1]+c[Z],X),mp(Y+1,Z)));
        if(Z<z-1) pq.push(mp(mp(a[X]+b[Y]+c[Z+1],X),mp(Y,Z+1)));
    }
}


Measured memory_bytes: 1152