akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
from bisect import bisect_left as bisect
import sys
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
zeros = []
count = defaultdict(list)
now = -1
for i in range(N):
    S[i] = S[i-1]^A[i]
    if S[i] == 0:
        zeros.append(i)
    else:
        count[S[i]].append(i)
if S[N-1] != 0:
    a = S[N-1]
    res = []
    cnt = 0
    for i in count[a]:
        res.append(bisect(zeros, i)-cnt)
        cnt+=res[-1]
    res0 = 1
    res1 = 0
    for c in res:
        res0 = res0+res1*c
        res1 = res1+res0
        res0%=mod
        res1%=mod
    print(res0)
    sys.exit()
ans = pow(2, len(zeros)-1, mod)
for a in count.keys():
    cnt = 0
    res = []
    for i in count[a]:
        res.append(bisect(zeros, i)-cnt)
        cnt+=res[-1]
    res0 = 1
    res1 = 0
    for c in res:
        res0 = res0+res1*c
        res1 = res1+res0
        res0%=mod
        res1%=mod
    ans+=res1
    ans%=mod
print(ans)   

Measured memory_bytes: 129280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

int main(){
    ll H, W; std::cin >> H >> W;
    std::vector<std::string> a0;
    for(int i=0; i<H; ++i){
        std::string b; std::cin >> b; a0.push_back(b);
    }

    std::vector<std::string> a1;
    for(int i=0; i<a0.size(); ++i){
        bool flag=false;
        for(int j=0; j<a0.at(0).size(); ++j){
            if(a0[i][j]=='#'){
                flag=true;
                break;
            }
        }
        if(flag) a1.push_back(a0[i]);
    }

    std::vector<std::string> a2(a1.size());
    for(int i=0; i<a1.at(0).size(); ++i){
        bool flag=false;
        for(int j=0; j<a1.size(); ++j){
            if(a1[j][i]=='#'){
                flag=true;
                break;
            }
        }
        if(flag){
            for(int j=0; j<a1.size(); ++j){
                a2[j] += a1[j][i];
            }
        }
    }

    for(int i=0; i<a2.size(); ++i){
        std::cout << a2[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int pre[100000];
vector<int> bfs(const vector<vector<int>> &G, int s) {
    vector<int> ret(G.size(),-1);
    ret[s] = 0;
    queue<int> que;
    que.emplace(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (ret[nv] != -1) continue;
            ret[nv] = ret[v] + 1;
            pre[nv] = v+1;
            que.emplace(nv);
        }
    }

    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    auto dist = bfs(G,0);
    cout << "Yes" << ln;
    for (int i = 1; i < N; i++) cout << pre[i] << ln;
}

Measured memory_bytes: 10692
S = gets.chomp
a = S[0..1].to_i
b = S[2..3].to_i
is_yymm =
is_mmyy =
if (a > 0 && a <= 12) && (b > 0 && b <= 12)
  puts 'AMBIGUOUS'
elsif (a > 0 && a <= 12)
  puts 'MMYY'
elsif (b > 0 && b <= 12)
  puts 'YYMM'
else
  puts 'NA'
end


Measured memory_bytes: 1788
import collections

words = []
n = int(input())
for i in range(n):
    words.append(input())
c = collections.Counter(words)
l = c.most_common()
ans = []
maxi = l[0][1]
for pair in l:
    if pair[1] == maxi:
        ans.append(pair[0])
ans = sorted(ans)
for i in ans:
    print(i)

Measured memory_bytes: 119888
'use strict'

function Main(input) {
  const inputList = input.split(' ');
  const n = Number(inputList[0])
  const a = Number(inputList[1])
  const b = Number(inputList[2])
  let sum = 0

  for (let i=1; i<=n; i++) {
    const fifthDigit = Math.floor(i/10000)
    const fourDigit = Math.floor((i-10000*fifthDigit )/1000)
    const thirdDigit = Math.floor((i-10000*fifthDigit-1000*fourDigit)/100)
    const secondDigit = Math.floor((i-10000*fifthDigit-1000*fourDigit-100*thirdDigit)/10)
    const firstDigit =  Math.floor((i-10000*fifthDigit-1000*fourDigit-100*thirdDigit-10*secondDigit)/1)
    const digitTotal = fifthDigit + fourDigit + thirdDigit + secondDigit + firstDigit

    if (digitTotal >= a && digitTotal <= b) {
      sum += i
    }
  }

  console.log(sum)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

//TEMPLATE
/*
    for(int i=0; i<N; i++){
    }
*/

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H.at(i);
    }
    int cnt = 0, cnt_max = 0;
    for(int i=0; i<N-1; i++){
        if(H.at(i+1) <= H.at(i)){
            cnt++;
        }else{
            if(cnt>cnt_max) cnt_max = cnt;
            cnt = 0;
        }
    }
    if(cnt>cnt_max) cnt_max = cnt;
    cout << cnt_max;
}

Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int x,cnt=0;
  cin >> x;
  for(int i=0;;i++) {
    cnt+=i;
    if(cnt>=x) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        int a,b;
        int ans;
        String ob;
        Scanner scan = new Scanner(System.in);
        while(true){
        a = scan.nextInt();
        ob = scan.next();
        b = scan.nextInt();
        if(ob.equals("+"))ans = a+b;
        else if(ob.equals("-"))ans = a-b;
        else if(ob.equals("*"))ans  = a *b;
        else if(ob.equals("/"))ans=a/b;
        else break;
        System.out.println(ans);
        }
        scan.close();
    }   
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;

signed main(){
    cin>>N>>K;
    int g=0;
    int m=0;
    rep(i,N){
        int a;cin>>a;
        chmax(m,a);
        g=__gcd(g,a);
    }

    if(K%g!=0||K>m){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        cout<<"POSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x;
ll a[100005];
ll ans;
int main(void){
	cin>>n>>x;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]+a[i+1]>x){
			ans=ans+a[i+1]-(x-a[i]);
			a[i+1]=x-a[i];
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 1024
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [n;k] = reads int
    let ss = (read string).ToCharArray()

    // 不幸な人数を数える
    // 左端で左を向いている人と右端で右を向いている人は前に人がいないので不幸
    let x =
        match (ss.[0], ss.[n-1]) with
        | ('L', 'R') -> 2
        | ('L', _) -> 1
        | (_, 'R') -> 1
        | _ -> 0
    // 'RL'となっている2人はお互いに前の人が別の方向を向いているため不幸
    let y =
        Array.pairwise ss
        |> Array.sumBy (fun (x, y) -> if x = 'R' && y = 'L' then 1 else 0)
    // 全体の人数から不幸な人数を引くと幸福な人数が求まる
    let z = n - x - y * 2
    // 操作回数1回につき幸福にできる人数は最大2人
    let z' = z + k * 2

    // 全員同じ方向を向いているときの幸福な人数n-1を超えることはない
    printfn "%i" (min (n - 1) z')
    0

Measured memory_bytes: 17500
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		long ac = a*c;
		long ad = a*d;
		long bc = b*c;
		long bd = b*d;
		
		long max = Math.max(ac,Math.max(ad,Math.max(bc,bd)));
		
		System.out.println(max);
	}
}


Measured memory_bytes: 35736
package main

import (
	"fmt"
)

func main() {
	// 勉強用。先人の丸パクリです
	var n, m int
	fmt.Scan(&n, &m)
	//arr is　i番目の電飾が光るかどうかを判定するのに使用するスイッチの番号と、電飾の番号
	arr := make([][]int, m)
	for i:=0; i<m; i++ {
		var d int
		fmt.Scan(&d)
		// slice内で要素数の違うsliceを毎度毎度新たに定義するならコレ↓
		arr[i] = make([]int, d)
		for j:=0; j<d; j++ {
			fmt.Scan(&arr[i][j])
		}
	}
	ps := make([]int, m)
	for i:=0; i<m; i++ {
		fmt.Scan(&ps[i])
	}
	count := 0
	//全BIT探索を２＊＊ｎ回行う
	for i :=0; i< ( 1 << uint(n)); i++ {
		//iの動きは0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1011, 1100, 1101...
		switches := make([]int, 0)
		//ボタンの数だけループ
		//このループがなぜあるのかが分からない
		for j := 0; j<n; j++ {
			//なぜｊぶんビットをずらすのかが分からない
			//シフトさせた後の2進数の末尾が１であればTRUE
			//区切り｜を１つずつずらしていってその場所のスイッチがついているかどうかをみている
			if 1 & (uint(i) >> uint(j)) == 1 {
				//switchesとは何者？なぜ＋１？
				//実際に押されているスイッチをカウントしている！
				switches = append(switches, j+1)
			}
		}
		ok := true
		for j :=0; j<m ; j++ {
			//ここのループで一つでも点いていない電球があった場合は論理積でずっとfalseになる
			ok = ok && isLightUp(arr[j], switches, ps[j])
		}
		//↑の処理を電球をすべて数え終わるまでループ
		//すべてOKの場合にのみカウントアップ
		if ok {
			count++
		}
	}
	//↑というのをスイッチの押し方を変えるたびに毎回行っている、パソコンすごい。
	fmt.Println(count)

}
//光るためのスイッチと実際に押されているスイッチを比較している。（ｐの条件のもと）
func isLightUp(lamp, switches []int, ps int) bool {
	count := 0
	//このランプってのが押されていたらオッケーなスイッチ
	for _, i := range lamp {
		//このすいっちーずはいま実際におされているスイッチども
		for _, j := range switches {
			//ｍ番目の電飾について考えるという条件のもと、
			//今押されているスイッチの中にｍ電飾を光らせるスイッチが含まれているとき
			//カウントアップ
			if i == j {
				count++
				break
			}
		}
	}
	//それが条件を満たしているかどうかを返す
	return count % 2 == ps
}

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define gcda(x,y) gcd(abs(x),abs(y))

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  REP(i,n){
    int a;
    cin >> a;
    if(i%2==0){
      if(a%2!=0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[210000];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	a=0;
	
	for(i=0;i<n;i++){
		cin>>t[i];
		a^=t[i];
	}
	for(i=0;i<n;i++){
		t[i]^=a;
	}
	array_show(t,n);
}

Measured memory_bytes: 4536
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    int64 ans = 0;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if(n - (i*j) < 1) {
                break;
            }
            ans++;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3252
#include <cstdio>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int N, D;
map<unsigned int, vector<pair<unsigned int, int> > > add, sub; // x + y, x - y, (x, id)
vector<pair<int, int> > p;
int cnt[100010], par[100010];

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

void conn(int i, vector<pair<unsigned int, int> > &v, bool add){
  int x = p[i].first, pi = par_(i);

  if(add){
    auto s = lower_bound(v.begin(), v.end(), make_pair(0u + x, -1));
    auto e = lower_bound(v.begin(), v.end(), make_pair(0u + x + D, -1));
    cnt[i] += e - s;

    for(auto it = s; it != e; it++){
      int pit = par_(it->second);
      if(par[pit] == pi) break;
      par[pit] = pi;
    }
    e--; s--;
    for(auto it = e; it != s; it--){
      int pit = par_(it->second);
      if(par[pit] == pi) break;
      par[pit] = pi;
    }
  }
  else{
    auto s = upper_bound(v.begin(), v.end(), make_pair(0u + x, N));
    auto e = upper_bound(v.begin(), v.end(), make_pair(0u + x + D, N));
    cnt[i] += e - s;

    for(auto it = s; it != e; it++){
      int pit = par_(it->second);
      if(par[pit] == pi) break;
      par[pit] = pi;
    }
    e--; s--;
    for(auto it = e; it != s; it--){
      int pit = par_(it->second);
      if(par[pit] == pi) break;
      par[pit] = pi;
    }
  }
}

int main(){
  int A, B; scanf("%d%d%d", &N, &A, &B);
  A--; B--;

  for(int i = 0; i < N; i++){
    int x, y; scanf("%d%d", &x, &y);
    p.push_back(make_pair(x, y));
  }

  int Ax = p[A].first, Ay = p[A].second;
  int Bx = p[B].first, By = p[B].second;
  D = abs(Ax - Bx) + abs(Ay - By);

  sort(p.begin(), p.end());

  for(int i = 0; i < N; i++){
    int x = p[i].first, y = p[i].second;

    if(x == Ax && y == Ay) A = i;
    if(x == Bx && y == By) B = i;

    unsigned int addv = 0u + x + y, subv = 0u + x - y;
    add[addv].push_back(make_pair(0u + x, i)); sub[subv].push_back(make_pair(0u + x, i));
  }

  for(int i = 0; i < N; i++) par[i] = i;

  for(int i = 0; i < N; i++){
    int x = p[i].first, y = p[i].second;
    unsigned int addv = 0u + x + y + D, subv = 0u + x - y + D;

    if(add.find(addv) != add.end()) conn(i, add[addv], true);
    if(sub.find(subv) != sub.end()) conn(i, sub[subv], false);
  }

  for(int i = 0; i < N; i++) par_(i);

  long long ans = 0;
  for(int i = 0; i < N; i++) if(par[i] == par[A]) ans += cnt[i];

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 20724
$k=<>=~$"*$';/ /,$\+=$-=($h[$`]=$s+=$k-->0?$h[$`]?$d[@d]=$':$x+$'+ ++$x:$h[$`]?0:$x-(pop(@d)||9e9)+$'+ ++$x)-$\for`sort -nrk2`;print

Measured memory_bytes: 23732
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<long long int> res(n, 0);
    vector<int> next(n, -1);
    unordered_map<int, int> um;
    for (int i = n - 1; i >= 0; i--) {
        if (um.find(v[i]) != um.end()) {
            next[i] = um[v[i]];
        }
        um[v[i]] = i;
    }
    res[0] = 1;
    const int mod = 1e9 + 7;
    long long int c = 0;
    for (int i = 0; i < n; i++) {
        c += res[i];
        c %= mod;
        if (next[i] != -1 && next[i] - i > 1) {
            res[next[i]] += c;
            res[next[i]] %= mod;
        }
    }
    cout << c << endl;
}




Measured memory_bytes: 14520
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
    cin>>n>>m;
    vector<int> p(m);
    vector<string> s(m);
    vector<int> t(n+1,0);
    int ans_wa=0;

    for(int i=0;i<m;++i){
        cin>>p.at(i)>>s.at(i);
    }
    for (int i=0;i<m;++i){
        if(s.at(i)=="AC"){
            if(t.at(p.at(i))==-1){
                continue;
            }
            ans_wa+=t.at(p.at(i));
            t.at(p.at(i))=-1;
        }
        else if(s.at(i)=="WA"){
            if(t.at(p.at(i))==-1){
                continue;
            }
            else{
                t.at(p.at(i))+=1;
            }
        }
    }
    int ans_ac=count(t.begin(),t.end(),-1);

    cout<<ans_ac<<" "<<ans_wa<<endl;
}

Measured memory_bytes: 7172
import sys
N, K = [int(i) for i in input().split()]
if N <= 2:
    print(0)  # 2段以下のカレンダーでは3x3の正方形を作りようがない
    sys.exit()

ans = 0
for i in range(min(N - 3 + 1, 11)):
    for j in range(5):
        # 3x3の真中のマスの整数をxとすると、正方形内の数字の和は9x
        # xはカレンダーの端でないことから、
        # x = 7(i-1) + j (2 <= i <= n-1, 2 <= j <= 6)
        # x = 7(i+1) + (j+2) (0 <= i <= n-3, 0 <= j <= 4)
        # と表されるので、この範囲で合同式を満たす整数の組(i,j)の個数が解。

        # jを固定したとき i=11q+r と表すことにすると、 0<=i<=10 の範囲で
        # 解は唯一存在する(その値はr)。iを11で剰余を取った値はすべて異なるから。
        # i,jをこの範囲で動かし、条件を満たす組の個数がわかれば、
        # 全体での個数もわかる。
        if 9 * (7 * (i + 1) + (j + 2)) % 11 == K:
            r = i % 11
            # ある場所(r,j)が条件を満たすなら、そこに丸をつけてみる。
            # すると、(r+11t,j)にも丸をつけることになる。
            # カレンダーのうち丸をつける可能性のある場所の数は、
            # 11行5列のグリッドが (N-3)//11 個、row行5列のグリッドが1個ある。
            # もしrowの値がrより小さかったなら、row行5列のグリッドのj列目に
            # 丸をつけられる場所はない。
            ans += ((N - 3) // 11) + (1 if (N - 3) % 11 >= r else 0)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int A, B, cnt;

int main() {
	cin >> A >> B;
	for (int i = A; i <= B; ++i) {
		if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10)
			++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

bool F[30][MAX+1];

int main() {
	int n,c;cin>>n>>c;
	rep(i,c) rep1(j,n) F[i][j]=false;
	rep(i,n) {
		int s,t,c2;cin>>s>>t>>c2;c2--;
		for(int j=s;j<=t;j++) F[c2][j]=true;
	}
	int ans=0;
	rep1(i,MAX) {
		int t_ans=0;
		rep(j,c) {
			if(F[j][i]) t_ans++;
			ans=max(ans,t_ans);
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int count = 0;
  for(int i=0;i<3;i++){
    if(s.at(i) == t.at(i)){
      count++;
    }
  }
  cout << count <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.141592653589793238462643383279502884197
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dis[409][409];
signed main(){
	int h,w;
	cin>>h>>w;
	vector<string> fi(h);
	for(int i=0;i<h;i++){
		cin>>fi[i];
	}
	for(int i=0;i<h*w;i++){
		for(int j=0;j<h*w;j++){
			if( i != j ) dis[i][j] = LINF;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int cur = i*w+j;
			if( fi[i][j] == '.' ){
				if( i != 0 && fi[i-1][j] == '.' ){
					dis[cur][cur-w] = 1;
					dis[cur-w][cur] = 1;
				}
				if( i != h-1 && fi[i+1][j] == '.' ){
					dis[cur][cur+w] = 1;
					dis[cur+w][cur] = 1;
				}
				if( j != 0 && fi[i][j-1] == '.' ){
					dis[cur][cur-1] = 1;
					dis[cur-1][cur] = 1;
				}
				if( j != w-1 && fi[i][j+1] == '.' ){
					dis[cur][cur+1] = 1;
					dis[cur+1][cur] = 1;
				}
			}
		}
	}
	for(int k=0;k<h*w;k++){
		for(int i=0;i<h*w;i++){
			for(int j=0;j<h*w;j++){
				dis[i][j] = min( dis[i][j], dis[i][k] + dis[k][j] );
			}
		}
	}
	int ma = 0;
	for(int i=0;i<h*w;i++){
		for(int j=0;j<h*w;j++){
			if( dis[i][j] != LINF && dis[i][j] > ma ) ma = dis[i][j];
		}
	}
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26136
#include <bits/stdc++.h>
 
using namespace std;
 
struct node
{
    int x;
    int y;
}ma[90005];
 
int main()
{
    int n,m,d;
    int ans[90005];
    scanf("%d%d%d",&n,&m,&d);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            int a;
            scanf("%d",&a);
            ma[a].x=i;
            ma[a].y=j;
        }
    for(int i=1;i<=n*m;i++)
    {
        if(i<=d) ans[i]=0;
        else
        {
            ans[i]=ans[i-d]+abs(ma[i].x-ma[i-d].x)+abs(ma[i].y-ma[i-d].y);
        }
    }
    int q,l,r;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d%d",&l,&r);
        printf("%d\n",ans[r]-ans[l]);
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

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

	if (a == 'H') {
		if (b == 'H') {
			cout << 'H' << endl;
		}
		else {
			cout << 'D' << endl;
		}
	}
	else {
		if (b == 'H') {
			cout << 'D' << endl;
		}
		else {
			cout << 'H' << endl;
		}
	}

    return 0;
}

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

int main() {
    char s[100],st[50]={},dr[50]={};
    ///string str;
    int ok=1,n;
    ///str.length()
    cin.getline(s,100);//cin>>(s+1);
    n=strlen(s);
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            cout<<"No";
            return 0;
        }
        st[i]=s[i];
        dr[i]=s[n-i-1];
    }
    n=n/2;
    for(int i=0;i<n/2;i++){
        if(st[i]!=st[n-i-1]){
            cout<<"No";
            return 0;
        }
        if(dr[i]!=dr[n-i-1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;



import java.io.*;
public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    }
    
    public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr = new FastReader();
            int n = fr.nextInt();
            int x=fr.nextInt();
            int t=fr.nextInt();
           int time=0;
            time=(int)Math.ceil((double)n/x);
            System.out.print(time*t);
            
            
        }
        catch(Exception e){}
        finally{}

	}

}


Measured memory_bytes: 32648
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int num=scan.nextInt();
    int dice=scan.nextInt();
    int in;
    double par[]=new double[num];
    for(int x=0; x<num; x++){
      in=scan.nextInt();
      if(in==1){
        par[x]=1;
      }else{
        par[x]=(1.0+in)/2.0;
      }
    }
    double max=0;
    double spare=0;
    for(int x=0; x<dice; x++){
      max+=par[x];
    }
    spare=max;
    for(int x=0; x<num-dice; x++){
      spare=spare-par[x]+par[x+dice];
      if(max<spare){
        max=spare;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 65952
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	//cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		ll a=0,b=0;
		for(ll i=0;i<3;i++)
		{
			if(s[i]=='A')
			{
				a++;
				}
			if(s[i]=='B')
			{
				b++;
				}
			}
		if((a==2 && b==1) || (a==1 && b==2))
		{
			cout<<"Yes"<<endl;
			}
		else
		{
			cout<<"No"<<endl;
			}
	}
	
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 998244353
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll modex(ll a, ll b)
{
    ll ans = 1;
    for(; b > 0; b >>= 1, a = (a * a) % mod)
        if(b & 1)
            ans = (ans * a) % mod;
    return ans;
}
ll f[MAX];
ll ncr(ll n, ll r)
{
    if(n < r || r < 0)
        return 0;
    ll ans = (f[n] * modex(f[n - r], mod - 2)) % mod;
    ans = (ans * modex(f[r], mod - 2)) % mod;
    return ans;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, k, m, ans = 0, pr = 1;
    cin >> n >> m >> k;
    f[0] = 1;
    for(i = 1; i < MAX; i++)
        f[i] = (i * f[i - 1]) % mod;
    for(i = n - k; i <= n; i++)
    {
        ll ex = (m * modex(m - 1, i - 1)) % mod;
        ex = (ex * ncr(n - 1, i - 1)) % mod;
        ans = (ans + ex) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int N, M;
vector<pair<int, int>> A;

int main() {
  cin >> N >> M;
  A.resize(M);
  for (int i = 0; i < M; i++) {
    int from, to;
    cin >> from >> to;
    if (from > to) swap(from, to);
    A[i].first = to;
    A[i].second = from;
  }

  sort(A.begin(), A.end());

  int count = 0;
  int leftmostUncutLand = 0;
  for (int i = 0; i < M; i++) {
    int from = A[i].second;
    int to = A[i].first;
    if (from < leftmostUncutLand) continue;
    leftmostUncutLand = to;
    count++;
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
 int a,b;
 scanf("%d%d",&a,&b);
 int tmp=0;
 if(b==1){
   printf("0\n");
   return 0;
  }
 for(int i=0;;i++){
  if(a+i*(a-1)>=b){
   printf("%d\n",i+1);
   return 0;
  }
 }
return 0;}

Measured memory_bytes: 1732
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::cout << tools::ceil<i64>(N, 111) * 111 << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;cin>>a>>b;
    cout<<(a+b)%24<<endl;
}
// abc057_a

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int R, G, B, N, tmp, count=0;
    cin >> R >> G >> B >> N;
    
    for(int i=0; R*i<=N; i++){
        for(int j=0; R*i + G*j<=N; j++){
            tmp = N - (R*i + G*j);
            if(tmp % B == 0)
            count++;
        }
    }
    
    cout << count << "\n";
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k; cin >> n >> k;
  vector<int> cnt(n);
  for (int i = 0; i < n; i++) {
    int a; cin >> a; a--;
    cnt[a]++;
  }
  vector<int> res;
  for (int i = 0; i < n; i++) {
    if (cnt[i]) res.push_back(cnt[i]);
  }
  sort(res.begin(), res.end(), greater<int>());
  int ans = 0;
  for (int i = k; i < res.size(); i++) {
    ans += res[i];
  }
  cout << ans << '\n';
  return 0;
}

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

int main(void){
    int n,m;
    cin >> n >>m;
    pair<int,int> request[m];
    for(int i=0;i<m;i++){
        cin >>request[i].second >> request[i].first;
    }
   sort(request,request+sizeof(request)/sizeof(request[0]));
    int index=0,ans=0;
    for(int i=0;i<m;i++){
        if(index<request[i].second){
            index = request[i].first-1;
            ans++;
        }
    }
    cout << ans <<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll              long long int
#define nl              '\n'
using namespace std;

int main(void){

   ll t,n,a,b,c,d,mx=-100000000,mx1=-100000000,sum=0,cnt=0;

    vector<ll>ar,v;

        cin>>a>>b>>c>>d;

        mx=max(a*c,a*d);
        mx1=max(b*c,b*d);

        cout<<max(mx,mx1);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
using namespace std;

ll a, b, c, d;
int main() {
    IOS
    cin >> a >> b >> c >> d;
    ll f = b/c - (a-1)/c;
    ll s = b/d - (a-1)/d;
    ll lcm = (c*d)/__gcd(c, d);
    ll r = b/lcm - (a-1)/lcm;
    cout << (b-a+1) - (f+s-r) << endl;
    return 0;
}



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

const int MOD = 1000000007;

int main()
{
    long long l, r;
    cin >> l >> r;

    vector<int> dp(8, 0);
    dp[0] = 1;
    for(int i=0; i<63; ++i){
        int l2 = (l >> i) & 1;
        int r2 = (r >> i) & 1;
        vector<int> nextDp(8, 0);
        for(int j=0; j<8; ++j){
            for(int a=0; a<2; ++a){
                for(int b=0; b<2; ++b){
                    if(a < b)
                        continue;

                    int k = j;
                    if(a > r2)
                        k |= 1;
                    else if(a < r2)
                        k &= ~1;
                    if(b < l2)
                        k |= 2;
                    else if(b > l2)
                        k &= ~2;
                    if(a == 1 && b == 1)
                        k |= 4;
                    else if(a != b)
                        k &= ~4;

                    nextDp[k] += dp[j];
                    nextDp[k] %= MOD;
                }
            }
        }
        dp = move(nextDp);
    }
    cout << dp[4] << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
L = [chr(i) for i in range(ord("a"), ord("z") + 1)]

# print(L)
res = ""
for s in S:
    res += chr((ord(s) - ord("A") + N) % (ord("Z") - ord("A") + 1) + ord("A"))
    # print((ord(s) - ord("A") + N), (ord("Z") - ord("A")))
print(res)


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

#define ll long long

using namespace std;

vector< vector<int> > G;
vector<int> D;

void DFS(int u, int p, int val) {
    for(int i = 0; i < G[u].size(); i++)
        if(G[u][i] != p)
            DFS(G[u][i], u, val + D[u]);
    D[u] += val;
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, q, a, b;
    cin >> n >> q;
    G.resize(n);
    D.resize(n, 0);
    for(int i = 0; i < n - 1; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < q; i++) {
        cin >> a >> b;
        D[a - 1] += b;
    }
    DFS(0, -1, 0);
    for(int i = 0; i < n; i++)
        cout << D[i] << " ";
    return 0;
}


Measured memory_bytes: 26624
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 5;
int main()
{
	int n , m ,k , a[maxn ] , dp[maxn];
	for(int i = 1;i <= 1e5 + 5;i++)dp[i] = 1e9;
	scanf("%d %d",&n , &k);
	for(int i = 1;i <= n;i++)scanf("%d",&a[i]);
	dp[1] = 0,dp[2] = abs(a[1] - a[2]);
	for(int j = 3;j <= n;j++){
		for(int i = 1;i <= k;i++){
			if(j == i) break;
		dp[j] = min(dp[j],dp[j - i] + abs(a[j - i] - a[j]));
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,sum=0;

int main(){
    cin>>N;
    int A[N+2];
    A[0]=0;
    A[N+1]=0;
    repi(i,1,N+1){
        cin>>A[i];
        sum+=abs(A[i]-A[i-1]);
    }
    sum+=abs(A[N+1]-A[N]);
    rep(i,N){
        out(sum+abs(A[i+2]-A[i])-abs(A[i+1]-A[i])-abs(A[i+2]-A[i+1]));
    }

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

int main() {
    ll N;
    cin >> N;
    VV<ll> pairs;
    ll sum = (N & 1 ? N : N + 1);
    for(ll i = 1; i <= sum / 2; i++) pairs.push_back({i, sum - i});
    if(N & 1) pairs.push_back({N});
    V<PLL> ans;
    for(ll i = 0; i < pairs.size(); i++) {
        ll j = (i + 1) % pairs.size();
        for(ll e : pairs[i]) {
            for(ll ee : pairs[j]) {
                ll f = min(e, ee);
                ll t = max(e, ee);
                ans.emplace_back(f, t);
            }
        }
    }
    sort(ALL(ans));
    auto ite = unique(ALL(ans));
    ans.erase(ite, ans.end());
    cout << ans.size() << endl;
    for(PLL e : ans) {
        ll a, b;
        tie(a, b) = e;
        cout << a << ' ' << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())
s = deque(list(S))
re = False
 
for i in range(Q):
    q = list(map(str,input().split()))
    if q[0] == "1":
        re = not re
    else:
        b = int(q[1])-1
        if (re and b) or not(re or b):
            s.appendleft(q[2])
        else:
            s.append(q[2])
 
ans = ""
if re:
    while s:
    	ans += s.pop()
else:
    while s:
        ans += s.popleft()
print(ans)

Measured memory_bytes: 6628
#include <bits/stdc++.h>
#define vel vector<long long>
#define vech vector<char>
#define ves vector<string>
#define veb vector<bool>
#define vvel vector<vel>
#define vvech vector<vech>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define maxel(vec, j) *max_element(vec.begin(), vec.begin()+j)

using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
int vsum(vel v){ return accumulate(v.begin(), v.end(), 0); }
int msum(vvel v){
    int ans = 0;
    rep(i, v.size()){
        ans += vsum(v[i]);
    }
    return ans;
}
signed main() {
    int pr = 1000;
    pr *= pr * pr; pr += 7;
    string S;
    cin >> S;
    int w = 0;
    rep(i, S.size()){
        if(S[i] == 'o'){
            w++;
        }
    }
    if((15 - S.size() + w) >= 8){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

    return 0;
}
/*
2 2
2 1 2
1 2
0 1
 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// #define ll long long
// bool isEven(ll n) {return (n%2!=0)?false:true;}

using namespace std;

//atcoder - dp
//g

const int SIZE = 1e5 + 5;
int dist[SIZE];
bool visited[SIZE];
int in_degree[SIZE];
vector<int> adj[SIZE];

void dfs(int a)
{
    if(visited[a])  return;

    visited[a] = true;

    for (int i = 0; i < adj[a].size(); ++i)
    {
        int v = adj[a][i];

        dist[v] = max(dist[v], dist[a] + 1);
        in_degree[v]--;

        if(!visited[v]&&in_degree[v]==0)
            dfs(v);
    }
}

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

    while(m--)
    {
        int u, v;
        cin>>u>>v;

        adj[u].push_back(v);
        in_degree[v]++;
    }

    for (int i = 1; i <= n; ++i)
    {
        if(!visited[i]&&in_degree[i]==0)
        {
            dfs(i);
        }
    }

    int ans= 0;

    for (int i = 1; i <= n; ++i)
    {
        ans = max(ans, dist[i]);
    }

    cout<<ans<<endl;
}

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

int main(){
    int n;
    cin>>n;
    ll ans=0;
    rep(i,n){
        int k;
        cin>>k;
        ans += k-1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
if A==1 or B==1:
  if A==B:
    print('Draw')
    exit()
  else:
    if A==1:
      print('Alice')
      exit()
    else:
      print('Bob')
      exit()
if A>B:
  print('Alice')
elif A==B:
  print('Draw')
else:
  print('Bob')

Measured memory_bytes: 9180
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] a = s.toCharArray();
		Arrays.sort(a);
		System.out.println(new String(a).equals("abc") ? "Yes" : "No");
	}
}

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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}
long long dp[233];

int main()
{
	int q,h,s,d,n;
	scanf("%d%d%d%d%d",&q,&h,&s,&d,&n);
	long long mi=min(q*8,min(h*4,min(s*2,d))),rest=20+n%2,ans;
	ans=(long long)(n-rest)/2ll*mi;
	rest*=4ll;
	dp[0]=0;
	for(int i=1;i<=rest;i++)
	{
		dp[i]=dp[i-1]+(long long)q;
		if(i>1)dp[i]=min(dp[i],dp[i-2]+(long long)h);
		if(i>3)dp[i]=min(dp[i],dp[i-4]+(long long)s);
		if(i>7)dp[i]=min(dp[i],dp[i-8]+(long long)d);
	}
	wrll(dp[rest]+ans);
	puts("");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=410,mod=998244353;
int n,sa,sb,ans;
int a[N],b[N],fac[N],ifac[N],dp[N][N][N];
inline int pw(int x,int y){
	int res=1;
	for(;y;x=x*x%mod,y>>=1) if(y&1) res=res*x%mod;
	return res;
}
void pre(){
	fac[0]=1; for(int i=1;i<=N-10;i++) fac[i]=fac[i-1]*i%mod;
	ifac[N-10]=pw(fac[N-10],mod-2);
	for(int i=N-10-1;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
} 
signed main(){
	scanf("%lld",&n); pre();
	for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]),sa+=a[i],sb+=(b[i]-1);
	dp[0][0][0]=-1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=sa;j++)
			for(int k=0;k<=sb;k++){
				if(!dp[i-1][j][k]) continue; 
				dp[i][j][k]+=dp[i-1][j][k],dp[i][j][k]%=mod;
				for(int c=0,mul=1;c<b[i];c++,mul=mul*a[i]%mod) 
					dp[i][j+a[i]][k+c]+=-1ll*dp[i-1][j][k]*mul%mod*ifac[c]%mod,dp[i][j+a[i]][k+c]%=mod;
			}
			
	for(int i=0;i<=sa;i++)
		for(int j=0,mul=pw(i,mod-2),tp=mul;j<=sb;j++,mul=mul*tp%mod){
			ans=(ans+dp[n][i][j]*sa%mod*fac[j]%mod*mul%mod)%mod;
		}
	printf("%lld",(ans+mod)%mod);
} 

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

int main(void)
{
    char input;
    cin >> input;

    if (input == 'C')
        cout << 'G';
    else if (input == 'A')
        cout << 'T';
    else if (input == 'T')
        cout << 'A';
    else
        cout << 'C';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G,T INF){
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
        d[u]=d[v]+c;
        b[u]=v;
        q.emplace(d[u],u);
      }
    }
  }
  return d;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];

  using P = pair<Int, Int>;
  vector<P> va,vb;
  for(Int i=0;i<n;i++){
    va.emplace_back(a[i],i);
    vb.emplace_back(b[i],i);
  }
  sort(va.begin(),va.end());
  sort(vb.begin(),vb.end());

  vector<vector<P> > G(n*2);
  for(Int i=1;i<n;i++){
    {
      Int x=va[i-1].second,y=va[i].second;
      G[x].emplace_back(y,a[y]-a[x]);
      G[y].emplace_back(x,a[y]-a[x]);
    }    
    {
      Int x=vb[i-1].second,y=vb[i].second;
      G[n+x].emplace_back(n+y,b[y]-b[x]);
      G[n+y].emplace_back(n+x,b[y]-b[x]);
    }
  }

  for(Int i=0;i<n;i++){
    G[i].emplace_back(n+i,0);
    G[n+i].emplace_back(i,0);
  }

  const Int INF = 1e17;
  auto da=dijkstra(0,G,INF);
  auto db=dijkstra(n,G,INF);
  for(Int i=0;i<n;i++) cout<<min(da[i],db[i])<<endl;
  return 0;
}



Measured memory_bytes: 38056