akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

struct Tower {
  int id;
  vector<Tower *> connections;
  int height = {0};

  Tower(int id, int height) : id(id), height(height) {
    id = id;
    height = height;
  }
};

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

  // 展望台の初期化
  map<int, Tower *> tower_map;
  for (auto i = 0; i < N; i++) {
    int id = i + 1;
    int height;
    cin >> height;
    tower_map[id] = new Tower(id, height);
  }
  for (auto i = 0; i < M; i++) {
    int a_i, b_i;
    cin >> a_i;
    cin >> b_i;

    Tower *a, *b;
    a = tower_map[a_i];
    b = tower_map[b_i];
    a->connections.push_back(b);
    b->connections.push_back(a);
  }

  int ans(0);
  for (const auto &tower : tower_map) {
    int max_height = 0;
    for (const auto &connections : tower.second->connections) {
      max_height = std::max(connections->height, max_height);
    }

    int height = tower.second->height;
    if (height > max_height) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 18080
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;

    int arr[n];
    for (int i = 0; i < n; i++)cin >> arr[i];
    int ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                ret += (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[j] + arr[k] > arr[i] && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[k]!=arr[i]) ;
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt n,k;
	std::cin >> n >> k;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	lnt g=a[0];
	rep(i,n) g=std::gcd(g,a[i]);
	if(k%g==0 && k<=*std::max_element(all(a))) print("POSSIBLE");
	else print("IMPOSSIBLE");
}


Measured memory_bytes: 3972
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

N = int(input())

print(L[N-1])

Measured memory_bytes: 3060
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


MOD = 10 ** 9 + 7
BASE = 29


def has_dup(V, sz):
    N = len(V)

    h = 0
    p = 1
    for i in range(sz):
        h *= BASE
        h += V[i]
        h %= MOD

        p *= BASE
        p %= MOD

    h2i = {h: [0]}
    for i in range(sz, N):
        j = i - sz + 1
        h *= BASE
        h += V[i]
        h += MOD - ((p * V[i - sz]) % MOD)
        h %= MOD
        if h not in h2i:
            h2i[h] = []
        h2i[h].append(j)

    for a in h2i.values():
        alen = len(a)
        for i in range(alen):
            ii = a[i]
            for j in range(i + 1, alen):
                ji = a[j]
                if ji - ii < sz:
                    continue
                if V[ii:ii + sz] == V[ji:ji + sz]:
                    return True

    return False


def solve(N, S):
    if N <= 26:
        has_ans = False
        for v in range(ord('a'), ord('z') + 1):
            ch = chr(v)
            if S.count(ch) >= 2:
                has_ans = True
                break
        if not has_ans:
            return 0

    V = [ord(c) - ord('a') for c in S]

    lb = 1
    ub = N // 2 + 1
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if has_dup(V, mid):
            lb = mid
        else:
            ub = mid

    return lb


def main():
    N = int(inp())
    S = inp()
    print(solve(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 43504
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

food = []

for _ in range(5):
    food.append(inint())

all = sum(food)
loss = []

for f in food:
    loss_t = 200
    for i in range(0,131, 10):
        if 0 <= i-f < loss_t:
            loss_t = abs(f-i)
    loss.append(loss_t)

print(all+sum(loss)-max(loss))

Measured memory_bytes: 61832
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	
   	char c;
   	cin >> c;
   	cout << (c >= 'a' && c <= 'z' ? "a" : "A");
}

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

using pii = pair<int, int>;

constexpr int INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    vector<int> C(N), R(N);
    for(int i = 0; i < N; ++i) {
        cin >> C[i] >> R[i];
    }
    for(int i = 0; i < M; ++i) {
        int s, t;
        cin >> s >> t;
        g[s - 1].push_back(t - 1);
        g[t - 1].push_back(s - 1);
    }
    vector<int> d(N, INF);
    d[0] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.emplace(0, 0);
    while(!que.empty()) {
        int c, v;
        tie(c, v) = que.top();
        que.pop();
        if(c > d[v]) {
            continue;
        }
        c += C[v];
        vector<bool> visited(N);
        queue<pii> que2;
        que2.emplace(v, R[v]);
        visited[v] = true;
        while(!que2.empty()) {
            int vv = que2.front().first;
            int r = que2.front().second;
            que2.pop();
            for(auto to : g[vv]) {
                if(visited[to]) {
                    continue;
                }
                visited[to] = true;
                if(r - 1 > 0) {
                    que2.emplace(to, r - 1);
                }
                if(d[to] > c) {
                    d[to] = c;
                    que.emplace(c, to);
                }
            }
        }
    }
    cout << d.back() << endl;
}



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

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


Measured memory_bytes: 256
x, y, z = map(int, input().split())


def swap(t1, t2):
    return t2, t1


if x > z:
    x, z = swap(x, z)
if x > y:
    x, y = swap(x, y)
if y > z:
    y, z = swap(y, z)
print(x, y, z)




Measured memory_bytes: 5600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> in(m);
	for (int i = 0; i < m; i++) {
		cin >> in[i];
	}
	sort(in.begin(), in.end());
	vector<long long> dif(m - 1);
	for (int i = 0; i < m - 1; i++) {
		dif[i] = abs(in[i + 1] - in[i]);
	}
	sort(dif.begin(), dif.end());
	long long ans = 0;
	for (int i = 0; i < m - n; i++) {
		ans += dif[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int x,y;
    cin >> x >> y;
    int ans = 0;
    int mon[3] = {300000,200000,100000};
    if(x == 1 && y == 1) ans += 400000;
    if(x < 4) ans += mon[x-1];
    if(y < 4) ans += mon[y-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll n;
//ld ;
string s, t;
 
int main() {
  cin >> n;
  cin >> s >> t;
  for(ll i=0; i<n; i++){
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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



int main(){fastio
    ll n,m;cin>>n>>m;
    ll a[n];rep(i,0,n-1)a[i]=-1;
    while(m--){
        ll s,x;cin>>s>>x;
        s--;
        if(a[s]==-1){
            a[s]=x;
        }else{
            if(a[s]!=x){
                cout<<-1<<endl;return 0;
            }
        }
    }
    if(n==1){
        if(a[0]==-1)a[0]=0;
        cout<<a[0]<<endl;
        return 0;
    }
    rep(i,0,n-1){
        if(i==0){
            if(a[i]==0){
                cout<<-1<<endl;return 0;
            }
            if(a[i]==-1)a[i]=1;
        }else{
            if(a[i]==-1)a[i]=0;
        }
    }
    rep(i,0,n-1)cout<<a[i];
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int mid_exam,final_exam,re_exam;
        while(true){
            mid_exam=sc.nextInt();
            final_exam=sc.nextInt();
            re_exam=sc.nextInt();
            if(mid_exam==-1 && final_exam==-1 && re_exam == -1) break;
            if(mid_exam==-1 || final_exam ==-1){
                System.out.println("F");
            }
            else if(mid_exam+final_exam>=80){
                 System.out.println("A");
            }
            else if(mid_exam+final_exam>=65){
                 System.out.println("B");
            }
            else if(mid_exam+final_exam>=50){
                 System.out.println("C");
            }
            else if(mid_exam+final_exam>=30 )
                 {
                   if(re_exam>=50) System.out.println("C");  
                  else System.out.println("D");
                 }
            else System.out.println("F");
        }
        
    }
}


Measured memory_bytes: 26156
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{	
		int N = Int32.Parse(Console.ReadLine());
		
		List<int> option = new List<int>();

		option.Add(1);

		for(int i = 1; ; i++)
		{
			if(Math.Pow(6,i) > N)
				break;
			option.Add((int)Math.Pow(6,i));
		}

		for(int i = 1; ; i++)
		{
			if(Math.Pow(9,i) > N)
				break;
			option.Add((int)Math.Pow(9,i));
		}

		option.Sort();
		
		int[] dp = new int[N+1];  // dp[0] = 0;
		for(int i = 1; i <= N; i++)
		{
			int tmp = Int32.MaxValue;
			for(int j = 0; j < option.Count; j++)
			{
				if(option[j] > i)
					break;
				tmp = Math.Min(tmp, dp[i - option[j]]);
			}
			dp[i] = tmp + 1;
		}

		Console.WriteLine(dp[N]); 
	}	
}





Measured memory_bytes: 11360
import fractions
import functools
n = int(input())
*a, = map(int, input().split())

left = [0]*(n+1)
for i in range(n):
    left[i+1] = fractions.gcd(left[i], a[i])
right = [0]*(n+1)
for i in range(n-1, -1, -1):
    right[i] = fractions.gcd(right[i+1], a[i])

ans = 0
for i in range(n):
    ans = max(fractions.gcd(left[i], right[i+1]), ans)

print(ans)


Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll N,K;
    cin >> N >> K;
    N %= K;
    while (N > abs(N-K)) {
      N = abs(N-K);
    }
    cout << N << endl;
  }
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	vector<int> CNT(100010, 0);
	int A;
	int sum = 0;
	rep(i, 0, N)
	{
		cin >> A;
		CNT[A]++;
		sum += A;
	}

	int Q;
	cin >> Q;
	int C, D;
	rep(i, 0, Q)
	{
		cin >> C >> D;
		sum -= CNT[C] * C;
		sum += CNT[C] * D;
		CNT[D] += CNT[C];
		CNT[C] = 0;
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
pp = gets.split.map{|e| e = e.to_i; [e, e, true]}

class SegTree
    def update(k); @d[k] = @op.call(@d[2 * k], @d[2 * k + 1]); end

    def initialize(v, e, &op)
        @n = v.size
        @log = (@n - 1).bit_length
        @size = 1 << @log
        @op = op
        @d = Array.new(2 * @size, e)

        @n.times{|i| @d[@size + i] = v[i]}
        (@size - 1).downto(1) {|i| update(i)}
    end

    def set(pos, x)
        pos += @size
        @d[pos] = x
        1.upto(@log) {|i| update(pos >> i)}
    end

    def prod(l, r)
        sml = smr = @d[0]
        l += @size
        r += @size

        while l < r
            (sml = @op.call(sml, @d[l]); l += 1) if l[0] == 1
            (r -= 1; smr = @op.call(@d[r], smr)) if r[0] == 1
            l >>= 1
            r >>= 1
        end
        @op.call(sml, smr)
    end
end

st = SegTree.new(pp, -1) do |c1, c2|
    if c1 == -1
        c2
    elsif c2 == -1
        c1
    elsif c1[2] && c2[2] && c1[1] < c2[0]
        [c1[0], c2[1], true]
    else
        [[c1[0], c2[0]].min, [c1[1], c2[1]].max, false]
    end
end

memo = Array.new(n - k + 1) {|i| st.prod(i, i+k)}

ans = 1
f = memo[0][2]
(n - k).times do |i|
    j = i + 1
    next if (memo[i][0] == pp[i][0] && memo[j][1] == pp[i+k][0]) || (f && memo[j][2])
    f |= memo[j][2]
    ans += 1
end
p ans

Measured memory_bytes: 61364
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a1 = Integer.parseInt(s.substring(0, 2));
        int a2 = Integer.parseInt(s.substring(2));
        if(a1 > 0 && a1 < 13 && a2 > 0 && a2 < 13) {
            System.out.println("AMBIGUOUS");
        } else if(a1 > 0 && a1 < 13) {
            System.out.println("MMYY");
        } else if(a2 > 0 && a2 < 13) {
            System.out.println("YYMM");
        } else {
            System.out.println("NA");
        }
    }
}

Measured memory_bytes: 35540
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int [] ab = {sc.nextInt(),sc.nextInt()};
        Arrays.sort(ab);
        int ans = ab[1]-(ab[0]+W);
        if(ans<0)ans=0;
        System.out.println(ans);
    }
}


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

int x[400000];
ll dat[2][1600000],N;

ll query(int id,int a,int b,int k,int l,int r){
	if(b<=l||r<=a)return INF;
	if(a<=l&&r<=b)return dat[id][k];
	return min(query(id,a,b,k*2+1,l,(l+r)/2),query(id,a,b,k*2+2,(l+r)/2,r));
}
void update(int id,int k,ll x){
	k+=N-1;
	dat[id][k]=x;
	while(k){
		k=(k-1)/2;
		dat[id][k]=min(dat[id][k*2+1],dat[id][k*2+2]);
	}
}
int main(){
	int n,q,a,b;scanf("%d%d%d%d",&n,&q,&a,&b);
	N=1;while(N<n+1)N<<=1;
	rep(j,2)rep(i,2*N-1)dat[j][i]=INF;
	x[0]=a;
	rep(i,q)scanf("%d",&x[i+1]);
	update(0,b,n-b);update(1,b,b);
	ll sum=0;
	for(int i=1;i<=q;i++){
		int diff=abs(x[i]-x[i-1]);
		sum+=diff;
		ll Min=min(query(0,0,x[i],0,0,N)-(n-x[i]),query(1,x[i],n+1,0,0,N)-x[i]);
		update(0,x[i-1],Min-diff+n-x[i-1]);
		update(1,x[i-1],Min-diff+x[i-1]);
	}
	ll Min=INF;
	rep(i,n+1)Min=min(Min,query(0,i,i+1,0,0,N)-(n-i));
	cout<<Min+sum<<endl;
}

Measured memory_bytes: 13312
n = int(input())
a = list(map(int, input().split()))
b = []
i = n-1
while i >=1:
  b.append(a[i])
  i = i-2
b.append(a[0])
if n%2==0:
  j=2
else:
  j =1
while j <= n-2:
  b.append(a[j])
  j = j+2
for nums in b:
  print(nums, end = ' ')

Measured memory_bytes: 26020
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
    ll n,X;
    cin >> n >> X;
    vector<ll>x(n);
    vector<ll>dist(n);
    REP(i,n){
        cin >> x[i];
    }
    x.push_back(X);
    sort(x.begin(),x.end());
    REP(i,n){
        dist[i] = x[i+1]-x[i];
    }
    ll answer = gcd(dist[0],dist[1]);
    FOR(i,2,n){
        answer = gcd(answer,dist[i]);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 2560
a,b,k=map(int,input().split())
list=set()
for i in range(k):
    if a+i<=b:
        list.add(a+i)
for i in range(k):
    if b-k+i+1>=a:
        list.add(b-k+i+1)
l=sorted(list)
for x in l:
    print(x)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());

        var ans = 0;

        for (int i = 1; i <= N; i++)
        {
            var digit = (int)(Math.Log10(i) + 1);
            if (digit % 2 == 1)
                ans++;
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 27656
#include <iostream>
#include <utility>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

//集合を表すデータ構造、根は大きさを負で持ち、子は根を正で持つ
//[0]に全体の集合の数を入れる
//swapを使用するため<utility>をインクルードする
struct UnionFind{
    vector<int>data;
    UnionFind(int size) :   data(size+1, -1){
        data[0] = size;
    }

    //集合のmerge
    //すでに同じならfalse
    bool merge(int x, int y){
        x = root(x);    y = root(y);
        if(x == y)  return false;
        //要素数の少ない方を多い方に繋げる
        if(data[y] < data[x])   swap(x, y);
        data[x] += data[y];
        data[y] = x;
        data[0]--;
        return true;
    }

    //どの集合に属しているか
    int root(int x){
        //根に繋ぎ直す
        return (data[x] < 0) ? x : (data[x] = root(data[x]));
    }

    //ある要素が属する集合の大きさ
    int size(int x){
        return -data[root(x)];
    }

    //集合の数
    int set(){
        return data[0];
    }
};

int main(){
    int n,m;    cin >> n >> m;
    UnionFind UF(n);
    rep(i, m){
        int x,y,z;  cin >> x >> y >> z;
        UF.merge(x, y);
    }
    cout << UF.set() << endl;
}


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

using Int = long long int;
using UInt = unsigned long long int;


int main(void) {
    int x, a, b;
    cin >> x >> a >> b;
    int da = abs(x - a);
    int db = abs(x - b);
    if (da < db) {
        cout << 'A' << endl;
    } else {
        cout << 'B' << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
n = int(input())
h = [int(i) for i in input().split()]
    
# 無限大の値
f_inf = float('inf')
# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)
# 初期条件
dp[0] = 0
# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i-1]))
    # 一番目の足場では一つ前しか存在しない
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i -2]))
print(dp[n-1])

Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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

int main(){
    int H, W, sx, sy, N;
    cin >> H >> W >> N;
    cin >> sy >> sx;
    string s, t;
    cin >> s;
    cin >> t;
    sy--;
    sx--;
    int sx_tmp = sx;
    int sy_tmp = sy;

    for(int i = 0; i < N; i++){
        if(s[i] == 'U'){
            sy--;
        }
        if(sy < 0){
            cout << "NO" << endl;
            return 0;
        }
        else if(t[i] == 'D' && sy < H-1){
            sy++;
        }
    }
    sx = sx_tmp;
    sy = sy_tmp;
    for(int i = 0; i < N; i++){
        if(s[i] == 'D'){
            sy++;
        }
        if(sy >= H){
            cout << "NO" << endl;
            return 0;
        }
        else if(t[i] == 'U' && sy > 0){
            sy--;
        }
    }
    sx = sx_tmp;
    sy = sy_tmp;

    for(int i = 0; i < N; i++){
        if(s[i] == 'L'){
            sx--;
        }
        if(sx < 0){
            cout << "NO" << endl;
            return 0;
        }
        else if(t[i] == 'R' && sx < W-1){
            sx++;
        }
    }
    sx = sx_tmp;
    sy = sy_tmp;

    for(int i = 0; i < N; i++){
        if(s[i] == 'R'){
            sx++;
        }
        if(sx >= W){
            cout << "NO" << endl;
            return 0;
        }
        else if(t[i] == 'L' && sx > 0){
            sx--;
        }
    }

    cout << "YES" << endl;


    return 0;
}


Measured memory_bytes: 776
long a,b,c;o;
main(A){
	b=c=-1e18;
	for(scanf("%*d%ld",&a);~scanf(" %c%d",&o,&A);)
		b=o%3?a+=A,fmax(b-A,c+=A):(a=fmax(a-A,c=b+A));
	printf("%ld",a);
}

Measured memory_bytes: 128
K, N = map(int, input().split())
A = list(map(int, input().split()))

M = 0
for i in range(N):
    if M <= A[i] - A[i-1] :
        M = A[i] - A[i-1]
    elif M <= K - A[N-1] + A[0]:
        M = K - A[N-1] + A[0]
ans = K - M
print(ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

ld euclideanDist(vector<ld>& a, vector<ld>& b) {
  assert(a.size() == b.size());
  ld sum = 0;
  forx(i, a.size()) {
    ld temp = a[i] - b[i];
    sum += temp*temp;
  }
  return sqrt(sum);
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n, d;
  cin >> n >> d;
  vector<vector<ld>> points(n, vector<ld>(d));
  forx(i,n) forx(j,d) {
    cin >> points[i][j];
  }
  int cnt = 0;
  forx(i,n) {
    forx(j,i) {
      ld dist = euclideanDist(points[i], points[j]);
      if (dist == round(dist)) ++cnt;
    }
  }
  cout << cnt << nl;
  
  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}



Measured memory_bytes: 256
N = int(input())

W = [int(s) for s in input().split()]


t = 0
diff_min = float('inf')
for i in range(N):
    big = W[i:]
    sma = W[:i]
    if diff_min > abs(sum(big)-sum(sma)):
        diff_min = abs(sum(big) - sum(sma))
print(diff_min)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(1e3)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;

int main() {
	int n, r;
	cin >> n >> r;
	cout << (n < 10 ? r+(1000-100*n) : r) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll gcd( ll a, ll b )
{
    ll temp;

    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;

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

void solve(){

    ll p,q;
    cin >> p >> q;
    cout << p*q/(gcd(p,q)) << endl;

}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin >>n;
  
  vector<long int> a(n);
  long int ans;
  cin >>a.at(0);
  ans=a.at(0);
  for(int i=1;i<n;++i)
  {
  cin >> a.at(i); 
  ans=gcd(ans,a.at(i));
  }
  cout << ans;
return 0;
}

Measured memory_bytes: 4056
package main

import "fmt"

func main() {
	var A, B, C, X, Y int
	fmt.Scan(&A, &B, &C, &X, &Y)
	abMax := Max(X, Y)
	ans := 1 << 62
	for ab := 0; ab <= abMax; ab++ {
		v := A*Max(0, X-ab) + B*Max(0, Y-ab) + 2*C*ab
		ans = Min(ans, v)
	}
	fmt.Println(ans)
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 1772
#include<iostream>
#include<algorithm>
using namespace std;
int main () {
    int N,count=0;
    cin>>N;
    int a[2*N];
    for(int i=0;i<2*N;i++){
        cin>>a[i];
    }
    sort(a,a+2*N);
    for(int i=0;i<2*N;i=i+2){
        count+=a[i];
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, M;
  cin >> N;
  vector<int> a(N);
  rep(i,0,N) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  M=a[N-1];
  vector<int> b(M+3);
  rep(i,0,M+3) {
    b[i]=0;
  }
  rep(i,0,N) {
    b[a[i]]++;
    b[a[i]+1]++;
    b[a[i]+2]++;
  }
  sort(b.begin(),b.end());
  cout << b[M+2] << endl;
}

Measured memory_bytes: 3972
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する(一部改変).
// tourist氏
// https://atcoder.jp/contests/agc035/submissions/6377009
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(58);

int main(){

    int N;
    scanf("%d", &N);
    // __builtin_popcount関数: 整数N を 2進数表記した場合の, 1 の個数.
    if(__builtin_popcount(N) == 1){
        printf("%s\n", "No");
        return 0;
    }
    
    printf("%s\n", "Yes");
    vector<int> all(N);
    // 指定された値から始まる整数列を生成.
    // https://cpprefjp.github.io/reference/numeric/iota.html
    iota(all.begin(), all.end(), 1);
    int v = 0;
    for(int x : all) v ^= x;
    if(v == 0){
        for(int i = 1; i < 2 * N; i++) printf("%d %d\n", i, i + 1);
        return 0;
    }

    if(v <= N){
        all.erase(all.begin() + v - 1);
        while(true){
            shuffle(all.begin(), all.end(), rng);
            vector<int> pref(1, 0);
            for(int rot = 0; rot < 2; rot++){
                for(int i = 0; i < N - 1; i++){
                    pref.push_back(pref.back() ^ all[i]);
                }
            }
            map<int, int> mp;
            int from = -1, to = -1;
            for(int it = 0; it < (int)pref.size(); it++){
                int x = pref[it];
                if(mp.find(x ^ v) != mp.end()){
                    from = mp[x ^ v];
                    to = it;
                    break;
                }
                mp[x] = it;
            }
            if(from != -1){
                vector<int> vers;
                for(int i = 0; i < N - 1; i++) vers.push_back(all[i]);
                for(int i = 0; i < N - 1; i++) vers.push_back(all[i] + N);
                for(int i = 0; i < 2 * N - 3; i++) printf("%d %d\n", vers[i], vers[i + 1]);
                printf("%d %d\n", vers[from], v);
                printf("%d %d\n", vers[to - 1], v + N);
                break;
            }
        }
        return 0;
    }
    assert(v == N + 1);
    vector<int> vers;
    for(int i = 2; i <= N - 1; i++) vers.push_back(i);
    swap(vers[vers.size() - 2], vers[vers.size() - 1]);
    for(int i = 2; i <= N - 1; i++) vers.push_back(i + N);
    swap(vers[vers.size() - 2], vers[vers.size() - 1]);
    for(int i = 0; i < (int) vers.size() - 1; i++) printf("%d %d\n", vers[i], vers[i + 1]);
    printf("%d %d\n", N - 1, 1);
    printf("%d %d\n", N - 2, N + 1);
    printf("%d %d\n", N - 2, N);
    printf("%d %d\n", N + 2, N + N);
    return 0;

}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

struct Comp{
  bool operator()(pll a,pll b) const
  {
    if(a.fi == b.fi) return a.se <= b.se;
    return a.fi < b.fi;
  }
};

vector<pll> v(3001);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    int x,y;
    multimap<int,int> m;
    rep(i,n){
      cin >> x >> y;
      v[i] = mp(x,y);
      m.insert(v[i]);
    }
    sort(begin(v),begin(v)+n);
    ll res = 0;
    rep(i,n){
      REP(j,i+1,n){
        int dx = v[j].fi - v[i].fi,dy = v[j].se - v[i].se;
        int CX = v[i].fi - dy,CY = v[i].se + dx;
        int DX = v[j].fi - dy,DY = v[j].se + dx;
        if(value(CX,CY,5001,5001) && value(DX,DY,5001,5001)){
          bool f1 = false,f2 = false;
          auto tmp = m.equal_range(CX);
          for(auto it = tmp.fi; it != tmp.se; ++it){
            if(it->se == CY){
              f1 = true;
              break;
            }
          }
          tmp = m.equal_range(DX);
          for(auto it = tmp.fi; it != tmp.se; ++it){
            if(it->se == DY){
              f2 = true;
              break;
            }
          }
          if(f1 && f2){
            ll dis = (dx * dx + dy * dy);
            res = max(res,dis) ;
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3336
#include "bits/stdc++.h"
using namespace std;
static const int MAX = 200000;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b)
		cout << "a > b" << endl;
	if (a == b)
		cout << "a == b" << endl;
	if (a < b)
		cout << "a < b" << endl;
	return 0;
}


Measured memory_bytes: 3100
;; B - Papers, Please

(defun divisible (x n) (zerop (mod x n)))
(defun approved (a)
  (every #'(lambda (x) (or (oddp x) (divisible x 3) (divisible x 5)))
         a))

(let* ((n (read))
       (a (loop repeat n collect (read))))
  (princ (if (approved a) "APPROVED" "DENIED")))


Measured memory_bytes: 16608
#include <stdio.h>

int main() {
	int n, m, l_, r_, x;

	scanf("%d%d", &n, &m);
	l_ = 1, r_ = n;
	while (m--) {
		int l, r;

		scanf("%d%d", &l, &r);
		if (l_ < l)
			l_ = l;
		if (r_ > r)
			r_ = r;
	}
	x = r_ - l_ + 1;
	printf("%d\n", x < 0 ? 0 : x);
	return 0;
}


Measured memory_bytes: 128
/*input
2
1 2
50 50
50
*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
// int dp[5003][5003];
#define maxl( X, Y) ((X) > (Y))? X : Y
// const int nax =100;
const int maxn = 1e5 +5;
#define debug(x) cout << #x << " " << x << "\n";

int exp(int a, int n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return (a * exp((a*a), n/2));
	else
		return exp((a*a), n/2);
}
const int nax =25;
int a[nax];
int c[nax];

signed main()
{
	int n;
	cin >> n;
	for ( int i =1 ; i <= n; i++)
		cin >> a[i];
	int sum =0;
	for ( int i=0; i < n; i++)
	{
		int x;
		cin >> x;
		sum+= x;
	}
	for ( int i =1; i <= n; i++)
		cin >> c[i];
	for ( int i =2; i <= n; i++)
	{
		if ( a[i] - a[i-1] == 1)
			sum+= c[a[i-1]];
	}
	cout << sum ;

}


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

int main ()
{
  int H,W,flag=1;
  while(1)
    {
      cin >> H >> W;
      if(H==0&&W==0)   break;
      for(int i=0;i<H;i++)
        {
          for(int j=0;j<W;j++)
            {
              if((i+j)%2==0)  cout << "#";
              else   cout << ".";
            }
          cout << endl;
        }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 3096
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ans := 0
	for i := 1; i <= N; i += 2 {
		if len(enumDiv(i)) == 7 {
			ans++
		}
	}
	fmt.Println(ans)
}

func enumDiv(x int) (ret []int) {
	ret = []int{}
	upperRet := []int{}
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			ret = append(ret, i)
			if i != 1 && i*i != x {
				upperRet = append(upperRet, x/i)
			}
		}
	}
	ret = append(ret, upperRet...)
	return
}


Measured memory_bytes: 512
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,w,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
   cin>>n>>s;
   m=0;
   p=0;
   q=0;
   rep(i,0,n){
       if(s[i]=='R'){
       m++;
       ans+=p*q;
       }
       else if(s[i]=='G'){
       p++;
       ans+=m*q;
       }
       else if(s[i]=='B'){
           q++;
           ans+=p*m;
       }
       
   }
  rep(i,0,n){
      rep(j,1,n){
          
          if(i+j*2>n-1)
          break;
          
          if(s[i]!=s[i+j]&&s[i]!=s[i+j+j]&&s[j+i]!=s[i+j+j])
          ans--;
      }
  }
   
   cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct P{
  int x,y;
};

int main(){
  int n,m;
  P p[101];

  cin >> n >> m;
  for(int i = 0 ; i < m ; i++)
    cin >> p[i].x >> p[i].y;
  
  bool flg = true;
  int d = 1,a = 0;

  for(int i = 0 ; i < m ; i++){
    int t = -1;
    
    for(int j = 0 ; j < m ; j++){
      if(p[j].x <= d){
	t = max(t,p[j].y);
      }
    }

    if(t == -1){
      flg = false;
      break;
    }
    
    a++;
    d = t+1;
    if(d > n) break;
  }

  if(d > n) cout << a << endl;
  else cout << "Impossible" << endl; 

  return 0;
}

Measured memory_bytes: 1160
#include <set>
#include <string>
#include <iostream>

using namespace std;

int const none_s = 0;
int const left_s = 1;
int const right_s = 2;

int main()
{
  set<char> const left = {
    'q', 'w', 'e', 'r', 't',
    'a', 's', 'd', 'f', 'g',
    'z', 'x', 'c', 'v', 'b'
  };

  set<char> const right = {
    'y', 'u', 'i', 'o', 'p',
    'h', 'j', 'k', 'l',
    'n', 'm'
  };

  string s;
  while( cin >> s ) {
    if ( s == "#" ) {
      break;
    }

    int status = none_s;
    int times = 0;
    for( const char c : s ) {
      if ( left.find( c ) != left.end() ) {
        if ( status == right_s ) { ++times; }
        status = left_s;

      } else if ( right.find( c ) != right.end() ) {
        if ( status == left_s ) { ++times; }
        status = right_s;
      }
    }
    cout << times << endl;
  }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int n;cin>>n;
	vector<int> v(n);
	rep(i,n){
		cin>>v[i];
	}
	double ans = 1;
	double tmp = 0; 
	rep(i,n){
		ans *= v[i];
		double tmp2 = 1;
		rep(j,n){
			if(i==j)continue;
			tmp2 *= v[j];
		}
		tmp += tmp2;
	}
	printf("%.12f\n",ans/tmp);
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char n,m,t,s[3]={'A','B','C'};
	int a,b,i;
	while(~scanf("%c,%c",&m,&n))
	{
		for(i=0;i<3;i++)
		{
			if(m==s[i]) a=i;
			if(n==s[i]) b=i;
		}
		t=s[a]; s[a]=s[b]; s[b]=t; 
	}
	printf("%c\n",s[0]);
	return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
int stoi(string a){
	return (a[0]-'0')*10+a[1]-'0';
}
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P> > que;
int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0) break;
		rep(i,n){
			string x,y;
			cin >> x >> y;
			int a=stoi(x.substr(0,2))*3600+stoi(x.substr(3,2))*60+stoi(x.substr(6,2));
			int b=stoi(y.substr(0,2))*3600+stoi(y.substr(3,2))*60+stoi(y.substr(6,2));
			que.push(P(b,0));
			que.push(P(a,1));
		}
		int now=0,ans=0;
		while(!que.empty()){
			P q=que.top();
			que.pop();
			if(q.second==0) now++;
			else{
				if(now>0) now--;
				else ans++;
			}
		}
		cout << ans << endl;
	}
}

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

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


Measured memory_bytes: 256
num=[int(i) for i in input().split()]
for i in range(len(num)):
    for j in range(i+1,len(num)):
        if num[i]>num[j]:
            bigger = num[i]
            num[i]=num[j]
            num[j]=bigger
for i in range(len(num)-1):
    print(num[i],end=" ")
print(num[len(num)-1])

Measured memory_bytes: 7792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>

using namespace std;

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

int H, W, M;
P pt[300000 + 10];
int cntX[300000 + 10], cntY[300000 + 10];
map<P, bool> exist;

int main() {
	cin >> H >> W >> M;
	for (int i = 0; i < M; i++) {
		cin >> pt[i].first >> pt[i].second;
		exist[pt[i]] = true;
		cntX[pt[i].first]++;
		cntY[pt[i].second]++;
	}

	vector<P> sortX, sortY;
	for (int i = 0; i <= 300000; i++) {
		sortX.push_back(make_pair(cntX[i], i));
		sortY.push_back(make_pair(cntY[i], i));
	}
	sort(sortX.begin(), sortX.end(), greater<P>());
	sort(sortY.begin(), sortY.end(), greater<P>());

	int ans = sortX[0].first + sortY[0].first - 1;
	vector<P> maxX, maxY;
	for (int i = 0; i <= 300000; i++) {
		if (sortX[0].first == sortX[i].first) {
			maxX.push_back(sortX[i]);
		}
		else break;
	}
	for (int i = 0; i <= 300000; i++) {
		if (sortY[0].first == sortY[i].first) {
			maxY.push_back(sortY[i]);
		}
		else break;
	}

	for (int i = 0; i < maxX.size(); i++) {
		for (int j = 0; j < maxY.size(); j++) {
			int tmp = maxX[i].first + maxY[j].first;
			if (exist[make_pair(maxX[i].second, maxY[j].second)]) tmp--;
			if(tmp > ans){
				ans = tmp;
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;++i){
		ll A;cin>>A;
		a[i]=A-i-1;
	} 
	sort(a.begin(),a.end());
	int b=a[n/2];
	ll ans=0;
	for(int i=0;i<n;++i){
		a[i]+=-1*b;
		ans+=abs(a[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>
#include <set> 
#include<algorithm>
#define ll long long int
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define out(n) printf("%lld\n",n)
#define inf 100000000000000
#define endl "\n"
#define precise(x) fixed << setprecision(x) 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
const int MOD =998244353;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}
 //ll power(ll x, ll y) 
//{ 
  //  ll temp; 
    //if( y == 0) 
     //   return 1; 
    //temp = power(x, y/2); 
    //temp=temp%MOD;
    //if (y%2 == 0) 
     //   return (temp%MOD)*(temp%MOD); 
    //else
      //  return (x%MOD)*(temp%MOD)*(temp%MOD); 
//} 
 
 
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
 //diamond[2000005],ans[1000006];
 const int maxn=2e5+100;
//vector<int>v[maxn];


int main()
{
	ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout.tie(0);
     ll t;
    //cin>>t;
   
    t=1;	
   while(t--)
    {
        ll n,i1,i2,k,m,j,j1,a1,i31,i3,j2,i5,i4,i6,i7,i;
        ll x,y,z;
        ll total=0,cnt=0;
        ll flag=0;
        y=0;
        ll res,res1,ans,res2,q;
        ans=0;
        res1=0,res=0;
        ll s1,s2,s3;
        s2=0;
        ll sum=0,flag1=0;
        s1=0;
        ll k1,k2,k3;
        ll d,h,c,required;
        cin>>n>>m;
        //cin>>h>>c>>required;
        cout<<n*m<<endl;
		
     }
    
}
	


Measured memory_bytes: 3640