akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define out(ans) cout << ans << endl
typedef pair<int,int>P;
const ll mod=1e9+7;

int n,q;
string s;
char t[200010],d[200010];

int simu(int k){

  rep(i,0,q){
    if(s[k]!=t[i])continue;

    if(d[i]=='L')k--;
    else k++;

    if(k<0)return -1;
    if(k>=s.size())return 1;
  }
  return 0;
}

int main(){

  cin>>n>>q;
  cin>>s;
  int sn=s.size();
  rep(i,0,q)cin>>t[i]>>d[i];

  int l=-1,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(simu(mid)==-1)l=mid;
    else r=mid;
  }
  int L=r;

  l=-1,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(simu(mid)==1)r=mid;
    else l=mid;
  }
  int R=n-1-l;

  out(n-(R+L));

  return 0;
}


Measured memory_bytes: 900
<?php
  list($k) = explode(" ", trim(fgets(STDIN)));

  list($a, $b) = explode(" ", trim(fgets(STDIN)));

  for($i=$a; $i<=$b;$i++){
    if($i % $k == 0){
      echo "OK";
      exit;
    }
  }
 echo "NG";




Measured memory_bytes: 16184
use std::io::stdin;

fn main(){
    let (x, y) = getpair();
    println!("{}", solve(x, y))
}

fn solve(x: usize, y: usize) -> usize {
    let mut ans = 1;
    let mut i = x;
    while i*2 <= y {
        ans += 1;
        i *= 2;
    }
    ans
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec<T: std::str::FromStr>() -> Vec<T>{
    let line = getline();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    int n;
    cin>>n;
    int ans=0;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        ans+=a.at(i);
    }
    ans-=n;
    cout<<ans<<endl;








    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static int[] vim;
    private static boolean[] flag;
    private static List<Buld> list;
    private static int sum;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        list = new ArrayList<>();
        vim = new int[n];
        flag = new boolean[n];
        sum = 0;
        for(int i=0;i<m;i++){
            int k = in.nextInt();
            List<Integer> swi = new ArrayList<>();
            for(int j=0;j<k;j++){
                swi.add(in.nextInt());
            }
            list.add(new Buld(swi));
        }
        for(int i=0;i<m;i++){
            list.get(i).p=in.nextInt();
        }
        dfs(0,n,m);
        System.out.println(sum);
    }
    public static void dfs(int x,int n,int m){
        if(x == n){
            for(int i=0;i<m;i++){
                Buld b = list.get(i);
                int att=0;
                for(Integer s:b.swi){
                    att^=vim[s-1];
                }
                if(att != b.p)
                    return;
            }
            sum++;
        } else {
            for (int i = 0; i < 2; i++) {
                vim[x] = i;
                dfs(x + 1, n, m);
            }
        }
    }
    static class Buld{
        public List<Integer> swi;
        public Integer p;
        public Buld(List<Integer> list){
            this.swi = list;
        }

    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll MOD = 998244353;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int s=0;
  rep(i,n)s+=a[i];
  vector<vector<ll>> dp1(n+1,vector<ll>(s+1,0));
  dp1[0][0]=1;
  rep(i,n){
    rep(j,s+1){
      if(j>=a[i]){
        dp1[i+1][j]+=dp1[i][j-a[i]];
        dp1[i+1][j]%=MOD;
      }
      dp1[i+1][j] += 2 * dp1[i][j];
      dp1[i+1][j] %= MOD;
    }
  }
  vector<vector<ll>> dp2(n+1,vector<ll>(s+1,0));
  dp2[0][0]=1;
  rep(i,n){
    rep(j,s+1){
      if(j>=a[i]){
        dp2[i+1][j]+=dp2[i][j-a[i]];
        dp2[i+1][j]%=MOD;
      }
      dp2[i+1][j] += dp2[i][j];
      dp2[i+1][j] %= MOD;
    }
  }
  ll ans=1;
  rep(i,n){
    ans *= 3;
    ans %= MOD;
  }
  for(int i=s/2+s%2;i<=s;i++){
    //cout << ans << endl;
    ans -= dp1[n][i]*3;
    ans %= MOD;
  }
  if(s%2==0)ans += dp2[n][s/2]*3;
  ans += MOD;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 423744
using System;

namespace ITP1_4_C
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int j = 1; ; j++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                string op = input[1];
                int b = int.Parse(input[2]);

                if (op == "?")
                    break;

                switch (op)
                {
                    case "+":
                        Console.WriteLine(a + b);
                        break;
                    case "-":
                        Console.WriteLine(a - b);
                        break;
                    case "*":
                        Console.WriteLine(a * b);
                        break;
                    case "/":
                        Console.WriteLine(a / b);
                        break;
                }
            }
            
        }
    }
}

Measured memory_bytes: 9248
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, Y;
    cin >> N >> Y;

    FOR(i, 0, N+1){
        FOR(j, 0, N-i+1){
            ll k = N - i - j;
            if(Y == 10000LL*i + 5000LL*j + 1000LL*k){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    p("-1 -1 -1");

    return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, a, m=LLONG_MAX;
  cin >> n;
  forll(i, 0, 5){
	cin >> a;
	m = min(m, a);
  }
  cout << 5 + (ll)ceil((double)max((ll)0, n - m) / m) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

void swap(int *,int *);

main(){

  int N;
  int i,j,minj,swapc=0;
  int A[100];
  
  scanf("%d",&N);

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

  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    swap(&A[i],&A[minj]);
    if(i!=minj)swapc++;
  }


  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1)printf(" ");
    else if(i==N-1)printf("\n");
  }
  printf("%d\n",swapc);
  
  
  return 0;
}

void swap(int *x,int *y)
{
  int temp;

  temp=*x;
  *x=*y;
  *y=temp;
}

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

using namespace std;

void Main() {
    int H, N;
    cin >> H >> N;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        H -= a;
    }

    if (H <= 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 3604
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define mod 998244353LL
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define sq(x) ((x)*(x))

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

#define EPS 1e-7

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

typedef pair<i64, i64> pii;

#define maxn 4005

int dp[2005][2005] ;

int Next[2][2005] , pos[2][2005] ;
int type[maxn] , a[maxn] ;

int big[2][2005][4005] ;

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

    for(int i=1 ; i<=2*n ; i++)
    {
        char s[5] ;
        scanf("%s %d",s,&a[i]) ;
        if( s[0]=='W' ) type[i] = 0 ;
        else type[i] = 1 ;
        pos[ type[i] ][ a[i] ] = i ;
    }

    for(int t=0 ; t<2 ; t++)
    {
        for(int i=1 ; i<=2*n ; i++)
        {
            if( type[i]==t )
            {
                Next[ t ][ 0 ] = i ;
                break ;
            }
        }
        for(int i=1 ; i<n ; i++)
        {
            if( a[ Next[t][i-1] ] > i )
            {
                Next[ t ][i] = Next[t][i-1] ;
                continue ;
            }
            for(int j= Next[t][i-1]+1 ; j<=2*n ; j++ )
            {
                if( type[j]==t && a[j] > i )
                {
                    Next[t][i] = j ;
                    break ;
                }
            }
        }
        Next[t][n] = 2*n+1 ;
    }

 //   for(int i=0 ; i<=n ; i++) printf("%d %d\n" , Next[0][i] , Next[1][i] ) ;

    for(int t=0 ; t<2 ; t++)
    {
        for(int i=0 ; i<=n ; i++)
        {
            for(int j=1 ; j<=2*n ; j++)
            {
                big[t][i][j] = big[t][i][j-1] ;
                if( type[j]==t && a[j] > i ) big[t][i][j]++ ;
            }
            big[t][i][2*n+1] = big[t][i][2*n] ;
        }
    }

    dp[n][n] = 0 ;

    for(int i=n ; i>=0 ; i--)
    {
        for(int j=n ; j>=0 ; j--)
        {
            if(i==n && j==n ) continue ;

            dp[i][j] = 10*n*n ;

            int Nxt = min( Next[0][i] , Next[1][j] ) ;

            if( i+1 <= n )
            {
                dp[i][j] = min( dp[i][j] , big[0][i+1][pos[0][i+1]]-big[0][i+1][Nxt-1] + big[1][j][pos[0][i+1]]-big[1][j][Nxt-1] + dp[i+1][j] ) ;
            }
            if( j+1 <= n )
            {
                dp[i][j] = min( dp[i][j] , big[1][j+1][pos[1][j+1]]-big[1][j+1][Nxt-1] + big[0][i][pos[1][j+1]]-big[0][i][Nxt-1] + dp[i][j+1] ) ;
            }
      //      printf("%d %d: %d\n" ,i, j ,dp[i][j] ) ;
        }
    }

    printf("%d\n" , dp[0][0] ) ;

    return 0 ;
}


Measured memory_bytes: 78720
import java.util.*;
import java.io.*;
public class Main {
    static final double phi = (1.0 + Math.sqrt(5)) / 2;
    static final double phi_1 = phi - 1;
    static final double C1 = 1000 * (1 - phi_1);
    static final double C2 = 1000 * phi_1;
    static int N;
    static int[] X, Y;
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        N = nextInt();
        X = new int[N];
        Y = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = nextInt();
            Y[i] = nextInt();
        }

        double x = calc(0, C1, C2, 1000);
        System.out.println(calc_r(x, calc_y(0, C1, C2, 1000, x)));
    }

    public static double calc(double low, double x1, double x2, double high) {
        if (x2 - x1 < 0.000001) return x1;

        if (calc_r(x1, calc_y(0, C1, C2, 1000, x1)) < calc_r(x2, calc_y(0, C1, C2, 1000, x2))) {
            return calc(low, low + (x2 - low) * (1 - phi_1), x1, x2);
        } else {
            return calc(x1, x2, x1 + (high - x1) * (phi_1), high);
        }
    }

    public static double calc_y(double low, double y1, double y2, double high, double x) {
        if (y2 - y1 < 0.000001) return y1;

        if (calc_r(x, y1) < calc_r(x, y2)) {
            return calc_y(low, low + (y2 - low) * (1 - phi_1), y1, y2, x);
        } else {
            return calc_y(y1, y2, y1 + (high - y1) * (phi_1), high, x);
        }
    }

    public static double calc_r(double x, double y) {
        double r = 0;
        for (int i = 0; i < N; i++) {
            double dx = x - X[i];
            double dy = y - Y[i];
            r = Math.max(r, Math.sqrt(dx * dx + dy * dy));
        }
        return r;
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }

    public static double nextDouble() throws Exception {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 25044
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    // メンバ変数---
    int N;
    int K;
    string[] S;
    // -------------

    void calc()
    {
        N = cin.nextInt();
        K = cin.nextInt();
        string s = cin.next();
        S = new string[N];

        for (var i = 0;i < N;i++)
        {
            S[i] = s[i].ToString();
        }

        int p = 0;
        for(int i = 0;i < N - 1; i++)
        {
            if(S[i] == S[i + 1])
            {
                p++;
            }
        }
        int ans = Math.Min(p+2*K, N - 1);
        write(ans);

    }

    void write(string v)
    {
        Console.WriteLine(v);
    }

    void write(int v)
    {
        Console.WriteLine(v);
    }

    void write(double v)
    {
        Console.WriteLine(v);
    }
    void write(long v)
    {
        Console.WriteLine(v);
    }

    int Pow(int x, int y)
    {
        return (int)Math.Pow(double.Parse(x.ToString()), double.Parse(y.ToString()));
    }

    double Pow(double x, double y)
    {
        return Math.Pow(x, y);
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

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

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

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


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

Measured memory_bytes: 16608
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N+2, 0);
    vector<int> B(N+2, 0);
    for (size_t i=1; i<=N; i++) {
        cin >> A[i];
       // cout << A[i];
        B[i] = A[i] - A[1];
    }
    B[N+1] = K;
    B[0] = -(K - A[N] + A[1]);

    int Dmin = K;
    vector<int> D(N+1, 0);
    for (size_t i=1; i<=N; i++) {
        //int toleft = K - abs(B[i+1] - B[i]);
        //int toright = K - abs(B[i] - B[i-1]);
        int toleft = K - (B[i+1] - B[i]);
        int toright = K - (B[i] - B[i-1]);
        D[i] = min(toleft, toright);
        Dmin = min(Dmin, D[i]);
    }
    cout << Dmin << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 3000
int x[MAX_N][MAX_N];
int H, W;
int r(int X, int Y, int Z) {
	int B = x[X - 1][Y - 1] + x[X + Z - 1][Y + Z - 1] - x[X - 1][Y + Z - 1] - x[X + Z - 1][Y - 1];
	if (B == 0) { return true; }
	return false;
}
int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 1; i < MAX_N; i++) {
		for (int j = 1; j < MAX_N; j++) {
			if (i > H || j > W) {
				x[i][j] = 1;
			}
		}
	}
	for (int i = 1; i < MAX_N; i++) {
		for (int j = 1; j < MAX_N; j++) {
			x[i][j] += x[i][j - 1];
		}
	}
	for (int i = 1; i < MAX_N; i++) {
		for (int j = 1; j < MAX_N; j++) {
			x[j][i] += x[j - 1][i];
		}
	}
	int maxn = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			int L = 0, R = 1500, M;
			for (int k = 0; k < 50; k++) {
				M = (L + R) / 2;
				bool a1 = r(i, j, M), a2 = r(i, j, M + 1);
				if (a1 == true && a2 == false) {
					maxn = max(maxn, M);
					break;
				}
				if (a1 == false) {
					R = M;
				}
				if (a2 == true) {
					L = M;
				}
			}
		}
	}
	cout << maxn*maxn << endl;
	return 0;
}

Measured memory_bytes: 36312
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;

int main(void) {
	ll n, a, b;
	cin >> n >> a >> b;
	
	ll ans = n / (a + b) * a;
	ll m = n % (a + b);
	
	ans += min(m, a);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (a, b) = get!(i64, i64);

    if a == 0 || b == 0 || (a < 0 && b > 0) {
        println!("Zero");
        return;
    }

    if b < 0 {
        if (b.abs() - a.abs()).abs() % 2 == 0 {
            println!("Negative");
        } else {
            println!("Positive");
        }
    } else {
        println!("Positive");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define mod 1000000007
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
inline ll mo(ll a,ll b){if(b<0){b=abs(b)%mod;b=a-b;return (b<0)?b+mod:b;}else{return (a+b)%mod;}}
inline ll pow(ll a,ll b){if(b==0){return 1;}else{if(b%2==0){ll temp=pow(a,b/2);return temp*temp;}
else{return a*pow(a,b-1);}}}

struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        if(p1.first!=p2.first)return p1.first<p2.first;
        else return p1.second<p2.second;
    }
}; 

int main()
{
    fio;
    ll n,weight;cin>>n>>weight;
    vl w(n),v(n);
    f(n){
        cin>>w[i]>>v[i];
    }
    vl dp(weight+1,0);
    for(ll i=0;i<n;i++){
        for(ll j=weight-w[i];j>=0;j--){
            dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    cout<<dp[weight]<<endl;
}

Measured memory_bytes: 3968
#include <iostream>

using namespace std;
typedef long long ll;

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

    for (int i = 0; i < K; i++) {
        if (i % 2 == 0) {
            if (A % 2 == 1) {
                A--;
            }
            auto half = A / 2;
            A -= half;
            B += half;
        } else {
            if (B % 2 == 1) {
                B--;
            }
            auto half = B / 2;
            B -= half;
            A += half;
        }
    }

    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int n,m,i,total=0,a[1000],c=0;
  scanf("%d %d",&n,&m);
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
    total=total+a[i];
  }
  double p = (double)total/(double)(4*m);
  for (i=0;i<n;i++){
    if (a[i]>=p){
      c=c+1;
    }
  }
  if(c>=m){
    printf("Yes");
  }
  else{
     printf("No");
    }
  return 0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;

void main()
{
    auto nmk = readln.split.to!(int[]);
    auto N = nmk[0];
    auto M = nmk[1];
    long K = nmk[2];

    auto AS = readln.split.to!(long[]);
    foreach (i, ref a; AS) if (i) a += AS[i-1];
    auto BS = readln.split.to!(long[]);
    foreach (i, ref b; BS) if (i) b += BS[i-1];

    long res;
    foreach (a; 0..N+1) {
        long k = a == 0 ? K : K - AS[a-1];
        if (k < 0) continue;

        if (BS[0] > k) {
            res = max(res, a);
        } else if (BS[$-1] <= k) {
            res = max(res, a + M);
        } else {
            int l, r = M-1;
            while (l+1 < r) {
                auto m = (l+r)/2;
                if (BS[m] <= k) {
                    l = m;
                } else {
                    r = m;
                }
            }
            res = max(res, a + r);
        }
    }
    writeln(res);
}

Measured memory_bytes: 20608
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100005];
inline char nc(){
	static char buf[100000],*p1,*p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
bool cmp(int x,int y){return x>y;}
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n,cmp);
	int now=0;while(a[now+2]>now+1) now++;
	int x=a[now+1]-now,y=0;
	for (int i=now+1;i<=n;i++)
	if(a[i]>now) y++;else break;
	puts(x&y&1?"Second":"First");
	return 0;
}

Measured memory_bytes: 640
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << "[" << pa.first << ", " << pa.second << "]";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  os << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "}";
  return os;
}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;


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

  ll n,c;
  std::cin>>n>>c;

  std::vector<ll> max(200020,0),sum(200020,0);

  std::vector<std::vector<P>> channel(c);

  rep(i,0,n){
    ll s,t,temp;
    std::cin>>s>>t>>temp;
    temp--;
    channel[temp].push_back({s,t});
  }

  rep(i,0,c){
    if(!channel[i].empty()){
      rep(j,0,200020)max[j]=0;

      rep(j,0,channel[i].size()){
        max[channel[i][j].first*2-1]++;
        max[channel[i][j].second*2]--;
      }

      rep(j,1,200020){
        max[j]+=max[j-1];
      }
      rep(j,0,200020)if(max[j]>0)sum[j]++;
    }
  }

  ll ans=0;

  rep(i,0,200020)ans=std::max(ans,sum[i]);

  std::cout<<ans<<"\n";

  return 0;
}






Measured memory_bytes: 5888
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  map<int, int> map;
  rep(i, n) {
    int a; cin >> a;
    if (map.find(a) == map.end()) map.insert(make_pair(a, 1));
    else map[a]++;
  }
  ll sum = 0;
  for (auto p : map) {
    if (p.first <= p.second) sum += p.second - p.first;
    else sum += p.second;
  }
  outl(sum);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

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

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

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

    for (int i = 0; i < N; i++)
    {
        int ans = 0;
        int best = INT_MAX;
        for (int j = 1; j <= M; j++)
        {
            int distance = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (distance < best)
            {
                ans = j;
                best = distance;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
main = do
    input <- readLn ::IO Int
    let
        plusminus = [1,-1]
        patterns = [[a,b,c,d]| a<-[1],b<-plusminus,c<-plusminus,d<-plusminus]
        a = div input 1000
        b = div input 100 `mod` 10
        c = div input 10 `mod` 10
        d = input `mod` 10
        result=map (\x->if x>=0 then '+':show x else show x)$tail$head$filter ((7==) . sum) $ map (zipWith (*) [a,b,c,d]) patterns
    putStrLn $ show a ++(foldl1 (++) result) ++"=7"
    



Measured memory_bytes: 508
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<long long,long long>;

long long N,L;
vector<long long> memo,sum;
vector<p> lr;
map<long long,long long> mp;

long long solve();
bool asc(const p &l,const p & r){
    if(l.fi != r.fi)return l.fi < r.fi;
    return l.se > r.se;
}

int main(){
    cin >> N >> L;
    lr.resize(N);
    for(int i = 0;i < N;++i){
        cin >> lr[i].fi >> lr[i].se;
        memo.push_back(lr[i].fi);
        memo.push_back(lr[i].se);
    }
    sort(memo.begin(),memo.end());
    memo.erase(unique(memo.begin(),memo.end()),memo.end());
    cout << solve() << endl;
    return 0;
}

long long solve(){
    sort(lr.begin(),lr.end(),asc);
    sum.resize(memo.size(),0);
    long long ans = 0,now = 0,msize = memo.size();
    for(int i = 0;i < N;){
        long long nextp = now;
        while(i < N && lr[i].fi <= now){
            nextp = max(nextp,lr[i].se);
            ++i;
        }
        ++ans;
        now = nextp;
        if(nextp >= L){
            cout << ans << " ";
            break;
        }
    }
    for(int i = 0;i < msize;++i)
        mp[memo[i]] = i;
    for(int i = 0;i < N;++i){
        ++sum[mp[lr[i].fi]];
        if(mp[lr[i].se] + 1 < msize)--sum[mp[lr[i].se] + 1];
    }
    ans = sum[0];
    for(int i = 1;i < msize;++i)
        if(memo[i] <= L){
        sum[i] += sum[i-1];
        ans = min(ans,sum[i]);
    }
    return N - ans + 1;
}


Measured memory_bytes: 35824
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n,m,a,b,c,d,x=0,y,z;
  string s,t;
  //

  // ここから
  IN(n);
  FOR(i,1,n+1) x+=i;
  OUT(x);
}

Measured memory_bytes: 256
// arock - 2019-02-09

#include <iostream>

using i64 = long long;

int main() {
    int K, A, B;
    std::cin >> K >> A >> B;

    if (B - A <= 2) {
        std::cout << K + 1 << std::endl;
        return 0;
    }

    int first = A - 1;
    if (first >= K) {
        std::cout << K + 1 << std::endl;
        return 0;
    }

    K -= first;
    i64 cur = A;
    cur += i64(B - A) * (K / 2);
    K %= 2;
    if (K == 1) {
        cur++;
    }

    std::cout << cur << std::endl;
}


Measured memory_bytes: 256
# coding=utf-8

line = input().split(" ")
a = int(line[0])
b = int(line[1])

def judge(n):
    n = str(n)
    return n == (n[::-1])

ret = 0
for n in range(a,b+1):
    if judge(n):
        ret += 1

print(ret)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int main(){
    long long N, K;
    long long a, b, c;

    cin >> N >> K;

    long long cnt = 0;
    long long q;

    for (a = 1; a <= K; ++a){
        b = c = a;
        // cout << a << " " << b << " " << c << endl;
        if ((2 * (a + b + c)) % K == 0 && (a + b) % K == 0) {
            q = N/K;
            if (N % K >= a){
                ++q;
            }
            cnt += q;
            cnt += (q * (q - 1) * (q - 2));
            cnt += (q * (q - 1)) * 3;
            // cout << "(x, x, x) = " << q << endl;
            // cout << "(x1, x1, x2) = " << q * (q - 1) << endl;
            // cout << "(x1, x2, x3) = " << q * (q - 1) * (q - 2) << endl;

        }
    }
    cout << cnt;
}


Measured memory_bytes: 256
h, w = [int(x) for x in input().split()]
s = []
s.append(list("･" * (w + 2)))
for _ in range(h):
  s.append(list("･" + input() + "･"))
  
s.append(list("･" * (w + 2)))

for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j] == "#":
      continue
    
    neighbors = [
      s[i-1][j-1], 
      s[i-1][j], 
      s[i-1][j+1], 
      s[i][j-1], 
      s[i][j+1], 
      s[i+1][j-1], 
      s[i+1][j], 
      s[i+1][j+1],
    ]
    s[i][j] = str(len(list(filter(lambda x : x == "#", neighbors))))

for l in s[1:len(s)-1]:
  print(''.join(l[1:len(l)-1]))
  


Measured memory_bytes: 9140
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n, m;
	cin >> n >> m;

	vector<pair<ll, ll>> v(n);
	rep(i, n) cin >> v[i].first >> v[i].second;

	sort(all(v));

	ll sum = 0;
	ll cnt = 0;
	rep(i, n)
	{
		if (m <= 0) {
			break;
		}
		sum += v[i].first * min(m, v[i].second);
		m -= min(m, v[i].second);
	}

	out(sum);

	return 0;
}

Measured memory_bytes: 4756
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

ll N;
vector<ll> mem(11,0);
void rec(ll rem,ll now){
    if(rem==0){
        rep1(i,N){
            cout<<(char)('a'-1+mem[i]);
        }
        cout<<endl;
    }
    else{
        rep1(i,now){
            mem[N+1-rem]=i;
            rec(rem-1,max(now,i+1));
        }
    }
}

int main(){
    cin>>N;
    ll now=1;
    rec(N,1);
}


Measured memory_bytes: 3516
import java.util.Scanner;

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

        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int h = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();
        String judge = "";

        if(x-r < 0 || y-r < 0 || x+r > w || y+r > h)
            judge = "No";
        else
            judge = "Yes";

        System.out.println(judge);
    }
}



Measured memory_bytes: 26336
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N;
    cin >> N;
    unordered_set<lint> distinct_diameters;
    range(i, 0, N) {
        lint d;
        cin >> d;
        distinct_diameters.emplace(d);
    }
    cout << distinct_diameters.size() << "\n";
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] t = new int[N+1];
        t[0] = 0;
        int x = 0;
        int y = 0;
        int X;
        int Y;
        String ans = "Yes";
        
        for(int i = 1; i <= N; i++){
            t[i] = Integer.parseInt(sc.next());
            X = Integer.parseInt(sc.next());
            Y = Integer.parseInt(sc.next());
            if(X + Y > x + y + t[i] - t[i-1]) {
                ans = "No";
                break;
            }else if(X + Y == x + y + t[i] - t[i-1]) {
                x = X;
                y = Y;
            }else {
                if((x + y + t[i] - t[i-1] - X - Y) % 2 == 0) {
                    x = X;
                    y = Y;
                }else {
                    ans = "No";
                    break;
                }
            }
        } 
        
        System.out.println(ans);
        
        
    }
}

Measured memory_bytes: 60092
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
 
    def to_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= (i & -i)
        return s
 
    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += (i & -i)
 
    def get(self, i, j):
        return self.to_sum(j)-self.to_sum(i-1)

import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
C = list(map(int,input().split()))
#print(C)
LR = []
ans = [0 for _ in range(Q)]
for i in range(Q):
  temp= list(map(int,input().split()))
  LR.append((temp,i)) #クエリとID
LR.sort(key=lambda x : x[0][1]) #右端で昇順にソート
#print(LR)
CMAX = max(C)
Tree = BIT(N)
last = [-1 for _ in range(CMAX)] #色を0index
left,right = LR[0][0]
for j in range(right):
  mae = last[C[j]-1]
  last[C[j]-1] = j
  if mae !=-1:
    Tree.add(mae+1,-1) #BITは1から
  Tree.add(last[C[j]-1]+1,1) #BITは1から
  #print(Tree.get(left,right))
#print(last)
D = []
#for i in range(1,N+1):
#  detemp = Tree.get(i,i)
#  D.append(detemp)
#print(D)

temp = Tree.get(left,right)
ID = LR[0][1]
ans[ID] = temp
lastright = right  
#print(Tree.get(left,right))
for i in range(1,Q):
  left,right = LR[i][0]
  #print(right,lastright)
  if lastright < right:
    for j in range(lastright,right):
      mae = last[C[j]-1]
      last[C[j]-1] = j
      #print(C[j],mae,j,last[C[j]-1] )
      if mae !=-1:
        #rint(C[j],"A")
        Tree.add(mae+1,-1) #BITは1index
      Tree.add(j+1,1) #BITは1index
  temp = Tree.get(left,right)
  ID = LR[i][1]
  ans[ID] = temp
  lastright = right
  #print(last)


print(*ans,sep="\n")

Measured memory_bytes: 227588
/*input
4 5
1 2
1 3
3 2
2 4
3 4
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

const int N = 1e5+1;
int n,m;
vector<int> adj[N];
vector<int> top;
bool vis[N];
int dp[N];

void dfs(int u){
	 vis[u] = 1;
	 for(int v:adj[u]){
	 	//if(u == 2)cout << v << " ";
	 	if(!vis[v])dfs(v);
	 }
	// cout << u << " ";
	 top.pb(u);
}

void solve(){
	 RE(i,N){vis[i] = 0;adj[i].clear();}
	 cin >> n >> m;
	 RE(i,m){
	 	int a,b;cin >> a >> b;
	 	//cout << a << " " << b << endl;
	 	adj[a].pb(b);
	 }
	 RE(i,n){
            if(!vis[i])dfs(i);
	 }
	 reverse(all(top));
	 dp[top[0]] = 0;
	 REP(i,n){
	 	for(int v:adj[top[i]]){
            dp[v] = max(dp[v],dp[top[i]]+1);
	 	}
	 }
	 int ans = 0;
	 for(int i = 1;i <= n;i++)remax(ans,dp[i]);
	 cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

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

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

	cout << a << " " << b << " " << c;
	return 0;
}

Measured memory_bytes: 3152
N = int(input())
A = [int(input()) for _ in range(N)]


def counter(ar):
    count = 0
    for i in range(N):
        # print(i, ar, count)
        if i > 0:
            c = min(ar[i - 1], ar[i])
            ar[i - 1] -= c
            ar[i] -= c
            count += c
        c = ar[i] // 2
        ar[i] -= c * 2
        count += c
        if i < N - 1:
            c = min(ar[i], ar[i + 1])
            ar[i] -= c
            ar[i + 1] -= c
            count += c
    return count

# print(N)
# print(A)

# greedy left -> right, left <- right, take max
AA1 = A[:]
c1 = counter(AA1)
AA2 = A[::-1]
c2 = counter(AA2)
# print(c1)
# print(c2)
print(max(c1, c2))

Measured memory_bytes: 53208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    string a,b;
    cin>>a>>b;
    int ans = 0;
    if(a.size()>b.size()){
        ans = 1;
    }else if(a.size()<b.size()){
        ans = 2;
    }else{
        rep(i,a.size()){
            
            if(a[i]>b[i]){
                ans = 1;
                break;
            }else if(a[i]<b[i]){
                ans = 2;
                break;
            }
        }
    }
    
    if(ans==1){
        cout << "GREATER" << endl;
    }else if(ans==2){
        cout << "LESS" << endl;
    }else
        cout << "EQUAL" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256