akhauriyash/Code-Regression huggingface dataset:
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a,b; cin>>a>>b;
    ll mod = 1e9+7;
    vec<vec<ll>> m(a, vec<ll>(b));
    vec<vec<ll>> dp(a, vec<ll>(b));
    for(int q=0; q<a; q++){
        str t; cin>>t;
        for(int w=0; w<b; w++){
            m[q][w] = t[w]=='.';
            if(m[q][w]) dp[q][w] = (q ? dp[q-1][w] : 0) + (w ? dp[q][w-1] : 0);
            if(q+w==0) dp[q][w] = m[q][w];
            dp[q][w] %=mod;
        }
    }
    cout<<dp[a-1][b-1];
}

Measured memory_bytes: 16000
sa = input()
sb = input()
sc = input()

tmp = sa[0]
sa = sa[1:]
while True:
    if tmp == 'a':
        if sa=='':
            print('A')
            break
        tmp = sa[0]
        sa = sa[1:]
    elif tmp == 'b':
        if sb=='':
            print('B')
            break
        tmp = sb[0]
        sb = sb[1:]
    elif tmp == 'c':
        if sc=='':
            print('C')
            break
        tmp = sc[0]
        sc = sc[1:]

Measured memory_bytes: 3064
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

import sys
sys.setrecursionlimit(max(1000, 2*n))


ns = defaultdict(set)
for _ in range(n-1):
    u,v = [int(c) for c in input().split()]
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)

from bisect import bisect_left
 
l = [a[0]]
# for a in A[1:]:
#     if a > L[-1]:
#         # Lの末尾よりaが大きければ増加部分列を延長できる
#         L.append(a)
#     else:
#         # そうでなければ、「aより小さい最大要素の次」をaにする
#         # 該当位置は、二分探索で特定できる
#         L[bisect_left(L, a)] = a
# return len(L)

ans = [None] * n

def sub(u, prev, lst, old, ind, ans):
    aa = a[u]
    if len(lst)==0 or aa > lst[-1]:
        lst.append(aa)
        old = -1
        ind = None
    else:
        ind = bisect_left(lst, aa)
        old = lst[ind]
        lst[ind] = aa
    ans[u] = len(lst)
#     print(lst)
    for v in ns[u]:
        if prev==v:
            continue
        sub(v, u, lst, old, ind, ans)
    if old==-1:
        lst.pop()
    elif old is not None:
        lst[ind] = old

lst = []
sub(0, -1, lst, None, None, ans)
print("\n".join(map(str, ans)))


Measured memory_bytes: 443836
from math import ceil,floor
N,M=map(int,input().split())
Graph=[[] for i in range(N)]
for i in range(M):
  a,b,s=map(int,input().split())
  Graph[a-1].append((b-1,s))
  Graph[b-1].append((a-1,s))
inf=float("inf")  
node=[(0,0) for i in range(N)]
visited=[False]*N
node[0],visited[0]=(1,0),True
L,R=1,inf
stack=[0]
while stack:
  n=stack.pop()
  x,y=node[n]
  visited[n]=True
  for i,s in Graph[n]:
    if visited[i]:
      continue
    p,q=node[i]
    stack.append(i)
    if p:
      if p+x==0:
        if y+q!=s:
          print(0)
          exit()
      elif (s-y-q)%(p+x) or (not L<=(s-y-q)/(p+x)<=R):
        print(0)
        exit()
      else:
        L=R=(s-y-q)//(p+x)
    else:
      p,q=-x,s-y
      if p>0:
        L=max(L,floor(-q/p)+1)
      else:
        R=min(R,ceil(-q/p)-1)
      if L>R:
        print(0)
        exit()
      node[i]=(-x,s-y)
print(R-L+1)
#print(node)

Measured memory_bytes: 77984
N=gets.to_i;A=gets.split.map &:to_i;D=[*0..10**6];s=0;2.upto(N-2){|i|s+=A[i];1.upto(A[i]){|j|D.unshift D[j*2-1]}};gets;$<.map{|e|p (D[x=e.to_i]||x-s)+A[0]-A[1]}

Measured memory_bytes: 56844
#include<iostream>
#include<map>

using namespace std;

int main()
{
	map<int,int> card;

	int N;
	int *a;
	int ans = 0;

	cin >> N;
	a = new int[N];

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

	for(auto c : card)
	{
		if(c.second%2 == 1)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

using namespace std;
#define prev prev55

long long n, m;
vector<int> g[500000];

int color[500000];
int bipartite = 1;
int c[3];

void dfs(int v, int fl)
{
    color[v] = fl;
    c[fl]++;
    for (auto u : g[v])
    {
        if (color[u] == fl) bipartite = 0;
        else if (color[u] == 0) dfs(u, 3 - fl);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, 1);
    if (bipartite)
    {
        cout << 1LL * c[1] * c[2] - m;
    }
    else
    {
        cout << n * (n - 1) / 2 - m;
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, m, a, ans = 0;
  cin >> n >> m;
  rep(i, m) cin >> a, ans += a;

  cout << (n - ans < 0 ? -1 : n - ans) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S;
	cin >> S;

	int left = atoi(S.substr(0, 2).c_str());
	int right = atoi(S.substr(2, 2).c_str());

	bool bLeftM = (left >= 1 && left <= 12);
	bool bRightM = (right >= 1 && right <= 12);

	if (bLeftM && bRightM)
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if (bLeftM)
	{
		cout << "MMYY" << endl;
	}
	else if (bRightM)
	{
		cout << "YYMM" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL N, C, K;
  cin >> N >> C >> K;
  VEC<LL> T(N);
  REP(i, 0, N) cin >> T[i];
  sort(ALL(T));
  LL lim = T[0] + K;
  int first = 0;
  int num = 0;
  int pcnt = 0;
  int bcnt = 0;

  int i = 0;
  while (pcnt <= N && i<N) {
    // DUMP(i,pcnt,bcnt,lim);
    if (T[i] <= lim && num < C) {
      ++num;
      ++i;
    } else {
      pcnt += num;
      num = max(num - C, 0LL);
      ++bcnt;
      lim = T[i]+K;
    }
  }
  if(pcnt!=N)++bcnt;
  cout << bcnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

vector<ll> rnrn;


ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}
ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}


void dfs(ll x, ll n){
	rnrn.push_back(x);
	if (n == 10) return;
	string s = to_string(x);
	if (s[n-1] == '0'){
		dfs(x*10, n+1);
		dfs(x*10+1, n+1);
	}else if (s[n-1] == '9'){
		dfs(x*10+8, n+1);
		dfs(x*10+9, n+1);
	}else{
		dfs(x*10+(s[n-1]-'0')-1, n+1);
		dfs(x*10+(s[n-1]-'0'), n+1);
		dfs(x*10+(s[n-1]-'0')+1, n+1);
	}

}


int main(){
	int k;
	cin >> k;
	dfs(1, 1);
	dfs(2, 1);
	dfs(3, 1);
	dfs(4, 1);
	dfs(5, 1);
	dfs(6, 1);
	dfs(7, 1);
	dfs(8, 1);
	dfs(9, 1);
	sort(rnrn.begin(), rnrn.end());
	cout << rnrn[k-1] << endl;
 	return 0;
 }




Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  int n,ans=0;
  string s;
  cin >> n >> s;
  REP(i,n-2) {
    string abc;
    REP(j, 3) {
      abc.push_back(s[i+j]);
    }
    ans += (abc == "ABC");
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
d=defaultdict(int)
S=[input() for _ in range(n)]
for i in range(n):
    S[i] = ''.join(sorted(S[i]))
    d[S[i]]+=1

t=0
for v in d.values():
    if v > 1:
        t+=v*(v-1)//2
print(t)

Measured memory_bytes: 19824
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll K;
    in(K);

    ll L;

    if (K % 7 == 0)
    {
        L = 9 * (K / 7);
    }
    else
    {
        L = 9 * K;
    }

    ll tmp = 1;

    repse(i, 1, L)
    {
        tmp *= 10;
        tmp %= L;

        if (tmp == 1)
        {
            outl(i);
            return 0;
        }
    }

    outl(-1);

    return 0;
}

Measured memory_bytes: 3660
package main

import "fmt"

func main() {
	var n, s int
	fmt.Scan(&n, &s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var m int64 = 998244353
	dp := make([][]int64, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int64, s+1)
	}

	dp[0][0] = 1
	for i := 0; i < n; i++ {
		for j := 0; j <= s; j++ {
			if j+a[i] <= s {
				dp[i+1][j+a[i]] += dp[i][j]
				dp[i+1][j+a[i]] %= m
			}
			dp[i+1][j] += dp[i][j] * 2 % m
			dp[i+1][j] %= m
		}
	}
	fmt.Println(dp[n][s])
}


Measured memory_bytes: 77012
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
const int maxn = 2e5 + 10;
const int inf = 1 << 30;
int anw[maxn];

typedef pair<pair<int, int>, int> Node;

/*struct Node{
    int time, x, value;
    bool operator < (const Node &rhs) const{
        return (time < rhs.time) || (time == rhs.time && x < rhs.x);
    }
};*/

typedef pair<int, int> Node2;

int main(){
    int N, Q;
    vector <Node> event;
    scanf("%d%d", &N, &Q);
    for(int i = 0; i < N; i++){
        int s, t, x;
        scanf("%d%d%d", &s, &t, &x);
        event.push_back(make_pair(make_pair(s - x, 1), x));
        event.push_back(make_pair(make_pair(t - x, -1), x));
    }
    event.push_back(make_pair(make_pair(inf, inf), inf));
    sort(event.begin(), event.end());
    set <int> stop;
    int idex = 0;
    vector <Node2> D;
    for(int i = 0; i < Q; i++){
        int d;
        scanf("%d", &d);
        D.push_back(make_pair(d, i));
    }
    sort(D.begin(), D.end());
    for(int i = 0; i < Q; i++){
        while(event[idex].first.first <= D[i].first){
            if(event[idex].first.second == 1){
                stop.insert(event[idex++].second);
            }
            else{
                stop.erase(event[idex++].second);
            }
        }
        if(stop.empty() || event[idex].first.first == inf){anw[D[i].second] = -1;}
        else{
            anw[D[i].second] = *(stop.begin());
        }
    }
    for(int i = 0; i < Q; i++){
        printf("%d\n", anw[i]);
    }
    return 0;
}


Measured memory_bytes: 17644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int d(int a){
    if(a < 10)return a;
    return a % 10 + d(a / 10);
}
main(){
    int N,a;
    cin >> N;
    a = d(N);
    if(N % a)cout << "No" << endl;
    else     cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int A,B,C; cin >> A >>B >> C;
	if(A+B+C>=22)  cout << "bust" << endl;
	else cout << "win" << endl;

}


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

int main()
{
    long N;
    std::cin >> N;
    int result[10000000]={};
    long now=0;
    while(N!=0 && N!=1){
        long temp=N;
        N = std::ceil((double)N/(double)(-2));
        long mod=temp-(-2)*N;
        result[now]=mod;
        now++;
    }
    result[now]=N;
    
    for(long i=now; i>=0; i--){
        std::cout << result[i];
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 39296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <functional>
#include <string>
#include <math.h>
#include <queue>

using namespace::std;


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

 
    // for(int i(1); i < n+1; ++i)
    // {
    //     cout << m << endl;
    // }
    cout << n/m << endl;

    return 0;
}

Measured memory_bytes: 764
X, N = map(int, input().split())

if N == 0:
  print(X)
  exit()

P = list(map(int, input().split()))



for i in range (100+1):
  if(X-i) not in P:
    print(X-i)
    exit()
  elif (X+i) not in P:
    print(X+i)
    exit()
      
  else:
    continue

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

int gcd(int x,int y){
 int tmp;
 int r;
 if(x > y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = y % x;
  while(r!=0){
    y = x;
    x = r;
    r = y % x;
  }
  return x;
}

int main(){
    int K;
    cin >> K;
    int i,j,k,l,m;
    int ans =0;
    for(i=1;i<K+1;i++){
        for(j=1;j<K+1;j++){
            l=gcd(i,j);
            for(k=1;k<K+1;k++){
                m=gcd(k,l);
                ans += m;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
    int N, M;
    vector<string> s, t;
    cin >> N;
    s.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    cin >> M;
    t.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> t[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        string target = s[i];
        int score = 0;
        for (int j = 0; j < N; j++) {
            if (s[j] == target) {
                score++;
            }
        }
        for (int j = 0; j < M; j++) {
            if (t[j] == target) {
                score--;
            }
        }
        ans = max(ans, score);
    }

    cout << ans << endl;
}

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

int main (void) {
	double a, b, c, d, e, f;
	double aOrigin, bOrigin, cOrigin;
	double common, ysa, uhensa;
	double xans, yans;

	//??£???????¨?????????¢???
	//a * x + b * y = c
	//d * x + e * y = f

	while (scanf ("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		aOrigin = a;	//?????°a?????????????????????
		bOrigin = b;	//?????°b?????????????????????
		cOrigin = c;	//?????°c?????????????????????
		common = a * d;

		b = b * d;
		e = e * a;
		c = c * d;
		f = f * a;
		a = common;
		d = common;

		ysa = b - e;
		uhensa = c - f;

		yans = uhensa / ysa;
		xans = (cOrigin - (bOrigin * yans)) / aOrigin;

		printf("%.3f %.3f\n", xans, yans);
	}

	return 0;
}

Measured memory_bytes: 652
#include <algorithm>
#include <array>
#include <cstdio>

/*
https://atcoder.jp/contests/abc153/submissions/9767872
*/
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) {
    fread_unlocked(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}
inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm)
    while ((ct = getcha()) >= '0')
      A = A * 10 + ct - '0';
  else
    while ((ct = *ci++) >= '0')
      A = A * 10 + ct - '0';
  return A;
}
/*
https://atcoder.jp/contests/abc153/submissions/9767872
*/

inline constexpr bool test(const int x, const int y) noexcept {
  return x & 1 << y;
}

int main() {
  const int n = getint();
  std::array<int, 100000> v = {};
  for (int i = 0; i != n - 1; i += 1) {
    const int x = getint();
    const int y = getint();
    const int a = getint();
    v[x] ^= a;
    v[y] ^= a;
  }
  int ans = n;
  int b = 0;
  for (int i = 0; i != n; i += 1) {
    const int e = v[i];
    if (e == 0) {
      ans -= 1;
    } else {
      if (test(b, e))
        ans -= 1;
      b ^= 1 << e;
    }
  }

  std::array<int, 65536 / 2> dp = {};
  dp[b >> 1] = 1;
  for (int s = b; s != 0; s -= 2) {
    if (dp[s >> 1] == 0)
      continue;
    int i = 16;
    while (i != 0) {
      i -= 1;
      if (test(s, i))
        break;
    }
    for (int j = 0; j != i; j += 1) {
      if (!test(s, j))
        continue;
      const int k = i ^ j;
      if (k > j)
        continue;
      int &d = dp[(s ^ 1 << i ^ 1 << j ^ 1 << k) >> 1];
      if (test(s, k))
        d = std::max(d, dp[s >> 1] + 1);
      else
        d = std::max(d, dp[s >> 1]);
    }
  }
  printf("%d", ans - dp[0] + 1);
}

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

int main() {
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    int h, idx;
    double minn = 1000000000;
    for(int i = 0; i < n; i++){
        cin >> h;
        if(minn > abs(a - (t - h * 0.006))){
            idx = i + 1;
            minn = abs(a - (t - h * 0.006));
        }
    }
    cout << idx << endl;
}

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

int N,K;

int main()
{
    cin>> N>> K;
    int x=1;
    for (int i=0; i<N; i++){
        if (x+K < 2*x) x+=K;
        else x*=2;
    }
    cout<< x;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
d = {}

for i in range(n):
    s = input()
    if s not in d:
        d.update({s: 1})
    else:
        d[s] += 1

max_val = max(d.values())
keys_of_max_val = [key for key in d if d[key] == max_val]
print("\n".join(sorted(keys_of_max_val)))


Measured memory_bytes: 36736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()

#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t  main() {fast;
	int n; cin>>n;
	set<string> set;
	rep(i, n){
		string s; cin>>s;
		set.insert(s);
	}
	cout<<sz(set)<<endl;
}
 


Measured memory_bytes: 19252
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;
 
using namespace std;
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	vector<pair<ll, pair<ll,ll>>> ab;
	rep (i, 0, n) {
		cin >> a[i] >> b[i];
		ab.pb({a[i], {0, i}});
		ab.pb({b[i], {1, i}});
	}
	sort(all(ab));
	ll s = 0;
	vector<vector<int>> is(2, vector<int>(n));
	DBG(SZ(ab));
	rep (i, 0, n) {
		s += ab[i].ft;
		DBG(s, ab[i].ft);
		is[ab[i].sd.ft][ab[i].sd.sd] = 1;
	}
	DBG("ok", s);
	bool tw = 0, isa = 0, isb = 0;
	rep (i, 0, n) {
		if (is[0][i]) {
			isa = 1;
		}
		if (is[1][i]) {
			isb = 1;
		}
		if (is[0][i] and is[1][i]) {
			tw = 1;
		}
	}
	if (tw or !isa or !isb) {
		cout << s;
	} else {
		if (ab[n].sd.sd != ab[n - 1].sd.sd) {
			cout << s + ab[n].ft - ab[n - 1].ft;
		} else {
			cout << s + min(ab[n].ft - ab[n - 2].ft, ab[n + 1].ft - ab[n-1].ft);
		}
	}
	
}


Measured memory_bytes: 10096
import bisect

n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a), min(a))
    exit()

a.sort()
ans1 = a[-1]
tmp = ans1 // 2
index = bisect.bisect_left(a, tmp)
tmp1 = abs(tmp - a[index - 1])
tmp2 = abs(tmp - a[index])
if tmp1 < tmp2:
    ans2 = index - 1
else:
    ans2 = index

print(ans1, a[ans2])

Measured memory_bytes: 14052
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  std::vector<int> height(N);
  for (auto &h : height) {
    cin >> h;
  }
  std::vector<int> cost(N,0);
  for(int i=1;i<N;++i){
    if( i!=1 ){
      cost[i] = min(cost[i-1]+abs(height[i]-height[i-1]),cost[i-2]+abs(height[i]-height[i-2]));
    } else {
      cost[i] = cost[i-1]+abs(height[i]-height[i-1]);
    }
  }
  cout << cost[N-1] << endl;
}

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




int main(){
   string s;
   cin>>s;
   bool b="true";
   int cnt[2]={};
   vector<int> vec(s.size(),0);
   int t=0;
   int last=0;
   rep(i,s.size()){
       if(b){
           if(s[i]=='R')cnt[(i+last)%2]++;
           else{
               b=false;
               cnt[(i+last)%2]++;
               t=i;
               if(i==s.size()-1){
                   vec[t]+=cnt[(t+last)%2];
                vec[t-1]+=cnt[(t+last+1)%2];;
               }
           }
       }else{
           if(s[i]=='R'||i==s.size()-1){
               if(i==s.size()-1)cnt[(i+last)%2]++;
               b=true;
                vec[t]+=cnt[(t+last)%2];
                vec[t-1]+=cnt[(t+last+1)%2];;
               cnt[0]=cnt[1]=0;
               last=(t+1)%2;
               cnt[(i+last)%2]++;
           }
           else cnt[(i+last)%2]++;
               
           
       }
   }
   for(int i:vec)cout<<i<<" ";
   cout<<endl;
   return 0;
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007

int main() {
    int n,m;
    cin>>n>>m;
    vector<int>h(n+1);
    for(int i=1;i<=n;++i) {
        cin>>h[i];
    }
    vector<int>v[n+1];
    int a,b;
    while(m--) {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    int res=0;
    for(int i=1;i<=n;++i) {
        int x = h[i],f=1;
        for(int j : v[i]) {
            if(h[j] >= x) {
                f = 0;
                break;
            }
        }
        if(f == 1)
            res++;
    }
    cout<<res;
}


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

int main() {
  int n;cin>>n;
  long lucas[100];
  lucas[0]=2;lucas[1]=1;
  rep(i,90) lucas[i+2] = lucas[i] + lucas[i+1];
  
  cout << lucas[n];
}


Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(str(input()))
import collections
L = []
for s in S:
    S_dict = collections.Counter(s)
#     print(S_dict.keys())
    for i in S_dict.keys():
        L.append(i)
# print(L)

ans = ""
for i in "abcdefghijklmnopqrstuvwxyz":
    if L.count(i) == N:
        check = 10 ** 18
        for j in S:
            check = min(j.count(i), check)
        ans += i * check
print(ans)

Measured memory_bytes: 3316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize
    }
    if (a + b) % 2 == 1 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (a + b) / 2);
    }
}


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

int main() {

  int a,b,k;
  cin >> k;
  cin >> a >> b;
  int flag =0 ;

for(int i=a;i<=b;i++){
  if(i%k==0){
    flag = 1;
    break;
  }

}

  if(flag ==1)
    cout << "OK" << endl;
  else
  cout << "NG" << endl;
}

Measured memory_bytes: 3636
n=int(input())
t=[tuple(map(int,input().split()))for i in range(n)]
import math
from fractions import Fraction
dp=[0]*n
dp[0]=1
for i in range(1,n):
    dp[i]=math.ceil(max(Fraction(t[i-1][0],t[i][0]),Fraction(t[i-1][1],t[i][1]))*dp[i-1])
x=dp[-1]
print(x*t[n-1][0]+x*t[n-1][1])



Measured memory_bytes: 5304
let () = Scanf.scanf "%d" @@ fun n ->
  let hh = Array.init n @@ fun _ -> Scanf.scanf " %d" Fun.id in
  let dp = Array.make n 0 in
  dp.(0) <- 0;
  for i = 1 to n - 1 do
    if hh.(i - 1) >= hh.(i) then dp.(i) <- dp.(i - 1) + 1 else dp.(i) <- 0
  done;
  Printf.printf "%d\n" @@ Array.fold_left max 0 dp

Measured memory_bytes: 7560
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int a = 0, b = 0, c = 0;
    for (int i = 0; i < S.length(); i++) {
      char x = S.charAt(i);
      if (x == 'a') a++;
      if (x == 'b') b++;
      if (x == 'c') c++;
    }
    boolean ans = Math.max(Math.max(a,b),c)-Math.min(Math.min(a,b),c) <= 1;
    System.out.println(ans ? "YES" : " NO");
  }
}


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

void fnInput(vector<char>& rvcSLine, vector<char>& rvcTLine)
{
  string sSLine, sTLine;
  cin >> sSLine >> sTLine;

  rvcSLine.resize(sSLine.size());
  for (int i = 0; i < sSLine.size(); i++)
    rvcSLine[i] = sSLine[i];

  rvcTLine.resize(sTLine.size());
  for (int i = 0; i < sTLine.size(); i++)
    rvcTLine[i] = sTLine[i];
}

int fnAnagramCheck(vector<char>& rvcSLine, vector<char>& rvcTLine)
{
  sort (begin(rvcSLine), end(rvcSLine));
  sort (begin(rvcTLine), end(rvcTLine), greater<char>());

  string sSLine (begin(rvcSLine), end(rvcSLine));
  string sTLine (begin(rvcTLine), end(rvcTLine));

  if (sSLine < sTLine) return 1;
  else                 return 0;
}

int main()
{
  vector<char> vcSLine;
  vector<char> vcTLine;

  fnInput(vcSLine, vcTLine);
  if (fnAnagramCheck(vcSLine, vcTLine))
    cout << "Yes" << endl;
  else
    cout << "No"  << endl;

  return 0;
}

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

using namespace std;

int main(){
  vector<int> a(3);  
  for(int i=0;i<3;i++){
    cin >> a[i];
  }
  //sort(a.begin(), a.end());
  //int c=0, pre=0;
  //for(int i=0;i<2;i++){
  //  c+=abs(a[i]-pre);
  //  pre=a[i];
  //}

  cout << *max_element(a.begin(),a.end()) - *min_element(a.begin(), a.end()) << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b,c;
    cin >> a >> b >> c;
    if((a*100+b*10+c)%4==0)cout << "YES" << endl; else cout << "NO" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# define N 400010
int n,a[N],b[N],tree[N];
void add(int x,int y) {
	int i;
	for(i=x;i<=n;i+=i&(-i)) tree[i]+=y;
}
int query(int x) {
	int i,ans=0;
	for(i=x;i>=1;i-=i&(-i)) ans+=tree[i];
	return ans;
}
void prt() {
	for(int i=1;i<=n;i++) printf("%d ",n);
}
int main() {
	int k,i;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++) scanf("%d",a+i);
	if(k>40) {prt(); return 0;}
	while(k--) {
		memset(tree,0,sizeof(tree));
		for(i=1;i<=n;i++) {
			b[i]=query(n)-query(i-1);
			add(a[i]+i>n?n:a[i]+i,1);
		}
		memset(tree,0,sizeof(tree));
		for(i=n;i>=1;i--) {
			b[i]+=query(i)+1;
			add(i-a[i]<1?1:i-a[i],1);
		}
		memcpy(a,b,sizeof(b));
	}
	for(i=1;i<=n;i++) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 5600
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int h, w;
	cin >> h >> w;
	vector<string> vs;
	vector<vector<int> > vh, vv;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		vs.push_back(s);
	}
	vh = vector<vector<int> > (h, vector<int> (w, 0));
	vv = vector<vector<int> > (h, vector<int> (w, 0));

	for (int i = 0; i < h; i++) {
		int j = 0;
		while (j < w){
			while (j < w && vs[i][j] == '#')
			j++;
			int start = j;
			while (j < w && vs[i][j] == '.') {
				j++;
			}
			// j - start
			for (int k = start; k < j; k++)
				vh[i][k] = j - start;
		}
	}
	for (int i = 0; i < w; i++) {
		int j = 0;
		while (j < h) {
			while (j < h && vs[j][i] == '#')
			j++;
			int start = j;
			while (j < h && vs[j][i] == '.') {
				j++;
			}
			for (int k = start; k < j; k++) 
				vv[k][i] = j - start;
			
		}
	}
	int res = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			res = max(res, vh[i][j] + vv[i][j] - 1);
		}
	}
	cout << res << endl;
}














Measured memory_bytes: 35840
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int l;
    cin >> l;
    // スペース区切りの整数の入力
    int r,kari;
    cin >> r ;
  if(r - l +1 > 2019){
    cout<<0;
	}else{
  
  int co = 2019;
    // 文字列の入力
   	for (long int i = l; i < r; i++) {
		for (long int j = i+1; j <= r; j++) {
		 kari = (i*j) % 2019;
             if(co > kari) co = kari;
		}
	}
    // 出力
    cout<<co;
  }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
X = list(map(int, input().split()))
X_max = max(X)
X_min = min(X)
tes_min = 10000000

for i in range(X_min, X_max + 1):
    tes = 0
    for j in X:
        tes += (j - i)**2
    if tes_min > tes:
        tes_min = tes
print(tes_min)

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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int r;
	cin >> r;
	
	cout << 3 * r * r << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M,Q;cin >> N >> M >> Q;
    int S[510][510] = {};
    REP(i,M){
        int l,r;cin >> l >> r;
        REPP(j,r,501) S[l][j]++;
    }
    int ans;
    REP(i,Q){
        int l,r;cin >> l >> r;
        ans = 0;
        REPP(j,l,r+1) ans += S[j][r] - S[j][l-1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;
 
// ??????x????????????y????????????
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
int meiro[40][40][40][40];
// meiro[a][b][c][d] ... (a, b)??????(c, d)????§???????????£????????????°1??????????????°0
int tesu[40][40];
int issearched[40][40];
int w, h;
 
void tansaku(int a, int b);
 
int main()
{
    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        for(int i = 0; i < w; i++){
            for(int j = 0; j < h; j++){
                tesu[i][j] = 0;
                issearched[i][j] = 0;
            }
        }
        for(int i = 0; i < h - 1; i++){
            for(int j = 0; j < w - 1; j++){
                cin >> meiro[j][i][j + 1][i];
                meiro[j + 1][i][j][i] =  meiro[j][i][j + 1][i];
            }
            for(int j = 0; j < w; j++){
                cin >> meiro[j][i][j][i+1];
                meiro[j][i + 1][j][i] = meiro[j][i][j][i+1];
            }
        }
        for(int i = 0; i < w - 1; i++){
            cin >> meiro[i][h - 1][i + 1][h - 1];
            meiro[i + 1][h - 1][i][h - 1] = meiro[i][h - 1][i + 1][h - 1];
        }
        tansaku(0, 0);
        cout << tesu[w - 1][h - 1] << endl;
    }
    return 0;
}
 
void tansaku(int a, int b)
{
    queue<pair<int, int> > qu;
    qu.push(pair<int, int>(a, b));
    tesu[a][b] = 1;
    issearched[a][b] = 1;
    int x, y, next_x, next_y;
    while(1){
        if(qu.empty()) break;
        x = (qu.front()).first;
        y = (qu.front()).second;
        for(int i = 0; i < 4; i++){
            next_x = x + dx[i];
            next_y = y + dy[i];
            if(next_x < 0 || next_x >= w || next_y < 0 || next_y >= h) continue;

            if(issearched[next_x][next_y] == 0 && meiro[x][y][next_x][next_y] == 0){
                issearched[next_x][next_y] = 1;
                tesu[next_x][next_y] = tesu[x][y] + 1;
                qu.push(pair<int, int>(next_x, next_y));
            }
        }
        qu.pop();
    }
    return;
}

Measured memory_bytes: 8416
N, M = map(int, input().split())
X_list = list(map(int,input().split()))

if M == 1:
    print(0)
else:
    sorted_X_list = sorted(X_list)
    sabun_list = []

    for i in range(0,len(sorted_X_list)-1):
        sabun_list.append(sorted_X_list[i+1]-sorted_X_list[i])

    sabun_list.sort(reverse=True)
    del sabun_list[:N-1]

    print(sum(sabun_list))

Measured memory_bytes: 13968
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()

  sc.Scan()
  m, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  l, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  r, _ := strconv.Atoi(sc.Text())

  for i := 1; i < m; i++ {
    sc.Scan()
    p, _ := strconv.Atoi(sc.Text())
    sc.Scan()
    q, _ := strconv.Atoi(sc.Text())

    if p > l {
      l = p
    }

    if q < r {
      r = q
    }
  }

  if r >= l {
    fmt.Println(r - l + 1)
  } else {
    fmt.Println(0)
  }
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>

bool func(int N, std::vector<std::string>& vstr, int C) noexcept {
    for (int a = 0; a < N; a++) {
        for (int b = 0; b < N; b++) {
            if (vstr[(a + C) % N][b] != vstr[(b + C) % N][a]) {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    int N;
    std::cin >> N;
    std::vector<std::string> vstr;
    for (int n = 0; n < N; n++) {
        std::string s;
        std::cin >> s;
        vstr.emplace_back(s);
    }

    int count = 0;
    for (int c = 0; c < N; c++) {
        if (func(N, vstr, c)) {
            count += N;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};

int main() {
	string s,t;
	cin >> s>>t;
	ll ans = 0;
	rep(i, 3) {
		if (s[i] == t[i]){
			ans++;
		}

	}
	cout << ans;
}
	

Measured memory_bytes: 3176
#include <cstdio>
#include <algorithm>
using namespace std;

int N,M;
const int MAX_N = 100010;

struct line{
    int s,e;
    bool operator<(const line& r)const{
        return s!=r.s?s<r.s:e<r.e;
    }
}a[MAX_N];
int b[MAX_N];

int main(){
    scanf("%d%d",&N,&M);
    for(int i=0;i<M;i++){
        scanf("%d%d",&a[i].s,&a[i].e);
    }
    sort(a,a+M);
    for(int i=1;i<=N;i++){
        b[i] = N+1;
    }
    for(int i=0;i<M;i++){
        b[a[i].s] = min(b[a[i].s],a[i].e);
    }

    int ans = 0;
    for(int i=1,j=1;i<=N;i++){
        if(b[i]==N+1)continue;
        if(j > b[i]){
            j = b[i];
        }
        if(j <= i){
            ans++;
            j = b[i];
        }
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>

using namespace std;

#define MAX_N 11

int T;
int num[MAX_N];
int BStack[MAX_N];
int BTop;
int CStack[MAX_N];
int CTop;

bool dfs(int cur)
{
	bool b1=false,b2=false;

	if(cur==10)
		return true;
	if(BTop==-1 || BStack[BTop]<num[cur])
	{
		BStack[++BTop]=num[cur];
		b1=dfs(cur+1);
		--BTop;
	}
	if(CTop==-1 || CStack[CTop]<num[cur])
	{
		CStack[++CTop]=num[cur];
		b2=dfs(cur+1);
		++CTop;
	}

	return b1|b2;
}

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

	while(T--)
	{
		for(int i=0;i<10;i++)
			scanf("%d",&num[i]);
		BTop=CTop=-1;

		if(dfs(0))
			printf("YES\n");
		else
			printf("NO\n");
	}
}

Measured memory_bytes: 1168
n = int(input())
S_dict = {}
for i in range(n):
    s = str(input())
    if s in S_dict.keys():
        S_dict[s] += 1
    else:
        new = {s:1}
        S_dict.update(new)

Ans = []
count = 0
for j in S_dict.values():
    count = max(j, count)

for key, value in S_dict.items():
    if value == count:
        Ans.append(key)

Ans = sorted(Ans)
for a in Ans:
    print(a)

Measured memory_bytes: 32988