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

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    int N, K;
    cin >> N >> K;

    vi arr(N, 0);
    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int tp;
            cin >> tp;
            tp--;
            arr[tp]++;
        }
    }
    int ans = 0;
    rep(i, N){
        if(arr[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
import queue
n,m=map(int,input().split())
road_list=[set() for i in range(n)]
mitisirube=[0]*n
mitisirube[0]=1
for i in range(m):
    a,b=map(int,input().split())
    road_list[a-1].add(b)
    road_list[b-1].add(a)

q = queue.Queue()

counter_set=set()
counter_set.add(1)
for i in road_list[0]:
    q.put(i)
    mitisirube[i-1]=1
    counter_set.add(i)

while not q.empty():
    tmp=q.get()
    for i in road_list[tmp-1]:
        if i not in counter_set:
            q.put(i)
            counter_set.add(i)
            if mitisirube[i-1]==0:
                mitisirube[i-1]=tmp
print("Yes")
for i in range(1,len(mitisirube)):
    print(mitisirube[i])

Measured memory_bytes: 68832
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


# inputs
N = 0
S = ""

def set_inputs():
    global N, S
    N = get_int()
    S = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    if S.count("R") > S.count("B"):
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func modInv(a, mod int) int {
	b := mod
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		u -= t * v
		a, b = b, a
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

// 二項係数のmodを求める
func modCom(n, k, mod int) int {
	ret := 1
	for i := n - k + 1; i <= n; i++ {
		ret = (ret * i) % mod
	}
	for i := 2; i <= k; i++ {
		ret = (ret * modInv(i, mod)) % mod
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const mod = 1000000007

	n, k := nextInt2()

	for i := 1; i <= k; i++ {
		// k個の青いボールをi個のグループに分ける
		blue := 1
		if i < k {
			blue = modCom(k-1, i-1, mod)
		}
		// n-k個の赤いボールをi+1グループに分ける
		if n-k < i-1 {
			puts(0)
			continue
		}
		red := modCom(n-k+1, i, mod)

		puts((blue * red) % mod)
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,y=0;
	double x;
	cin>>n>>m;
	double a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		x+=a[i];
	}
	x=x/(4*m);
	for(int i=0;i<n;i++)
	{
		if(a[i]>=x)
		y++;
	}
	if(y>=m)
	printf("Yes");
	else
	printf("No");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int num = -4;
    if (S.charAt(0) == '+') num += 2;
    if (S.charAt(1) == '+') num += 2;
    if (S.charAt(2) == '+') num += 2;
    if (S.charAt(3) == '+') num += 2;
    System.out.println(num);
  }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

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

	int n;
	cin >> n;

	while(n--) {
		string ope, message;
		cin >> ope >> message;

		const int l = message.size();
		for(int i = ope.size() - 1; i >= 0; --i) {
			switch(ope[i]) {
			case 'A':
				reverse(message.begin(), message.end());
				break;
			case 'C':
				rotate(message.begin(), message.begin() + 1, message.end());
				break;
			case 'E':
				message = message.substr((l + 1) / 2)
					+ (l & 1 ? string(1, message[l / 2]) : "")
					+ message.substr(0, l / 2);
				break;
			case 'J':
				rotate(message.begin(), message.begin() + l - 1, message.end());
				break;
			case 'M':
				for(int j = 0; j < (int)message.size(); ++j)
					if(isdigit(message[j]))
						message[j] = (message[j] - '0' + 1) % 10 + '0';
				break;
			case 'P':
				for(int j = 0; j < (int)message.size(); ++j)
					if(isdigit(message[j]))
						message[j] = (message[j] - '0' + 10 - 1) % 10 + '0';
			}
		}

		cout << message << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1236
import math
def main():
  n=int(input())
  s = [input() for i in range(n)]
  m=int(input())
  t = [input() for i in range(m)]
  ans=0
  while len(s)>0:
    num=s.count(s[0])-t.count(s[0])
    if ans<num:
      ans=num
    s=[x for x in s if x != s[0]]
  print(ans)
  
main()


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int k, s, cnt=0;
    cin >> k >> s;
    rep(x, k+1){
        rep(y, k+1){
            if(s-x-y>=0&&s-x-y<=k){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 4e5 + 10;
ll h1, m1, h2, m2, t, ans;

int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> h1 >> m1 >> h2 >> m2 >> t;
    for(int i = h1; i <= h2; i ++){
        for(int j = 0; j <= 59; j ++){
            if(i == h1 && j < m1) continue;
            if(i == h2 && j > m2) continue;
            ll nh = i, nm = j + t;
            while(nm >= 60){
                nh ++;
                nm -= 60;
            }
            if(nh < h2) ans ++;
            else if(nh == h2 && nm <= m2) ans ++;
        }
    }
    cout << ans - 1 << '\n';
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


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

using namespace std;

int main(void){
    int N;    
    cin >> N;
    
    int max = 0;
    vector<int> s(N);
    for (int i=0; i<N; i++) {
        cin >> s[i];
        max += s[i];
    }

    if (max%10!=0) {
        cout << max;
        return 0;
    } else {
        sort(s.begin(), s.end());
        for (int i=0; i<N; i++) {
            if (s[i]%10==0) {
                continue;
            } else {
                cout << max - s[i];
                return 0;
            }
        }
        cout << 0;
        return 0;
    }
}


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

int main(){
	int n;
  	cin>>n;
  	vector<pair<int, int> > a;
  	for(int i=0;i<n;i++){
      	int t;
    	cin>>t;
      	a.push_back(make_pair(t, i));
    }
  	sort(a.begin(), a.end());

  	int ck[2]={a[0].first, 0};
  	long int sck=0; int b[n]={0};
  	for(int i=0;i<n;i++){
      	if(i==n-1){
        	int k=n-1-ck[1];
          	if(ck[0]==a[n-1].first) k++;
          	if(k>1){
          		sck+=(long int)k*(k-1)/2;
            }
          	for(int j=n-1;j>=ck[1];j--){
            	b[a[j].second]=k;
            }
          	if(ck[0]!=a[n-1].first) b[a[n-1].second]=1;
          	break;
        }
      	if(ck[0]!=a[i].first){
          	int k=i-ck[1];
            if(k>1){
        		sck+=(long int)k*(k-1)/2;
        	}
          	for(int j=i-1;j>=ck[1];j--){
            	b[a[j].second]=k;
            }
          	ck[0]=a[i].first; ck[1]=i;
        } 	
    }
  
  	for(int i=0;i<n;i++){
      	long int l=b[i]-1;
      	cout<<sck-l<<endl;
    }
  
}

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

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

    if (n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3560
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    words = list()
    word = input()
    words.append(word)
    prev = word[-1]

    for i in range(n - 1):
        cur = input()

        if cur in words:
            print('No')
            exit()

        if prev != cur[0]:
            print('No')
            exit()

        words.append(cur)
        prev = cur[-1]

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N, M = map(int, input().split())
K, S = [], []
for i in range(M):
  l = list(map(int, input().split()))
  K.append(l[0])
  S.append(l[1:])
P = [int(i) for i in input().split()]
ans = 0
for bit in range(1 << N):
  ok = True
  for i in range(M):
    cnt = 0
    for v in S[i]:
      if bit & (1<<(v-1)):
        cnt += 1
    if cnt%2!=P[i]:
      ok = False
  if ok:
    ans += 1
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<ll> t, a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<ll> minh(n);
    for (int i = 0; i < n; i++)
    {
        ll tempt;
        cin >> tempt;
        t.push_back(tempt);
    }
    for (int i = 0; i < n; i++)
    {
        ll tempa;
        cin >>tempa;
        a.push_back(tempa);
        minh[i]=min(t[i],tempa);
    }
    if(n==1){
        if(a[0]!=t[0])return cout<<0<<"\n",0;
    }
    vector<bool> used(n,false);
    used[0]=true;
    used[n-1]=true;
    for(int i=0;i<n-1;i++){
        if(t[i]<t[i+1]){
            if(used[i+1]==true&&a[i+1]<t[i+1])return cout<<0<<"\n",0;
            used[i+1]=true;
        }
    }
    for(int i=n-1;i>0;i--){
        if(a[i]<a[i-1]){
            if(a[i-1]>t[i-1]) return cout<<0<<"\n",0;
            used[i-1]=true;
        }
    }
    ll ans=1;
    for(int i=0;i<n;i++){
        if(!used[i]){
            ans*=minh[i];
            ans%=MOD;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3316
#include<iostream>
#include<vector>

const static int MAX = 1000;
const static int INF = 1001001001;

int M[MAX];
int C[MAX][MAX];

int main(void){
    int n;
    int trash;
    std::cin >> n;
    std::cin >> M[0];
    for(int i = 1; i <= n; i++){
	std::cin >> M[i];
	std::cin >> trash;
    }

    for(int i = 0; i < MAX; i++){
	for(int j = 0; j < MAX; j++){
	    C[i][j] = INF;
	}
    }

    for(int i = 0; i < MAX; i++){
	C[i][i] = 0;
    }


    for(int l = 2; l <= n; l++){
	for(int i = 1; i <= n - l + 1; i++){
	    int j = i + l - 1;
	    for(int k = i; k <= j; k++){
		int tmp = C[i][k] + C[k+1][j] + M[i-1] * M[k] * M[j]; 
		if(tmp < C[i][j]){
		    C[i][j] = tmp;
		}
	    }
	}
    }

    std::cout << C[1][n] << std::endl;

    return 0;
}



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

int main(void)
{
    char str[81];

    while (gets(str) != NULL) {
        int i, j, flag = 0;
        int len = strlen(str);

        for (i = 0; i <= 'z' - 'a'; ++i) {
            for (j = 0; j < len - 1; ++j)
                if ('a' <= str[j] && str[j] <= 'z')
                    str[j] = (str[j] == 'z') ? 'a' : str[j] + 1;

            for (j = 0; j < len - 4; ++j) {
                if (strncmp(str + j, "the", 3) == 0
                        || strncmp(str + j, "this", 4) == 0
                        || strncmp(str + j, "that", 4) == 0) {
                    printf("%s\n", str);
                    flag = 1;
                    break;
                }
            }

            if (flag)
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 520
#include <iostream>

using namespace std;

int main(void){

  int n,cnt;
  int s[12];
  int copys[12];
  while( cin >> n , n ){

    for( int i = 0 ; i < n ; i++ ){
      cin >> s[i];
      copys[i] = s[i];
    }

    int ans = 0;
    while(1){

      for( int i = 0 ; i < n ; i++ ){
	cnt = 0;
	for( int j = 0 ; j < n ; j++ ){
	  // cout << "s[i] = " << s[i] << " ";
	  //cout << "s[j] = " << s[j] << " " << endl;;
	  if( s[i] == s[j] ){
	    //cout << "cnt" << endl;
	    cnt++;
	  }
	}
	copys[i] = cnt;
	cnt = 0;
      }

      cnt = 0;
      for( int i = 0 ; i < n ; i++ ){
	if( copys[i] == s[i] ){
	  cnt++;
	}
	s[i] = copys[i];
      }   
      if( cnt == n ) break;
      ans++;
    }

    cout << ans << endl;
    for( int i = 0 ; i < n - 1 ; i++ )
      cout << s[i] << " ";
    cout << s[n - 1] << endl;
  }
  return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    vec p(m);
    vector<string> s(m);
    init(p, s);
    int ok = 0, pen = 0;
    vec rejected(n + 1);
    vector<bool> accepted(n + 1);

    rep (i, m) {
        if (not accepted[p[i]]) {
            if (s[i] == "WA")
                rejected[p[i]]++;
            else {
                accepted[p[i]] = true;
                ok++;
            }
        }
    }

    For(i, 1, n + 1) {
        if (accepted[i]) pen += rejected[i];
    }

    print(ok, pen);

    return 0;
}


Measured memory_bytes: 7296
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Exception Handling
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int a0 = 0, a1 = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", as + i);
    if (a0 < as[i]) a1 = a0, a0 = as[i];
    else if (a1 < as[i]) a1 = as[i];
  }
  //printf("a0=%d, a1=%d\n", a0, a1);

  for (int i = 0; i < n; i++)
    printf("%d\n", (a0 == as[i]) ? a1 : a0);
  return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>

int main(void){
    
    int x,y,W,H,r;
    
    scanf("%d",&W);
    scanf("%d",&H);
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&r);


    if(x>100 && x<-100)
        return 0;
    
    if(y>100 && y<-100)
        return 0;
    
    if(1>W && W>100)
        return 0;
    
    if(1>H && H>100)
        return 0;
    
    if(1>r && r>100)
        return 0;
    
    if(x-r>=0 && y-r>=0){
        
        if(x+r<=W && y+r<=H ){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
        
        
    }else{
        printf("No\n");
    }
    
    
    
    return 0;
}

Measured memory_bytes: 584
def main():
    N, M = map(int, input().split())
    A = [0] * (N + 1)
    for _ in range(M):
        A[int(input())] = 1
    dp = [0] * (N + 2)
    dp[-2] = 1
    for i in range(N - 1, -1, -1):
        if A[i] == 1:
            continue
        dp[i] = dp[i + 1] + dp[i + 2]
    print(dp[0] % 1000000007)


main()


Measured memory_bytes: 460788
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
int main() {
	int a, b, ans;
	vector<string> Si{};
	a = b = ans = 0;
	int ac, wa, tle, re;
		ac = wa = tle = re = 0;
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		
		Si.push_back("");
		cin >> Si[i];
		if (Si[i] == "AC")ac++;
		if (Si[i] == "WA")wa++;
		if (Si[i] == "TLE")tle++;
		if (Si[i] == "RE")re++;
	}

		cout << "AC x " << ac << endl;
		cout << "WA x " << wa << endl;
		cout << "TLE x " << tle << endl;
		cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 5948
import java.util.*;
 
 
class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
        int ans = 0;
        int t[] = new int[101];
        for(int i=0; i<t.length; i++) t[i] = 0;
        for(int i=a; i<b; i++) t[i]++;
        for(int i=c; i<d; i++) t[i]++;
        for(int i=0; i<100; i++) {
            if(t[i] == 2){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  string s; cin>>s;
  int ans=0;
  rep(i,3){
    if(s[i]=='1') ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て

int		main(void)
{
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> ref(A);
	vector<int> mic(B);
	for (int i = 0; i < A; i++)
		cin >> ref[i];
	for (int i = 0; i < B; i++)
		cin >> mic[i];
	int ans = 1e9;
	for (int i = 0; i < M; i++)
	{
		int x, y, c;
		cin >> x >> y >> c;
		ans = min(ans, ref[x-1] + mic[y-1] - c);
	}
	sort(all(ref));
	sort(all(mic));
	ans = min(ans, ref[0] + mic[0]);
	cout << ans << endl;
}



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

int64_t solve(int a, int b, int c){
  if(a%2 != 0 || b%2 != 0 || c%2 != 0){
    return 0;
  }
  else{
    if(a==b && b==c){ return -1; }
    else{
      const int offset= a/2 + b/2 + c/2;
      int64_t ans= 0;
      while(a%2==0 && b%2==0 && c%2==0){
        a= offset- a/2;
        b= offset- b/2;
        c= offset- c/2;
        ans++;
      }

      return ans;
    }
  }
}

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

  int64_t ans= solve(a,b,c);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s[100010];
char ans[100010];
int main()
{
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	for(int i=1;i<=n;i++)
	cin>>s[i];
	for(int i=1;i<=n;i++)
	{
		if(s[i]=="AB"){
			if(a==0&&b==0){
				printf("No\n");
				return 0;
			}
			if(a>b)a--,b++,ans[i]='B';
			else if(a<b)a++,b--,ans[i]='A';
			else{
				if(s[i+1]=="BC")a--,b++,ans[i]='B';
				else a++,b--,ans[i]='A';
			}
		}
		if(s[i]=="BC"){
			if(c==0&&b==0){
				printf("No\n");
				return 0;
			}
			if(c>b)c--,b++,ans[i]='B';
			else if(c<b)c++,b--,ans[i]='C';
			else{
				if(s[i+1]=="AB")c--,b++,ans[i]='B';
				else c++,b--,ans[i]='C';
			}
		}
		if(s[i]=="AC"){
			if(a==0&&c==0){
				printf("No\n");
				return 0;
			}
			if(a>c)a--,c++,ans[i]='C';
			else if(a<c)a++,c--,ans[i]='A';
			else{
				if(s[i+1]=="BC")a--,c++,ans[i]='C';
				else a++,c--,ans[i]='A';
			}
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n;i++)
	printf("%c\n",ans[i]);
}

Measured memory_bytes: 6988
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	dp := make([][]int, 10)
	for i := range dp {
		dp[i] = make([]int, 10)
	}
	for i := 1; i <= n; i++ {
		x := strconv.Itoa(i)
		dp[x[0]-'0'][x[len(x)-1]-'0']++
	}
	// puts(dp)

	ans := 0
	for i := 1; i <= n; i++ {
		x := strconv.Itoa(i)
		ans += dp[x[len(x)-1]-'0'][x[0]-'0']
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}


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

int n;
vector<bool> visited(9);
vector<int> perm;
double sum = 0;
double cnt = 0;
vector<pair<double, double>> a(9);
void dfs () {
    if ((int) perm.size() == n) {
        cnt++;
        for (int i = 0; i < n - 1; i++) {
            int ii = perm[i];
            int jj = perm[i + 1];
            double dx = a[ii].first - a[jj].first;
            double dy = a[ii].second - a[jj].second;
            sum += pow(dx * dx + dy * dy, 0.5);
        }
    } else {
        for (int i = 0; i < n; i++) {
            if(visited[i]) continue;
            visited[i] = 1;
            perm.push_back(i);
            dfs();
            visited[i] = 0;
            perm.pop_back();
        }
    }
}
void solve () {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    dfs();
    cout << fixed << setprecision(10) << sum / cnt;
}

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


Measured memory_bytes: 4288
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const LL MOD = 1e9+7;

LL X, Y;
int ans_depth;
LL ans_cnt;

LL fib[100];
vector<LL> A, B;
VI add;

void init() {
    fib[0] = fib[1] = 1;
    for (int i=2; i<100; i++) fib[i] = fib[i-1] + fib[i-2];
}

void calc() {
    A.clear(); B.clear(); add.clear();
    A.push_back(1);
    B.push_back(1);
    add.push_back(0);

    for (int depth=0; ; depth++) {
	if (fib[depth] <= X && fib[depth+1] <= Y && (X < fib[depth+1] || Y < fib[depth+2])) {
	    ans_depth = depth;
	    REP (i, A.size()) {
		if (A[i] <= X && B[i] <= Y && A[i] < fib[depth+2] && B[i] < fib[depth+2]) {
		    ans_cnt += (Y - B[i]) / A[i] + 1;
		    if (B[i] <= X && A[i] <= Y) {
			ans_cnt++;
		    }
		    if (ans_cnt >= (LL)(1e18)) ans_cnt %= MOD;
		}
	    }
	    break;
	} else {
	    int len = A.size();
	    REP (i, len) {
		if (add[i] == 0) {
		    LL tmp = A[i] + B[i] + B[i];
		    if (B[i] <= X && tmp <= Y) {
			A.push_back(B[i]);
			B.push_back(A[i]+B[i]+B[i]);
			add.push_back(1);
		    }
		}
		LL tmp = A[i] + B[i];
		A[i] = B[i];
		B[i] = tmp;
	    }
	}
    }

}

void MAIN() {
    scanf("%lld%lld", &X, &Y);
    if (X > Y) swap(X, Y);

    if (X == 1) {
	ans_cnt = Y % MOD;
	ans_depth = 1;
    } else if (X == 2 && Y == 2) {
	ans_depth = 1;
	ans_cnt = 4;
    } else {
	ans_depth = 1<<29;
	ans_cnt = 0;
	calc();
//	rec(1, 1, 1, 1, 0, 0);
	ans_cnt %= MOD;
    }
    printf("%d %lld\n", ans_depth, ans_cnt);
}

int main() {
    init();
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

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

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

int H,W;
cin >> H >> W;
vector<string> fi(H);
rep(h,H) cin >> fi[h];

vvi dist(H,vi(W,-1));
queue<pii> que;

// 初期条件
rep(h,H) rep(w,W) {
    if(fi[h][w] == '#') {
        dist[h][w] = 0;
        que.push(make_pair(h,w));
    }
}

int ans = 0;
while(!que.empty()) {
    pii p = que.front();
    que.pop();

    rep(i,4) {
        int nph =  p.first + dx[i];
        int npw = p.second + dy[i];
        if(nph < 0 || nph >= H || npw < 0 || npw >= W) continue;
        if(dist[nph][npw] != -1 ) continue;
        dist[nph][npw] = dist[p.first][p.second] + 1;
        chmax(ans, dist[nph][npw]);
        que.push(make_pair(nph, npw));
    }
}
cout << ans << endl;
return 0;
}

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

main()
{
    int h[10000],w[10000];

    for(int i=0;i<10000;i++)
    {
        cin>>h[i]>>w[i];
        if (h[i]==0&&w[i]==0) break;
    }



        for(int i=0;i<10000;i++)
        {
            if (h[i]==0&&w[i]==0) break;
            else
            {
                for(int j=0;j<h[i];j++)
                {
                    for(int k=0;k<w[i];k++)
                        cout<<"#";
                    cout<<endl;
                }
                cout<<endl;
            }
        }
}



Measured memory_bytes: 3136
L = input()
MOD = 10 ** 9 + 7

# dp[i][flg] := 上からi番目の桁まで見た時に、L以下であることがflg（未確定/確定）であるような、条件を満たす組み合わせの通り数
dp = [[0] * 2 for i in range(len(L) + 1)]
dp[0][0] = 1
for i, l in enumerate(L, start=1):
    if l == '0':
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD
    else:
        dp[i][0] = (2 * dp[i - 1][0]) % MOD
        dp[i][1] = (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD

print(sum(dp[-1]) % MOD)


Measured memory_bytes: 19620
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }


    a.mapIndexed { index, i -> Pair(index + 1, i) }
            .sortedBy { it.second }
            .forEach {
                print(it.first)
                print(' ')

            }

}

Measured memory_bytes: 84420
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
start = []
goal = []
flag = False
for x in range(M):
    if ab[x][0] == 1:
        start.append(ab[x][1])

    if ab[x][1] == N:
        goal.append(ab[x][0])

start_goal = set(start) & set(goal)

if start_goal:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 103640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var W = (double)sc.nextInt();
        var H = (double)sc.nextInt();
        var x = (double)sc.nextInt();
        var y = (double)sc.nextInt();
        var ans = W == x * 2 && H == y * 2 ? "1" : "0";
        WriteLine($"{(W * H) / 2} {ans}");
    }
}

class Combination {
    static int mod = 1000000007;

    public static long Calc(int a, int b) {
        if (b > a - b) return Calc(a, a - b);

        long ansMul = 1;
        long ansDiv = 1;
        for (int i = 0; i < b; i++) {
            ansMul *= (a - i);
            ansDiv *= (i + 1);
            ansMul %= mod;
            ansDiv %= mod;
        }
        return ansMul * ModPow(ansDiv, mod - 2) % mod;
    }

    private static long ModPow(long a, int p) {
        if (p == 0) return 1;
        if (p % 2 == 0) {
            long half = ModPow(a, p / 2);
            return half * half % mod;
        } else {
            return a * ModPow(a, p - 1) % mod;
        }
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



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

  string s;
  cin >> s;

  map<char, int> m;
  rep(i, s.length()) m[s[i]]++;
  bool f = true;
  if (m['N'] == 0 && m['S'] != 0) f = false;
  if (m['S'] == 0 && m['N'] != 0) f = false;
  if (m['W'] == 0 && m['E'] != 0) f = false;
  if (m['E'] == 0 && m['W'] != 0) f = false;
  cout << (f ? "Yes" : "No") << '\n';





  
  return 0;
}

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

using namespace std;

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int cntR = 0, cntB = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R')
      cntR++;
    else
      cntB++;
  if (cntB < cntR)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int N = 32;
  int an[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  std::cin >> K;
  --K;
  std::cout << an[K] << std::endl;
  return 0;
}

Measured memory_bytes: 256
/***********************************
*******AUTHOR SHASHI KANT **********         
****GMAIL Shshiksnt140895@gmail.com*
************************************                                  
***********************************/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
/*class graph
{
	map<int,list<int>>adj;
	public :
	       void addedge(int a, int b)
	       {
	           adj[a].push_back(b);
	           adj[b].push_back(a);
	       }

}*/
struct activity
{
	int a,b, c;
};
int max_val(vector<activity>ar, int n)
{
	vector<vector<int>>dp(n+1, vector<int>(4));
	dp[1][1] = ar[1].a;
	dp[1][2] = ar[1].b;
	dp[1][3] = ar[1].c;
	for(int i=2; i<=n; i++)
	{
		dp[i][1] = ar[i].a + max(dp[i-1][2], dp[i-1][3]);
		dp[i][2] = ar[i].b + max(dp[i-1][1], dp[i-1][3]);
		dp[i][3] = ar[i].c + max(dp[i-1][1],dp[i-1][2]);

	}
	return max(dp[n][1], max(dp[n][2], dp[n][3]));
}
int main(){
    //   int t;
      // cin>>t;
       //while(t--)
       //{
       	int n;
       	cin>>n;
           vector<activity>ar(n+1);
           for(int i=1; i<=n; i++)
           {
           	cin>>ar[i].a;
           	cin>>ar[i].b;
           	cin>>ar[i].c;
           }
         cout<<   max_val(ar, n) <<endl;


      // }	
	return 0;
}

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



int x1, x2, x3, x4, y11, y2, y3, y4;

int main(){
    scanf("%d %d %d %d", &x1, &y11, &x2, &y2);
    int base = (x2 -x1);
    int altura = (y2- y11);

    x3 = x2 - altura;
    y3 = y2 + base;

    x4 = x1 - altura;
    y4 = y11 + base;

    printf("%d %d %d %d\n", x3, y3, x4, y4);
}


Measured memory_bytes: 128
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
s = ns()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(10000):
    if 2 + 2 * i >= n: break
    for j in range(10000):
        if 2 + 2 * i + j >= n: break
        if not(s[j] == s[i+1+j] or s[i+1+j] == s[2*i+2+j] or s[2*i+2+j] == s[j]):
            ans -= 1

print(ans)

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

using Weight = int;
using Vertex = int;
struct Edge {Vertex from, to; Weight weight, charge;};
using Graph = vector<vector<Edge>>;

int main() {
  int N, M, L;
  cin >> N >> M >> L;

  Graph G(N);
  for(auto i = 0; i < M; ++i) {
    int A, B, C;
    cin >> A >> B >> C;
    --A; --B;
    if(L < C) continue;
    G[A].push_back({A, B, C});
    G[B].push_back({B, A, C});
  }

  vector<vector<Weight>> memo(G.size(), vector<Weight>(G.size(), -1));
  priority_queue<Edge, vector<Edge>, function<bool(const Edge&, const Edge&)>> q([](const Edge& lhs, const Edge& rhs) {
    if(lhs.charge != rhs.charge) return lhs.charge > rhs.charge;
    return lhs.weight < rhs.weight;
  });
  for(auto s = 0; s < N; ++s) {
    vector<vector<Weight>> d(G.size()+1, vector<Weight>(G.size(), -1));
    auto& m = memo[s];
    q.push({s, s, L, 0});
    while(!q.empty()) {
      auto cur = q.top(); q.pop();
      if(m[cur.to] != -1) continue;
      m[cur.to] = cur.charge;
      for(const auto& nex: G[cur.to]) if(m[nex.to] == -1) {
        auto w = cur.weight - nex.weight;
        auto c = cur.charge;
        if(cur.weight < nex.weight) w = L - nex.weight, ++c;
        if(w <= d[c][nex.to]) continue;
        d[c][nex.to] = w;
        q.push({cur.to, nex.to, w, c});
      }
    }
  }

  int Q;
  cin >> Q;
  for(auto i = 0; i < Q; ++i) {
    int s, t;
    cin >> s >> t;
    --s, --t;
    cout << memo[s][t] << endl;
  }
}


Measured memory_bytes: 4216
n = int(input())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))

li_a_sum = sum(li_a)
answer = 0


for idx in range(n):
    if li_a[idx] >= li_b[idx]:
        li_a[idx] -= li_b[idx]
        li_b[idx] = 0
    else:
        li_b[idx] = li_b[idx] - li_a[idx]
        li_a[idx] = 0

    if li_b[idx] > 0:
        if li_a[idx + 1] >= li_b[idx]:
            li_a[idx + 1] = li_a[idx + 1] - li_b[idx]
            li_b[idx] = 0
        else:
            li_b[idx] -= li_a[idx + 1]
            li_a[idx + 1] = 0

print(li_a_sum - sum(li_a))


Measured memory_bytes: 18440
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = 1; i < S.size()+1; i++)
	{
		if (i % 2)cout << S[i - 1];
	}
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

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

    static class SkillUp {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int x = in.nextInt();

            int[] c = new int[n];
            int[][] a = new int[n][m];

            for (int i = 0; i < n; i++) {
                c[i] = in.nextInt();
                for (int j = 0; j < m; j++) {
                    a[i][j] = in.nextInt();
                }
            }

            List<Integer> costs = new ArrayList<>();
            for (int i = 0; i < 1 << n; i++) {
                int[] tmpSkill = new int[m];
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    if ((1 & i >> j) == 1) {
                        // j冊目を購入
                        for (int k = 0; k < m; k++) {
                            tmpSkill[k] += a[j][k];
                        }
                        cost += c[j];
                    }
                }

                boolean over_x = true;
                for (int j = 0; j < m; j++) {
                    if (tmpSkill[j] < x) {
                        over_x = false;
                        break;
                    }
                }

                if (over_x) {
                    costs.add(cost);
                }
            }


            if (!costs.isEmpty()) {
                costs.sort(Comparator.naturalOrder());
                out.append(String.valueOf(costs.get(0)));
                return;
            }
            out.append("-1\n");
        }

    }
}



Measured memory_bytes: 37976
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int cnt[30]={};
    for(int i=0;i<4;i++){
        cnt[s[i]-'A']++;
    }
    int res=0;
    rep(i,30){
        if(cnt[i]==2)res++;
    }
    if(res==2)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();
            int[] GCDW = new int[N + 1];
            int[] GCDE = new int[N + 1];

            GCDW[0] = 0;
            GCDE[0] = 0;

            for (int i = 1; i < N + 1; i++)
            {
                if (S[i - 1] == 'W')
                {
                    GCDW[i] = GCDW[i - 1] + 1;
                    GCDE[i] = GCDE[i - 1];
                }
                else
                {
                    GCDW[i] = GCDW[i - 1];
                    GCDE[i] = GCDE[i - 1] + 1;
                }
            }

            int ans = N;

            for (int i = 0; i < N; i++)
            {
                int res = GCDW[i] + (GCDE[N] - GCDE[i + 1]);
                if (res < ans)
                {
                    ans = res;
                }
            }

            Console.WriteLine(ans);

        }
    }
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  vector<ll> a(n);

  bool all_0 = true;
  rep(i, n){
    cin >> a[i];
    if(a[i]!=0){
      all_0 = false;
    }
  }

  if(all_0){
    cout << "Yes" << endl;
  }else{

    if(n % 3 != 0){
      cout << "No" << endl;
      return 0;
    }

    map<ll, int> mp;
    rep(i, n){
      mp[a[i]]++;
    }

    if(mp.size() == 3){
      vector<ll> b;
      bool ok = true;
      for(auto p : mp){
        b.push_back(p.first);
        if(p.second != n / 3){
          ok = false;
        }
      }

      if(((b[0] ^ (b[1] ^ b[2])) == 0LL) && ok){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }

    }else if(mp.size()==2){
      
      if(mp[0] == n/3){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }

    }else{
      cout << "No" << endl;
    }

  }

  return 0;
}


Measured memory_bytes: 5760