akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
ll dp[MAX][4];
ll a[MAX][4];
int main(){FAST;
cin>>n;
for(ll i=1;i<=n;++i){
  for(ll j=1;j<=3;++j){
    cin>>a[i][j];
  }
}
for(ll i=1;i<=n;++i){
  for(ll j=1;j<=3;++j){
    for(ll k=1;k<=3;++k){
      if(j != k){
        dp[i][j] = max(dp[i-1][k]+a[i][j],dp[i][j]);
      }
    }
  }
}
cout<<*max_element(dp[n]+1,dp[n]+4);  
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 9804
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 400005;
const int MM = 1000000007;

int main()
{
	int mn[10] = {}, a, N;
	for(int i = 0; i < 10; i++) mn[i] = 1e9;
	scanf("%d", &N);
	ll sum = 0;
	for(int i = 1; i <= N; i++){
		scanf("%d", &a);
		sum += a;
		mn[a%10] = min(mn[a%10], a);
	}
	if( sum%10 != 0) return !printf("%lld\n", sum);
	int gmn = 1e9;
	for(int i = 1; i < 10; i++){
		gmn = min(gmn, mn[i]);
	}
	if( gmn == 1e9 ) printf("0\n");
	else printf("%lld\n", sum - gmn);
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a  = sc.nextInt();
        int b = sc.nextInt();

        if(b%a==0){
            System.out.println(a+b);
        }else{
            System.out.println(b-a);
        }
        
    }

}


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

int main(){
    int N;
    cin >> N;
    
    vector<tuple<string, int, int>> restaurant(N);
    for(int i = 0; i < restaurant.size(); i++){
        get<2>(restaurant.at(i)) = i + 1;
        cin >> get<0>(restaurant.at(i)) >> get<1>(restaurant.at(i));
        get<1>(restaurant.at(i)) *= -1;
    }
    
    sort(restaurant.begin(), restaurant.end());
    
    for(auto r: restaurant){
        cout << get<2>(r) << endl;
    }

    
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


using P = pair<int ,int>;
using LPP = pair<ll, P>;
int main(){
	int N;
	cin >> N;
	vector<LPP> hxy(N);
	for(int i=0; i<N; i++){
		int x, y; ll h;
		cin >> x >> y >> h;
		hxy.emplace_back(h, P(x, y));
	}
	sort(hxy.rbegin(), hxy.rend());

	int ansx=-1, ansy=-1; ll ansH=-1;
	for(int Cx=0; Cx<=100; Cx++){
		for(int Cy=0; Cy<=100; Cy++){
			bool is_ok = true;
			ll h = hxy[0].first;
			int x = hxy[0].second.first;
			int y = hxy[0].second.second;
			ll H = h + abs(x-Cx) + abs(y-Cy);
			for(int i=1; i<N; i++){
				ll tmp = max(H - abs(hxy[i].second.first-Cx) - abs(hxy[i].second.second-Cy), (ll)0);
				// cout << " Cx: " << Cx << " Cy: " << Cy << " i: " << i << " H: " << H << " x: " << x << " y: " << y << " h: " << h << "  tmp: " << tmp << endl;
				if(hxy[i].first == tmp) continue; 
				is_ok = false;
				if(is_ok == false) break;
			}
			if(is_ok == true){
				ansH = H;
				ansx = Cx;
				ansy = Cy;
				break;
			}
		}
	}

	cout << ansx << " " << ansy << " "  << ansH << endl;


}



Measured memory_bytes: 3652
local n,x=io.read("n","n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local counter=0
for i=1,n-1 do
    local sum=a[i]+a[i+1]
    if sum>x then
        local diff=sum-x
        counter=counter+diff
        if diff<a[i+1] then
            a[i+1]=a[i+1]-diff
        else
            diff=diff-a[i+1]
            a[i+1]=0
            a[i]=a[i]-diff
        end
    end
end
print(string.format("%d",counter))

Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define inf 1000000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int x,y,a,b,c;
int p[100005],q[100005],r[100005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++)
		cin>>p[i];
	for(int i=1;i<=b;i++)
		cin>>q[i];
	for(int i=1;i<=c;i++)
		cin>>r[i];
	p[0]=inf,q[0]=inf;
	sort(p+1,p+a+1);
	reverse(p+1,p+a+1);
	sort(q+1,q+b+1);
	reverse(q+1,q+b+1);
	sort(r+1,r+c+1);
	reverse(r+1,r+c+1);
	int ans=0;
	for(int i=1;i<=x;i++)
		ans+=p[i];
	for(int i=1;i<=y;i++)
		ans+=q[i];
	int cnt=1;
	while(1)
	{
		int i=p[x],j=q[y],k=r[cnt];
		if(i>=k&&j>=k)
			break;
		if(i>j)
		{
			ans-=j;
			ans+=k;
			cnt++;
			y--;
		}
		else
		{
			ans-=i;
			ans+=k;
			cnt++;
			x--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

int min(int a, int b) {
	if (a < b)
		return a;
	return b;
}

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


string s, k;
int dp[3005][3005];

int getLen(int i, int j) {

	if (i >= s.length() || j >= k.length() ) {
		return 0;
	}

	if (dp[i][j] != -1)	return dp[i][j];

	if (s[i] == k[j])		dp[i][j] = 1 + getLen(i + 1, j + 1);

	dp[i][j] = max(dp[i][j], max(getLen(i + 1, j), getLen(i, j + 1)));

	return dp[i][j];
}

string getLcs(int len) {
	string ans = "";
	int i, j;
	i = j = 0;

	while (i < s.length() && j < k.length()) {

		if (s[i] == k[j]) {
			ans += s[i];
			i++; j++;
			len--;
		}
		else {
			if (dp[i][j + 1] > dp[i + 1][j]) {
				j++;
			}
			else {
				i++;
			}
		}
	}

	return ans;

}

void solve() {
	int len = getLen(0, 0);
	cout << getLcs(len);
	nl;

	return;
}

int32_t main() {

	fastIO();

	memset(dp, -1, sizeof(dp));

	cin >> s;
	cin >> k;

	solve();

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;

Measured memory_bytes: 74556
n = gets.to_i
vs = gets.split.map(&:to_i)
e = {}
o = {}
e1 = 0
e1v = nil
e2 = 0
e2v = nil
o1 = 0
o1v = nil
o2 = 0
o2v = nil
vs.each_with_index do |v, i|
  if i % 2 == 0
	e[v] = 0 unless e[v]
    e[v] += 1
    if e[v] > e1
      if v == e2v
        e2v = e1v
        e2 = e1
        e1v = v
        e1 = e[v]
      else
        e1v = v
        e1 = e[v]
      end
    elsif e[v] > e2
      e2 = e[v]
      e2v = v
    end
  else
	o[v] = 0 unless o[v]
    o[v] += 1
    if o[v] > o1
      if v == o2v
        o2v = o1v
        o2 = o1
        o1v = v
        o1 = o[v]
      else
        o1v = v
        o1 = o[v]
      end
    elsif o[v] > o2
      o2 = o[v]
      o2v = v
    end
  end
end
if e1v != o1v
  puts (n - e1 - o1)
else
  puts [ (n - e1 - o2), (n - e2 - o1)].min
end

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int x, a, b;
  cin >> x >> a >> b;
  int t = b - a;
  if (t <= 0) cout << "delicious" << '\n';
  else if (t <= x) cout << "safe" << '\n';
  else cout << "dangerous" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s; cin >> s;
    int res = 0; rep(i,s.size())res += s[i] - '0';
    cout << (stoll(s)%res?"No":"Yes") << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N,1);
  set<int> B;
  B.insert(0);
  int r=0;
  for(int i=0;i<M;i++){
    int x,y;
    cin>>x>>y;
    if(B.count(x-1)){
      if(A[x-1]==1){
        B.erase(x-1);
      }
      B.insert(y-1);
    }
    A[x-1]--;
    A[y-1]++;
  }
  cout<<B.size()<<endl;
}

Measured memory_bytes: 8200
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

const int INF = 0x0ffffff;

int main()
{
    int n;
    cin >> n;
    
    vector<pair<int, int>> job(n);
    for (int i = 0; i < n; ++i) {
    	int x, l;
    	cin >> x >> l;
        job[i].second = x - l;
        job[i].first = x + l;
    }
    
    int res = 0, t = -INF;
    sort(job.begin(), job.end());
    for (int i = 0; i < n; ++i) {
        if (t <= job[i].second) {
            ++res;
            t = job[i].first;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

// var rdr = bufio.NewReaderSize(os.Stdin, 100000)
var rdr *bufio.Reader

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	// ABC093C
	in := nextInt
	a := in()
	b := in()
	c := in()

	start := a + b + c
	m := max(a, max(b, c))

	ans := 0
	if (m*3-start)%2 == 0 {
		ans = (m*3 - start) / 2
	} else {
		ans = ((m+1)*3 - start) / 2
	}

	fmt.Println(ans)
}

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

func readLine() string {
	buf := make([]byte, 0, 100000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextI64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func maxi64(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func updateMax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func mini64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func updateMin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func absi64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 640
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

A_p1 = [a+1 for a in A]
A_m1 = [a-1 for a in A]

cnt = Counter(A_p1)
cnt += Counter(A)
cnt += Counter(A_m1)

print(max(list(cnt.values())))

Measured memory_bytes: 30684
#include <stdio.h>

int main(void)
{
	int n, i;
	char s[101], t[101];

	scanf("%d", &n);

	scanf("%s", &s);
	scanf("%s", &t);

	for (i = 0; i < n; i++) //SとTを交互に表示する
	{
		printf("%c%c", s[i], t[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
 
int main(){
  int i,cnt;
  double xa, ya, ra, xb, yb, rb, dist;
  scanf("%d", &cnt);
  for(i=0;i<cnt;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&xa, &ya,&ra,&xb,&yb,&rb);
    dist = sqrt(pow(xa-xb,2)+pow(ya-yb,2));
    if(dist>ra+rb){
      printf("0\n");
    }else if(dist >= fabs(ra-rb)){
      printf("1\n");
    }else if(ra>rb){
      printf("2\n");
    }else{
      printf("-2\n");
    }
  }
  return 0;
}

Measured memory_bytes: 620
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
h,n = map(int, stdin.readline().rstrip().split())
As = list(map(int, stdin.readline().rstrip().split()))
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

sum = 0
for i in range(n):
    sum += As[i]

if sum >= h:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14092
#include<iostream>
using namespace std;
typedef long int li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
#define Please return
#define AC 0

int vec[]={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 main(){
  int k; cin >>k;
  cout << vec[k-1];
  Please AC;
}


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

using namespace std;

typedef long long ll;

ll a[500500], b[500500], d[500500];

int main() {
	int n; scanf("%d%lld", &n, &a[0]);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &d[i]);
		a[i] = min(a[i - 1], llabs(a[i - 1] - d[i]));
	}
	int q; scanf("%d", &q); b[n] = 1;
	for(int i = n; i > 0; i--) {
		if(b[i] <= (d[i] / 2)) b[i - 1] = b[i];
		else b[i - 1] = b[i] + d[i];
	}
	for(int i = 1; i <= q; i++) {
		int x; scanf("%d", &x); puts((b[x] <= a[x - 1]) ? "YES" : "NO");
	}

	/*for(int i = 1; i <= n; i++) printf("%lld ", a[i]);
	puts("");
	for(int i = 1; i <= n; i++) printf("%lld ", b[i]);
	puts("");*/
	

	return 0;
}

Measured memory_bytes: 13696
use std::io;

fn main() {
    let R=get_int();
    let G=get_int();
    println!("{}",2*G-R);
}

fn get_String()->String{
    let mut s =String::new();
    io::stdin().read_line(&mut s).expect("Fail!");        
    s.trim().to_string()
}

fn get_int()->i32{
    let mut input =String::new();
    io::stdin().read_line(&mut input).expect("Fail!");
    input.trim().to_string().parse().unwrap()
}


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

int main() {

    int n;
    cin >> n;

    string str;
    cin >> str;

    int a = 0;
    int m = 0;

    for(int i = 0; i < n; i++){
        if(str[i] == 'I'){
            ++a;
            m = max(a, m);
        }
        if(str[i] == 'D'){
            --a;
        }
    }
    cout << m << endl;

    return 0;
}


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

const int N = 5e5 + 10;
char s[N];
int n, q;

struct Node {
	int l, r;
	int v;
} t[26][N << 2];

void pushup(Node tr[], int u) {
	tr[u].v = tr[u << 1].v + tr[u << 1 | 1].v;
}

void build(int i, Node tr[], int u, int l, int r) {
	tr[u] = {l, r, 0};
	if(l == r) {
		tr[u].v = (s[l] - 'a' == i);
		return ;
	}

	int mid = l + r >> 1;
	build(i, tr, u << 1, l, mid), build(i, tr, u << 1 | 1, mid + 1, r);
	pushup(tr, u);
}

void modify(int i, Node tr[], int u, int x, int d) {
	if(tr[u].l == x && tr[u].r == x) {
		tr[u].v = d;
		return ;
	}

	int mid = tr[u].l + tr[u].r >> 1;
	if(x <= mid) modify(i, tr, u << 1, x, d);
	else modify(i, tr, u << 1 | 1, x, d);
	pushup(tr, u);
}

int query(int i, Node tr[], int u, int l, int r) {
	if(l <= tr[u].l && r >= tr[u].r) return tr[u].v;

	int mid = tr[u].l + tr[u].r >> 1;

	int res = 0;
	if(l <= mid) res += query(i, tr, u << 1, l, r);
	if(r > mid) res += query(i, tr, u << 1 | 1, l, r);

	return res;
}

int main() {
	scanf("%d%s%d", &n, s + 1, &q);
	for(int i = 0; i < 26; i++) build(i, t[i], 1, 1, n);

	while(q--) {
		int op, x, y;
		char ch[2];
		scanf("%d", &op);

		if(op == 1) {
			scanf("%d%s", &x, ch);
			char c2 = s[x];
			if(c2 == ch[0]) continue;
			else {
				s[x] = ch[0];
				int t1 = ch[0] - 'a';
				int t2 = c2 - 'a';
				modify(t1, t[t1], 1, x, 1);
				modify(t2, t[t2], 1, x, 0);
			}
		}

		else {
			scanf("%d%d", &x, &y);
			int ans = 0;
			for(int i = 0; i < 26; i++) if(query(i, t[i], 1, x, y)) ans++;
			printf("%d\n", ans);
		}
	}

	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,Y;
    cin>>N>>Y;
    REP(i,N+1) {
        REP(j,N-i+1) {
            int n = N - (i + j);
            int m = Y - i * 10000 - j * 5000;
            if (m == n * 1000) {
                cout<<i<<" "<<j<<" "<<n<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)


const i64 NUM = 998244353LL;
i64 pow_(i64 a, i64 b) {
  i64 ans = 1;
  while(b != 0) {
    if(b % 2 == 1) {
      ans *= a;
      ans %= NUM;
    }

    b /= 2;
    a = a * a;
    a %= NUM;
  }
  return ans;
}

int main(int argc, char *argv[]) {
  i64 N;
  cin >> N;
  i64 D0;
  cin >> D0;
  --N;
  i64 i;
  map<i64, i64> D;
  REP(0, N, i) {
    i64 d;
    cin >> d;
    if(D.find(d) == D.end())
      D[d] = 1;
    else
      D[d]++;
  }
  if(D0 != 0) {
    cout << 0 << endl;
  }
  else {
    bool valid = true;
    i64 d = 0;
    i64 ans = 1;
    i64 c_prev = 1;
    for(auto it: D) {
      //cout << it.first << " " << it.second << endl;
      if(it.first != d + 1) {
	valid = false;
	break;
      }
      //ans *= (c_prev * it.second) % NUM;
      ans *= pow_(c_prev, it.second);
      ans %= NUM;
      d = it.first;
      c_prev = it.second;
    }
    if(!valid)
      cout << 0 << endl;
    else
      cout << ans << endl;
  }

  return 0;
}


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

int main(){
    int n, i, wc, c = 1000000;
    string s;
    cin >> n >> s;
    int l[n] = {}, r[n+1] = {};
    wc = 0;
    for(i=0; i<n; i++){
        l[i] = wc;
        if(s[i] == 'W') wc++;
    }
    wc = 0;
    for(i=n-1; i>=0; i--){
        r[i] = wc;
        if(s[i] == 'E') wc++;
    }
    for(i=0; i<n; i++){
        c = min(c, l[i]+r[i]);
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 2948
def solve():
    n = int(input())
    a = tuple(map(int,input().split()))
    cnt = [0]*1000000
    for i in a:
        if i!=0:
            cnt[i-1]+=1
        cnt[i]+=1
        cnt[i+1]+=1
    mx = (0,0)
    for i in range(100100):
        if cnt[i]>mx[0]:
            mx = (cnt[i],i)
    print(mx[0])
if __name__ == "__main__":
    solve()

Measured memory_bytes: 15872
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            for(var i = 0;i<S.Length;i++)
            {
                S = S[S.Length - 1].ToString() + S.Remove(S.Length-1);
                if(S.SequenceEqual(T))
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int n, head[100009], to[100009 * 2], nxt[100009 * 2], val[100009 * 2], tot = 1;

void add(int x, int y) {
    to[++tot] = y;
    nxt[tot] = head[x];
    head[x] = tot;
}

int maxcol = INT_MIN;

void dfs(int x, int fa, int col) {
    int num = 0;
    for (int i = head[x]; i; i = nxt[i]) {
        int y = to[i];
        if (y == fa)continue;
        ++num;
        if (num == col)num++;
        maxcol = max(maxcol, num);
        val[i] = val[i ^ 1] = num;
        dfs(y, x, num);
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        add(u, v);
        add(v, u);
    }
    dfs(1, 0, 0);
    printf("%d\n", maxcol);
    for (int i = 2; i < tot; i += 2)
        printf("%d\n", val[i]);
    return 0;
}

Measured memory_bytes: 4736
#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 COUT(x) cout << (x) << endl
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(ALL(d));
    n /= 2;
    COUT(d[n] - d[n - 1]);

    return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String N = String.valueOf(n);
    if(N.charAt(0)==N.charAt(2)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    for(int i=0; i<s.length(); i++){
        string temp = "";
        temp+=s[s.length()-1];
        s.insert(0,temp);
        s.pop_back();
        if(s==t) return cout<<"Yes"<<endl,0;
    }
    cout<<"No"<<endl;


    return 0;
}


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

int main() {
	int n = 200005;
	int a[200005];
	
	for(int i = 0; i < n; i++) {
		a[i] = 1;
	}
	
	for(int i = 2; i < n; i+=2) {
		a[i] = 0;
	}
	
	a[2] = 1;
	
	for(int i = 3; i < n; i+=2) {
		for(int j = 2*i; j < n; j+=i) {
			a[j] = 0;
		}
	}
	
	int x; 
	
	cin >> x;
	
	for(int i = x; i < n; i++) {
		if(a[i]) {
			cout << i; 
			return 0;
		}
	}
	
	return 0;
}

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

typedef pair<int, int> pii;
const int MAXN = 1e5 + 10;

int N;
int A[MAXN], B[MAXN];
pii AA[MAXN], BB[MAXN];
int D[MAXN];
int CK[MAXN];
void y(){
    cout << "Yes\n";
    exit(0);
}

void n(){
    cout << "No\n";
    exit(0);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;
    for(int i = 1 ; i <= N ; i++) cin >> A[i];
    for(int i = 1 ; i <= N ; i++) cin >> B[i];

    for(int i = 1 ; i <= N ; i++) AA[i].first = A[i], BB[i].first = B[i];
    for(int i = 1 ; i <= N ; i++) AA[i].second = i, BB[i].second = i;

    sort(A + 1, A + 1 + N);
    sort(B + 1, B + 1 + N);
    for(int i = 1 ; i <= N ; i++) if(A[i] > B[i]) n();

    sort(AA + 1, AA + 1 + N);
    sort(BB + 1, BB + 1 + N);

    int pos = 1;
    for(int i = 1 ; i <= N ; i++){
        int cnt = 0;
        while(pos <= N && BB[i].first >= AA[pos].first) cnt++, pos++;
        
        if(cnt == 0) n();
        else if(cnt > 1) y();
    }

    for(int i = 1 ; i <= N ; i++) D[BB[i].second] = AA[i].second;

    int cnt = 0;
    int p = 1;
    while(!CK[p]){
        CK[p] = 1;    cnt++;
        p = D[p];
    }

    if(cnt == N) n();
    else y();

    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main ()
{
    int N[3];
    
    //A,B,Cの値を標準入力から入力
        scanf("%d%d%d",&N[0],&N[1],&N[2]);
    
    int flag = 1;
    if ( N[0] != N[1] && N[1] != N[2] && N[2] != N[0] ){
        flag = 0;
    }
    if ( N[0] == N[1] && N[1] == N[2] ){
        flag = 0;
    }
        
    if ( flag == 0 ) puts("No");
    else puts("Yes");
    
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
import numpy as np


def solve(r: int):
    print(r*r)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12504
a = [int(s) for s in input().split()]
b = a[1]
c = [b]
d = {b:0}
flag = int(0)
k = int(0)
t = int(0)
m = int(0)
suma = int(0)
sumb = int(0)
cnt = int(0)
newc = []
newnewc = []

for i in range(1, a[0]):
    b = (b ** 2) % a[2]
    if d.get(b) == None:
        d[b] = i
        c.append(b)
    else:
        flag = 1
        sumb = sum(c)
        k = int(c.index(b))
        newc = c[k:]
        suma = sum(newc)
        k = len(newc)
        t = i
        m = (a[0] - t) % k
        break

if flag == 1:
    newnewc = newc[:m]
    print((a[0] - t) // k * suma + sumb + sum(newnewc))
else:
    print(sum(c))


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

int main() {
    int x;cin>>x;
    if (x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
H,W=map(int,input().split())
while (W>0 and H>0):
    for j in range(H):
        for i in range(W):
            if (j==0 or j==H-1 or i==0 or i==W-1):
                print("#",end="")
            else:
                print(".",end="")
        print("")
    print()
    H,W=map(int,input().split())


Measured memory_bytes: 7012
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
	fastio
	int n;
	cin>>n;
	if(n<1200) cout<<"ABC";
	else cout<<"ARC";
	return 0;
}

Measured memory_bytes: 3500
#include <stdio.h>

int main(void){
    int N,V[55],C[55],count=0,i;
    scanf("%d",&N);

    for(i=0;i<N;i++){
        scanf("%d",&V[i]);
    }
    for(i=0;i<N;i++){
        scanf("%d",&C[i]);
    }

    for(i=0;i<N;i++){
        if(V[i]>C[i]){
            count = count + (V[i] - C[i]);
        }
    }

    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
# coding: utf-8
import math
N = int(input())
abcde = [int(input()) for _ in range(5)]

time = 0
n = N # 次の都市でまだ残っている人数
last = 0 # 最後の1回で移動する人数

for i in range(5):
  time += n // abcde[i]
  if n % abcde[i] > 0:
    time += 1

  last = n % abcde[i]
  if last == 0:
    last = abcde[i]

  if i < 4: 
    n = last + max((N-last) - (time-i-1) * abcde[i+1], 0)
  
print(time)
#print("ans:", math.ceil(N / min(abcde)) + 4)

Measured memory_bytes: 3064
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;


using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int n;
	scanf("%d", &n);
	printf("%d\n", n * n * n);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL& x, LL& y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % m;
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

int main()
{
	LL N, M, K;
	in >> N >> M >> K;

	LL ansX = 0, ansY = 0;
	mod_fact(N * M, mod);
	rep(i, M) (ansX += i * (M - i) % mod) %= mod;
	rep(i, N) (ansY += i * (N - i) % mod) %= mod;
	(ansX *= N * N % mod) %= mod;
	(ansY *= M * M % mod) %= mod;

	out << (ansX + ansY) % mod * mod_comb(N * M - 2, K - 2, mod) % mod << std::endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
from itertools import product
import sys


def solve(N: int):
    sN = str(N)
    ans = 0
    for i in range(1, len(sN) + 1):
        for p in product("357", repeat=i):
            if len(set(p)) == 3 and int("".join(p)) <= N:
                ans += 1
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import kotlin.math.abs

fun main() {
    val (x, n) = readLine()!!.split(" ").map(String::toInt)
    if (n == 0) {
        println(x)
        return
    }
    val nums = readLine()!!.split(" ").map(String::toInt).sorted()
    val candidate = (0..101)
        .filter { it !in nums }
    val near = candidate.fold(candidate.first()) { acc, i ->
        if (abs(x - i) < abs(x - acc)) {
            i
        } else {
            acc
        }
    }
    println(near)
}


Measured memory_bytes: 38976
X = int(input())
cum = [0]*(10**5+10)
ans = None
for i in range(1, 10**5 + 1):
    cum[i] = cum[i-1] + i

for t in range(1, 10**5 + 1):
    if cum[t] >= X:
        ans = t
        break
print(ans)
    

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	
	ll N, K; cin >> N >> K;

	vector<ll> A(N);
	REP(i,N) cin >> A[i];


	int left = 0;
	int right = K;

	REP(i,N-K){

		if(A[left++] < A[right++]) cout << "Yes" << endl;
		else cout << "No" << endl;

	}



	return 0;

}


Measured memory_bytes: 4840
#include<stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
  /*
    int N,K;
    int T_len;
    int i;
    char *ret;
    char S[51]="UNRESTORABLE";
    char SR[51]="";
    char T[51]="";
*/
    char Ci[3]={""};
    char Cj[3]={""};
    int i=0;
    int hanntei=0;
  
  // 整数の入力
    scanf("%s", Ci);
 //   printf("%c\n",Ci);

    scanf("%s", Cj);
//    printf("%c\n",Cj);
  
  for(i=0;i<3;i++){   
  if(Ci[i] != Cj[2-i]){
       printf("NO\n");
       return 0;
  }
  }
//    printf("%s,%s\n",&Ci[i],&Cj[2-i]);
    printf("YES\n");
    return 0;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll a[n+1];
        loop(i,1,n) cin>>a[i];
        ll x=0;
        loop(i,1,n)
        {
            if(a[i]==x+1) x++;
        }
        if(x) cout<<n-x;
        else cout<<-1;
    }
    return 0;
}


Measured memory_bytes: 5220
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = sorted(list(zip(LI(),[0.25,0.5,1.0,2.0])), key=lambda x: x[0]/x[1])
    n = I() * 4
    r = 0
    for i in range(4):
        k,t = a[i]
        t = int(t*4)
        if n >= t:
            r += k * (n//t)
            n %= t

    return r

print(main())



Measured memory_bytes: 8104
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

ll a, b, c, d;

ll ceilD(ll a, ll b) {
    return (a + b - 1) / b;
}
                 
void solve() {                   
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);    
    ll x = a - b;

    if (x > c) {
        ll k = ceilD(x - c, b);
        x -= k * b;
    }

    if (x < 0) {
        printf("No\n");
        return;
    }

    ll step = d - b;

    if (step < 0) {
        printf("No\n");
        return;
    }

    if (step == 0) {
        printf("Yes\n");
        return;
    }

    x %= step;        
    ll g = __gcd(b, step);

    ll l = x - (b - 1);
    ll r = x - (c + 1);

    if (l > r) {
        printf("Yes\n");
        return;
    }

    if (l < 0) {
        ll k = ceilD(-l, g);
        l += k * g;
        r += k * g;
    }

    if (ceilD(l, g) <= r / g) {
        printf("No\n");
        return;
    }                       
    
    printf("Yes\n");
}

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

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A == B) {
    cout << C << endl;
  } else if (B == C) {
    cout << A << endl;
  } else if (C == A) {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>

uint64_t seqlen(char *p) {
  uint64_t ctr = 0;
  for (; *p != '\0'; p++, ctr++) {
    if ((*p != 'A') && (*p != 'C') && (*p != 'G') && (*p != 'T')) break;
  }
  return ctr;
}


int main(int argc, char const* argv[])
{
  char str[11];
  // memset(str, 0, 11);
  fgets(str, 11, stdin);
  uint64_t longest = 0;
  char *p = str;
  for (; *p != '\0'; p++) {
    if (longest < seqlen(p)) longest = seqlen(p);
  }
  printf("%lu\n", longest);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int n;
    cin >> n;
    while(n > 10) {
        n %= 10;
    }

    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << "\n";
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << "\n";
    } else {
        cout << "bon" << "\n";
    }
}

Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String input = scan.nextLine();
		scan.close();

		List<Character> list = new ArrayList<Character>();
		list.add(input.charAt(0));
		for (int i = 1; i < input.length(); i++) {
			if (!list.contains(input.charAt(i))) {
				list.add(input.charAt(i));
			}
		}

		if (list.size() == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const ll MOD = 1e9+7;

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

template<typename T>
void chmax(T &a, T b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

class RMQ{
	int n;
	vector<int> dat;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int x){
		if(a <= l && r <= b) return dat[x];
		if(r <= a || b <= l) return INF;

		int res = INF;
		res = min(query(a, b, l, (l+r)/2, x*2+1), query(a, b, (l+r)/2, r, x*2+2));
		return res;
	}
	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

const ll mod = 1e9+7;

int N, K;
vector<ll> a;
bool dp[5050] = {};

bool ok(ll in){
	if(in >= N) return true;
	memset(dp, 0, sizeof(dp));
	dp[0] = true;
	REP(i, N){
		if(i == in) continue;
		for(int j = K+1;j >= a[i];j--){
			if(dp[j-a[i]]) dp[j] = true;
		}
	}
	FOR(i, max(0, (int)K-(int)a[in]), K){
		if(dp[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	string o, e;
	cin >> o >> e;
	REP(i, o.size()){
		cout << o[i];
		if(i < e.size())
			cout << e[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
## AからＣ　ＢからＤに移動させたい
## C<D なら簡単

N,A,B,C,D = map(int,input().split())
S = input()
flag = 0
obs = []
esc = []
ans = 1

#ＡとＢで小さいほうを low
if A<B:
    low = A
    mid1 = B
else:
    low = B
    mid1 = A
#ＣとＤで大きいほうをhigh
if C<D:
    high = D
    mid2 = C
else:
    high = C
    mid2 = D



for i in range(low,high):
     if S[i]=="#" and flag == 1:
         obs.append(i)
         flag = 0
     elif S[i] == "#":
         flag = 1
     else: flag = 0

 # obsに通れない位置を入力
flag = 0
for i in range(low,high):
      if S[i]=="." and flag == 2:
          esc.append(i)
          flag = 0
      elif S[i] == ".":
          flag += 1
      else:
          flag = 0

if len(obs)!=0:
    ans = 0

if D<C :
    flag = 0
    for i in range(len(esc)):
        if mid1<= esc[i] <= mid2:
            flag = 1
    if flag == 0:
        ans = 0


if ans==1:
    print("Yes")
else:
    print("No")


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

int max(int a, int b)
{
	if (a > b){
		return (a);
	}
	return (b);
}

void bubble_sort(int *a, int *b, int n)
{
	int i, j;
	
	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (a[j] > a[j + 1]){
				a[j] ^= a[j + 1];
				a[j + 1] ^= a[j];
				a[j] ^= a[j + 1];
				
				b[j] ^= b[j + 1];
				b[j + 1] ^= b[j];
				b[j] ^= b[j + 1];
			}
		}
	}
}

int main(void)
{
	int n, m;
	int height[201], width[201];
	int i, j;
	int res;
	int dp[201];
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d%d", &height[i], &width[i]);
		}
		
		scanf("%d", &m);
		
		for (i = 0; i < m; i++){
			scanf("%d%d", &height[i + n], &width[i + n]);
		}
		
		bubble_sort(&height, &width, m + n);
		
		memset(dp, 0, sizeof(dp));
		res = 0;
		for (i = 0; i < n + m; i++){
			dp[i] = 1;
			for (j = 0; j < i; j++){
				if (height[j] < height[i] && width[j] < width[i]){
					dp[i] = max(dp[i], dp[j] + 1);
				}
				res = max(res, dp[i]);
			}
		}
		
		printf("%d\n", res);
	}
	
	return (0);
}

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

int main(){
	double a,b,c,d,e,f,y,x;
	
	while(cin>>a>>b>>c>>d>>e>>f){
	
	
	x = (double)((e*c-b*f)/(a*e-b*d));
	
	y = (double)((-(d*c)+a*f)/(a*e-b*d));
	
	if(x == 0)
		x = 0;
	if(y == 0)
		y =0;
	
	printf("%.3f %.3f\n",x,y);
	}
}

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

typedef unsigned long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll a,b,c;

    cin >> a >> b >> c;

    if( c <= (a+b) ){
        cout << "No" << endl;
        return 0;
    }

    ll ab = a*b;
    ll x = (c-b-a)*(c-b-a);

    if( 4 * ab < x ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <cstdio> 
bool f[100001]; 
int c[100002]; 
int N,L,R; 
int main() { 
  for(int i=2;i<=100000;i++)
    if(!f[i])for(int j=i+i;j<=100000;j+=i) f[j]=true; 
  for(int i=3;i<=100000;i+=2)if(!f[i]&&!f[(i+1)/2])c[i]++; 
  for(int i=3;i<=100000;i++)c[i]+=c[i-1]; 
  scanf("%d",&N); 
  while(N--) { 
    scanf("%d%d",&L,&R); 
    printf("%d\n",c[R]-c[L-1]); 
  } 
}

Measured memory_bytes: 1024