akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
    char b[8][8];
    int a[8][8];
    char en;
int main(void){
 
 
 
    while(cin>>b[0]){
        cin>>b[1]>>b[2]>>b[3]>>b[4]>>b[5]>>b[6]>>b[7];
 
 
    for(int n=0;n<8;n++){
        for(int m=0;m<8;m++){
            if(b[n][m]=='1')a[n][m]=1;
            else a[n][m]=0;
        }
    }
    int i,j;
    int flag=0;
    char t;
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(a[i][j]==1){
             //   cout<<i<<j;
                flag=1;
                break;
            }
        }
        if(flag==1)break;
    }
    if(a[i][j]==a[i][j+1]){
        //cout<<".";
        if(a[i][j+1]==a[i][j+2])t='C';
        else if(a[i][j+1]==a[i+1][j]){
            if(a[i+1][j]==a[i+1][j+1])t='A';
            else if(a[i+1][j]==a[i+1][j-1])t='G';
        }
        else if(a[i][j+1]==a[i+1][j+2])t='E';
    }
    else if(a[i][j]==a[i+1][j]){
        if(a[i+1][j]==a[i+2][j])t='B';
        else if(a[i+1][j]==a[i+1][j+1])t='F';
        else if(a[i+1][j]==a[i+1][j-1])t='D';
    }
    //else cout<<".....";
 
    cout<<t<<endl;
 
 
    }
 
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

ll A[400][400], B[400][400];

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

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            std::cin >> A[i][j];
        }
    }

    fill(&B[0][0], &B[0][0]+400*400, 1001001001001001001ll);

    for(int i=0;i<N;++i){
        B[i][i] = 0;
    }

    ll res = 0ll;
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            int v = -1;
            for(int k=0;k<N;++k){
                if(k == i || k == j){continue;}

                if(A[i][j] == A[i][k] + A[k][j]){
                    v = k;
                }
            }

            if(v == -1){
                B[i][j] = B[j][i] = A[i][j];
                res += A[i][j];
            }
        }
    }

    res /= 2;
    
    for(int k=0;k<N;++k){
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
            }
        }
    }

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(B[i][j] != A[i][j]){
                res = -1;
                break;
            }
        }
    }

    std::cout << res << std::endl;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

// 最大公約数
LL gcd(LL x, LL y) {
    return y ? gcd(y, x%y) : x;
}

// 最小公倍数
LL lcm(LL m, LL n) {
    return m/gcd(m, n)*n;
}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<LL> a(n), b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    LL x = 0;
    for(int i=n-1;i>=0;i--){
        a[i] += x;
        if(a[i]%b[i] == 0) continue;
        if(a[i] <= b[i]){
            x += b[i]-a[i];
        }else{
            x += (a[i]+b[i]-1)/b[i]*b[i]-a[i];
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> a(n);
    vector <ll> b(n);
    vector <ll> c(n-1);
    for (int z=0;z<n;z++) cin >> a[z];
    for (int z=0;z<n;z++) cin >> b[z];
    for (int z=0;z<n-1;z++) cin >> c[z];
    ll ans = 0;
    ll prev = -2;
    for (int z=0;z<n;z++){
        ans += b[a[z]-1];
        if (prev+1 == a[z]-1) ans += c[prev];
        prev = a[z]-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(list)


def sortpy(y):
    return {x: i for i, x in enumerate(sorted(y), 1)}


n, m = map(int, input().split())
py = [[int(x) for x in input().split()] for _ in range(m)]

for p, y in py:
    d[p].append(y)

nd = {p: sortpy(y) for p, y in d.items()}

for p, y in py:
    print('{:06g}{:06g}'.format(p, nd[p][y]))

Measured memory_bytes: 75964
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
long long f(long long k)
{
	if(k==0) return 2;
	return f(k-1)*2+2;
}
int main ()
{
    long long n;
    cin>>n;
    cout<<f(n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <utility>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    long long int x,y,count=1;
    cin >> x >> y;
    while(1){
        x*=2;
        if(x>y)break;
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/07/14.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n,m;
    cin >> n >> m;
    vi a(n),b(m);
    vl bcnt(200001,0);
    rep(i,n) cin >> a[i];
    rep(i,m){
        cin >> b[i];
        bcnt[b[i]]++;
    }
    ll ans=0;
    int k = sqrt(200001);
    repl(i,1,k){
        if(bcnt[i]==0) continue;
        ll tmp=0;
        rep(j,n){
            tmp+=a[j]%i;
        }
        ans+=tmp*bcnt[i];
    }
    int l=200000/k+1;
    mtl acnt(l,vl(k,0));
    rep(i,n){
        acnt[a[i]/k][a[i]%k]++;
    }
    mtl aa(l,vl(k,0));
    mtl ar(l,vl(k+1,0));
    rep(i,l){
        rep(j,k){
            ar[i][j+1]=ar[i][j]+acnt[i][j];
            rep(x,k){
                aa[i][j]+=(j+x)%k*acnt[i][x];
            }
        }
    }
    repl(i,k,200002){
        if(bcnt[i]==0) continue;
        int zpos=0;
        int top=0;
        ll tmp=0;
        rep(j,l){
            int one=(zpos>=k?0:(k-zpos)%k);
            tmp+=aa[j][one];
            tmp+=(top-one)*ar[j][min(zpos,k)];
            zpos-=k;
            if(zpos<0) zpos+=i;
            top=(top+k)%i;
        }
        ans+=tmp*bcnt[i];
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 10784
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: u64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut xs: Vec<u64> = sc.vec(n);
    xs.sort();
    xs.reverse();
    let mut c = 2;
    let mut dc = 1;
    for _ in 1..n {
        c = (c * 4) % M;
        dc = (dc * 4) % M;
    }
    // trace!(c, dc);
    let mut ans = 0;
    for i in 0..n {
        ans += (xs[i] * c) % M;
        // trace!(xs[i], c);
        c = (c + dc) % M;
    }
    put!(ans % M);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll r, g, b;
  cin >> r >> g >> b;
  cout << ((g * 10 + b) % 4 == 0 ? "YES" : "NO") << endl;
}


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

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
typedef long long int int64;

void print() {
    cout << endl;
}

void print(const char* s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(string s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int64 s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int s, bool endline = true) {
    cout << s;
    if (endline) print();
}

template <typename T, typename T2>
void print(pair<T, T2>& p, bool endline = true) {
    cout << "(";
    print(p.first, false);
    cout << ", ";
    print(p.second, false);
    cout << ")";

    if (endline) print();
}

template <typename T>
void print(T& t, bool endline = true) {
    cout << "[";
    for (auto it = t.begin(); it != t.end(); ++it) {
        if (it != t.begin()) cout << ", ";
        print(*it, false);
    }
    cout << "]";

    if(endline) print();
}

template <typename T>
vector<T> operator+(const vector<T> &a, const vector<T> &b)
{
    vector<T> ret;
    ret.reserve( a.size() + b.size() );                // preallocate memory
    ret.insert( ret.end(), a.begin(), a.end() );        // add A;
    ret.insert( ret.end(), b.begin(), b.end() );        // add B;

    return ret;
}

template <typename T>
vector<T> &operator+=(vector<T> &a, const vector<T> &b)
{
    a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
    a.insert( a.end(), b.begin(), b.end() );         // add B;
    return a;
}

bool c(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.first + a.second > b.first + b.second); 
} 

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp

    int64 n;
    cin >> n;

    vector<int64> a(n);
    vector<int64> b(n);

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

    vector<pair<int64, int64>> arr;

    for (int64 i = 0; i < n; ++i) {
        arr.push_back({a[i], b[i]});
    }

    sort(arr.begin(), arr.end(), c);

    int64 taka = 0;
    int64 aoki = 0;
    
    for(int64 i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            taka += arr[i].first;
        } else {
            aoki += arr[i].second;
        }
    }

    print(taka - aoki);

    return 0;
}

Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll X,K,D; cin>> X >>K >> D;
    if(X == 0){
        if(K % 2 == 0) cout << 0 << endl;
        else cout << D << endl;
        return 0;
    }else{
        if(X < 0) X *= -1;
        ll t = X/D;
        if(t >= K){
            cout << abs(X - K*D) << endl;
            return 0;
        }else{
            K -= t;
            if(K % 2 == 0){
                cout << abs(X - D*t) << endl;
            }else{
                cout << abs(X - D*t - D) << endl;
            }
        }
    }
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        boolean ans = true;
        int v = 0;
        
        long[] h = new long[N];
        h[0] = Long.parseLong(sc.next());
        for(int i = 1; i < N; i++) {
            h[i] = Long.parseLong(sc.next());
        }
        
        for(int i = N-1; i >= 1; i--) {
            if(h[i] >= h[i-1]) {
                continue;
            }else if(h[i] - h[i-1] == -1) {
                h[i-1]--;
            }else {
                ans = false;
                break;
            }
        }
        
        if(ans) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 48560
N, K = map(int, input().split())

if K % 2 == 0:
    list_abc = []
    list_abc_2 = []
    for i in range(1, N + 1):
        if i % K == 0:
            list_abc.append(i)
        elif i % K == (K / 2):
            list_abc_2.append(i)
    print(len(list_abc) ** 3 + len(list_abc_2) ** 3)


else:
    list_abc = []
    for i in range(1, N + 1):
        if i % K == 0:
            list_abc.append(i)
    print(len(list_abc) ** 3)

Measured memory_bytes: 11024
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
#define isOn(x, k)    ((x>>k)&1)
bool ispalindrome(int x)
{
  int ret =0;
  int tmp= x;
  while(x!=0)
  {
    ret*=10;
    ret+=x%10;
    x/=10;
  }
  return ret==tmp;
}
int main(){
 int l , r;
 cin>>l>>r;
 int ans=0;
 while(l<=r)
 {
   if(ispalindrome(l))
   {
        ans++;
   }
   l++;
 }
 cout<<ans<<endl;
}


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

using namespace std;

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

    vector<pair<long,long>> lr(n);
    for(auto &x: lr) cin >> x.first >> x.second, x.second++;

    if(n == 2) {
        long r = 0;
        r += lr[0].second - lr[0].first;
        r += lr[1].second - lr[1].first;
        cout << r << endl;
        return 0;
    }

    long r1, ml = 0, mr = 1e9, mrl = 1e9, mlr = 0;
    {
        long mli = -1, mri = -1;

        for(int i=0; i<n; i++)
            ml = max(ml, lr[i].first), mr = min(mr, lr[i].second);

        for(int i=0; i<n; i++) {
            if(ml == lr[i].first)
                mli = mli == -1 ? i : -2, mlr = max(mlr, lr[i].second);
            if(mr == lr[i].second)
                mri = mri == -1 ? i : -2, mrl = min(mrl, lr[i].first);
        }

        long m = 0;
        for(int i=0; i<n; i++)
            if(mli != i && mri != i)
                m = max(m, lr[i].second - lr[i].first);

        r1 = max(mr-ml, 0l) + m;
    }

    long r2 = 0;
    {
        vector<pair<long,long>> v;
        for(auto &x: lr)
            x.first = max(x.first, mrl), x.second = min(x.second, mlr);
        for(auto &x: lr)
            v.push_back({-max(x.second - ml, 0l), max(mr - x.first, 0l)});
        sort(v.begin(), v.end());

        vector<long> mrs(n);
        mrs[n-1] = v.back().second;
        for(int i=n-2; i>=0; i--)
            mrs[i] = min(v[i+1].second, v[i].second);

        for(int i=0; i<n-1; i++)
            r2 = max(r2, -v[i].first + mrs[i+1]);
            r2 = max(r2, -v[n-1].first);
    }

    cout << max(r1, r2) << endl;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    int n, m; cin >> n >> m;
    vector<int> h(n+1);
    for (int i = 1; i <= n; i++) cin >> h[i];

    vector<vector<int>> adj(n+1);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int high = 0;
        for (auto& u : adj[i]) high = max(high, h[u]);
        if (h[i] > high) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8724
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

vector<vector<mint>> succ(10, vector<mint>(200001));
vector<mint> ten(200001);

struct S{
	mint v;
	int size;
};

S op(S x, S y) {
	return {
		x.v * ten[y.size] + y.v,
		x.size + y.size
	};
}

S e() {
	return S{0, 0};
}

struct F {
	int v;
	bool id;
};

S mapping(F f, S x) {
	if (f.id) return x;
	else return {
		succ[f.v][x.size],
		x.size
	};
}

F composition(F f, F g) {
	if (f.id) return g;
	else return f;
}

F id() {
	return F{1, true};
}

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	for (int i = 1; i < 10; ++i) {
		mint x = i;
		for (int j = 1; j < 200001; ++j) {
			succ[i][j] = x;
			x = x * 10 + i;
		}
	}
	mint t = 1;
	for (int i = 0; i < 200001; ++i) {
		ten[i] = t;
		t *= 10;
	}
	int n, q; cin >> n >> q;
	lazy_segtree<S, op, e, F, mapping, composition, id> st(vector<S>(n, S{1, 1}));
	for (int i = 0; i < q; ++i) {
		int l, r, d; cin >> l >> r >> d;
		st.apply(l-1, r, F{d, false});
		cout << st.all_prod().v.val() << "\n";
	}
	return 0;
}

Measured memory_bytes: 19648
#include <stdio.h>

int main(void) {
  char S[11];
  scanf("%s", S);

  int num = 0;
  int max = 0;
  for(int i = 0; ; i++) {
    if(S[i] == '\0') break;
    if(S[i] == 'A' || S[i] == 'T' ||
       S[i] == 'G' || S[i] == 'C') {
      num++;
    } else {
      if(max < num) max = num;
      num = 0;
    }
  }
  if(max < num) max = num;
  
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
int M;
int Q;

int L[202020],R[202020];

int st[505][505];

int main(){
  cin >> N >> M >> Q;
  rep(i,0,M - 1){
    cin >> L[i] >> R[i];
    st[L[i]][R[i]]++;
  }
  rep(i,1,N){
    rep(j,1,N){
      st[i][j] += st[i - 1][j];
    }
  }
  rep(i,1,N){
    rep(j,1,N){
      st[i][j] += st[i][j - 1];
    }
  }
  vector<int> ans;
  rep(c,1,Q){
    i64 p,q;
    cin >> p >> q;
    int cnt = st[q][q] + st[p - 1][p - 1] - st[p - 1][q] - st[q][p - 1];
    ans.push_back(cnt);
  }
  for(int i  : ans){
    cout << i << endl;
  }
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>a>>b;
    Cout(a+b/2);
    return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

bool is_palindrome(string s) {
    rep(i, s.length()) {
        if (s[i] != s[s.length() - i - 1]) { return false; }
    }
    return true;
}

string S;
signed main() {
    cin >> S;
    if (is_palindrome(S) && is_palindrome(S.substr(0, (S.length() - 1) / 2))
        && is_palindrome(S.substr((S.length() + 3) / 2 - 1))) {
        cout << "Yes" << endl;
    } else { cout << "No" << endl; }
}


Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define B back()
#define FR front()
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
#define iceil(a) ((int)ceil(a))
#define ifloor(a) ((int)floor(a))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int n;
    cin >> n;

    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    lsort(l);

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]) - l.begin() - j - 1;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = 0;
        N = scanner.nextInt();
       if(N % 2==0){
           System.out.println(N);
        }else{
           System.out.println(2*N);
       }
    }

}


Measured memory_bytes: 21844
/**
Code by Nitin1184
**/
# include <bits/stdc++.h>
# define ll long long
# define pi 3.14159265358979323846
# define M 1000000007
# define pb push_back
# define mp make_pair
# define ff first
# define ss second
 
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(){
  int n,i;
  long long a;
  long long min=1000000;
  long long max=-1000000;
  long long sum=0;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    if(a<min)min=a;
    if(a>max)max=a;
    sum += a;
  }
  printf("%lld %lld %lld\n",min,max,sum);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
struct a{
  string s;
  li x;
};

void longestpallindrome(string s)
{
  li i,j,k;
  li n=s.length();
  bool table[n][n];
  memset(table,0,sizeof(table));
  for(i=0;i<n;i++)
  table[i][i]=1;
  li maxlength=1;
  li start=0;
  for(i=0;i<n-1;i++)
  {
    if(s[i]==s[i+1])
    {
      table[i][i+1]=1;
      if(maxlength<2)
      {maxlength=2;
      start=i;
       }
    }
  }
  for(k=3;k<=n;k++)
  {
    for(i=0;i<n-k+1;i++)
    {
      li j=i+k-1;

      if(table[i+1][j-1]&&s[i]==s[j])
      {
        table[i][j]=1;
        if(k>maxlength)
        {
          maxlength=k;
          start=i;
        }
      }
    }
  }
  cout<<s.substr(start,maxlength);
}

int main()
{
fast_io
li n,i,x;
cin>>n;
map<li,li>m;
li a[n];
for(i=0;i<n;i++)
{
  cin>>a[i];
  m[a[i]]++;
}
li ans=0;
for(auto j=m.begin();j!=m.end();j++)
{
    ans+=((j->second)*(j->second-1))/2;
}
for(i=0;i<n;i++)
{
  li x=ans;
  x-=m[a[i]]-1;
  cout<<x<<endl;
}
return 0;
}


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

int main(void)
{
    int num = 0;
    
    cin >> num;
    
    int a = num / 100;
    int b = num / 10 - a*10;
    int c = num - b*10 - a*100;
    
//    cout << a << endl << b << endl << c << endl;
    
    if(a == 7)
    {
        cout << "Yes";
    }
    else if(b == 7)
    {
        cout << "Yes";
    }
    else if(c == 7)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    vector<int> a(3);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[0]>>a[1]>>a[2];
        sort(a.begin(),a.end());
        if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1])cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3128
def main():
  N,M=map(int,input().split())

  if M == 0:
    print(-1)
    exit()

  INF = 10**6
  pqc = [tuple(map(lambda x:int(x)-1,input().split())) for _ in range(M)]

  to1d={v:{} for v in range(N)}
  count=2
  for p,q,c in pqc:
    if not to1d[p].get(c):
      to1d[p][c] = count
      count += 1
    if not to1d[q].get(c):
      to1d[q][c] = count
      count += 1

  G = [{} for _ in range(N+count)]
  for p,q,c in pqc:
    v1,v2 = to1d[p][c],to1d[q][c]
    G[v1][v2] = G[v2][v1] = 0

  for i in range(N):
    if len(to1d[i])<=1: continue
    for c in to1d[i].keys():
      v = to1d[i][c]
      G[v][count] = 1
      G[count][v] = 0
    count += 1

  def dijkstra(start = 0, goal = 1):
      from heapq import heappop, heappush
      NN = len(G)
      d = [INF]*NN
      d[start] = 0
      que = []
      heappush(que, start)
      while que:
          p = divmod(heappop(que),NN)
          v = p[1]
          if d[v] < p[0]: continue
          for u in G[v].keys():
              if d[u] > d[v] + G[v][u]:
                  d[u] = d[v] + G[v][u]
                  heappush(que, d[u]*NN+u)
          if v == goal: return d[goal]
      return d[goal]

  for c in to1d[0].keys():
    v = to1d[0][c]
    G[0][v] = 1
  for c in to1d[N-1].keys():
    v = to1d[N-1][c]
    G[v][1] = 0

  ans = dijkstra(0,1)
  print(ans if ans < INF else -1)
  
if __name__=="__main__":
  main()

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

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

int main()
{
  int N, X;
  cin >> N >> X;
  int x[N];
  for (int i = 0; i < N; i++)
    cin >> x[i];
  int ans = abs(x[0] - X);
  for (int i = 1; i < N; i++)
    ans = gcd(ans, abs(x[i] - X));
  cout << ans << endl;
  return 0;
}

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

int main() {
    int bit = 380000.0;
    float ans;
    int n;
    cin >> n; 
    float a[n];
    string b[n];
    
    for(int i = 0;i < n ;i++){
        
        cin >> a[i] >> b[i];
        if(b[i] == "BTC"){
            a[i] = a[i] * bit;
        }
        ans += a[i];
    }
    
    
    cout << ans;
	return 0;
}


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

const int INF = 1e9;
struct edge {int to, cap, rev;};

template <typename T> 
class Dinic {
public:
    Dinic(int V);
    void add_edge(int from, int to, T cap);
    T max_flow(int s, int t);

private:
    void bfs(int s);
    T dfs(int v, int t, T f);
    vector<vector<edge>> g;
    vector<int> level;
    vector<int> iter;
};

template <typename T> 
Dinic<T>::Dinic(int V){
    g = vector<vector<edge>> (V,vector<edge>());
    level = vector<int>(V);
    iter = vector<int>(V);
}

template <typename T> 
void Dinic<T>::add_edge(int from, int to, T cap) {
    g[from].push_back((edge){to, cap, (int)g[to].size()});
    g[to].push_back((edge){from, (T)0, (int)g[from].size()-1});
}

template <typename T> 
void Dinic<T>::bfs(int s){
    rep(i,level.size()) level[i] = -1;
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        rep(i,g[v].size()){
            edge &e = g[v][i];
            if(e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

template <typename T> 
T Dinic<T>::dfs(int v, int t, T f){
    if(v == t) return f;
    for(int &i = iter[v]; i < g[v].size(); i++) {
        edge &e = g[v][i];
        if(e.cap > 0 && level[v] < level[e.to]) {
            T d = dfs(e.to, t, min(f,e.cap));
            if(d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

template <typename T> 
T Dinic<T>::max_flow(int s, int t) {
    T flow = 0;
    while(true){
        bfs(s);
        if(level[t] < 0) return flow;
        rep(i,iter.size()) iter[i] = 0;
        T f;
        while((f = dfs(s,t,INF)) > 0){
            flow += f;
        }
    }
}

int main(){
    int v, e;
    cin >> v >> e;
    Dinic<int> dc(v);
    rep(i,e){
        int f, t, c;
        cin >> f >> t >> c;
        dc.add_edge(f,t,c);
    }
    cout << dc.max_flow(0,v-1) << endl;
}


Measured memory_bytes: 3152
#include <iostream>
using namespace std;
 
int F[105][105];
int xg,yg;
 
 
void DFS(int Y,int X,int c){
  if(F[Y][X] != c){
    return;
  }
 
  F[Y][X] = -2;
  DFS(Y-1,X  ,c);
  DFS(Y  ,X+1,c);
  DFS(Y+1,X  ,c);
  DFS(Y  ,X-1,c);
}
 
 
int main(){
  int w,h,xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<20; i++){
      for(int j=0; j<20; j++){
        F[i][j]=-1;
      }
    }
     
    cin >> xs >> ys >> xg >> yg >> n;
 
 
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }

  DFS(xs,ys,F[xs][ys]);
 
  if(F[xg][yg] == -2){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	private static final int MAX = 1000000;

	/**
	 * AOJ 0009 Prime Number
	 */
	public static void main(String[] args) throws IOException {

		int[] primeNums = new int[MAX];
		primeNums[2] = 1;

		ArrayList<Integer> inputList = getInputs();
		boolean isPrime = true;

		for (int i = 3; i < MAX; i++) {
			primeNums[i] = primeNums[i - 1];
			if (i % 2 == 0) {
				isPrime = false;
			}
			for (int j = 3; j <= Math.sqrt(i); j += 2) {
				if (i % j == 0) {
					isPrime = false;
					break;
				}
			}
			if (isPrime) {
				primeNums[i]++;
			}
			isPrime = true;
		}
		for (int index : inputList) {
			System.out.println(primeNums[index]);
		}
	}

	public static ArrayList<Integer> getInputs() throws IOException {
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));
		ArrayList<Integer> list = new ArrayList<Integer>();
		try {
			String input = null;
			while ((input = bufferedReader.readLine())!=null) {
				list.add(Integer.parseInt(input));
			}
		} finally {
			bufferedReader.close();
		}
		return list;
	}
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define MOD 1000000007

int main(){
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d;
    e = c;
    f = d;
    ll ans = 0;
    ll x = e * f;
    ll tmp, r;
    if (e < f)
    {
        tmp = e;
        e = f;
        f = tmp;
    }
    r = e % f;
    while(r!=0){
        e = f;
        f = r;
        r = e % f;
    }
    // cout << x / f << endl;
    ans += b / c - a / c + !(a % c);
    ans += b / d - a / d + !(a % d);
    ans -= b / (x / f) - a / (x / f) + !(a % (x / f));
    cout << (b - a) - ans + 1<< endl;
    return 0;
}

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

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

template <class T = int>
T in()
{
    T x;
    cin >> x;
    return (x);
}

int main()
{
    int n = in();
    set<int> S;
    rep(i, n)
    {
        int si = in();
        S.insert(si);
    }

    int q = in();
    int cnt = 0;
    rep(i, q)
    {
        int ti = in();
        cnt = S.count(ti) > 0 ? cnt + 1 : cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3148
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
  class Point
  {
    public double X { get; private set; }
    public double Y { get; private set; }
    public Point(double x, double y)
    {
      this.X = x;
      this.Y = y;
    }

    public double DistanceTo(Point other)
    {
      return Math.Sqrt(Math.Pow(other.X - this.X, 2) + Math.Pow(other.Y - this.Y, 2));
    }
  }

  class Circle
  {
    public Point Center { get; private set; }
    public double Radius { get; private set; }
    public Circle(double x, double y, double r)
    {
      this.Center = new Point(x, y);
      this.Radius = r;
    }
  }

  class Q0023
  {
    static void Main()
    {
      var n = int.Parse(Console.ReadLine());
      foreach (var circles in ReadCircles().Take(n))
      {
        var dist = circles[0].Center.DistanceTo(circles[1].Center);
        var largeCircle = circles[1].Radius < circles[0].Radius ? 0 : 1;
        var smallCircle = largeCircle == 0 ? 1 : 0;
        var r_sum = circles[0].Radius + circles[1].Radius;
        var r_dif = circles[largeCircle].Radius - circles[smallCircle].Radius;
        if (r_sum < dist)
        {
          Console.WriteLine(0);
          continue;
        }
        if (r_dif <= dist && dist <= r_sum)
        {
          Console.WriteLine(1);
          continue;
        }
        Console.WriteLine((largeCircle == 0 ? 1 : -1) * 2);
      }
    }

    static IEnumerable<Circle[]> ReadCircles()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
        yield return line.Split(' ').Select((s, i) => new { Index = i, Value = double.Parse(s) })
                                    .GroupBy(x => x.Index / 3)
                                    .Select(x => x.Select(v => v.Value))
                                    .Select(x => new Circle(x.First(), x.Skip(1).First(), x.Skip(2).First()))
                                    .ToArray();
    }
  }
}

Measured memory_bytes: 19040
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
  ll N;
  ll X,Y,H;
  cin >> N;
  vector<ll> x(N),y(N),h(N);
  rep(i,N) cin >> x[i] >> y[i] >> h[i];
  rep(i,101) rep(j,101){
    bool flag = 1;
    ll h1 = -1;
    rep(k,N){
      if(h[k] == 0){
        if(h1 != -1){
          if(h1 - abs(x[k]-i) - abs(y[k]-j) > 0) flag = 0;
        }
        continue;
      }
      if(h1 == -1){
        h1 = h[k] + abs(x[k] - i) + abs(y[k] - j);
      }else{
        if(h1 != h[k] + abs(x[k] - i) + abs(y[k] - j)) flag = 0;
      }
    }
    if(h[0] == 0){
        if(h1 - abs(x[0]-i) - abs(y[0]-j) > 0) flag = 0;
    }
    if(flag){
      X = i;Y = j;H = h1;
      break;
    }
  }
  cout << X << ' ' << Y << ' ' << H << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>
#include<queue>
#include<set>


#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}



bool comp(const pair<long long int, vector<int>> a, const pair<long long int, vector<int>> b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}
	else {
		return a.second < b.second;
	}

}










int main(){

	
	int n;
	cin >> n;

	cout << (n + 1) / 2 << endl;

	

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int n,x,y;
char w[200][20],hoge;
unsigned long long jg[110],z = 1;

int main() {

    scanf("%d",&n);

    for( x = 0 ; x < n ; x++ ) scanf("%s",w[x]);


    for( x = 0 ; x < n ; x++ ) {
        for( y = 0 ; y < 10 ; y++ ){
            if ( w[x][y] > 96 && w[x][y] < 123 ){
                if( y == 0 && x != 0 && hoge != w[x][y]){
                    printf("No\n");
                    return 0;
                }
                hoge = w[x][y];
                w[x][y] -= 96;
            }
            else w[x][y] = 0;
        }

        jg[x] = w[x][0];

        for( y = 1 ; y < 10 ; y++) {
            z *= 27;
            jg[x] += w[x][y]*z;
        }
        z = 1;
    }
    for( x = 0 ; x < n ; x++ ){
        for( y = 0 ; y < n ; y++ ){
            if( x != y && jg[x] == jg[y] ){
                printf("No\n");
                return 0;
            }
        }
    }

    printf("Yes\n");


    return 0;
}

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

int main(){
    long long a, b, c, x, y, z;
    cin >> a >> b >> c;
    long long sum = 0;
    z = a / c; y = b / c;
    for(int i = z; i <= y; i++){
        x = c * i;
        if(x <= b && x >= a) sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <numeric>

using namespace std;

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

int main() {
  int N, K, M{}, D{}, A;
  cin >> N >> K;
  while (cin >> A) {
    M = max(M, A);
    if (D) D = gcd(D, A);
    else D = A;
  }
  cout << (K <= M && (M - K) % D == 0 ? YES : NO) << endl;
}


Measured memory_bytes: 3600
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	flg=None
	dd = 1
	pv=al[0]
	for v in al[1:]:
		if flg is None:
			if pv == v:
				pass
			elif pv < v:
				flg = 'up'
			else:
				flg = 'down'
		elif flg == 'up':
			if v < pv:
				dd += 1
				flg = None
		else:
			if v > pv:
				dd += 1
				flg = None
		pv = v
	print(dd)
				
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 19856
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        vector<ll> a(n);
        rep(i, n) {
            cin >> a[i];
        }
        string s;
        cin >> s;
        bool x = false;

        vector<ll> bits(62);
        for(int i = n-1; i >= 0; --i) {
            if(s[i] == '0') {
                for(int j = 61; j >= 0; --j) {
                    if((a[i]>>j)&1) {
                        a[i] ^= bits[j];
                    }
                }
                int num = 63-__builtin_clzll(a[i]);
                if(num < 0) continue;
                rep(j, 62) {
                    if(((bits[j]>>num)&1) or j == num) {
                        bits[j] ^= a[i];
                    }
                }
            } else {
                for(int j = 61; j >= 0; --j) {
                    if((a[i]>>j)&1) {
                        a[i] ^= bits[j];
                    }
                }
                if(a[i]) {
                    cout << 1 << '\n';
                    x = true;
                }
            }
            if(x) break;
        }
        if(!x) cout << 0 << '\n';
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;
	
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
	
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
	
const int mod=1e9+7;
	
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
int mul(int a,int b)
{
  return ((a)*1ll*(b))%mod;
}
	
void add(int &a,int b)
{
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
	  output<<i<<' ';
	return output;
}

const int N=1000002;

void solve(){
  int n,q;
  cin>>n>>q;
  dsu d(n);
  while(q--){
    int tmp;
    cin>>tmp;
    int x,y;
    cin>>x>>y;
    if(tmp==0){
      d.merge(x,y);
    }
    else{
      if(d.same(x,y)){
	cout<<1;
      }
      else{
	cout<<0;
      }
      cout<<'\n';
    }
  }
  
  
}
	
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tc=1;
  // cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1)
      cout<<"\n";
  }
}


Measured memory_bytes: 4016
#include<iostream>
#include<string.h>
using namespace std;
int main()
{

  int N;
  cin >> N;
  int D[N][2];
  for(int i=0;i<N;i++)
  {
    cin >> D[i][0] >> D[i][1];
    if(i>1){
      if( D[i][0]==D[i][1] && 
        D[i-1][0]==D[i-1][1] && 
        D[i-2][0]==D[i-2][1])
      {
        cout << "Yes" << endl;
        return 0;
      }
    }        
  }
  
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n; cin >> n;
    int a, b, c; cin >> a >> b >> c;
    vi d(n);
    rep(i, n) cin >> d[i];
    sort(all(d), greater<int>());
    int ans = 0;
    rep(i, n){
        c += d[i];
        ans = max(ans, c/(a+(i+1)*b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1216