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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vec<ll> a(n);
    REP(i, n) {
        cin >> a[i];
    }

    rep(i, k, n) {
        if(a[i - k] < a[i]) {
            cout << "Yes" << en;
        } else {
            cout << "No" << en;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


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

#define int long long

int32_t main(){
	string s , t ;
	cin >> s >> t ;
	int ans = 0 ;
	for(int i = 0 ; i < s.size() ; i++)
		ans += s[i] != t[i] ;
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        map<string, ll> mp;
        rep(i, 0, N) {
                string s;
                cin >> s;
                mp[s]++;
        }

        printf("AC x %lld\n", mp["AC"]);
        printf("WA x %lld\n", mp["WA"]);
        printf("TLE x %lld\n", mp["TLE"]);
        printf("RE x %lld\n", mp["RE"]);
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

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

	string  s;
	cin>>s;

	if(s[2] ==s[3] && s[4] == s[5]){
		cout<<"Yes"<<endl;
	}else {
		cout<<"No"<<endl;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

static const int N = 100;
static const int INF = (1 << 21);

int n, M[N][N];
int d[N]; //頂点のコスト

void bfs(int s) {
	queue<int > q;
	q.push(s);
	for (int i = 0; i < n; i++) {
		d[i] = INF;
	}
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u= q.front();
		q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0) continue;
			if (d[v] != INF) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INF) ? (-1) : d[i]) << endl;
	}
}

int main(void) {
	int u, k, v; //頂点番号、出次数、隣接リスト
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;

  ll x=n%k;
  cout<<min(abs(x-k),x);
return 0;
}


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

#define all(x)            (x).begin(), (x).end()
#define sz(x)             (int)x.size()
#define len(x)            (int)x.length()
#define ac(x, i)          get<i>(x)
#define pb                push_back
#define mp                make_pair
#define ff                first
#define ss                second
#define trace(x)          cerr << #x << ": " << x << "\n"
#define trav0(a, n)       cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trav1(a, n)       cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trap0(a, n)       cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define trap1(a, n)       cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define travMap(a)        cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << "(" << i.ff << ", " << i.ss << "), "; cerr << "]\n"
#define traverse(a)       cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << i << ", "; cerr << "]\n"
#define random_permute(x) shuffle(all(x), mt)

typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<int, int> mapii;
typedef map<ll, ll> mapll;
typedef map<ll, int> mapli;
typedef unordered_map<int, int> umapii;
typedef unordered_map<ll, int> umapli;
const int infi = 1e9;
const ll infl = 1e18;
const int MOD = 1e9 + 7;
template <typename Map> bool map_compare (Map const &lhs, Map const &rhs) { return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());}
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 mt(seed);
int randint(int p = MOD) { return mt() % p;}
ll randlong(ll p = infl) { return mt() % p;}
ll log_2 (ll n) { return (n > 1ll)? 1ll + log_2(n/2): 0ll;}
inline void add(ll&a, ll b) {a += b; if (a >= MOD) a -= MOD;}
inline void sub(ll&a, ll b) {a -= b; if (a < 0) a += MOD;}
template <class T>
struct cmp { // for priority_queue
  bool operator() (const T& x, const T& y) const {
    return x > y; // edit here
  }
  typedef T first_argument_type;
  typedef T second_argument_type;
  typedef bool result_type;
};

signed main() {
#ifdef HP
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  string s;
  cin >> s;
  bool c= false;
  for (auto i : s) {
    if (i == '7') c = true;
  }
  if (c) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long a=scan.nextLong();
        long b=scan.nextLong();
        long c=scan.nextLong();
        long d=scan.nextLong();
        long ans1=a*c;
        long ans2=b*d;
        long ans4=b*c;
        long ans3=a*d;
        System.out.print(Math.max(Math.max(ans1,ans3),Math.max(ans2,ans4)));
    }
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int n = a * 100 + b * 10 + c;
    cout << (n % 4 == 0 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
case = []

for i in range(500):
  tmp = i * i
  case.append(tmp)

t = input()
a = str(t.split(' ')[0])
b = str(t.split(' ')[1])

x = int(a + b)

def search():
  for y in case:
    if y == x:
      return 'Yes'
  return 'No'

result = search()

print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	ll A, B, N;
	cin >> A >> B >> N;

	ll x = ((B-1) > N) ? N : B-1;
	ll result = (A*x/B) - A * (x/B);
	cout << result << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    string W,w,T,Z;
    
    N = 0;
    cin >> W;
    
    Z = "END_OF_TEXT";
    while(1){
        cin >> T;
      
        if(T == Z)break;
    
        transform(T.begin(), T.end(), T.begin(), ::tolower);
      
        if(T == W )N++;
        //N+=(T==W);
    }
    
    cout << N << endl;
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
int s, t,maxa =0;
cin >> s>>t;
for(int i=0;i <t;i++){
int a;
cin >> a;
maxa=max(maxa,a);
}

s -= maxa;
cout << max(maxa-s-1,0)<<endl;
return 0;
}

Measured memory_bytes: 256
import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

def roundup(n):
    return int(math.ceil(n /10)) * 10
def get_digit(number):
    return number % 10   
s = 0
m = []
li = [A, B, C, D, E]
for i in range(len(li)):
    if get_digit(li[i]) >= 1:
        m.append(get_digit(li[i]))
f = False
m.sort()        
for l in range(len(li)):
    if len(m) > 0:
        if m[0] == get_digit(li[l]) and f == False:
            s += li[l]
            f = True
        else:
            s += roundup(li[l])
            # print(roundup(li[l]))
    else:
        s =sum(li)
print(s)

Measured memory_bytes: 9048
n,k = map(int,input().split())

# okasi = k * [0]
sunuke = n * [0]
ans = 0

for i in range(k):
    a = input()
    l = list(map(int,input().split()))
    
    for j in l:
        sunuke[j-1] = j

for k in sunuke:
    if k == 0:
        ans = ans + 1

print(ans)


Measured memory_bytes: 9188
//
//  main.cpp
//  CompetitiveProgramming
//
//  Created by Yuma Kikuchi on 2018/03/02.
//  Copyright © 2018年 yumarimo. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;
    
    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }
    
    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];
    
    REP(i, n) {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    while (1) {
        minv = INFTY;
        int u = -1;
        REP(i, n) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        REP(v, n) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > d[u] + M[u][v]) {
                d[v] = d[u] + M[u][v];
                color[v] = GRAY;
                }
            }
        }
    }
    
    REP(i, n) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 24) {
        cout << 0 << endl;
    } else {
        cout << ((a + b > 24) ? a + b - 24 : a + b) << endl;
        
    }
    
    return 0;
}

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

using namespace std;

#define foru(i, l, r) for(register int i = l; i <= r; i++)
#define ford(i, r, l) for(register int i = r; i >= l; i--)

const int maxn = 1e5 + 5;

int H, N, a[maxn];

int main() {
  scanf("%d%d", &H, &N);
  int sum = 0;
  for(int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    sum += max(0, a[i]);
  }
  if(sum >= H) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 640
str1 = gets.chomp.downcase
num = 0
ary = []
ARGF.each do |line|
  break if line.chomp == "END_OF_TEXT"

  ary << line.chomp.split.map(&:downcase)
  ary = ary.flatten
  ary.count.times do |i|
    if str1 == ary[i]
      num += 1
    end
  end
  ary = []
end
puts num

Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int64_t a;
    string bs;
    cin >> a >> bs;
    int64_t bi = 100*(bs[0]-'0') + 10*(bs[2]-'0') + (bs[3] -'0');
    cout << a*bi/100 <<endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
int main(void){
    char s[200];
    int  i, j, n, S[200], sum = 0, key;
    while ( scanf("%s", s) != EOF ) {
        key = 0;
        for ( i = 0, j = strlen(s) - 1; i < strlen(s) / 2 + 1; i++, j-- ) {
            if ( s[i] == s[j]) {key++; /*printf("s[%d]:%c s[%d]:%c key:%d\n", i, s[i], j,  s[j], key);*/}
            else if ( s[i] != s[j]) break;
        }
        if ( key >= strlen(s) / 2 ) {/*printf("key:%d strlen / 2:%d\n", key, strlen(s) / 2);*/ sum++;}
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
using namespace std ;
int main()
{
	char arr[100][100];
	int H,W,h;
	cin>>H>>W;
	for(int rows =0;rows <H;rows++)
	{
		for(int col=0;col<W;col++)
			cin>>arr[rows][col];
	}
	
	for(int rows =0;rows <H;rows++)
	{
		for(int i=0;i<2;i++)
		{
		for(int col=0;col<W;col++)
		{
				cout<<arr[rows][col];
		}
		cout<<"\n";
				
		}
	}
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

map<_int64,_int64> mp;
int a[210000];

int main()
{
  _int64 ans,sum;
  int i,n;
  scanf("%d",&n);
  mp.clear();
  mp[0]++;
  sum=0;
  for (i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    sum+=a[i];
    mp[sum]++;
  }
  ans=0;
  for (map<_int64,_int64>::iterator it=mp.begin();it!=mp.end();it++)
  {
    ans+=it->second*(it->second-1)/2;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
   string S;
   cin >> S;
   bool f = 1;
   for(int i = 0;i < S.size(); ++i){

       if((i+1)%2 == 0){
           if(S[i] == 'R') f = 0;
       }else
       {
           if(S[i] == 'L') f = 0;
       }
   }
   if(f) cout<<"Yes"<<endl;
   else  cout<<"No"<<endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int a[300000], dp[300000], sum[300000], mod = 1e9+7;
signed main(){
  int n;cin >> n;
  rrep(i,n)cin >> a[i];
  dp[0] = 1;
  rrep(i,n){
    dp[i] = dp[i-1];
    if(a[i-1] != a[i]){
      dp[i] += sum[a[i]];
      sum[a[i]] += dp[i-1];
    }
    dp[i] %= mod;
    sum[a[i]] %= mod;
  }
  cout << dp[n] << endl;
  return 0;
}





Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a > k) cout << ":(";
  else cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

int main()
{
	int n;
	int a[200];
	
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];
	
	for(int i=0; i<n/2; i++){
		int temp = a[i];
		a[i] = a[n-1-i];
		a[n-1-i] = temp;
	}
	
	for(int i=0; i<n; i++){
		cout << a[i];
		if(i<=n-2)
			cout << ' ';
	}
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 3084
import sys
def input():
    return sys.stdin.readline()[:-1]
while True:
    S = input()
    if S=="#":
        break
    N = len(S)
    Sn = [ord(c)-97 for c in S]
    ans = []
    ansappend = ans.append
    zip_ = list(zip(range(N-1, -1, -1), Sn))
    i = 0
    #for i in range(1<<N):
    end = 1<<N
    Tst = [0] + [1]*25 + [0]
    while i < end:
        #tst = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]
        tst = Tst.copy()
        ans_ = []
        for j, n in zip_:
            if i>>j & 1:
                n += 1
                if tst[n]:
                    tst[n]=0
                    ans_.append(n)
                else:
                    i += 1<<j
                    break
            else:
                if tst[n]==0:
                    ans_.append(n)
                else:
                    i += 1<<j
                    break
        else:
            ansappend(ans_)
            i+=1
    #ans.sort()
    print(len(ans))
    if len(ans)<=10:
        for ans_ in ans:
            print(*map(lambda x: chr(x+97), ans_), sep="")
    else:
        for ans_ in ans[:5]:
            print(*map(lambda x: chr(x+97), ans_), sep="")
        for ans_ in ans[-5:]:
            print(*map(lambda x: chr(x+97), ans_), sep="")



Measured memory_bytes: 10304
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,VI(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
     
int main() {
  ll n, m, k, x=0, y=0 , z = 0, h,w, sum = 1, Max = -1, Min = 3e9+1;
  string u;
  bool ok=true;
  cin >> n;
  VL a(n);
  rep(i,n) {
    cin >> a[i]; 
    if(a[i] == 0){
      pri(0); return 0;
    }
  }

  rep(i,n){
    if(sum * a[i] == 0){
      pri(-1); return 0;
    }
    sum *= a[i];
    if(sum > 1000000000000000000){
      pri(-1); return 0;
    }
  }

  pri(sum);
  return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{

     ll t=1,i,j,n,k,m;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>t;
  ll c1=0,c2=0,c3=0,c4=0;
    while(t--)
    {
     string s;
      cin>>s;
      if(s=="AC")
        c1++;
      else if(s=="WA")
        c2++;
      else if(s=="TLE")
        c3++;
      else
        c4++;
    }
  cout<<"AC x "<<c1<<endl;
   cout<<"WA x "<<c2<<endl;
   cout<<"TLE x "<<c3<<endl;
   cout<<"RE x "<<c4<<endl;

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define INF 10000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

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

ll n;
vector<ll> v[maxn];
ll dp[maxn], dp2[maxn], child[maxn], ans[maxn];
ll f[maxn], finv[maxn];

ll power(ll a, ll b){
    if(b==0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

ll inv(ll x){ return power(x, MOD-2); }

void pre(){
    f[0] = finv[0] = 1;
    for(ll i = 1; i < maxn; i++){
        f[i] = (f[i-1]*i)%MOD; //cout << f[i] << " ";
        finv[i] = (finv[i-1]*(power(i, MOD-2))%MOD);
    }
}

ll dfs(ll u, ll p){
    ll c = 1, tmp  = 1;
    for(auto x: v[u]){
        if(x!=p){
            ll sizeu = dfs(x, u);
            c += sizeu;
            tmp = (tmp * dp[x])%MOD;
            tmp = (tmp * finv[sizeu])%MOD;
        }
    }
    tmp = (tmp * f[c-1])%MOD;
    dp[u] = tmp; child[u] = c;
    return c;
}

void dfs2(ll u, ll p){
    for(auto x: v[u]){
        if(x!=p){
            ans[x] = (ans[u] * ((child[x] *inv(n-child[x]))%MOD))%MOD;
            dfs2(x, u);
        }
    }
}

void solve(){
    cin >> n;
    for(ll i = 0; i < n-1; i++){
        ll x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 0);
    ans[1] = dp[1];
    dfs2(1, 0);
    for(ll i = 1; i <= n; i++){
        cout << ans[i] << "\n";
    }

}

int main()
{
    fast(); //power(2, 11);
    int t= 1; //cin >> t;
    while(t--){
        pre();
        solve();
    }
}

/*
5
1 2
2 3
3 4
3 5
*/


Measured memory_bytes: 24048
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    res = (N - K) // (K - 1) + 1
    if (N - K) % (K - 1) != 0:
        res += 1
    print(res)
    

Measured memory_bytes: 14008
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> xx(n,0);
  int i;
  for(i=0;i<n;i++) cin >> x[i];
  for(i=0;i<n;i++) xx[i] = x[i];
  sort(x.begin(),x.end());
  int d = x[n/2-1];
  int u = x[n/2];
  for(i=0;i<n;i++){
    if(xx[i]<=d) cout << u << "\n";
    else cout << d << "\n";
  }
  return 0;
}

Measured memory_bytes: 4828
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<=n;i++)
#define FORd(n) for(ll i=n;i>=0;i--)
#define FORrd(a,b) for(ll i=a;i>=b;i--)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ff first
#define ss second
#define w(t) ll t;cin>>t;while(t--)

bool chk(ll a[],ll b[],ll n)
{
    for(ll i=0;i<n;i++)
    {
        if(a[i]!=b[i])
            return false;
    }
    return true;
}

int main()
{
    //FIO;
    ll n,a=1,b=1;
    cin>>n;
    ll p[n],q[n],o[n];
    FOR(n-1)
    {
        o[i]=i+1;
        cin>>p[i];
    }
    FOR(n-1)
    {
        cin>>q[i];
    }
    while(!chk(o,p,n))
    {
        a++;
        next_permutation(o,o+n);
    }
    FOR(n-1)
    {
        o[i]=i+1;
    }
    while(!chk(o,q,n))
    {
        b++;
        next_permutation(o,o+n);
    }
    cout<<abs(a-b)<<'\n';
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String result = "NG";
		for(int i=a; i<=b;i++) {
			if(i % k == 0) {
				result = "OK";
				break;
			}
		}
		System.out.println(result);

	}

}


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

template<typename T> T gcd(T a, T b) {
  if(!b) return a;
  return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
  return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

const int MAXN = 2004;
const int INF = 100101001;

int dx[4] = {-1, 1,  0, 0};
int dy[4] = { 0, 0, -1, 1};

int main(void) {
  int N, M;
  int CN, CM, DN, DM;

  cin >> N >> M;
  cin >> CN >> CM >> DN >> DM;;

  vector<string> S(N);
  vector<vector<int>> dist(N, vector<int>(M, INF));

  CN -= 1;
  CM -= 1;
  DN -= 1;
  DM -= 1;

  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  priority_queue<pair<int, pair<int, int>>> q;
  q.push(make_pair(0, make_pair(CN, CM)));

  dist[CN][CM] = 0;

  while (!q.empty()) {
    int curr_cost = -q.top().first;
    int ci = q.top().second.first;
    int cj = q.top().second.second;
    q.pop();

    if (curr_cost > dist[ci][cj]) {
      continue;
    }


    for (int d = 0; d < 4; d++) {
      int ni = ci + dx[d];
      int nj = cj + dy[d];

      if (min(ni, nj) < 0 || ni >= N || nj >= M) {
        continue;
      }

      if (S[ni][nj] == '#') {
        continue;
      }

      if (dist[ni][nj] > dist[ci][cj]) {
        dist[ni][nj] = dist[ci][cj];
        q.push(make_pair(-dist[ni][nj], make_pair(ni, nj)));
      }
    }

    for (int x = -2; x <= 2; x++) {
      for (int y = -2; y <= 2; y++) {
        int ni = ci + x;
        int nj = cj + y;

        if (min(ni, nj) < 0 || ni >= N || nj >= M) {
          continue;
        }

        if (S[ni][nj] == '#') {
          continue;
        }

        if (dist[ni][nj] > dist[ci][cj] + 1) {
          dist[ni][nj] = dist[ci][cj] + 1;
          q.push(make_pair(-dist[ni][nj], make_pair(ni, nj)));
        }
      }
    }
  }

  int ans = dist[DN][DM];

  if (ans >= INF) {
    ans = -1;
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 9592
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S, T, ans = "Yes";
	cin >> S >> T;

	int size = S.size();

	if (size < 1 || size > 10) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < size; i++) {
		if ((int)(S.at(i) & T.at(i)) < 97 || (int)(S.at(i) & T.at(i)) > 122) {
			ans = "No";
			break;
		}
		else if (S.at(i) != T.at(i)) {
			ans = "No";
			break;
		}
	}

	if (T.size() != size + 1)
		ans = "No";

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

const lli mod = 1e9+7;
lli n;

int main(void){
    cin >> n;
    vector<lli> a(n);
    rep(i, n) cin >> a[i];
    if(n%2 == 1) a.push_back(0);
    sort(a.begin(), a.end());
    lli i = 0;
    while(i < a.size()-1){
        if(a[i+1] != a[i]){
            cout << 0 << endl;
            return 0;
        }
        i+=2;
    }
    lli ans = 1;
    lli k = n/2;
    while(k--){
        ans*=2;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    string ans = "NG";
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
a,b,c,x,y = map(int,input().split())
total = 0
if (a//2-c//2)+(b//2-c//2) >= 0:
	if x<=y:
		total += x*c*2
		if (y-x)*c*2 <= (y-x)*b:
			total += (y-x)*c*2
		else:
			total += (y-x)*b
	else:
		total += y*c*2
		if (x-y)*c*2 <= (x-y)*a:
			total += (x-y)*c*2
		else:
			total += (x-y)*a
else:
	total += (x*a+y*b)
print(total)

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

int main(){
  vector<int> a(5);
  int counter = 0, k;
  
  for(int i = 0;5 > i;i++)
    cin >> a.at(i);
  cin >>k;
  
  for(int i = 0;5 >i; i++){
    for(int j = i + 1; 5 > j;j++){
      if(abs(a.at(i) - a.at(j)) > k)
        counter++;
    }
  }
  
  if(counter == 0)
    cout << "Yay!" << endl;
  else
    cout << ":("<< endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true;
	else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
svo(int n) {
	static char buf[20];
	char *p = buf;
	bool minus = false;
	if(n < 0) minus = true, n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	if (minus) *p++ = '-';
	while (p != buf) pcu(*--p); }
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
svo(vector<T> v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(int &x:v)out(&x == &v[0]?"":" ",x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;

struct bst
{
	struct node { int v, l = -1, r = -1; };
	int root = -1, i = 0;
	vector<node> nodes;

	bst(int n)
	{
		nodes.resize(n);
	}

	int insert (int r, int n)
	{
		if (r == -1) {
			nodes[i].v = n;
			r = i++;
		} else if (nodes[r].v < n)
			nodes[r].r = insert(nodes[r].r, n);
		else
			nodes[r].l = insert(nodes[r].l, n);
		return r;
	}
	void insert (int n)
	{
		root = insert(root, n);
	}
	void print(int r, v &buf)
	{
		if (r == -1)
			return;
		node n = nodes[r];
		buf.push_back(n.v);
		print(n.l, buf);
		out(' ', n.v);
		print(n.r, buf);
	}
	void print()
	{
		v buf;
		print(root, buf);
		out('\n', buf);
	}
};

int main()
{
	int n = in();
	char s[20];
	bst b(n);

	while (n--) {
		scan(s);
		if (*s == 'i')
			b.insert(in());
		else
			b.print();
	}
}


Measured memory_bytes: 10216
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,subs;
  int n,mi=99999999;
  cin >> s;
  for(int i=0; i<s.size()-2; i++){
    n = stoi(s.substr(i,3));
    mi = min(mi,abs(n-753));
  }
  cout << mi << endl;
}

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

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

    int x[N], y[N], c[N];

    // まずは2K * 2Kの範囲に絞る
    for (int i = 0; i < N; ++i) {
        char sc;
        cin >> x[i] >> y[i] >> sc;
        x[i] %= K * 2;
        y[i] %= K * 2;
        c[i] = (sc == 'W');
    }

    int white[K][K];
    fill(white[0], white[K], 0);
    // while[x][y] = マス(x, y)を右上とした長方形に
    //               含まれている(白マス-黒マス)の総数

    int bnum = 0;
    // 含まれている黒マスの数

    // K * Kの範囲に絞る
    // 座標をKで割った値の偶奇で色が変わる
    for (int i = 0; i < N; ++i) {
        c[i] += x[i] / K + y[i] / K;
        c[i] %= 2;
        x[i] %= K;
        y[i] %= K;
        white[x[i]][y[i]] += (c[i] ? 1 : -1);
        if (c[i] == 0) ++bnum;
    }

    // 2次元imosの要領で展開
    for (int x = 0; x < K; ++x) {
        for (int y = 1; y < K; ++y) {
            white[x][y] += white[x][y - 1];
        }
    }

    for (int x = 1; x < K; ++x) {
        for (int y = 0; y < K; ++y) {
            white[x][y] += white[x - 1][y];
        }
    }

    int ans = 0;
    for (int x = 0; x < K; ++x) {
        for (int y = 0; y < K; ++y) {
            // (x, y)を右上の頂点とした長方形を白く塗る
            int w = white[K - 1][K - 1] - white[x][K - 1] - white[K - 1][y] + white[x][y] * 2 + bnum;

            ans = max(ans, max(w, N - w));
        }
    }

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


Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();
        int[] B = new int[M];
        int[][] A = new int[N][M];
        for(int i = 0; i < M; i++) {
            B[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < M; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        
        int count = 0;
        for(int i = 0; i < N; i++) {
            int sum = C;
            for(int j = 0; j < M; j++) {
                sum += A[i][j] * B[j];
            }
            if(sum > 0) {
                count++;
            }
        }
        
        System.out.println(count);
    }           
}

Measured memory_bytes: 23892
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m;
    cin>>n>>m;
    bool c[200010]={},d[200010]={};
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        if(a==1) c[b]=1;
        if(b==n) d[a]=1;
    }
    rep2(i,2,n){
        if(c[i]&&d[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,t;
    cin>>n>>t;
    int ans=inf;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        if(y<=t)ans=min(ans,x);
    }
    if(ans==inf)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#define INF 9999999
using namespace std;
char ch;
int n,m,t[21][21],u[21],v[21],a,b,c,d;
int cost(int start,int goal){
	int mini,miniNo;
	for(int i=0;i<21;i++){
		u[i]=INF;
		v[i]=0;
	}
	u[start]=0;
	while(1){
		mini=INF;
		for(int i=1;i<=n;i++){
			if(v[i]==0&&u[i]<mini){
				miniNo=i;
				mini=u[i];
			}
		}
		if(mini==INF)break;
		v[miniNo]=1;
		for(int i=1;i<=n;i++){
			if(u[i]>u[miniNo]+t[miniNo][i]){
				u[i]=u[miniNo]+t[miniNo][i];	
			}
		}
	}
	
	return u[goal];
}
int main(){
	for(int i=0;i<21;i++)for(int j=0;j<21;j++)t[i][j]=INF;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>ch>>b>>ch>>c>>ch>>d;
		t[a][b]=c;t[b][a]=d;
	}
	cin>>a>>ch>>b>>ch>>c>>ch>>d;
	cout<<c-d-cost(a,b)-cost(b,a)<<endl;
	return 0;
}
	

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    priority_queue<ll> pq;
    while(true){
        string str;
        ll n;
        cin >> str;
        if(str=="end") break;
        if(str=="insert"){
            cin >> n;
            pq.push(n);
        }
        if(str=="extract"){
            cout << pq.top() << endl;
            pq.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 11328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(a[a[i]-1]==i+1){
      cnt++;
    }
  }
  cout << cnt/2 << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array1 = new int[n];
        int[] array2 = new int[n];
        int[] used1 = new int[n];
        int[] used2 = new int[n];
        
        for (int i = 0; i < n; i++) {
            array1[i] = sc.nextInt() - 1;
        }
        for (int i = 0; i < n; i++) {
            array2[i] = sc.nextInt() - 1;
        }
        
        int count1 = 0;
        for (int i = 0; i < n-1; i++) {
            int tmp = 0;
            for (int j = 0; j <= array1[i]; j++) {
                if (used1[j] == 0) {
                    tmp++;
                }
            }
            count1 += tmp * fact(n - 1 - i);
            used1[array1[i]] = 1;
        }
        
        int count2 = 0;
        for (int i = 0; i < n-1; i++) {
            int tmp = 0;
            for (int j = 0; j <= array2[i]; j++) {
                if (used2[j] == 0) {
                    tmp++;
                }
            }
            count2 += tmp * fact(n - 1 - i);
            used2[array2[i]] = 1;
        }        
        System.out.println(Math.abs(count1 - count2));
    }
    
    public static int fact(int n) {
        int answer = 1;
        for (int i = 1; i <= n; i++) {
            answer = answer * i;
        }
        
        return answer;
    }
}


Measured memory_bytes: 23892