akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

template <class F>
class fix_point: F {
public:
  explicit constexpr fix_point(F&& f) noexcept: F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator ()(Args&&... args) const {
    return F::operator ()(*this, std::forward<Args>(args)...);
  }
};

template <class F>
static inline constexpr decltype(auto) make_fix_point(F&& f) noexcept {
  return fix_point<F>{std::forward<F>(f)};
}


template <typename Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost = 1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(edge<value_type> const& rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <typename Weight>
class graph: public std::vector<std::vector<edge<Weight>>> {
public:
  using value_type = Weight;

private:
  size_t M_size = 0;
  std::vector<size_t> M_ord, M_low;
  std::vector<size_t> M_articulation_point;
  std::vector<edge<value_type>> M_bridge;

  void M_lowlink_dfs(size_t s) {
    size_t count = 0;
    make_fix_point([&](auto f, size_t v, size_t p) -> void {
        M_low[v] = M_ord[v] = count++;
        size_t deg = 0;  // in terms of the dfs tree
        bool ap = false;
        for (auto const& e: (*this)[v]) {
          if (e.dst == p) continue;
          if (M_ord[e.dst]+1 != 0) {
            M_low[e.src] = std::min(M_low[e.src], M_ord[e.dst]);
          } else {
            f(e.dst, e.src);
            M_low[e.src] = std::min(M_low[e.src], M_low[e.dst]);
            ++deg;
            if (M_ord[e.src] > 0 && M_ord[e.src] <= M_low[e.dst]) ap = true;
            if (M_ord[e.src] < M_low[e.dst]) M_bridge.push_back(e);
          }
        }
        if (M_ord[v] == 0 && deg > 1) ap = true;
        if (ap) M_articulation_point.push_back(v);
    })(s, -1);
  }

  void M_lowlink() {
    if (!M_ord.empty()) return;
    M_ord.resize(M_size, -1);
    M_low.resize(M_size, -1);
    for (size_t i = 0; i < M_size; ++i)
      if (M_ord[i]+1 == 0) M_lowlink_dfs(i);
  }

public:
  graph() = default;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n), M_size(n) {}

  void connect_to(size_t src, size_t dst, value_type cost = 1) {
    (*this)[src].emplace_back(src, dst, cost);
  }

  void connect_with(size_t src, size_t dst, value_type cost = 1) {
    connect_to(src, dst, cost);
    connect_to(dst, src, cost);
  }

  std::vector<edge<value_type>> bridge() {
    M_lowlink();
    return M_bridge;
  }

  std::vector<size_t> articulation_point() {
    M_lowlink();
    return M_articulation_point;
  }
};

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  graph<int> g(n);
  for (size_t i = 0; i < m; ++i) {
    size_t s, t;
    scanf("%zu %zu", &s, &t);
    g.connect_with(s, t);
  }

  auto ap = g.articulation_point();
  std::sort(ap.begin(), ap.end());
  for (auto a: ap) printf("%zu\n", a);
}



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

#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  string s;
  cin >> s;
  int zeros = 0, ones = 0;
  rep1(i, 0, s.size()) if (s[i] == '0') zeros++;
  ones = s.size() - zeros;
  cout << s.size() - abs(ones - zeros) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 998244353;

ll dp[200005];

int main(){
  int N, K;
  cin >> N >> K;
  vector<pair<int,int>> v;
  rep(i,K){
    int a, b;
    cin >> a >> b;
    v.emplace_back(a,b);
  }

  dp[1] = 1;
  dp[2] = -1;
  ll base = 0;
  REP(i,1,N+1){
    base += dp[i];
    //cout << i << " " << base << endl;
    base %= MOD;
    rep(j,K){
      if(i+v[j].first < 200005){
        dp[i+v[j].first] += base;
        dp[i+v[j].first] %= MOD;
      }
      if(i+v[j].second+1 < 200005){
        dp[i+v[j].second+1] += (MOD - base);
        dp[i+v[j].second+1] %= MOD;
      }
    }
  }

  cout << base << endl;
  
  return 0;
}



Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll v, to, cost;};
struct UnionFind{
  ll N; //ノードの個数
  vector<edge> G;
  vector<int> par; // 親ノード
  vector<int> rank; // ランク

  UnionFind(int n) { //初期化
    N=n; par.resize(N); rank.resize(N);
    rep(i,N) {par[i] = i, rank[i] = 0;}
  }

  int root(int x) { //ノードの根を返す
    if(par[x] == x) return x; //親が自分なら自分を返す
    else{
      int r = root(par[x]); //根まで遡る
      return par[x] = r;
    }
  }
  bool issame(int x, int y) { //同じ根ならtrue,ちがうならfalse
    return root(x) == root(y);
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x; //ランクの小さい方に接続
    return true;
  }

  void add_edge(ll v,ll to,ll cost){
    G.emplace_back((edge){v, to, cost});
  }
/*
  bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
  }
  */
  ll kruskal() {
    //sort(G.begin(), G.end(), comp);
    sort(G.begin(), G.end(), [](const edge &a, const edge &b) {
       return a.cost < b.cost;
    });//比較関数をラムダ式で作る);
    ll res = 0;
    for(auto E: G) {
      if(!issame(E.v, E.to)) {
        merge(E.v, E.to);
        res += E.cost;
      }
    }
    return res;
  }

};


void Main(){

  int N;
  cin>>N;

  ll x[N];
  ll y[N];

  rep(i,N){
    cin>>x[i]>>y[i];
  }

  vector<pair<ll,ll>> xpr;
  vector<pair<ll,ll>> ypr;

  rep(i,N){
    xpr.emplace_back(x[i],i);
    ypr.emplace_back(y[i],i);
  }

  SORT(xpr);
  SORT(ypr);

  UnionFind uf(N);

  rep(i,N-1){
    ll x1=xpr[i].second; ll x2=xpr[i+1].second;
    uf.add_edge(x1,x2,min(abs(x[x1]-x[x2]),abs(y[x1]-y[x2])) );
    ll y1=ypr[i].second; ll y2=ypr[i+1].second;
    uf.add_edge(y1,y2,min(abs(x[y1]-x[y2]),abs(y[y1]-y[y2])) );
  }

  cout<< uf.kruskal() <<"\n";

}


//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 15328
s=input()
a=int(s[0:2])
b=int(s[2:4])
if 0<a<13 and 0<b<13:print("AMBIGUOUS")
elif not(0<a<13 or 0<b<13):print("NA")
elif 0<b<13:print("YYMM")
else:print("MMYY")


Measured memory_bytes: 2940
a,b,c=map(int,input().split())

lis=[]
if a>b:
    for i in range(b):
        if a%int(b-i)==0 and b%int(b-i)==0:
            lis.append(int(b-i))

else:
    for i in range(a):
        if a%(a-i)==0 and b%(a-i)==0:
            lis.append(int(a-i))

#print(lis)
print(lis[c-1])


Measured memory_bytes: 3060
N = int(input())
p = [int(i) for i in input().split()]
ct = 0
for i in range(N):
  if p[i] == i+1:
    continue
  elif p[i] > i+1:
    if p[p[i]-1] == i+1:
      ct += 1
    else:
      print("NO")
      exit()
if ct <= 1:
  print("YES")
else:
  print("NO")

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

using namespace std;

#define M  100000+100
#define mod 998244353
typedef long long ll;

ll a[M];
ll b[M];

ll pow_mod(ll a, ll n)
{
    ll ans = 1;
    a=a%mod;
    while(n){
        if(n&1){
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }
    return ans;
}
int main()
{

    ll n;
    cin>>n;
    memset(b,0,sizeof(b));
    ll c,sum=1;
    ll maxx=-1;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        b[a[i]]++;
        maxx=max(maxx,a[i]);
    }
    if(a[1]||b[0]>1) cout<<"0";
    else
    {
        sum=1;
        for(int i=2; i<=maxx; i++)
        {
            if(!b[i-1])
            {
                sum=0;
                break;
            }
            else
            {
                ll k=pow_mod(b[i-1],b[i]);
                sum=(sum*k)%mod;
            }
        }
        cout<<sum;
    }
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
rootn = int((N**0.5) +1)
A = range(1, rootn)
min_digits = 11
for i in A:
    if (N % i) == 0:
        B = N // i
        p, q =len(str(i)), len(str(B))
        if (p > q) and (p < min_digits):
            min_digits = p
        elif (p <= q) and (q < min_digits):
            min_digits = q
print(min_digits)

Measured memory_bytes: 3064
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
//public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s;
  cin >> s;
  ll now = 0;
  ll table[2019];
  for (int i = 0; i < 2019; i++){
    table[i] = 0;
  }
  table[0] = 1;
  ll mul = 1;
  ll temp = 0;
  for(int i=s.length()-1;i>=0;i--){
    int v = s[i]-'0';
    temp = v*mul;
    temp %= 2019;
    now += temp;
    now %= 2019;
    table[now]++;
    mul *= 10;
    mul %= 2019;
  }
  ll ans = 0;
  for(int i=0;i<2019;i++){
    ans += (table[i]*(table[i]-1))/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3316
from collections import deque, Counter
from itertools import chain, combinations
import json
import numpy as np
import bisect


def main():
    # N = int(input())
    N, R = [int(a) for a in input().split()]
    if N > 10:
        print(R)
    else:
        print(R + 100 * (10 - N))
    # A = [int(a) for a in input().split()]
    #
    # A = sorted(A)
    # A = np.array(A)
    #


if __name__ == "__main__":
    main()


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint factorial(int n){ return fact[n]; }
} C(1000010);


void solve()
{
  int n;
  cin >> n;

  mint m8 = 8;
  mint m2 = 2;
  mint ans = 0;
  
  // 0,9がkこ
  for(int k = 2; k <= n; ++k)
  {
    mint mk = k;
    ans += m8.pow(n - k) * C(n, n - k) * (m2.pow(k) - 2);
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

namespace AtCoder_Beginner_Contest_168
{
    class C
    {
        static void Main(string[] args)
        {
            var abhm = ReadIntArray(4);
            var hourLen = abhm[0];
            var b = hourLen;
            var minLen = abhm[1];
            var c = minLen;
            var h = abhm[2];
            var m = abhm[3];

            var mAngle = Math.PI * ((double)m) / 30.0;
            var hAngle = Math.PI * ((double)(h * 60 + m)) / 360.0;
            var angle = Math.Abs(mAngle - hAngle);
            var a = Math.Sqrt(b * b + c * c - 2 * b * c * Math.Cos(angle));
            Console.WriteLine(a);
        }
        private static int[] ReadIntArray() => ReadIntArrayFrom_StringSplit(Console.ReadLine());

        private static int[] ReadIntArray(int size) => ReadIntArrayFrom_FixedSize(Console.ReadLine(), size);

        private static int[] ReadIntArrayFrom_StringSplit(string s) =>
                s.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                .Select(int.Parse)
                .ToArray();


        private static int[] ReadIntArrayFrom_FixedSize(string s, int size)
        {
            var sLen = s.Length;
            var res = new int[size];
            var resIdx = 0;
            var start = 0;
            string ss;

            for (int i = 1; i <= sLen; i++)
            {
                if ((i == sLen || s[i] == ' '))
                {
                    ss = s.Substring(start, i - start);
                    {
                        res[resIdx++] = int.Parse(ss);
                        start = i + 1;
                    }
                }
            }
            return res;
        }

        //////////////////

        private static int ReadInt(string s) => int.Parse(s);

        private static int ReadInt() => int.Parse(Console.ReadLine());

        /////////

        static int Mod(int A, int n)
        {
            var a = A / n;
            if (A < 0)
            {
                return A - a * n + n;
            }
            else
            {
                return A - a * n;
            }
        }
    }
}


Measured memory_bytes: 27932
import sys
n, x = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
_sum = max(0, a_ls[0] - x)
last = min(x, a_ls[0])
for a in a_ls[1:]:
    if last + a > x:
        _sum += last + a - x
        last = x - last
    else:
        last = a
print(_sum)

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(int i=a;i<b;i++)
#define inf (long long int) 1e18
#define vi vector<int> 
#define pii pair<int, int>
#define mii map<int, int> 
#define mod 1000000007

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

int palindrome(string s){
    int l = 0;
    int h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

long long modexp(long long a, long long b, long long m){
    if (b==0)
        return 1;
    long long temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    int a[3];
    loop(i,0,3){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<abs(a[1]-a[0])+abs(a[2]-a[1]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n)
    {
        cin >> vec[i];
    }
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (vec[i] >= vec[i + 1])
        {
            cnt++;
        }
        else
        {
            cnt = 0;
        }
        ans = max(cnt, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        int N,K; cin>>N>>K;
        int ans=K*pow(K-1,N-1);
        cout<<ans<<endl;
}


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

void showVector(std::vector<int> readVec){
    int length = readVec.size();
    for(int i = 0; i < length; ++i){
        if(length - 1 != i){
            std::cout << readVec.at(i) << " ";
        }else{
            std::cout << readVec.at(i);
        }
    }
    
    std::cout << std::endl;
}

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

    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    bool flg = true;
    int j, tmp;
    int count = 0;
    while(flg){
        flg = 0;
        for(j = n - 1; 0 < j; --j){
            if(a.at(j) < a.at(j - 1)){
                a.at(j) += a.at(j - 1);
                a.at(j - 1) = a.at(j) - a.at(j - 1);
                a.at(j) = a.at(j) - a.at(j - 1);
                flg = true;
                ++count;
            }
        }
    }
    
    showVector(a);    
    std::cout << count << std::endl;

    return 0;
}



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

int main()
{
  int n,m;
  cin >> n >> m;
  int sum = 0;
  vector<int> a(m);
  for(int i = 0;i < m;i++){
    cin >> a[i];
    sum += a[i];
  }
  int yasumi = n - sum;
  if(yasumi >= 0) cout << yasumi << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 3668
/*
* @Author: 王文宇
* @Date:   2017-11-24 00:46:12
* @Last Modified by:   王文宇
* @Last Modified time: 2017-11-24 00:46:56
*/
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	cout<<m*2-n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int G[100][100],n,i,j,s,u,k;




  scanf("%d",&n);

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      G[i][j] = 0;

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    if(k!=0)for(j=0;j<k;j++){
	scanf("%d",&s);
	G[u-1][s-1] = 1;
      }
  }

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

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

int main() {
	int x, y;
	for(int i = 0; i < 3000; ++i) {
		cin >> x >> y;
		if((x == 0) && (y == 0)) {
			break;
		}
		bool isValid = true;
		isValid &= (0 <= x) && (x <= 10000);
		isValid &= (0 <= y) && (y <= 10000);
		if(isValid) {
			if(x > y) {
				int tmp = x;
				x = y;
				y = tmp;
			}
			cout << x << " " << y << endl;
		}
	}
}

Measured memory_bytes: 3104
import sys
input = sys.stdin.readline

'''

'''
def solve(n, arr):
    count = 0
    for i, ai in enumerate(arr, start=1):
        if i % 2 == 1 and ai % 2 == 1:
            count += 1
    return count

n = int(input())
arr = list(map(int, input().split()))
print(solve(n, arr))

Measured memory_bytes: 61872
import heapq
n = int(input())
v = list(map(int, input().split()))
heapq.heapify(v)
for i in range(n-1):
    v1 = heapq.heappop(v)
    v2 = heapq.heappop(v)
    heapq.heappush(v, (v1+v2)/2)
print(v[0])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[][] num = new int[4][2];
		while (scanner.hasNext()) {
			double a = scanner.nextDouble();
			double b = scanner.nextDouble();
			slove(a, 0, num);
			slove(b, 1, num);
		}
		for (int[] b : num) {
			System.out.println(b[0] + " " + b[1]);
		}
	}

	private static void slove(double a, int n, int[][] num) {
		if (a >= 1.1)
			num[0][n]++;
		else if (a >= 0.6)
			num[1][n]++;
		else if (a >= 0.2)
			num[2][n]++;
		else
			num[3][n]++;
	}
}

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

bool getResult(int redNum, int greenNum, int blueNum, int count){
  if(count == 0) return ((redNum < greenNum) && (greenNum < blueNum));

  bool result;
  result = getResult(redNum * 2, greenNum, blueNum, count - 1);
  if(result) return result;

  result = getResult(redNum, greenNum * 2, blueNum, count - 1);
  if(result) return result;
  
  result = getResult(redNum, greenNum, blueNum * 2, count - 1);
  return result;
}

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  string result = getResult(A, B, C, K)? "Yes" : "No";  
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int main(int argc, char* argv[]){
    int A, B, C, K, mx = 0, sum = 0;
    int num[3] = {};
    rep(i, 3){
        cin >> num[i];
        mx = std::max(mx, num[i]);
        sum += num[i];
    }
    cin >> K;
    sum -= mx;
    rep(i, K){
        mx *= 2;
    }
    sum += mx;
    cout << sum << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	int N;
	cin >> N;

	int ans = 0;
	int cur = 0;
	for (int i = 1; i <= N; i++)
	{
		cur += i;
	}
	ans += cur;
	for (int i = N; i >= 1; i--)
	{
		cur -= i;
		ans += cur;
	}

	for (int i = 0; i < N - 1; i++)
	{
		int u, v;
		cin >> u >> v;

		int ma = max(u, v);
		int mi = min(u, v);
		int l = mi * ((N - ma) + 1);

		ans -= l;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3168
N = int(input())
S = str(N)
m = len(S)
K = int(input())

#dp[i][j][k]: 上からi桁目までに0以外がj個あって、Nと一致しているならばk=0
dp = [[[0] * 2 for _ in range(4)] for _ in range(m+1)]
dp[0][0][0] = 1

for i in range(m): #i=0は架空の桁に相当。
  for j in range(4):
    for k in range(2):
      #dp[i][j][k]という状態が次の桁でどこに遷移するかを考える。遷移先のni,nj,nkを決定する。
      nd = int(S[i]) #Nのi桁目。1桁目はS[0]。
      for d in range(10): #dというのが今の桁(i+1)の値
        ni = i+1 #今の桁
        nj = j
        nk = k
        if d != 0: #もし今の桁が0でなければjは一つ増える。
          nj += 1
        if nj > K: #もしnjが許容値のKを超えたら無視。
          continue
        if k == 0: #ここまで完全一致の時
          if d > nd: #今の桁がNのi桁目より大きいつまりNを超えているので無視。
            continue
          elif d < nd: #今の桁がNのi桁目より小さいなら完全一致ではないのでnk=1と変更。
            nk = 1
        dp[ni][nj][nk] += dp[i][j][k]

ans = dp[m][K][0] + dp[m][K][1]
print(ans)

Measured memory_bytes: 41072
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int, int> AB;
typedef pair<int, int> BA;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int a, b;
  AB ab[n];
  for(int i = 0; i < n; i++) {
    cin >> a >> b;
    ab[i] = AB(a, b);
  }
  sort(ab, ab + n);
  BA ba[n];
  for(int i = 0; i < n; i++) {
    ba[i] = BA(ab[i].second, ab[i].first);
  }

  priority_queue<BA> que;

  int current_index = 0;
  int sum = 0;
  for(int i = 1; i <= m; i++) {
    while(current_index < n && ba[current_index].second <= i) {
      que.push(ba[current_index]);
      current_index++;
    }
    if(que.empty()) continue;
    sum += que.top().first;
    que.pop();
  }
  cout << sum << "\n";

  return 0;
}

Measured memory_bytes: 2936
#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;
    int count=0;
    int flag1 = true;
    int flag2 = true;
    int flag3 = true;
    int prea = 0;
    rep(i,N){
        int A;
        cin >> A;
        if(flag1){
            flag1 = false;
            count++;
            prea = A;
            continue;
        }
        if(flag2){
            if(prea < A){
                flag2 = false;
                flag3 = true;
            }else if(prea > A){
                flag2 = false;
                flag3 = false;
            }
            prea = A;
        }else{
            if(flag3){
                if(prea > A){
                    flag2 = true;
                    count++;
                }
            }else{
                if(prea < A){
                    flag2 = true;
                    count++;
                }
            }
            prea = A;
        }
    }

    cout << count << endl;


    return 0;
} 

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	int N, M;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		int[] s = new int[M];
		int[] c = new int[M];
		for (int i = 0; i < M; i++) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		int i = 0;
	lp:
		for (; i < 1000; i++) {
			String n = String.valueOf(i);
			if (n.length() != N) continue;
			for (int j = 0; j < M; j++) {
				if ( (n.charAt(s[j]-1) - '0') != c[j]) continue lp;
			}
			break;
		}
		if (i == 1000) System.out.println(-1);
		else System.out.println(i);
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;
constexpr int MAX_PRIME = 100003;

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

    int x;
    cin >> x;

    vector<bool> is_prime(MAX_PRIME + 1, true);
    for (int i = 2; i <= MAX_PRIME; ++i) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= MAX_PRIME; j += i) { is_prime[j] = false; }
        }
        if (x <= i && is_prime[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    string S;
    cin >> S;
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}



Measured memory_bytes: 3592
#include<stdio.h>
int n;
char s[110];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	int x=0,max=0;
	for (int i=0;i<n;i++){
		if (s[i]=='D') x--;
		else x++;
		if (x>max) max=x;
	}
	printf("%d\n",max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

struct mint {
    long long x;
    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 modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll sum = accumulate(all(A), 0LL);
    mint ans = 0;
    rep(i,N){
        ans += mint(A[i]) * mint(sum - A[i]);
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

ll mpow(ll base,ll exp);
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);
ll modInverse(ll n);
ll nCr(ll n, ll r);
ll myxor(ll a,ll b);

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

void solve(){
    string s;
    cin >> s;
    ll cur=0;
    ll n=s.size();
    loop(i,0,n){
        cur+=s[i]-'0';
        cur%=9;
    }

    if(cur==0) cout << "Yes";
    else cout << "No";
    cout << endl;

}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

ll myxor(ll a,ll b){
    return (a|b)&(~a|~b);
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 2e5+100;
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK";
			return 0;
		}
	} 
	cout<<"NG";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  uni(s);
  cout << sz(s) << endl;

  return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(100000)

mod = 1000000007
 
N, M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)] + [N + 1]
 
for i in range(len(A) - 1):
    if A[i] + 1 == A[i + 1]:
        print(0)
        quit()
 
memo = {0: 1, 1: 1, 2: 2, 3: 3}
 
def fib(n):
    if n not in memo:
        memo[n] = fib(n - 1) + fib(n - 2)
    return memo[n]
 
ans = 1
pre = -1
lo = 0
for a in A:
    f = fib(a - 1 - lo)
    ans = (ans * f) % mod
 
    lo = a + 1
    pre = a
 
print(ans)

Measured memory_bytes: 544360
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int MAXN = 200;

int a[MAXN];

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

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

	int sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += a[i];
	}

	int av = sum / n;
    int res = inf;
	for (int x = av - 2; x < av + 3; ++x) {
		int sc = 0;
		for (int i = 0; i < n; ++i) {
			sc += sqr(a[i] - x);
		}
		res = min(res, sc);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,m;
pair<ll,ll> a[100010];
ll ans;
int main()
{
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>a[i].first>>a[i].second;
  sort(a+1,a+n+1);
  for(int i=1;i<=n;i++)
  {
    ll q=min(1ll*m,a[i].second);
    ans+=(a[i].first*q);
    m-=q;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string S[1005];
ll A[1005][1005];
bool U[1005][1005];

ll H, W;
ll x[4] = {0, 1, 0, -1};
ll y[4] = {1, 0, -1, 0};

vector<pll> dfs(pll s) {
    queue<pll> q;
    q.push(s);
    vector<pll> ret;
    U[s.first][s.second] = true;
    while (!q.empty()) {
        pll t = q.front();
        ret.push_back(t);
        q.pop();
        REP(i, 4) {
            ll nx = t.first + x[i], ny = t.second + y[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W)
                continue;
            if (S[nx][ny] == '#')
                continue;
            if (U[nx][ny])
                continue;
            U[nx][ny] = true;
            q.push(pll(nx, ny));
        }
    }

    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    pll s, g;
    cin >> s.first >> s.second >> g.first >> g.second;
    s.first--;
    s.second--;
    g.first--;
    g.second--;

    memset(U, 0, sizeof(U));
    REP(i, H) {
        REP(j, W) {
            A[i][j] = INF;
        }
    }
    A[s.first][s.second] = 0;
    REP(i, H) {
        cin >> S[i];
    }

    queue<pll> q;
    q.push(s);
    while (!q.empty()) {
        pll t = q.front();
        q.pop();
        ll cost = A[t.first][t.second];
        if (U[t.first][t.second])
            continue;

        vector<pll> v = dfs(t);
        for (auto &p: v) {
            A[p.first][p.second] = std::min(cost, A[p.first][p.second]);
        }
        for (auto &p: v) {
            for (ll h = -2; h <= 2; ++h) {
                for (ll w = -2; w <= 2; ++w) {
                    ll nx = h + p.first, ny = w + p.second;
                    if (nx < 0 || nx >= H || ny < 0 || ny >= W)
                        continue;
                    if (S[nx][ny] == '#')
                        continue;
                    if (U[nx][ny])
                        continue;
                    if (A[nx][ny] <= cost + 1)
                        continue;
                    A[nx][ny] = std::min(cost + 1, A[nx][ny]);
                    q.push(pll(nx, ny));
                }
            }
        }
    }

    if (A[g.first][g.second] == INF)
        cout << -1 << endl;
    else
        cout << A[g.first][g.second] <<
             endl;
    return 0;
}

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

int main(){
  int n, w;
  cin >> n;
  w = 0;
  for(int i = 0; i < n; i++){
    int l, r;
    cin >> l >> r;
    w += (r - l + 1);
  }
  cout << w << endl;
}
      
    


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

const int N = 200005;

int n,dp[N],best[ 1 << 26];
string s;

int main(void){
    cin >> s;
    n = s.size();
    
    for(int i = 0; i < 1 << 26; i++){
        best[i] = 1e9;
    }
    best[0] = 0;
    int mask = 0;
    
    for(int i = 0; i < n; i++){
        mask ^= 1 << s[i] - 'a';
        
        dp[i] = best[mask] + 1;
        for(int j = 0; j < 26; j++){
            dp[i] = min(dp[i],best[mask ^ 1 << j] + 1);
        }
        
        best[mask] = min(best[mask],dp[i]);
    }
    /*
    for(int i = 0; i < n; i++){
        cout << dp[i] << " ";
    }
    cout << endl;
    */
    cout << dp[n-1] << endl;
    
    
}


Measured memory_bytes: 263556
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,f=0;
  cin >> N;
  for(int i=0;i<100;i++)
    for(int j=0;j<100;j++){
      if(i*4+j*7 == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  cout << "No" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int asum = 0;
  rep(i, n){
    cin >> a[i];
    asum += a[i];
  }
  int border = (asum - 1) / (4*m);
  sort(a.begin(), a.end(), greater<int>());
  if(a[m-1] > border) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    int p[n], a;
    for (int i = 0; i < n; ++i) p[i] = 0;
    for (int i = 0; i < q; ++i) {
        cin >> a;
        ++p[a-1];
    }
    for (int i = 0; i < n; ++i) {
        if (k - q + p[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
int N, K;

int main() {
    crap;
    cin >> N >> K;
    vi dp(N+1, INT_MAX);
    vi h(N+1);
    
    forin(i,1,N+1) cin >> h[i];
    dp[1] = 0;

    forin(i, 1, N+1) {
        forin(k, 1, K+1) {
            if(i+k<=N) 
                dp[i+k] = min(dp[i+k], dp[i]+abs(h[i]-h[i+k]));
        }
    }
    cout << dp[N] << endl;

}

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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
#define x first
#define y second
#define point pair<int,int>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
ll pow_(ll b, ll p){
    if(p == 0) return 1;

    if(p&1) return b * pow_(b*b, p/2);
    else return pow_(b*b, p/2);
}

ll co[1000000];
ll values[1000000];

ll evaluate(int val, int n){
    ll res=0;
    loop(i, n){
        res += co[i] * pow_(val, n-i-1);
    }

    return res;
}

int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    //cin.tie(0);
    //cin.sync_with_stdio(0);

    int n, k; cin>>k>>n;
    vector<int>  a (n);

    loop(i, n) cin>>a[i];
    sort(a.begin(), a.end());

    int mx= k - (a[n-1] - a[0]) ;

    loop1(i, n - 1){
        mx = max(mx, abs(a[i] - a[i-1]));
    }

    cout<<k - mx;
}



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

int main() {
  int n;
  double t, a;
  cin >> n >> t >> a;
  double h;
  double tm = 10000000;
  int res;
  double s;
  for (int i = 1; i <= n; i++) {
    cin >> h;
    s = abs(t - h * 0.006 - a);
    if (s <= tm) {
      tm = s;
      res = i;
    }
  }
  cout << res << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for (int i=1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }
  cout << sum << endl;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int x = 0;
  for (int i = 1; ; i++) {
    x += i;
    if (x >= X) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[][100],int b[][100],int p,int q,int r,int n){
  int mn=-1;
  if(a[p][q]==1)
    for(;q+1<n&&a[p][q+1]==1;q++);
  else if(a[p][q]==2){
    for(;q>-1&&a[p][q]==2;q--);
    if(q==-1)
      return -1;
  }
  if(q>=n-1)
    return r;
  if(b[p][q]==-1||b[p][q]>r){
    int tmp;
    b[p][q]=r;
    if((tmp=f(a,b,(p+1)%2,q,r+1,n))!=-1){
      if(mn==-1||mn>tmp)
	mn=tmp;
    }
    if((tmp=f(a,b,(p+1)%2,q+1,r+1,n))!=-1){
      if(mn==-1||mn>tmp)
	mn=tmp;
    }
    if((tmp=f(a,b,(p+1)%2,q+2,r+1,n))!=-1){
      if(mn==-1||mn>tmp)
	mn=tmp;
    }
  }
  return mn;
}
int main(){
  int i,j;
  int a[2][100],b[2][100],n;
  int mn,tmp;
  while(cin>>n&&n){
    for(i=0;i<2;i++)
      for(j=0;j<n;j++)
	cin>>a[i][j];
    memset(b,-1,sizeof(b));
    mn=-1;
    if((tmp=f(a,b,0,0,0,n))!=-1){
      if(mn==-1||mn>tmp)
	mn=tmp;
    }
    if((tmp=f(a,b,1,0,0,n))!=-1){
      if(mn==-1||mn>tmp)
	mn=tmp;
    }
    if(mn==-1)
      cout<<"NA"<<endl;
    else
      cout<<mn<<endl;
  }
  return 0;
}

Measured memory_bytes: 0