akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;

class Main {
    int N, Q, K;
    int[] x, y;
    ArrayList<Cost>[] list;
    long[] fromK;
    void solve(){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        list = new ArrayList[N];
        fromK = new long[N];
        for(int i = 0; i < N; i++){
            list[i] = new ArrayList<>();
        }
        for(int i = 0; i < N - 1; i++){
            int a = in.nextInt() - 1, b = in.nextInt() - 1, c = in.nextInt();
            list[a].add(new Cost(b, c));
            list[b].add(new Cost(a, c));
        }
        Q = in.nextInt(); K = in.nextInt() - 1;
        x = new int[Q]; y = new int[Q];
        for(int i =0; i < Q; i++){
            x[i] = in.nextInt() - 1;
            y[i] = in.nextInt() - 1;
        }
        in.close();
        dfs(K, -1, 0);
        for(int i = 0; i < Q; i++){
            System.out.println(fromK[x[i]] + fromK[y[i]]);
        }
    }

    void dfs(int pos, int parent, long cost){
        fromK[pos] = cost;
        for(Cost c : list[pos]){
            if(c.to == parent){
                continue;
            }
            dfs(c.to, pos, cost + c.cost);
        }
    }
    public static void main(String[] args) {
        new Main().solve();
    }
}

class Cost{
    int to;
    int cost;
    Cost(int t, int c){
        to = t; cost = c;
    }
}

Measured memory_bytes: 193652
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int main() {
	double a, b, c, d, e, f, x, y, G;

	while (cin >> a >> b >> c >> d >> e >> f) {
		//a*d-b*c=0:?§£??????
		G = 1 / (a*e - b*d);
		x = G*(e*c + (-b)*f);
		y = G*((-d)*c + a*f);
		if (fabs(x) < 1e-3) x = 0;
		if (fabs(y) < 1e-3) y = 0;
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
import java.util.*;


public class Main {

    private static final int INF = 1000000007;
    private static final int INF1 = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String str = sc.next();

        int[] array = new int[str.length()];

        for(int i=1; i<str.length(); i++){
            if(str.charAt(i) == 'C' && str.charAt(i-1) == 'A'){
                array[i] = array[i-1] + 1;
            }else{
                array[i] = array[i-1];
            }
        }

        for(int i=0; i<q; i++){
            int l = sc.nextInt();
            --l;
            int r = sc.nextInt();
            --r;
            System.out.println(array[r] - array[l]);
        }

    }
}


Measured memory_bytes: 61936
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+7;
ll qpow(ll a,ll b)
{
  ll ans=1;
  while(b)
  {
    if(b&1)
      ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}
ll C(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=a;i++)
  {
    ans=ans*i%mod;
  }
  ll res=1;
  for(int i=1;i<=b;i++)
    res=res*i%mod;
    ll ant=1;
  for(int i=1;i<=a-b;i++)
  {
    ant=ant*i%mod;
  }
  ans=ans*qpow(res,mod-2)%mod*qpow(ant,mod-2)%mod;
    return ans;
}
int a[55];
int main()
{
   ios::sync_with_stdio(0); cin.tie(0);
   int n;
   cin>>n;
   int sum=0;
   for(int i=1;i<=n;i++)
   {
     cin>>a[i];
     sum+=a[i];
   }
   ll ans=0;
   for(int i=1;i<n;i++)
   {
     sum-=a[i];
     ans+=a[i]*sum;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		double b = sc.nextDouble();
		long ib = (long) (b * 100 + 0.5);
		a *= ib;
		a /= 100;
		System.out.println(a);
		
		sc.close();
	}
}




Measured memory_bytes: 28964
#include <iostream>
using namespace std;
int main(void){
    int n,k,t,s,cnt = 0,cnt2 = 0,ans;
    cin >> n;
    k = n;
    t = n;
    s = n;
    if(n % 4 == 0){
        cout << "Yes" << endl;
        return 0;
    }
    else if(n % 7 == 0){
        cout << "Yes" << endl;
        return 0;
    }
    else if(n >= 5){
        while(n > 0){
            n -= 4;
            if(n % 7 == 0){
                cout << "Yes" << endl;
                return 0;
            }
            n -= 7;
            if(n % 4 == 0){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int player = 0;
	int judger = 0;
	int ave_li[100] = {};
	int flag = 1;
	int num = 0;
	while (flag == 1) {
		scanf("%d", &judger);
		if (judger > 0) {
			int max = -1;
			int min = 1001;
			int sum = 0;
			for (int i = 0; i < judger; i++) {
				scanf("%d", &num);
				if(max < num) max = num;
				if(min > num) min = num;
				sum += num;
			}
			ave_li[player] = (sum - max - min) / (judger -2);
			player++;
		} else {
			flag = 0;	
		}
	}
	for (int i = 0; i < player; i++) {
		printf("%d\n", ave_li[i]);
	}
	return 0;
}



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

int kiri,kanan,k,x,i;

int main(){
	ios_base::sync_with_stdio(false);

	cin>>k>>x;
	kiri=x-(k-1);
	kanan=x+(k-1);

	for(i=kiri;i<=kanan;i++){
		cout<<i;
		if(i!=kanan)cout<<" ";
	}
	cout<<"\n";
}

Measured memory_bytes: 256
//n - slimes
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
#include <iomanip>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007

ll dp[10000][10000] = {0};
ll n;
ll solve(vector<ll> &A) {



	ll sum1[1000000];
	for (ll i = 0; i < n; i++)
	{
		sum1[i] += ((i > 0) ? sum1[i - 1] : 0) + A[i];

	}


	for (ll d = 1; d < n; d++) {

		ll i = 0, j = d;

		while (j < n) {
			ll ans = 1e15;
			for (ll k = i; k < j; k++)
			{
				ans = min ( ans, dp[i][k] + dp[k + 1][j] + (sum1[j] - ((i > 0) ? sum1[i - 1] : 0 )));
			}


			dp[i][j] = ans;
			i++; j++;
		}
	}
	return dp[0][n - 1];
}


int main() {



	cin >> n;
	vector<ll> A;
	for (ll i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		A.push_back(a);
	}
	cout << solve(A);
	return 0;
}



Measured memory_bytes: 31232
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
int gate[100005];
int ans=0;
int main(void)
{
  int N,M;
  memset(gate,0,sizeof(gate));
  cin >> N >> M;
  for (int i = 0; i < M; ++i)
    {
      int l,r;
      cin >> l >> r;
      gate[l]++;
      gate[r+1]--;
    }
  for (int i = 1; i < N; ++i)
    {
      gate[i+1]+=gate[i];
    }
  for (int i = 1; i <= N; ++i)
    {
      if(gate[i]==M) ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long

using namespace std;
const int MN = 1e6+7;
const int MD = 1e9+7;
const ll BIG_INF = 1e18+7;
const int INF = 2147483645;

int a[MN], n;
string s[2];

int main()
{
    cin >> n;
    cin >> s[0] >> s[1];
    n *= 2;
    for(int i = 0; i < n; i++){
        cout << s[i&1][i/2];
    }
}


Measured memory_bytes: 256
fun main(args:Array<String>) {
	val c = (1..3).map{ readLine()!!.split(" ").map{ it.toInt() }}
	listOf(
			c[0][0]-c[0][1]==c[1][0]-c[1][1],
			c[0][0]-c[0][1]==c[2][0]-c[2][1],
			c[0][1]-c[0][2]==c[1][1]-c[1][2],
			c[0][1]-c[0][2]==c[2][1]-c[2][2],
			c[0][0]-c[1][0]==c[0][1]-c[1][1],
			c[0][0]-c[1][0]==c[0][2]-c[1][2],
			c[1][0]-c[2][0]==c[1][1]-c[2][1],
			c[1][0]-c[2][0]==c[1][2]-c[2][2]
	).all{it}.let{
		println( if(it)"Yes" else "No")
	}
	
}

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

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s)
    {
        a--;
    }
    else
    {
        b--;
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int M = 2e5 + 10;
int a[M] , b[M];
int main() {
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++) cin >> a[i];
    int flag = 0;
    int l = 1 , r = n;
    for(int i = n ; i >= 1 ; i--) {
        if(flag == 0) {
            b[l] = a[i];
            l++;
            flag = 1;
            continue;
        }
        else {
            b[r] = a[i];
            r--;
            flag = 0;
        }
    }
    for(int i = 1 ; i <= n ; i++) cout << b[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, M) { cin >> B[i]; }
    rep(i, N) {
        rep(j, M) { cin >> A[i][j]; }
    }
    int ans = 0;
    rep(i, N) {
        int k = 0;
        rep(j, M) { k += B[j] * A[i][j]; }
        if (0 < k + C) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 998244353LL;

ll dp[3300][3300];

int main() {
  ll n, s;
  cin >> n >> s;
  vll a(n);
  rep(i,n) cin >> a[i];
  dp[0][0] = 1;
  for(int i = 1; i<=n; i++) {
    for(int j = 0; j<=s; j++) {
      dp[i][j] = dp[i-1][j]*2;
      if(j-a[i-1]>=0) dp[i][j] += dp[i-1][j-a[i-1]];
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}


Measured memory_bytes: 80976
n = int(input())
a = list(map(int, input().split()))

if 1 in a:
    num = 1
    for i in range(n):
        if a[i] == num:
            a[i] = 0
            num += 1
        else:
            a[i] = 1
    print(sum(a))
else:
    print(-1)

Measured memory_bytes: 32276
while True:
    h,w = [int(x) for x in input().split( )]
    if h == w == 0:
        break
    else:
        print('#'*w)
        for i in range(h-2):
            print('{0}{1}{0}'.format('#','.'*(w-2)))
        print('#'*w)
        print('')









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

import sys
import os
import math
import re
import random

tableA = {
    "A": "00000",
    "B": "00001",
    "C": "00010",
    "D": "00011",
    "E": "00100",
    "F": "00101",
    "G": "00110",
    "H": "00111",
    "I": "01000",
    "J": "01001",
    "K": "01010",
    "L": "01011",
    "M": "01100",
    "N": "01101",
    "O": "01110",
    "P": "01111",
    "Q": "10000",
    "R": "10001",
    "S": "10010",
    "T": "10011",
    "U": "10100",
    "V": "10101",
    "W": "10110",
    "X": "10111",
    "Y": "11000",
    "Z": "11001",
    " ": "11010",
    ".": "11011",
    ",": "11100",
    "-": "11101",
    "'": "11110",
    "?": "11111"}

tableB = {
    "101": " ",
    "000000": "'",
    "000011": ",",
    "10010001": "-",
    "010001": ".",
    "000001": "?",
    "100101": "A",
    "10011010": "B",
    "0101": "C",
    "0001": "D",
    "110": "E",
    "01001": "F",
    "10011011": "G",
    "010000": "H",
    "0111": "I",
    "10011000": "J",
    "0110": "K",
    "00100": "L",
    "10011001": "M",
    "10011110": "N",
    "00101": "O",
    "111": "P",
    "10011111": "Q",
    "1000": "R",
    "00110": "S",
    "00111": "T",
    "10011100": "U",
    "10011101": "V",
    "000010": "W",
    "10010010": "X",
    "10010011": "Y",
    "10010000": "Z"}

def my_solve(s):
    # encode
    lst = []
    for c in s:
        lst.append(tableA[c])
    s = ''.join(lst)

    # en = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + ' .,-\'?'
    a = b = c = ''
    # for x in s: a += str(bin(en.index(x)))[2:].zfill(5)
    # s = a
    a = s

    # de = {
    #     '101': ' ', '000000': '\'', '000011': ',', '10010001': '-', '010001': '.', '000001': '?',
    #     '100101': 'A', '10011010': 'B', '0101': 'C', '0001': 'D', '110': 'E', '01001': 'F',
    #     '10011011': 'G', '010000': 'H', '0111': 'I', '10011000': 'J', '0110': 'K', '00100': 'L',
    #     '10011001': 'M', '10011110': 'N', '00101': 'O', '111': 'P', '10011111': 'Q', '1000': 'R',
    #     '00110': 'S', '00111': 'T', '10011100': 'U', '10011101': 'V', '000010': 'W', '10010010': 'X',
    #     '10010011': 'Y', '10010000': 'Z'
    # }
    # for x in a:
    #     b += x
    #     if b in de: c += de[b];b = ''
    # return c

    tmp, ans = '', ''
    for c in s:
        tmp += c
        if tmp in tableB:
            ans += tableB[tmp]
            tmp = ''
    return ans

while True:
    try:
        s = input()
    except:
        break

    print(my_solve(s))

Measured memory_bytes: 11788
# siawaseegoisuto273さんのものを参考にした。(pythonで書いた)
#

# N, Mの数
N, M = map(int, input().split())
L = [0] * M
R = [0] * M

# 明るさ
A = list(map(int, input().split()))


# 制約条件
for i in range(M):
    L[i], R[i] = map(int, input().split())
    
pre = [0] * (N+1)
dp = [0] * (N+1)

# 制約条件の書き換え
# pre[i]は、位置iが含まない制約の番号の最大を表す(ただしiより小さい)
# pre[i]が0は、同一の制約の中にi=1が含まれることを表す。
# preの作成のアルゴリズムが一番むずかしい
#
# 1. 
# R[i]の値を配列の位置情報(何番目)で表現する。
# pre[R[i]]は、L[i]の情報を表す(正確にはL[i]-1)
# ※制約条件は広い方に吸収される
# (R[i], L[i]) = {(4, 5), (3, 5), (6, 9), (7, 8), (10, 11), (10, 13)}
#              ->{(3, 5), (6, 9), 10, 13} となる。
#
# 2. 条件の隅の情報しか更新していないため、最後に後ろから値を詰めていって、完成する。
# 


# 制約の初期化
for i in range(1, N+1):
    pre[i] = i - 1

# 制約条件に含まれない左側
for i in range(M):
    pre[R[i]] = min(pre[R[i]], L[i]-1)
    # print("print pre")
    # print(pre)
    # print("")
    
for i in range(N-1, 0, -1):
    pre[i] = min(pre[i], pre[i+1])
    # print("print pre2")
    # print(pre)
    # print("")

# 動的計画法を解いていく
# 小さい方から値を詰めていく
for i in range(1, N+1):
    dp[i]=max(dp[i-1], dp[pre[i]] + A[i-1])
    # print(dp)

print(dp[N])


Measured memory_bytes: 38240
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

void precomp()
{
}



void solve()
{
    map<string, int> cnt;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        cnt[s]++;
    }
    cout<<"AC x " <<cnt["AC"]<<endl;
    cout<<"WA x " <<cnt["WA"]<<endl;
    cout<<"TLE x " <<cnt["TLE"]<<endl;
    cout<<"RE x " <<cnt["RE"]<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    precomp();
    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b;
	int n;
	int MAP[17][17];
	int dp[17][17];
	int y,x;
	int i,j;
	while(1){
		cin>>a>>b;
		if(a==0&&b==0)	break;
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++){
				MAP[i][j]=0;
				dp[i][j]=0;
			}
		}
		cin>>n;
		for(i=0;i<n;i++){
			cin>>x>>y;
			MAP[y][x]=-1;
		}
		dp[1][1]=1;
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++){
				if(MAP[i+1][j]!=-1&&i+1<=b)	dp[i+1][j]+=dp[i][j];
				if(MAP[i][j+1]!=-1&&j+1<=a)	dp[i][j+1]+=dp[i][j];
			}
		}
		cout<<dp[b][a]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3056
n, k = map(int, input().split())
a = list(map(int, input().split()))

# n-k回やる
for i in range(n-k):
    # iこ目をなくしてk+iこめをふやす
    if a[k+i] > a[i]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 94284
fun main(args:Array<String>) {
	val (h,w,b,a) = readLine()!!.split(" ").map {it.toInt()}
	val aa = Math.min(a,h-a)
	val bb = Math.min(b,w-b)

	val r = Array(h) {CharArray(w) {'0'}}

	for(i in 0 until aa) {
		for(j in 0 until bb) {
			r[i][j] = '1'
		}
	}
	for(i in aa until h) {
		for(j in bb until w) {
			r[i][j] = '1'
		}
	}

	r.forEach {println(it)}
}


Measured memory_bytes: 41460
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		String str=input.readLine();
		String[] str2=str.split(" ");
		int W=Integer.parseInt(str2[0]);
		int H=Integer.parseInt(str2[1]);
		int x=Integer.parseInt(str2[2]);
		int y=Integer.parseInt(str2[3]);
		int r=Integer.parseInt(str2[4]);
		if(x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0){
		System.out.println("Yes");

		}else{
		System.out.println("No");
		
		}

	}
}

Measured memory_bytes: 24352
n, x = map(int, input().split())

f_dict = {
  0: 1
}
def f(n):
  if f_dict.get(n):
    return f_dict.get(n)
  return (3 + f(n-1) * 2)


patty_dict = {
  0: 1
}
def total_patty(n):
  if patty_dict.get(n):
    return patty_dict.get(n)
  return (1 + 2 * total_patty(n - 1))

def count_patty(n, x):
  if n == 0 and x == 1:
    return 1
  elif x == 0:
    return 0
  elif 1 <= x and x <= f(n - 1) + 1:
    return count_patty(n - 1, x - 1)
  elif x == f(n - 1) + 2:
    return total_patty(n - 1) + 1
  elif f(n - 1) + 2 <= x and x <= 2 * f(n - 1) + 2:
    return total_patty(n - 1) + 1 + count_patty(n - 1, x - f(n - 1) - 2)
  else:
    return total_patty(n)

print(count_patty(n, x))

Measured memory_bytes: 9048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var o = Console.ReadLine();
			var e = Console.ReadLine();

			var password = new StringBuilder();

			for(var i = 0; i < e.Length; i++)
			{
				password.Append(o[i]);
				password.Append(e[i]);
			}

			if(o.Length > e.Length)
			{
				password.Append(o.Last());
			}
			
			Console.WriteLine(password.ToString());
		}
	}
}


Measured memory_bytes: 13268
import sys

sys.setrecursionlimit(10 ** 6)
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    def com(com_n, com_r):
        return fac[com_n] * inv[com_r] * inv[com_n - com_r] % md

    n, k = MI()
    aa = LI()
    # combinationの準備
    md = 10 ** 9 + 7
    n_max = n + 3
    fac = [1] * (n_max + 1)
    inv = [1] * (n_max + 1)
    for i in range(2, n_max + 1): fac[i] = fac[i - 1] * i % md
    inv[n_max] = pow(fac[n_max], md - 2, md)
    for i in range(n_max - 1, 1, -1): inv[i] = inv[i + 1] * (i + 1) % md

    dp = [0] * (n + 1)
    dp[0] = 1
    for a in aa:
        for j in range(n, -1, -1):
            pre = dp[j]
            if pre == 0: continue
            dp[j] = 0
            for dj in range(a + 1):
                nj = j + dj
                if nj > n or a - dj < 0 or n - j < dj: break
                dp[nj] += pre * com(n - j, dj) * com(n - dj, a - dj)
                dp[nj] %= md
        # print(dp)
    print(dp[n])

main()


Measured memory_bytes: 62044
#include<bits/stdc++.h>
using ll = int_fast64_t;

ll lcm(ll a, ll b){
	if(a==0) return b;
	else return a / std::__gcd(a, b) * b;
}

int main(){
	int n;
	ll ans = 0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		ll t;
		scanf("%ld", &t);
		ans = lcm(ans, t);
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
n = int(input())

if n == 1:
    print(0)
else:

    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        return arr

    fact = factorization(n)

    ans = 0
    for x, y in fact:
        tmp = 1
        while True:
            if (tmp + 1) * (tmp + 2) // 2 <= y:
                tmp += 1
            else:
                break

        ans += tmp

    print(ans)


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

int main() {
  int N, A, M = 1e9+7;
  cin >> N;
  long ans = 1;
  vector V(3, 0);
  while (cin >> A) {
    int cnt = 0, j = 0;
    for (int i = 0; i < 3; i++) {
      if (V.at(i) == A) cnt++, j = i;
    }
    ans *= cnt;
    ans %= M;
    V.at(j)++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  sort(a,a+n);
  ll ans=0;
  rep(i,n) {
    REP(j,i+1,n) {
      ll k=lower_bound(a,a+n,a[i]+a[j])-a;
      k--;
      ans+=max(0LL,k-j);
    }
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999999;

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    int x = *max_element(All(a));
    int y = INF;
    if(x%2){
        int tg = x/2;
        REP(i, n){
            if(x == a[i]) continue;
            if(abs(tg-y) > abs(tg-a[i])) y = a[i];
        }
        tg = x/2+1;
        REP(i, n){
            if(x == a[i]) continue;
            if(abs(tg-y) > abs(tg-a[i])) y = a[i];
        }
    }else{
        int tg = x/2;
        REP(i, n){
            if(x == a[i]) continue;
            if(abs(tg-y) > abs(tg-a[i])) y = a[i];
        }
    }

    cout << x << " " << y << "\n";
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (L, R, d) = readIntList()
    var ans = 0
    for (i in L .. R) {
        if (i % d == 0) ans++
    }
    println(ans)


}


private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readStringList(): MutableList<String> = read().split(" ").toMutableList()

private fun readIntList(): MutableList<Int> = readStringList().map { it.toInt() }.toMutableList()

private fun readLongList(): MutableList<Long> = readStringList().map { it.toLong() }.toMutableList()

private fun readDoubleList(): MutableList<Double> = readStringList().map { it.toDouble() }.toMutableList()

private fun readStringMatrix(n: Int): MutableList<MutableList<String>> {
    val matrix = mutableListOf<MutableList<String>>()
    for (i in 0 until n) {
        val list = readStringList()
        matrix.add(list)
    }
    return matrix
}

private fun readIntMatrix(n: Int): MutableList<MutableList<Int>> {
    val matrix = mutableListOf<MutableList<Int>>()
    for (i in 0 until n) {
        val list = readIntList()
        matrix.add(list)
    }
    return matrix
}

private fun readDoubleMatrix(n: Int): MutableList<MutableList<Double>> {
    val matrix = mutableListOf<MutableList<Double>>()
    for (i in 0 until n) {
        val list = readDoubleList()
        matrix.add(list)
    }
    return matrix
}

private fun readLongMatrix(n: Int): MutableList<MutableList<Long>> {
    val matrix = mutableListOf<MutableList<Long>>()
    for (i in 0 until n) {
        val list = readLongList()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 36476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  REP(i, 3) if (s[i] == t[i]) ans++;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3608
let s' = read_line ()
let t = read_line ()
let f = String.map (function '?' -> 'a' | c -> c)
let n, m, u = String.(length s', length t, ref "")
let _ = String.(for i = n - m downto 0 do let b = ref true in u := init m (fun j -> match s'.[i + j] with '?' -> t.[j] | c -> if c <> t.[j] then b := false; c);
  if !b then (print_endline @@ (f @@ sub s' 0 i) ^ !u ^ (f @@ sub s' (i + m) @@ n - i - m); exit 0) done); print_endline "UNRESTORABLE"

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

const int INF = 1e9+7;
int a[301][301];
int dp[301][301];

int main() {
    int N;
    cin >> N;
    rep(i, N) rep(j, N) {
        cin >> a[i][j];
        dp[i][j] = a[i][j];
    }
    rep(k, N) rep(i, N) rep(j, N) {
        if (k == i or k == j or i == j) continue;
        if (dp[i][k] + dp[k][j] == a[i][j]) {
            dp[i][j] = INF;
        }
        else if (dp[i][k] + dp[k][j] < a[i][j]) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll sum = 0;
    rep(i, N) rep(j, N) if (dp[i][j] != INF) sum += dp[i][j];
    cout << sum / 2 << endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  ll n, k; cin >> n >> k;
  ll ans = 0;
  if(k&1){
    ll x = n/k;
    ans = x*x*x;
  }else{
    k/=2;
    ll x = (n+k)/k/2;
    ans += x*x*x;
    x = n/k/2;
    ans += x*x*x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;


inline uint32 popcount(uint32 c) {
	c = (c & 0x55555555) + ((c >> 1) & 0x55555555);
	c = (c & 0x33333333) + ((c >> 2) & 0x33333333);
	c = (c & 0x0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f);
	c = (c & 0x00ff00ff) + ((c >> 8) & 0x00ff00ff);
	return c;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	cin >> n;
	uint32 f[100] = {};
	int32 p[100][10] = {};
	uint32 a;
	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> a;
			f[i] |= a << j;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, 11)
			cin >> p[i][j];
	}
	int32 ans = -INF;
	int32 cur;
	rep(i, 1, 1024) {
		cur = 0;
		rep(j, 0, n) {
			cur += p[j][popcount(i&f[j])];
		}
		ans = max(ans, cur);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
int i,j,k;
void solve(){
    int n;	
    cin>>n;	
    vector<int> L(n);
    for(int i=0;i<n;i++) cin>>L[i];
    int N = n;
    ll cnt = 0;
    for(i=0;i<N-2;i++){
        for(j=i+1;j<N-1;j++){
            if(L[i]==L[j]) continue;
            for(k=j+1;k<N;k++){
                if(L[j]==L[k] || L[k]==L[i]) continue;
                if(((L[i]+L[j])>L[k])
                     && ((L[i]+L[k])>L[j])
                         && ((L[j]+L[k])>L[i])){
                            cnt++;
                         }
            }
        }
    }
    cout<<cnt<<"\n";
    return;
}

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


Measured memory_bytes: 3608
#include <stdio.h>

int main(int argc, char *argv[])
{
    int a, b, c;
    int ans = 0;

    scanf("%d%d%d", &a, &b, &c);
    for (int x = a; x <= b; x++) {
        if (c % x == 0)
            ans++;
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};


    ll dp[2005];
    ll ok(int s){
        // cout<<"in "<<s<<"\n";
        if(s==0)
            return 1LL;
        else if(s==1 || s==2)
            return 0LL;
        else if(s>=3 && s<=5)
            return 1LL;
        else if(dp[s]!=-1)
            return dp[s];
        else{
            ll total=0;
            for(int i=3;i<=s;i++){
                if(s-i>=0)
                    total=add(total,ok(s-i));
            }
            return dp[s]=total;
        }
    }
    void solve(){
        int s;
        cin>>s;
        memset(dp,-1,sizeof(dp));
        dp[0]=1;
        cout<<ok(s);
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3680
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 200002;
const int MOD = 1000000007;

int n, c[MAX_N], f[MAX_N], ps[MAX_N];

void read_input() {
	cin >> n;

	for (int i=1; i<=n; ++i)
		cin >> c[i];
}

void dp() {
	f[0] = 1;

	for (int i=1; i<=n; ++i) {
		if (c[i]!=c[i-1])
			ps[c[i]] = (ps[c[i]] + f[i-1]) % MOD;
		f[i] = ps[c[i]];
	}
	// debug(f[1]);

	cout << f[n];
}

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".in", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);

	read_input();
	dp();
}

Measured memory_bytes: 2560
#pragma GCC opointimize("Ofset_asc")
#pragma GCC opointimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC opointimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        // freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    int n;
    IN n;
    vll v(n);
    unordered_map<ll,int> countt;
    ll sum=0;
    loop(i,0,n)
    {
        IN v[i];
        countt[v[i]]++;
        sum+=v[i];
    }
    int q;
    IN q;
    while(q--)
    {
        ll b,c;
        IN b>>c;
        sum-=(countt[b]*b);
        sum+=(countt[b]*c);
        countt[c]+=countt[b];
        countt[b]=0;
        OUT sum<<endl
    }
    return 0;
}

Measured memory_bytes: 7880
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String s= sc.nextLine();
		char c[]= s.toCharArray();

		for(int i=0;i<c.length;++i){
			if(Character.isUpperCase(c[i])) c[i]=Character.toLowerCase(c[i]);
			else if(Character.isLowerCase(c[i])) c[i]=Character.toUpperCase(c[i]);
		}

		StringBuilder sb = new StringBuilder(new String(c));

		System.out.println(sb.toString());


	}
}


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

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

    sort(a.begin(), a.end());
    int ans = 0;
    int k = 0;
    for(int i=0; i<n; ++i){
        if(a[i] - a[k] > 2)
            ++ k;
        ans = max(ans, i - k + 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
 
int main()
{
  
  long long int a,b,k;
  cin>>a>>b>>k;
  
  long long int tot = min(a,k);
  a -= tot;
  k -= tot;
  tot = min(b,k);
  b -= tot;
  
  cout<<a<<" "<<b<<"\n";
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    int n; cin >> n;
    int cnt = 0;
    string ans = "No";
    while(n--)
    {
      int a, b; cin >> a >> b;
      
      if(a == b) cnt++;
      else cnt = 0;
      if(cnt == 3) ans = "Yes";
    }
    cout << ans <<"\n";
  }
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

template <typename T>
class SegmentTree {
    using F = function<T(T, T)>;
    int n;
    F f;
    T t;
    vector <T> dat;
public:
    SegmentTree(F f, T t) : f(f), t(t) {}
    void init(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        dat.assign(n << 1, t);
    }
    void build(const vector <T> &v) {
        auto n_ = (int)v.size();
        init(n_);
        for (int i = 0; i < n_; i++) dat[n + i] = v[i];
        for (int i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }
    //k番目の値をxに変更する。
    void set_val(int k, T x) {
        dat[k += n] = x;
        while (k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
    //[a,b)に対してfを適用する。
    T query(int a, int b) {
        T vl = t, vr = t;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) vl = f(vl, dat[l++]);
            if (r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  auto f = [](long long a, long long b) { return a + b; };
  vector<SegmentTree<long long>> seg;
  REP(i, 26){
    SegmentTree<long long> segt(f, 0LL);
    segt.build(vector<long long>(n, 0LL));
    seg.push_back(segt);
  }
  REP(i, n){
    seg[s[i] - 'a'].set_val(i, 1LL);
  }
  char temp[n];
  REP(i, n){
    temp[i] = s[i];
  }
  int q;
  cin>>q;
  REP(h, q){
    int t;
    cin>>t;
    if(t == 1){
      int i;
      char c;
      cin>>i>>c;
      i--;
      if(temp[i] == c)continue;
      char x = temp[i];
      seg[x - 'a'].set_val(i, 0LL);
      seg[c - 'a'].set_val(i, 1LL);
      temp[i] = c;
    }else{
      int l, r;
      cin>>l>>r;
      l--;
      int res = 0;
      REP(i, 26){
        int num = seg[i].query(l, r);
        if(num > 0)res++;
      }
      cout<<res<<endl;
    }
  }
  return 0;
}

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

using namespace std;

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

  string s;cin>>s;
  int a=200001,z=-1,len=s.length();
  for(int i=0;i<len;i++){
      if(s[i]=='A') a=min(a,i);
      else if(s[i]=='Z') z=i;
  }
  cout<<z-a+1<<endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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 N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  int num_4 = 0;
  int num_2 = 0;
  int num_1 = 0;

  rep(i, N) {
    if (a[i] % 4 == 0)
      num_4++;
    else if (a[i] % 2 == 0)
      num_2++;
    else
      num_1++;
  }

  if (num_2 == 0) {
    if (num_1 <= num_4 + 1) {
      cout << "Yes" << endl;
      return 0;
    }
  } else {
    if (num_1 <= num_4) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int mod = 1e9 + 7;

const int nax = 2e5 + 5;
int fac[nax], inv_fac[nax];

int mul(int a, int b) {
    return (ll) a * b % mod;
}
int my_pow(int a, int b) {
    int r = 1;
    while(b) {
        if(b % 2) {
            r = mul(r, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return r;
}
int my_inv(int a) {
    return my_pow(a, mod - 2);
}

int binomial(int a, int b) {
    if(a < 0 || b < 0 || b > a) {
        return 0;
    }
    return mul(fac[a], mul(inv_fac[b], inv_fac[a-b]));
}

int f(int a, int b) {
    int tmp = binomial(a + b, b);
    //~ debug() << imie(a) imie(b) imie(tmp);
    return tmp;
}

int sub(int a, int b) {
    return (a - b + mod) % mod;
}

int main() {
    fac[0] = inv_fac[0] = 1;
    for(int i = 1; i < nax; ++i) {
        fac[i] = mul(fac[i-1], i);
        inv_fac[i] = my_inv(fac[i]);
    }
    int h, w, n;
    scanf("%d%d%d", &h, &w, &n);
    vector<pair<int,int>> in(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &in[i].first, &in[i].second);
    }
    sort(in.begin(), in.end(), [&](pair<int,int> a, pair<int,int> b) {
        return a.first + a.second < b.first + b.second;
    });
    // dp[i] - the number of paths to vertex in[i] such that it's the first
    // forbidden vertex
    
    in.emplace_back(h, w);
    
    vector<int> dp(n + 1);
    for(int i = 0; i <= n; ++i) {
        int tmp = f(in[i].first - 1, in[i].second - 1);
        debug() << imie(tmp);
        for(int j = 0; j < i; ++j) {
            if(in[j].first <= in[i].first && in[j].second <= in[i].second) {
                tmp = sub(tmp, mul(dp[j], f(in[i].first - in[j].first, in[i].second-in[j].second)));
            }
        }
        dp[i] = tmp;
    }
    debug() << imie(dp);
    printf("%d\n", dp[n]);
}

Measured memory_bytes: 1920
def abc147_c():
  # クエリ受け取り
  n = int(input())
  query = []
  for _ in range(n):
    a = int(input())
    q = [tuple(map(int, input().split())) for _ in range(a)]
    query.append(q)

  # bit全探索
  ans = 0
  for mask in range(1, 2**n):
    # i番目がTrueの人が正直者と仮定する
    honest = [False] * n
    for i in range(n):
      if (mask >> i) & 1: honest[i] = True

    # Trueの人の証言だけ拾って、矛盾があるかないか
    succ = True
    for i, q in enumerate(query):
      if (mask >> i) & 1:
        for x, y in q:
          if y == 1 and (not honest[x-1]):
            succ = False
            break
          elif y == 0 and honest[x-1]:
            succ = False
            break
      if not succ: break

    # 成り立っていれば、答えを更新
    if succ:
      ans = max(ans, honest.count(True))
  print(ans)

abc147_c()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    vector<int>B(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i)>>B.at(i);}
    int maxa=0;int ans=0;
    for(int i=0;i<N;i++){
       if(maxa<A.at(i)){maxa=A.at(i);ans=maxa+B.at(i);}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024