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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    string s, t; cin >> s >> t;
    LL n = s.length(), m = t.length(), cur = -1, rep = 0;
    vector<vector<LL>> v(26);

    for(int i = 0; i < n; i++) v[s[i]-'a'].push_back(i);

    for(char c : t) {
        if(v[c-'a'].empty()) return cout << -1, 0;

        auto it = upper_bound(v[c-'a'].begin(), v[c-'a'].end(), cur);

        if(it == v[c-'a'].end()) rep++, cur = *v[c-'a'].begin();
        else cur = *it;
    }  

    cout << rep * n + cur + 1;
}

Measured memory_bytes: 4548
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  vll x, y;
  x.pb(inf); y.pb(inf);
  x.pb(-inf); y.pb(-inf);
  ll a, b, q;
  cin >> a >> b >> q;
  rep(i, a) {
    cin >> tmp;
    x.pb(tmp);
  }
  rep(i, b) {
    cin >> tmp;
    y.pb(tmp);
  }
  sort(all(x));
  sort(all(y));
  while (q--) {
    ll to;
    cin >> to;
    ans = inf;
    ll xle, xri, yle, yri, idx;
    idx = upper_bound(all(x), to) - x.begin() - 1;
    xle = x[idx]; xri = x[idx + 1];
    idx = upper_bound(all(y), to) - y.begin() - 1;
    yle = y[idx]; yri = y[idx + 1];
    ans = min(ans, max(llabs(to - xle), llabs(to - yle)));
    ans = min(ans, max(llabs(to - xri), llabs(to - yri)));
    ans = min(ans, llabs(to - xle) + llabs(to - yri) + min(llabs(to - xle), llabs(to - yri)));
    ans = min(ans, llabs(to - xri) + llabs(to - yle) + min(llabs(to - xri), llabs(to - yle)));
    cout << ans << endl;
  }



  return 0;
}

Measured memory_bytes: 3060
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n, m, k = map(int, input().split())

    u = UnionFind(n)

    ans = [0 for i in range(n)]

    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        u.union(a, b)
        ans[a] -= 1
        ans[b] -= 1

    for i in range(k):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        if u.same(c, d):
            ans[c] -= 1
            ans[d] -= 1

    for i in range(n):
        ans[i] += u.size(i) - 1

    print(" ".join(map(str, ans)))

main()

Measured memory_bytes: 17992
function main (input) {
    const args = input.split('\n');
  	const n = args[0];
  	const a = args[1].split(' ');
  	var flg = true;
  	var cnt = 0;
  while (flg) {
    for (var i = 0; i<n; i++) {
      if (a[i]%2 != 0) {
        flg = false;
      }
    a[i] = a[i]/2;
    } cnt++;
  }
  console.log(cnt -1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
from itertools import combinations, count

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)
r = next(i for i in count(n, - 1) for x in map(set, combinations(r, i))
         if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x))
print(r)


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int  main() {

	int n;
	cin >> n;
	pr(24 + 24 - n);

	return 0;
}

Measured memory_bytes: 256
let _ =
  let join s lst =
    let rec iter s rst = function
      | [] -> rst
      | hd :: [] -> rst ^ (string_of_int hd)
      | hd :: tl -> iter s (rst ^ (string_of_int hd) ^ s) tl in
    iter s "" lst in
  let lst = Scanf.scanf "%d %d %d %d %d\n" (fun a b c d e -> List.sort (fun x y -> compare y x) [a; b; c; d; e]) in
  print_endline @@ join " " lst

Measured memory_bytes: 2316
import sys
from collections import defaultdict
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


N, M, V, P = map(int, input().split())

A = list(map(int, input().split()))
A.sort(reverse=True)

# A_P -> A_X (A_P - M = A_X)
A_P = A[P-1]
A_X = A[P]
i_X = P
for i in range(P, len(A)):
    if (A_P - A[i]) > M:
        A_X = A[i-1]
        i_X = i-1
        break
    elif i == (len(A)-1):
        A_X = A[i]
        i_X = i
    else:
        continue

NG_POINT = (P-1) * M


def isPossible(i):
    if (i+1) < P:
        return True
    elif i > i_X:
        return False

    MV = M * V
    ax = A[i]
    score = ax + M

    total = M + NG_POINT
    total += (N - i - 1) * M

    for j in range(i-1, P-2, -1):
        total += score - A[j]

    #print("i", i, "total", total, "NG_POINT", NG_POINT)

    if total >= MV:
        return True

    return False


left = 0
right = i_X

if not isPossible(left):
    print(1)
    exit()

if isPossible(i_X):
    print(i_X + 1)
    exit()

#print("A", A, "i_X", i_X)

for _ in range(i_X):
    #print("left", left, isPossible(left), "right", right, isPossible(right))
    if (left + 1) == right:
        break

    mid = (left + right) // 2

    if isPossible(mid):
        left = mid
    else:
        right = mid

print(left + 1)


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

int main(){
  int s,t,d; cin>>s>>t>>d;
  if(s%t==0){
    if(s/t<=d)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  else{
    if(s/t<d)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define r(i, n) for (ll i=0;i<n;i++)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  llc(n);
  llc(x);
  string s="Yes";
  if(500*n<x) s="No";
  cout << s << endl;
}

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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n : i32 = read();
    let white : i32 = read();
    let ans = (n * n ) - white;
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M, a, b; cin >> N >> M;
  vector<vector<int>> p(M + 100);
  REP(i,N){
    cin >> a >> b;
    if(a <= M) p[a].push_back(b);
  }
  int day = 1, ans = 0; // M - day日目にするバイトを決めたい
  priority_queue<int> q;
  for(int day = 1; day <= M; day++){ 
  	for(int b : p[day]){
    	q.push(b);
    }
    if(!q.empty()){
	    ans += q.top();
    	q.pop();
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
#define fst first
#define snd second
using namespace std;
typedef long long ll;
//#define int long long
template<class C>int size(const C &c){ return c.size(); }
template<class T,class ...U>bool chmin(T&a, const U&...bs){const T b(bs...);if(a<=b)return false;a=b;return true;}
template<class T,class ...U>bool chmax(T&a, const U&...bs){const T b(bs...);if(a>=b)return false;a=b;return true;}

bool solve(){
    int n; cin >> n;
    string a, b, c;
    cin >> a >> b >> c;

    int res = 0;
    rep(i, n) {
        if (a[i] == b[i] and b[i] == c[i]) {
        } else if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) {
            ++res;
        } else {
            res += 2;
        }
    }
    cout << res << endl;
    return true;
}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}
// vim:set foldmethod=marker commentstring=//%s:


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

ll dp[3005][3005][5];

int main() {
    int R, C, K;
    cin >> R >> C >> K;

    vec<vec<int>> mp(R + 1, vec<int>(C + 1, 0));
    rep(i, K) {
        ll r, c, v;
        cin >> r >> c >> v;
        mp[r][c] = v;
    }

    for (int i = 1; i <= R; ++i) {
        for (int j = 1; j <= C; ++j) {
            dp[i][j][0] = max({dp[i][j][0], dp[i][j - 1][0]});
            dp[i][j][1] = max({dp[i][j][1], dp[i][j - 1][1]});
            dp[i][j][2] = max({dp[i][j][2], dp[i][j - 1][2]});
            dp[i][j][3] = max({dp[i][j][3], dp[i][j - 1][3]});

            rep(k, 4) {
                dp[i][j][0] = max({dp[i][j][0], dp[i - 1][j][k]});
                dp[i][j][1] = max({dp[i][j][1], dp[i - 1][j][k]});
                dp[i][j][2] = max({dp[i][j][2], dp[i - 1][j][k]});
                dp[i][j][3] = max({dp[i][j][3], dp[i - 1][j][k]});
            }

            if (mp[i][j] != 0) {
                dp[i][j][3] = max({dp[i][j][3], dp[i][j][2] + mp[i][j]});
                dp[i][j][2] = max({dp[i][j][2], dp[i][j][1] + mp[i][j]});
                dp[i][j][1] = max({dp[i][j][1], dp[i][j][0] + mp[i][j]});
            }
        }
    }

    cout << max({dp[R][C][0], dp[R][C][1], dp[R][C][2], dp[R][C][3]}) << endl;
}


Measured memory_bytes: 390508
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	vt n, k, q, mx;
	cin >> n >> k >> q;
	vector<vt> a(q);
	rep(i, q) cin >> a.at(i);
	vector<vt> ans(n, 0);
	rep(i, q) ans.at(a.at(i) - 1)++;
	rep(i, n) {
		if (k - (q - ans.at(i)) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <vector>
#include <iostream>
#include <numeric>
#include <string>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> ar;
  ll res=0;
  ll r_counter=0;
  ll g_counter=0;
  ll b_counter=0;
  for(ll i=0;i<s.length();i++){
  	if(s[i]=='R'){
      ar.push_back(0);
      r_counter++;
    }
    else if(s[i]=='G'){
      ar.push_back(1);
      g_counter++;
    }else if(s[i]=='B'){
      ar.push_back(2);
      b_counter++;
    }
  }

	res=r_counter*g_counter*b_counter;
  
  for(ll i=0;i<ar.size();i++){
  	for(ll k=i+1;k<ar.size();k++){
      if(k-i+k>=ar.size())continue;
    	if(((ar[i]!=ar[k])&&(ar[k]!=ar[k-i+k]))&&(ar[i]!=ar[k-i+k])){
          res--;
    }
  }
  }
  cout << res << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k; cin>>h>>w>>k;
    vector<string> c(h);
    rep(i,h) cin>>c[i];
    vector<vi> sum(h, vi(w));
    rep(i,h)rep(j,w) sum[i][j]=(c[i][j]-'0');
    int ans=1e9;
    rep(i,1<<(h-1)){
        int cand=0;
        int I=i+(1<<(h-1));
        vector<vi> t;
        vi tmp(w);
        rep(j,h){
            rep(l,w) tmp[l]+=sum[j][l];
            if (I>>j&1){
                cand++;
                t.pb(tmp);
                tmp = vi(w);
            }
        }
        cand--;
        int r = t.size();
        bool ng=false;
        rep(j,r)rep(l,w)if(t[j][l]>k) ng=true;
        if (ng) continue;
        vi now(r);
        rep(j,w){
            bool flg=false;
            rep(l,r){
                now[l]+=t[l][j];
                if (now[l]>k) flg=true;
            }
            if(flg){
                cand++;
                rep(l,r) now[l]=t[l][j];
            }
        }
        chmin(ans,cand);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<pair<ll,ll>> ma(n);
  vector<pair<ll,ll>> mb(n);
  for(int i = 0;i < n;i++){
    ll a,b;
    cin >> a >> b;
    ma[i] = make_pair(a,b);
    mb[i] = make_pair(b,a);
  }
  sort(ma.begin(),ma.end());
  sort(mb.begin(),mb.end());
  ll res = 0;
  if(n % 2 == 1){
    res = mb[n / 2].first - ma[n / 2].first + 1;
  }
  else{
    res = (mb[n / 2].first + mb[n / 2 - 1].first) - (ma[n / 2].first + ma[n / 2 - 1].first) + 1;
    //cout << mb[n / 2].first << endl;
  }
  cout << res << endl;
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  string b,w;
  for (int i=0;i<(s.size()+1)/2;i++){
    b=b+'0'+'1';
    w=w+'1'+'0';
  }
  
  int cb=0;
  int cw=0;
  
  for (int i=0;i<s.size();i++){
    if (s.at(i)!=b.at(i))cb++;
    if (s.at(i)!=w.at(i))cw++;
  }
  cout << min(cb,cw)<<endl;
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    string s;
    cin>>s;
    
    if(s[2]==s[3] && s[4]==s[5]){
    	printf("Yes\n");
    }
    else{
    	printf("No\n");
    }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  int n,s;
  cin >> n >> s;
 long long dp[n+1][s+1]={};
  dp[0][0]=1;
  for(int i=1;i<n+1;i++){
      int a;
    cin >> a;
    for(int j=0;j<=s;j++){
      dp[i][j]+=dp[i-1][j]*2;
      dp[i][j]%=998244353;
      if(j+a<=s){
        dp[i][j+a]+=dp[i-1][j];
        dp[i][j+a]%=998244353;
      }
    }
  }
  cout << dp[n][s];
}


Measured memory_bytes: 73960
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << setprecision(7) << (x) << endl;

long double pi = 3.14159265359;

int n,d[100];

int main(){
    cin >> n;
    rep(i,n) cin >> d[i];
    int ans=0;
    rep(i,n){
        rep(j,n){
            if(i==j) continue;
            ans += d[i]*d[j];
        }
    }
    cout << ans/2 << endl;


return 0;
}

Measured memory_bytes: 3672
def test(a):
    print(*a)
    for i in range(len(a) - 1):
        a = [abs(a1 - a0) for a0, a1 in zip(a, a[1:])]
        # print(' ' * i, *a)
        print(*a)


# test([2, 3, 1, 1, 3, 1, 2, 3, 1, 2])
# test([2, 3, 1, 1, 3, 2, 2, 3, 1, 2])
# test([2, 3, 1, 1, 3, 3, 2, 3, 1, 2])
# test([1, 2, 0, 1, 2, 2, 2, 0, 0, 2, 1])
# test([1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0])
# test([0, 0, 0, 0, 0, 1, 0, 0, 1, 2, 0, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ])
# test([0] * 21 + [2] + [0] * 21)
# exit()

def solve(n, aaa):
    # シェルピンスキーの三角形
    if '2' not in aaa:
        factor = '3'
        effect = 2
    else:
        factor = '2'
        effect = 1
    # print(factor, effect)

    try_list = []
    m = n - 1
    while m:
        l = 1 << (m.bit_length() - 1)
        m ^= l
        try_list.append((l, m))
    # print(try_list)

    ans = 0
    for i, a in enumerate(aaa):
        if a == factor:
            for l, m in try_list:
                if i >= l:
                    i -= l
                if i == 0:
                    ans ^= effect
                    break
                elif i > m:
                    break
    return ans


n = int(input())
aaa = input()
print(solve(n, aaa))


Measured memory_bytes: 5148
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >>N ;
    
    int C0 = 0;
    int C1 = 0;
    int C2 = 0;
    int C3 = 0;
    
    for(int i=0;i<N;i++){
        string S;
        cin >> S;
        if (S == "AC"){
            C0++;
        }
        if (S == "WA"){
            C1++;
        }
        if (S == "TLE"){
            C2++;
        }
        if (S == "RE"){
            C3++;
        }
    }
    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;
}

Measured memory_bytes: 3600
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
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;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion

const string YES = "Yes";
const string NO = "No";

void Main();
void solve(long long N, std::vector<long long> t, std::vector<long long> x, std::vector<long long> y);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> t(N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&t[i]);
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(t), std::move(x), std::move(y));
}

void solve(long long N, std::vector<long long> t, std::vector<long long> x, std::vector<long long> y){
    ll nx=0, ny=0, bt=0;
    REP(i, N){
        ll s=t[i]-bt-(abs(x[i]-nx)+abs(y[i]-ny));
        if(s<0 || s%2){
            cout << NO << el;
            return;
        }
        nx=x[i], ny=y[i];
        bt=t[i];
    }
    cout << YES << el;
}



Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    string S,T,U;
    int A,B;
    
    cin >> S >> T ;
    cin >> A >> B ;
    cin >> U ;
    
    if (S == U) A = A-1;
    if (T==U)B=B-1;
    
    cout << A << endl ;
    cout << B;
    
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  double sumt = 0;
  vector<double> t(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> t.at(i);
    sumt += t.at(i);
  }
  for (int i = 0; i < n; i++) cin >> v.at(i);
  
  vector<double> x(sumt * 2 + 1, 1e9);
  
  int m = sumt * 2;
  for (double i = 0; i <= m; i++) x.at(i) = min(x.at(i), i / 2);
  for (double i = 0; i <= m; i++) x.at(m - i) = min(x.at(m - i), i / 2);
  double now = 0;
  for (int i = 0; i < n; i++) {
    for (double j = now; j <= now + 2 * t.at(i); j++) {
      x.at(j) = min(x.at(j), v.at(i));
    }
    for (double j = 0; j <= now; j++) {
      x.at(now - j) = min(x.at(now - j), v.at(i) + j / 2);
    }
    now += t.at(i) * 2;
    for (double j = 0; j <= m - now; j++) {
      x.at(now + j) = min(x.at(now + j), v.at(i) + j / 2);
    }
  }
  
  double ans = 0;
  for (int i = 1; i <= m; i++) {
    ans += (x.at(i - 1) + x.at(i)) / 4;
  }
  
  cout << fixed << setprecision(10) << ans << '\n';
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i=0;
    int tmp;
    int a[9]={0};
    for(i=0;i<9;i++){
        if(n/pow(10,8-i)!=0){
            tmp=n/pow(10,8-i);
            for(int j=0;j<i;j++){
                //cout <<i <<"引く " << a[7-j]*pow(10,i-j) <<tmp << endl;
                tmp=tmp-(a[7-j]*pow(10,i-j-1));
            }
            a[8-i]=tmp;
        }

    }
    int sum=0;
    for(i=0;i<9;i++){
        //cout << a[i] << endl;
        sum+=a[i];
    }
    if(n%sum==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int th, ta, ah, aa;
    cin >> th >> ta >> ah >> aa;
    if (th / aa + (th % aa > 0) < ah / ta + (ah % ta > 0))
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

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

#define MAX_SIZE 200

int Stack[MAX_SIZE];
int Stack_size;

void push(int x){
  Stack[++Stack_size]=x;
}

int pop(){
  Stack_size--;
  
  return Stack[Stack_size+1];
}

int main(void){
  int  num, a, b;
  char com[100];
  
  while(scanf("%s", com) != EOF){
    if(com[0] == '+'){
      push(pop()+pop());
    }
    else if(com[0] == '-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(com[0] == '*'){
      push(pop()*pop());
    }
    else{
      num=atoi(com);
      push(num);
    }
  }

  printf("%d\n", Stack[Stack_size]);
  
  return 0;
}



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

int main(){
    ll n,d,a;
    cin>>n>>d>>a;
    vector<P>xh(n);
    rep(i,n){
        ll x,h; cin>>x>>h;
        xh[i]=P(x,h);
    }
    sort(xh.begin(),xh.end());
    queue<P>q;
    ll bomb=0,ans=0;
    rep(i,n){
        //範囲外の爆弾の数を引く
        while(!q.empty()&&q.front().first<xh[i].first){
            bomb-=q.front().second;
            q.pop();
        }
        //当たってる分hp減らす
        xh[i].second-=bomb*a;
        //今回使う回数
        ll use=(xh[i].second+a-1)/a;
        if(use<=0)continue;
        ans+=use;
        bomb+=use;
        q.push(P(xh[i].first+2*d,use));
    }
    cout<<ans<<endl;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    int i, k, m, n, l;
    int data[5];
    for(i = 0;i < 5;i++){
        cin >> data[i];
    }
    cin >> k;
    for(m = 0;m < 5;m++){
        for(n = m+1;n < 5;n++){
            if(data[n] - data[m] > k){
                printf(":(\n");
                return 0;
            }
        }
    }
    printf("Yay!\n");
    return 0;
}

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

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

  string S, T;
  int A, B;
  string U;
  cin >> S >> T >> A >> B >> U;
  if(S == U){
    A--;
  } else{
    B--;
  }
  cout << A << " " << B <<endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define show(x) cerr << #x << " " << x << endl

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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

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

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = 1000000000 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  　　┓　　　┏
//  　＊┗┓　┏┛
//  　　　┫　┣　＊
//  　┏┳┻━┻┳┓
//  　┗┫　　　┣┛
//  ＊　┣　　━┃　＊        Merry Christmas!!
//  　┏┛　　〃┃
//  　┃●　　　┣━┳┓
//  　┗┻┳━━┛　┣┛
//  　＊　┃┏┓┣┓┃
//WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

int n;
int a[200001];
int b[200011];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1 = freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt", "r", stdin);
    //stream2 = freopen("out.txt", "w", stdout);
    if (stream1 == nullptr) return 0;
    //if (stream2 == NULL) return 0;
#endif
    // 操作回数を最小化するので、できるだけ動かさない数字を多くする
    // すでに昇順で並んでいるような数字は動かさない方が良い
    // 昇順であるだけではなく、連続でなければならない(ex. 3 4 5 6)
    // そのような数列の中で最も長い数列を動かさずに操作すると良い
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        b[a[i]] = b[a[i] - 1] + 1;
    }
    int _max = -1;
    for (int i = 1; i <= n; i++) {
        chmax(_max, b[i]);
    }
    cout << n - _max << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  string s;
  cin >> s;
  long long tot = 0;
  for (auto& ch : s) tot += ch - '0';
  cout << (tot % 9 == 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3716
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int x;
  cin >> x;
  cout << (x ^ 1) << endl;  

  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    VS s(h); cin >> s;
    auto dis = defvec<int>(INF, h, w);
    dis[0][0] = 1;
    queue<pair<int, int>> bfs;
    bfs.emplace(0, 0);
    int dy[] = { -1,0,0,1 }, dx[] = { 0,-1,1,0 };
    while (!bfs.empty()) {
        int y, x;
        tie(y, x) = bfs.front();
        bfs.pop();
        FOR(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (out(ny, nx))continue;
            if (s[ny][nx] == '#')continue;
            if (!chmin(dis[ny][nx], dis[y][x] + 1))continue;
            bfs.emplace(ny, nx);
        }
    }

    if (dis[h - 1][w - 1] == INF)cout << "-1\n";
    else {
        int ans = -dis[h - 1][w - 1];
        each(i, s)each(j, i)if (j == '.')++ans;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 256
N,M = map(int,input().split())

divs = set()
n = 1
while n*n <= M:
    if M%n == 0:
        divs.add(n)
        divs.add(M//n)
    n += 1

ans = 0
for d in divs:
    if d <= M//N:
        ans = max(ans,d)
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector < vector <int> > vvi;
const int HUGEI = 2147483647;  // (1 << 31) - 1
const ll HUGEL = 9223372036854775807;  // (1 << 63) - 1
const string ABC = "abcdefghijklmnopqrstuvwxyz";

int main(void) {
    string l1, l2, l3;
    cin >> l1;
    cin >> l2;
    cin >> l3;
    cout << l1[0] << l2[1] << l3[2];
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
using namespace std;
int main()
{
	int a, b, c;
	bool i;
	while (cin >> a >> b >> c)
	{
		i = 0;
		if (a == b || a == c || b == c)
			i = 1;
		if (a == b && b == c)
			i = 0;
		if (i == 1)
			cout << "Yes" << '\n';
		else cout << "No" << '\n';
	}
}

Measured memory_bytes: 256
N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    T[u].append([v, w])
    T[v].append([u, w])


dist = [float('inf')] * N
stack = [[0, 0]]
while stack:
    n, d = stack.pop()
    dist[n] = d

    for to, w in T[n]:
        if dist[to] != float('inf'):
            continue

        stack.append([to, d + w])

ans = [d % 2 for d in dist]
print(*ans, sep='\n')


Measured memory_bytes: 51336
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for m in range(c+1):
            if 500*int(i)+100*int(j)+50*int(m)==x:
                count+=1
print(count)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  int g[200100] = {};
  int n;
  cin >> n;

  rep(i, n - 1)
  {
    int a;
    cin >> a;
    g[a]++;
  }

  repi(i, 1, n + 1)
  {
    cout << g[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] isLand1ToLandx = new boolean[n + 1];
		boolean[] isLandxToLandn = new boolean[n + 1];
		
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if (a == 1) { isLand1ToLandx[b] = true; }
			if (b == n) { isLandxToLandn[a] = true; }
		}
		
		for (int i = 1; i < isLand1ToLandx.length; i++) {
			if (isLand1ToLandx[i]) {
				if (isLandxToLandn[i]) {
					System.out.println("POSSIBLE");
					System.exit(0);
				}
			}
		}
		
		System.out.println("IMPOSSIBLE");
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 43908
using System;
using System.Linq;
class P{
  static void Main(){
    int[] nmxy = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int x = nmxy[2];
    int y = nmxy[3];
    int xm = Console.ReadLine().Split().Select(int.Parse).ToArray().Max();
    int ym = Console.ReadLine().Split().Select(int.Parse).ToArray().Min();
    bool f = Math.Max(x,xm) < Math.Min(y,ym);
    Console.WriteLine(f ? "No War" : "War");
  }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ll n,k;
	cin>>n>>k;
	ll p[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>p[i];		
	}
	double dp[n];
	for (int i = 0; i < n; ++i)
	{
		dp[i] = double(p[i]+1)/double(2);
	}
	double sum=0;
	for (int i = 0; i < k; ++i)
	{
		sum+=dp[i];
	}
	double max1=sum;

	for (int i = 0; i < n-k; ++i)
	{
		double sum1 = sum-dp[i]+dp[i+k];
		sum=sum1;
		max1 = max(max1, sum1);	
	}
	cout<<setprecision(12)<<max1;

	return 0;
}

Measured memory_bytes: 3840
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int i = 1;
    int M = 0;
    while(i <= n){
        if(i <= k){
            M = M + x;
        }
        else if(i > k){
            M = M + y;
        }
        i++;
    }
    cout << M << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    long[long][long] G;
    auto edges = new long[][](N);
    foreach (id; 0 .. N - 1)
    {
        long a, b;
        scan(a, b);
        G[a - 1][b - 1] = (G[b - 1][a - 1] = id);
        edges[a - 1] ~= b - 1;
        edges[b - 1] ~= a - 1;
    }
    auto visited = new bool[](N);
    auto color = new long[](N - 1);
    void dfs(long v, long parent_color)
    {
        if (visited[v])
            return;
        visited[v] = true;
        long c = 1;
        foreach (w; edges[v])
        {
            // writefln("%d %d", v, w);
            long id = G[w][v];
            if (color[id] != 0)
                continue;
            if (c == parent_color)
                c++;
            color[id] = c;
            dfs(w, c);
            c++;
        }
    }

    dfs(0, -1);

    long k = color.reduce!max();
    writeln(k);
    foreach (c; color)
    {
        writeln(c);
    }
}


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

int main(){
  char c;
  cin >> c;
  if(isupper(c)) cout << "A" << endl;
  else cout << "a" << endl;

}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <map>

using namespace std;

int main(){
	int n;
	while (cin >> n, n){
		vector<tuple<string, char, string, int>> v(n);
		vector<int> used(n);

		map<string, pair<int, int>> comm_minmax;
		map<string, pair<int, int>> comm_sumcnt;
		map<string, pair<int, int>> dealer;

		for (int i = 0; i < n; ++i){
			string a, b, c;
			int x;
			cin >> a >> b >> c >> x;
			v[i] = make_tuple(a, b[0], c, x);
			dealer[a];
			int idx = -1, opt = x;
			bool buy = b[0] == 'B';
			for (int j = 0; j < i; ++j){
				if (used[j]) continue;
				if (a != get<0>(v[j]) && b[0] != get<1>(v[j]) && c == get<2>(v[j])){
					int y = get<3>(v[j]);
					if (buy && y <= opt){
						opt = y - 1, idx = j;
					}
					if (!buy && y >= opt){
						opt = y + 1, idx = j;
					}
				}
			}
			if (idx < 0) continue;
			used[i] = used[idx] = 1;
			string buyer = a, seller = get<0>(v[idx]);
			if (!buy) swap(buyer, seller);

			if (buyer == seller) continue;
			auto &c1 = comm_minmax[c], &c2 = comm_sumcnt[c], &db = dealer[buyer], &ds = dealer[seller];
			int val = (x + get<3>(v[idx])) / 2;
			c1.first = c1.first ? min(c1.first, val) : val, c1.second = c1.second ? max(c1.second, val) : val;
			c2.first += val, ++c2.second;
			db.first += val, ds.second += val;
		}

		for (auto &c : comm_minmax){
			int mean = comm_sumcnt[c.first].first / comm_sumcnt[c.first].second;
			cout << c.first << ' ' << c.second.first << ' ' << mean << ' ' << c.second.second << '\n';
		}
		cout << "--\n";
		for (auto &d : dealer){
			cout << d.first << ' ' << d.second.first << ' ' << d.second.second << '\n';
		}
		cout << "----------\n";
	}

	return 0;
}

Measured memory_bytes: 1356
s=input()
n=len(s)
a=[0]*n
pos=0
while pos<=n-1:
    c=1
    l=pos
    while pos<=n-2 and s[pos]==s[pos+1]:
        c+=1
        pos+=1
    if(s[pos]=="L"):
        a[l]+=(c+1)//2
        a[l-1]+=c//2
    else:
        a[pos]+=(c+1)//2
        a[pos+1]+=c//2
    
    pos+=1

for i in range(n):
    print(a[i],end=" ")

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string N;
    cin >> N;
    if (N[0] == '7' || N[1] == '7' || N[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
  int N, A;
  string op;
  cin >> N >> A;

if (N % 500 == 0){
	cout << "Yes" << endl;
	}
	else if (N % 500 <= A){
		cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  if((n - 7) % 10 == 0) puts("Yes");
  else if((n / 10 - 7) % 10 == 0) puts("Yes");
  else if((n / 100 - 7 % 100) == 0) puts("Yes");
  else puts("No");
  return 0;
}

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

int main() {
    int n;
    long r,g,b;
    cin >> n;
    string s;
    cin >> s;
    r=0;g=0;b=0;
    for(int i = 0;i < n;i++){
        switch(s[i]){
            case 'R':
                r++;break;
            case 'G':
                g++;break;
            case 'B':
                b++;break;
        }
    }
    long total = r*g*b;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            int k = 2*j + i;
            if (k >= n) break;
            if(s[i] != s[i+j] && s[i] != s[k] && s[i+j] != s[k])total--;
        }
    }

    cout << total << endl;
//--------------------
    return 0;
}

Measured memory_bytes: 3628