akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int k;
int n;
int a[maxn];

#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    k = readint();
    n = readint();
    repd(i, 1, n)
    {
        a[i] = readint();
    }
    a[n + 1] = a[1] + k;
    int ans = k;
    repd(i, 2, n + 1)
    {
        ans = min(ans, k - (a[i] - a[i - 1]));
    }
    printf("%d\n", ans );
    return 0;
}




Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();
        int[] B = new int[M];
        for (int i=0; i<M; i++) {
            B[i] = sc.nextInt();
        }

        int[][] A = new int[N][M];
        for (int i=0; i<N; i++) {
            for (int j=0; j<M; j++) {
                A[i][j] = sc.nextInt();
            }

        }

        System.out.println(solve(N, M, C, B, A));
    }

    private static int solve(int N, int M, int C, int[] B, int[][] A) {
        int count = 0;

        for (int i=0; i<N; i++) {
            int value = 0;
            for (int j=0; j<M; j++) {
                value += A[i][j] * B[j];
            }
            value += C;

            if (value > 0) count++;
        }

        return count;
    }
}

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

int main()
{
	int k,n;
	cin>>k>>n;
  	vector <int> arr;
  for(int i=0;i<n;i++)
  {
    int temp;
    cin>>temp;
	arr.push_back(temp);
  }
  int mx=0;
  int sum=0;
  int value;
  for(int i=0;i<n;i++)
  {
      if(i==n-1)
      {
        value=min(k-arr[i]+arr[0],arr[i]-arr[(i+1)%n]);
      }
    else
    value=abs(arr[i]-arr[(i+1)]);
            
        sum=sum+value;
        if(mx<value)
          mx=value;
        
  }
  cout<<sum-mx<<endl;
  
}


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

#define maxn 1000010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

vector<int> prime;
bool mark[maxn];

void sieve() {
  prime.push_back(2);
  for (int i = 3; i * i <= maxn; i += 2) {
    if (!mark[i]) {
      for (int j = i * i; j <= maxn; j += i + i) mark[j] = 1;
    }
  }
  for (int i = 3; i <= maxn; i += 2) {
    if (!mark[i]) prime.push_back(i);
  }
}

int f(ll num) {
  int cnt = 1;
  for (int i = 0; i < (int)prime.size(); ++i) {
    if (num % prime[i] == 0) {
      cnt++;
      while (num % prime[i] == 0) {
        num /= prime[i];
      }
    }
  }
  if(num>1)
    cnt++;
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  sieve();
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cout << f(g) << endl;
}


Measured memory_bytes: 1916
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

@njit((i8,i8,i8[:,:]), cache=True)
def main(N,T,A):
  dp = np.zeros(T+1, np.int64)
  for i in range(N):
    for t in range(T-1,-1,-1):
      u = min(T,t+A[i,0])
      dp[u] = max(dp[u],dp[t]+A[i,1])
  ans = dp[-1]
  return ans

N, T = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
A = np.array(sorted(A),np.int64)
print(main(N,T,A))

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a,b);
  }
  int ans = 0;
  rep(i,n) ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  string s; cin >> s;
  int ans = 0;
  int n = s.size();
  rep(i, n) {
    if(i == 0) ans += s[0]-'0'-1;
    else ans += 9;
  }
  int tmp = 0;
  rep(i, n) tmp += s[i]-'0';
  chmax(ans, tmp);
  cout << ans << endl;
}


Measured memory_bytes: 3520
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int N;
vector<int> a;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  a.resize(N);
  rep(i,N){
    cin >> a[i];
  }
  cout << accumulate(all(a),0LL) - N << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int c = Integer.parseInt(scan.next());
		String ans = "";

		if (a < b) {
			if(b < c) {
				ans = "Yes";
			}else {
				ans = "No";
			}
		} else {
			ans = "No";
		}

		System.out.println(ans);
	}

}



Measured memory_bytes: 26184
// AtCoder Regular Contest 068
// E - Snuke Line

#include <cstdio>
#include <algorithm>
#define MAX_N 300000
#define MAX_M 100000
#define MAX_BIT_IDX (MAX_M + 1)
using namespace std;
typedef long long int ll;
typedef pair<int, int> Sec;


template <typename T>
class BIT {
public:
  T b[MAX_BIT_IDX + 1];
  int n;
  void init(int num);
  T sum(int i);
  void add(int i, T x);
};

template <typename T>
void BIT<T>::init(int num) {
  n = num;
  for (int i = 0; i <= n; i++) {
    b[i] = 0;
  }
  return;
}

template <typename T>
T BIT<T>::sum(int i) {
  T s = 0;

  for (; i > 0; i -= i & -i) {
    s += b[i];
  }
  return s;
}

template <typename T>
void BIT<T>::add(int i, T x) {
  for (; i <= n; i += i & -i) {
    b[i] += x;
  }
  return;
}



template <typename T>
class RangeBIT {
public:
  BIT<T> bit0, bit1;
  int n;
  void init(int num);
  T sum(int i);
  void add(int l, int r, T x); // [l, r)
};

template <typename T>
void RangeBIT<T>::init(int num) {
  bit0.init(num);
  bit1.init(num);
  return;
}

template <typename T>
T RangeBIT<T>::sum(int i) {
  return bit1.sum(i) * i + bit0.sum(i);
}

template <typename T>
void RangeBIT<T>::add(int l, int r, T x) {
  bit0.add(l, -x * (l - 1));
  bit1.add(l, x);
  bit0.add(r, x * (r - 1));
  bit1.add(r, -x);
  return;
}


int N, M;
Sec sec[MAX_N + 1];
RangeBIT<int> rb;
int ans;

int main() {

  int l, r, idx;

  scanf("%d%d", &N, &M);
  rb.init(M + 1);
  for (int i = 0; i < N; i++) {
    scanf("%d%d", &l, &r);
    sec[i].first = r - l;
    sec[i].second = l;
  }
  sec[N] = (Sec){ M, 0 };
  sort(sec, sec + N + 1);

  idx = 0;
  for (int d = 1; d <= M; d++) {
    ans = 0;
    for (; sec[idx].first < d; idx++) {
      l = sec[idx].second;
      r = l + sec[idx].first;
      rb.add(l, r + 1, 1);
    }
    ans = N - idx;
    for (int i = d; i <= M; i += d) {
      ans += rb.sum(i) - rb.sum(i - 1);
    }
    printf("%d\n", ans);
  }

  return 0;

}




Measured memory_bytes: 3968
s=input()
k=int(input())
n=len(s)

koho=set()
for i in range(n):
    for j in range(i+1, min(i+k+1, n+1)):
        c=s[i:j]
        if c not in koho:
            koho.add(c)
ans=sorted(list(koho))
print(ans[k-1])


Measured memory_bytes: 4592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int n, m;
int memo[100100];

int dfs (Graph &g, int n) {
    if (memo[n] != -1) return memo[n];
    if (g[n].empty()) return 0;
    int sum = 0;
    for (auto next : g[n]) {
        sum = max (sum, dfs (g, next) + 1);
    }
    return memo[n] = sum;
}
int main() {
    cin >> n >> m;
    Graph g (n);
    rep (i, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back (y);
    }
    rep (i, n + 1) memo[i] = -1;
    int ans = 0;
    rep (i, n) { ans = max (ans, dfs (g, i)); }
    cout << ans << "\n";
}


Measured memory_bytes: 8192
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, K = map(int, input().split())
A = list(map(int, input().split()))

if K <= N:
    pos = 0
    for _ in range(K):
        pos = A[pos] - 1
    print(pos+1)
    quit()

reached = [-1] * N
pos = 0
step = 0
while True:
    if reached[pos] != -1:
        loop_start = reached[pos]
        loop_end = step
        break
    reached[pos] = step
    pos = A[pos] - 1
    step += 1

K -= step
K = K % (loop_end - loop_start)

# print("loop_start: {}".format(loop_start))
# print("loop_end: {}".format(loop_end))
# print("K: {}".format(K))
# print("pos: {}".format(pos))
for _ in range(K):
    pos = A[pos] - 1

print(pos+1)

Measured memory_bytes: 32380
#include <stdio.h>

int main(){
	int n, i, j, l1, l2, l3;
	
	scanf("%d", &n);
	i = 0;
	while (i<n){
		scanf("%d %d %d", &l1, &l2, &l3);
		if (l1*l1 == l2*l2 + l3*l3 || l2*l2 == l1*l1  +l3*l3 || l3*l3 == l1*l1 + l2*l2)
			printf("YES\n");
		else 
			printf("NO\n");
		i++;
	}
	return 0;
}

Measured memory_bytes: 576
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int i, j,k;
	ll h, w; int n, a, b;
	cin >> h >> w >> n;
	map<P, int> m;
	vector<P> s;
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		for (j = a - 1; j <= a + 1; j++) {
			for (k = b - 1; k <= b + 1; k++) {
				if (j >= 2 && k >= 2 &&j <= h-1 &&k <= w-1) {
					P p = make_pair(j, k);
					s.push_back(p);
					m[p]++;
				}
			}
		}
	}
	if (s.empty()) {
		cout << (h - 2)*(w - 2) << endl;
		for (i = 1; i < 10; i++) {
			cout << 0 << endl;
		}
		return 0;
	}
	sort(s.begin(), s.end());
	int len = s.size(); int out[10] = {};
	out[m[s[0]]]++;
	for (i = 1; i < len; i++) {
		if (s[i] != s[i - 1]) {
			out[m[s[i]]]++;
		}
	}
	ll sum = (h-2)*(w-2);
	for (i = 1; i < 10; i++) {
		sum -= out[i];
	}
	cout << sum << endl;
	for (i = 1; i < 10; i++) {
		cout << out[i] << endl;
	}
	return 0;
}

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

int main(){

 string S;
 int ans=0, num=0;
 getline(cin, S);

 for(int i=0; i<S.size(); i++){
   if(S[i]=='A' || S[i]=='T' || S[i]=='C' || S[i]=='G'){
     num++;
     ans = max(ans, num);
   }else{
     ans = max(ans, num);
     num = 0;
   }
 }

 cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

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

    vector<int> as(n);
    for (auto &a: as) scanf("%d", &a);

    int maxp = -1, maxi = -1;
    for (int i = 0; i + 1 < n; i++) {
        if (maxp < as[i] + as[i + 1]) {
            maxp = as[i] + as[i + 1];
            maxi = i;
        }
    }

    if (maxp < l) {
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;

    for (int i = 0; i < maxi; i++) cout << i + 1 << endl;
    // cout << "*" << endl;
    for (int i = n - 1; i > maxi; i--) cout << i << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int n, m;
  cin >> n >> m;
  vec1 a(n);
  int tmp = 0;
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    tmp = tmp + a.at(i);
  }
  int c = 0;
  for(int i = 0; i < n; i++) {
    int x = a.at(i)*(4*m);
    if(x >= tmp) {
      c++;
    }
  }
  if(c >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


int main(){
	string str;

	while(getline(cin,str)){
        for(int i=0;i<26;i++){
            if(str.find("the")!=string::npos)break;
            if(str.find("this")!=string::npos)break;
            if(str.find("that")!=string::npos)break;

            for(int j=0;j<str.size();j++){
                if(!isalpha(str[j]))continue;
                str[j]=(str[j]-'a'+1)%26+'a';
            }
        }
        cout<<str<<endl;
    }
    return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	vector<int> X;
	inputVector(X, N);

	vector<int> Y = X;
	sort(all(Y));
	int low = Y[N / 2 - 1];
	int high = Y[N / 2];

	rep(i, N) {
		int ret;
		if (X[i] <= low) ret = high;
		else ret = low;
		printf("%lld\n", ret);
	}

    return 0;
}


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

long long calc(int N) {

	int cnt = 0;
	for (int a = 0; a < 10; a++)
	{
		int suma = a;
		for (int b = 0; b < 10; b++)
		{
			if (!(suma == 0) && !(b >= a - 1 && b <= a + 1)) continue;
			int sumb = suma + b;
			for (int c = 0; c < 10; c++)
			{
				if (!(sumb == 0) && !(c >= b - 1 && c <= b + 1)) continue;
				int sumc = sumb + c;
				for (int d = 0; d < 10; d++)
				{
					if (!(sumc == 0) && !(d >= c - 1 && d <= c + 1)) continue;
					int sumd = sumc + d;
					for (int e = 0; e < 10; e++)
					{
						if (!(sumd == 0) && !(e >= d - 1 && e <= d + 1)) continue;
						int sume = sumd + e;
						for (int f = 0; f < 10; f++)
						{
							if (!(sume == 0) && !(f >= e - 1 && f <= e + 1)) continue;
							int sumf = sume + f;
							for (int g = 0; g < 10; g++)
							{
								if (!(sumf == 0) && !(g >= f - 1 && g <= f + 1)) continue;
								int sumg = sumf + g;
								for (int i = 0; i < 10; i++)
								{
									if (!(sumg == 0) && !(i >= g - 1 && i <= g + 1)) continue;
									int sumi = sumg + i;
									for (int j = 0; j < 10; j++)
									{
										if (!(sumi == 0) && !(j >= i - 1 && j <= i + 1)) continue;
										int sumj = sumi + j;
										for (int k = 0; k < 10; k++)
										{
											if (!(sumj == 0) && !(k >= j - 1 && k <= j + 1)) continue;
											if (cnt == N) {
												return
													k * 1
													+ j * 10
													+ i * 100
													+ g * 1000
													+ f * 10000
													+ e * 100000
													+ d * 1000000
													+ c * 10000000
													+ b * 100000000ll
													+ a * 1000000000ll;
											}
											cnt++;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

}

int main(){
	int N;
	cin >> N;
	cout << calc(N) << endl;
	return 0;
}


Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, k) = InputLine.to_ia
  p = InputLine.to_ia

  p.sort!

  puts p[0...k].inject(:+).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    double t, x;
    cin >> t >> x;

    P(t / x);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,k;
    scanf("%d%d",&n,&k);
    long long x[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&x[i]);
    }
    long long ans=300000000;
    long long a,b,c;
    for(int i=0;i<n-k+1;i++){
        a=x[i];
        b=x[i+k-1];
        if(b<0||a>=0){
            if(b<0)c=-a;
            if(a>=0)c=b;
        }
        else {
            if(b>=-a)c=b-2*a;
            else c=2*b-a;
        }
        if(c<ans)ans=c;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 896
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
int n;
cin>>n;
 vector<int>A(n);
 rep(i,n)cin>>A[i];
 vector<int>B(n);
 rep(i,n)B[i]=A[i];
sort(B.begin(),B.end());
if(B[n-2]==B[n-1]){rep(i,n)cout<<B[n-1]<<endl;return 0;}
int x=B[n-1];
int y=B[n-2];
rep(i,n){
    if(A[i]==x)cout<<y<<endl;
    else cout<<x<<endl;
    }
return 0;



}

Measured memory_bytes: 3200
#pragma GCC optimize("O3") 

#include <bits/stdc++.h>
using namespace std;

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << ": " << x << endl;
#define deb2(x,y)	        cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    ll n;
    cin >> n;
    if(n >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}


Measured memory_bytes: 3576
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 2e5 + 10;
int a[maxN];
ll dp[maxN];
int x[maxN];
ll pref[maxN];
unordered_map < ll, ll > mp[maxN];
ll solve(ll cur, int c) {
    if (c == 1) return cur;
    if (mp[c].count(cur)) return mp[c][cur];
    if (cur >= -pref[2]) return cur;
    int it = lower_bound(pref + 2, pref + c + 1, -cur) - pref;
    it -= 1;
    assert(-pref[it] >= cur);
    cur = -2 * pref[it] - cur;
    return mp[c][cur] = solve(cur, it - 1);

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n - 1; i++) pref[i] = pref[i - 1] + a[i];
    int m;
    cin >> m;
    while (m--) {
        ll cur;
        cin >> cur;
        cur -= pref[n - 1];
        cur = solve(cur, n - 2);
        cout << a[1] + pref[1] + cur << '\n';
    }
    /*for (int i = 1; i <= m; i++) {
        cin >> x[i];
    }
    dp[n - 1] = a[n - 1] - a[n];
    ll mn = -pref[n - 2] - dp[n - 1];
    for (int i = n - 2; i >= 1; i--) {
        dp[i] = a[i] + pref[i] + mn;
        mn = max(mn, -pref[i - 1] - dp[i]);
    }
    cout << dp[1];*/
    return 0;
}

Measured memory_bytes: 57044
#include <cstdio>
#include <cstring>

int dx[2][6] = {{-1, -1, -1, 0, 1, 0}, {0, -1, 0, 1, 1, 1}};
int dy[6]	=	{-1, 0, 1, -1, 0, 1};
int map[128][128];
int vis[128][128];
int W, H;

using namespace std;

int checkState(int nowy, int nowx)
{
	if (0 > nowy || 0 > nowx || nowy >= H || nowx >= W){
		return (2);
	}
	
	if (map[nowy][nowx] == 1){
		return (-1);
	}
	
	if (vis[nowy][nowx] == 0){
		vis[nowy][nowx] = 1;
		for (int i = 0; i < 6; i++){
			int nx = nowx + dx[(nowy + 1) % 2][i];
			int ny = nowy + dy[i];
			if (checkState(ny, nx) == 2){
				return (2);
			}
		}
	}
	
	return (-1);
}

int main(void)
{
	scanf("%d %d", &W, &H);
	
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			scanf("%d", &map[i][j]);
		}
	}
	
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			if (map[i][j] == 0){
				memset(vis, 0, sizeof(vis));
				map[i][j] = checkState(i, j);
			}
		}
	}
	
	int ans = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (map[i][j] == 1){
                for (int k = 0; k < 6; k++){
					int ny = i + dy[k];
					int nx = j + dx[(i + 1) % 2][k];
                    if (0 > ny || ny >= H || 0 > nx || nx >= W || map[ny][nx] == 2){
                        ans++;
                    }
                }
            }
        }
    }
     
    printf("%d\n", ans);
     
    return (0);
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll test,i,j,n,k,s=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                ll d=__gcd(i,j);
                d=__gcd(d,k);
                s+=d;
            }
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <functional>
#include <map>
#include <cmath>
#include <iostream>
 
 
using namespace std;
 
 
int N;
 
int main()
{
	int ans = 0;
	cin >> N;
	if (N < 105){
		ans = 0;
	}else if(N >=105 && N < 135){
		ans = 1;
	}else if(N >= 135 && N < 165){
		ans = 2;
	}else if(N >=165 && N < 189){
		ans = 3;
	}else if(N >=189 && N < 195){
		ans = 4;
	}else if(N >=195 && N <= 200){
		ans = 5;
	}
	cout << ans << endl;
}


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

int main(){
  int n, l;
  vector<string> str;
  string si;
  string res = "";
  
  cin >> n >> l;
  for (int i=0; i<n; i++) {
    cin >> si;
    str.push_back(si);
  }
  
  sort(str.begin(), str.end());
  
  for (int i=0; i<n; i++){
    res += str[i];
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  set<int> s;
  for(int i = 0; i < 10; ++i) {
    s.insert(i);
  }
  string N;
  int K, x;
  cin >> N >> K;
  int nn = stoi(N);
  for(int i = 0; i <= K; ++i) {
    cin >> x;
    s.erase(x);
  }
  bool flag = false, papa=false;
  int now;
  int ans = 0;
  for(int i = 0; N[i]; ++i) {
    if(flag) ans = ans*10 + *s.begin();
    else {
      if(s.lower_bound(N[i]-'0') == s.end()) {
        papa = true;
        break;
      }
      now = *s.lower_bound(N[i]-'0'); 
      //cout << now << ' ';
      ans = ans*10 + now;
      if(now > (N[i]-'0')) flag = true;
    }
  }
  //puts("");
  if(papa) {
    int fst = *s.upper_bound(0);
    //cout << "fst=" << fst<< endl;
    for(int i = 0; N[i]; ++i) {
      fst = fst*10 + *s.lower_bound(0);
    }
    cout << fst << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	char x;
	scanf("%c",&x);
	printf("%c", x);
	scanf("%c",&x);
	int y=0,tmp=0;
	for(int i=0;i<6;i++){
		y++;
	}
	while(y){
		for(int i=0;i<11;i++){
			tmp++;
		}
		y--;
	}
	if((int)x != tmp){
		printf("B");
	}
	else{
		int out=0;
		y=0;

		for(int i=0;i<8;i++){
			y++;
		}
		while(y){
			for(int i=0;i<10;i++){
				out++;
			}
			y--;
		}
		out++;
		out++;
		printf("%c",(char)out);
	}
	scanf("%c",&x);
	printf("%c\n", x);
	return 0;
}


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 3e3 + 5;
ll mod = 1e9 + 7;
ll dp[N][N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("VLJUM.INP", "r")){
                freopen("VLJUM.INP", "r", stdin);
                freopen("VLJUM.OUT", "w", stdout);
        }
        ll n;
        cin >> n;
        string s;
        cin >> s;
        s = "  " + s;
        dp[1][1] = 1;
        for (int i = 2; i <= n; i++){
                if (s[i] == '>') {
                        ll mem = 0;
                        for (int j = i - 1; j >= 1; j--){
                                mem = (mem + dp[i - 1][j]) % mod;
                                dp[i][j] = mem;
                        }
                } else {
                        ll mem = 0;
                        for (int j = 1; j < i; j++){
                                mem = (mem + dp[i - 1][j]) % mod;
                                dp[i][j + 1] = mem;
                        }
                }
        }
        ll ans = 0;
        for (int i = 1; i <= n; i++) ans = (ans + dp[n][i]) % mod;
        cout << ans;
}
/*
*/


Measured memory_bytes: 69120
left, right = map(int, input().split())

min = 2019
for i in range(left, right+1):
    for j in range(i+1, right+1):
        tmp = (i * j) % 2019
        if tmp < min:
            min = tmp
        if min == 0:
            print(min)
            exit()

print(min)


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


int main(){


    int n, i;

 
    cin >> n;


    for( i = 1 ; i * i <= n ; i = i + 1 ){

         }


    cout << ( i - 1 ) * ( i - 1 ) << endl;
         

    return 0;


    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<ll> a(3*n+1),x(2*n+1),y(2*n+10);
  priority_queue<ll,vector<ll>,greater<ll>> cnt1;
  priority_queue<ll> cnt2;
  ll sum1=0,sum2=0,ans=-inf;
  FOR(i,1,3*n+1){
    cin>>a[i];
    if(i<=n){
      cnt1.push(a[i]);
      sum1+=a[i];
    }else if(2*n+1<=i){
      cnt2.push(a[i]);
      sum2+=a[i];
    }
  }
  x[n]=sum1,y[2*n+1]=sum2;
  FOR(i,n+1,2*n+1){
    cnt1.push(a[i]);
    sum1+=a[i]-cnt1.top();
    cnt1.pop();
    x[i]=sum1;
  }
  for(int i=2*n;i>=n+1;i--){
    cnt2.push(a[i]);
    sum2+=a[i]-cnt2.top();
    cnt2.pop();
    y[i]=sum2;
  }
  FOR(i,n,2*n+1) ans=max(ans,x[i]-y[i+1]);
  cout<<ans<<endl;
}

Measured memory_bytes: 8052
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n;
        cin>>n;
        ll flag = 0;
        for(ll a = -500;a<=500;a++){
            for(ll b = -500;b<=500;b++){
                ll guess = power_without_mod(a,5) - power_without_mod(b,5);
                if(guess == n && flag == 0){
                    cout<<a<<" "<<b;
                    flag = 1;
                    break;
                }
            }
            if(flag)
                break;
        }
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> array;
  int sum = 0;
  for (int i = 0; i < N; i++) {
  	int a;
    cin >> a;
    sum += a;
    array.push_back(a);
  }
  sort(array.begin(), array.end());
  
  if (sum - array[N-1] > array[N-1]) {
     cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y=-1,sum=0;cin>>n>>x;
  vector<int>v(n);
  for(int i=0;i<n;i++){
    cin>>v.at(i);
  }
  sort(v.begin(),v.end());
  
    for(int i=0;i<n;i++){
    sum+=v.at(i);
    if(sum>x){
      cout<<i<<endl;
      y=0;
      break;
    }
  }
if(y==-1){
  if(sum==x)cout<<n<<endl;
  else cout<<n-1<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 100005
int n,m;
vector<int> tree[maxn];
int vis[maxn];
ll dp1[100005];
ll dp2[100005];
void solve2(ll par_ans,int src)
{
    vis[src] = 1;
    dp2[src] = ((1+par_ans)*dp1[src])%m;
    // cout<<src<<" "<<dp2[src]<<"\n";
    vector<ll>prefix;
    vector<ll>suffix;
    for(auto child:tree[src])
    {
        if(!vis[child])
        {
            prefix.push_back(1+dp1[child]);
            suffix.push_back(1+dp1[child]);
        }
    }
    for(int i=1;i<prefix.size();i++)
    prefix[i] = (prefix[i-1]*prefix[i])%m;
    for(int i=suffix.size()-2;i>=0;i--)
    suffix[i] = (suffix[i+1]*suffix[i])%m;

    int cnt=0;
    for(auto child:tree[src])
    {
        if(!vis[child])
        {
            ll ways = (1+par_ans);
            ways = (cnt>0)?(ways*prefix[cnt-1])%m : ways;
            ways = (cnt<suffix.size()-1)?(ways*suffix[cnt+1])%m : ways;
            // cout<<ways<<"\n";
            solve2(ways,child);
            cnt++;
        }
    }
}
void solve1(int src)
{
    vis[src]=1;
    dp1[src]=1;
    for(auto child:tree[src])
    {
        if(!vis[child])
        {
            solve1(child);
            dp1[src] = (dp1[src]*(1+dp1[child]))%m;
        }    
    }
}
int main() {
    cin>>n>>m;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    memset(dp1,0,sizeof dp1);
    memset(dp2,0,sizeof dp2);
    memset(vis,0,sizeof vis);
    solve1(1);
    memset(vis,0,sizeof vis);
    solve2(0,1);
    for(int i=1;i<=n;i++)
    {
        cout<<dp2[i]<<"\n";
    }
}


Measured memory_bytes: 26704
H, W, D = map(int, input().split())
peak = H * W
L = [[0 for j in range(i+1, peak+1, D)] for i in range(D)]
dd = {}
for i in range(H):
  line = list(map(int, input().split()))
  for j in range(W):
    dd[line[j]] = [i, j]
for m in range(D):
  ddd = (peak - m - 1) // D
  for k in range(1, ddd + 1):
    dist = abs(dd[k*D+m+1][0] - dd[(k-1)*D+m+1][0])
    dist += abs(dd[k*D+m+1][1] - dd[(k-1)*D+m+1][1])
    L[m][k] = L[m][k-1] + dist
Q = int(input())
for i in range(Q):
  pL, pR = map(int, input().split())
  l, r = (pL - 1) // D, (pR - 1) // D
  mod = (pL - 1) % D
  print(L[mod][r] - L[mod][l])

Measured memory_bytes: 34340
#include <map>
#include <iostream>
using namespace std;
int main(){
    string s;
    map<string,int> m;
    int q,k;
    cin>>q;
    while(q--){
        cin>>k;
        if(k==0){
            cin>>s>>k;
            if(m.find(s)!=m.end())m[s]=k;
            else m.insert({s,k});
        }
        else{
            cin>>s;
            cout<<m[s]<<endl;
        }
    }
}


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

int main(){
    char str[5];
    int a[5],num[5];
    scanf("%s",str);
    for(int i=1;i<=4;i++){
        num[i]=str[i-1]-'0';
    }
    int sum;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=2;j++){
            for(int k=1;k<=2;k++){
                a[1]=i,a[2]=j,a[3]=k;
                sum=num[1];
                for(int m=1;m<=3;m++){
                    if(a[m]==1)
                        sum+=num[m+1];
                    else
                        sum-=num[m+1];
                }
                if(sum==7){
                    printf("%d",num[1]);
                    for(int m=1;m<=3;m++){
                        if(a[m]==1)
                            printf("+");
                        else
                            printf("-");
                        printf("%d",num[m+1]);
                    }
                    printf("=7");
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define mp(a, b) make_pair((a),(b))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;
constexpr double eps = 0.000000001;


int main() {
    string s;
    cin >> s;
    int n = s.length(), r = n;
    for (int i = 1; i < n; i++) if (s[i] != s[i - 1]) r = min(r, max(i, n - i));
    cout << r << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
int a1,a2,a3,score;
scanf("%d %d %d", &a1,&a2,&a3);
score=a1+a2+a3;
if (score>=22) {
printf("bust\n");
}
else {
printf("win\n");
}

return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char s[200010];
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cin>>s;
    int len=strlen(s);
    int sum=0;
    for(int i=0;i<len;i++) sum+=s[i]-'0';
    if(sum%9==0){
        cout<<"Yes";
    }
	else{
        cout<<"No";
    }
}

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

int main() {
  int k, n;
  cin >> k >> n;
  int ans = k;
  int maxd = 0;
  int pre, init;
  cin >> pre;
  init = pre;
  rep(i, n-1) {
    int d;
    cin >> d;
    maxd = max(maxd, d-pre);
    pre = d;
  }
  maxd = max(maxd, init+k-pre);
  cout << k-maxd << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int f(int n) {
  return n % 10;
}

int main() {
  int A[5];
  rep(i,0,4) cin >> A[i];

  pair<int, int> last = make_pair(-1, 9);
  rep(i,0,4) {
    if (f(A[i]) == 0) continue;
    if (f(A[i]) < last.second) {
      last = make_pair(i, f(A[i]));
    }
  }

  if (0 <= last.first) swap(A[last.first], A[4]);
  rep(i,0,3) {
    while (f(A[i]) != 0) A[i]++;
  }

  int ans = 0;
  rep(i,0,4) ans += A[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
     
    int main(void){
        long long int n,T,sum=0;
        long long int tn[200000];
        long long int i,x;
        scanf("%lld %lld",&n,&T);
        for(i=0;i<n;i++){
            scanf("%lld",&tn[i]);
        }
        for(i=0;i<n;i++){
            x = tn[i+1]-tn[i];
            if(x<T&&i!=n-1){
            sum += x;
            } else {
            sum += T;
            }
        }
        printf("%lld\n",sum);
        return 0;
    }

Measured memory_bytes: 1664
import itertools

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

A = [tuple(int(i) for i in input().split()) for _ in range(n)]

memo = [[-1]*n for i in range(n)]
keiro_sum = 0

cnt = 0
for i in itertools.permutations(range(n)):
    cnt += 1
    one_root = 0
    for j in range(1,n):
        if(memo[i[j-1]][i[j]] == -1):
            distance = ((A[i[j]][0] - A[i[j-1]][0])**2 + (A[i[j]][1] - A[i[j-1]][1])**2)**0.5
            memo[i[j]][i[j-1]] = distance
            memo[i[j-1]][i[j]] = distance
        else:
            distance = memo[i[j-1]][i[j]]
        one_root += distance

    keiro_sum += one_root

print(keiro_sum/cnt)

        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(LL i=(a);i<(LL)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const LL INF=1LL<<60;
const LL MAX=1e10;
const int BITSIZE=1<<17;
const LL p=7+1e9;
const int SIZE=5+1e6;
LL primes[SIZE];
bool isNotPrime[SIZE];
map<pr,LL> mpi;
LL nums[SIZE];
pr results[SIZE];
pr revepr(pr x){
	return pr(x.second,x.first);
}
LL pow3(LL x){
	return x*x*x;
}
LL pow2(LL x){
	return x*x;
}
LL div3(LL x){
	for(LL i=0;pow3(primes[i])<=x;i++){
		while(x%pow3(primes[i])==0){
			x/=pow3(primes[i]);
		}
	}
	return x;
}
int main(){
	int num=0;
	FOR(i,2,SIZE){
		if(!isNotPrime[i]){
			for(LL j=i*i;j<SIZE;j+=i) isNotPrime[j]=true;
			primes[num++]=i;
		}
	}
	int N;
	LL x;
	cin >> N;
	FOR(j,1,N+1){
		cin >> nums[j];
		nums[j]=div3(nums[j]);
		x=nums[j];
		LL solos=1;
		LL duals=1;
		cat;
		for(LL i=0;pow3(primes[i])<=MAX && primes[i]<=x;i++){
			if(x%pow2(primes[i])==0){
				duals*=primes[i];
				x/=pow2(primes[i]);
			}
			if(x%primes[i]==0){
				solos*=primes[i];
				x/=primes[i];
			}
		}
		cat;
		LL sqx=sqrt(x);	
		if(sqx*sqx==x) duals*=sqx;
		else solos*=x;
		results[j]=pr(solos,duals);
		mpi[results[j]]=mpi[results[j]]+1;
	}
	LL ans=0;
	if(mpi[pr(1,1)]){
		ans++;
		mpi[pr(1,1)]=0;
	}
	FOR(i,1,N+1){
		ans+=max(mpi[results[i]],mpi[revepr(results[i])]);
		mpi[results[i]]=0;
		mpi[revepr(results[i])]=0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16640
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().split()))
N,Q = LI()
ab = [LI() for _ in range(N-1)]
px = [LI() for _ in range(Q)]
ans = [0]*(N+1) #1_index
graph = {i:collections.deque() for i in range(1,N+1)} #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [-1]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]!=-1:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int s = h1 * 60 + m1;
	int t = h2 * 60 + m2;
	int ans = t - s - k;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))
    ans=b[a[0]-1]
    for i in range(1,n):
        ans+=b[a[i]-1]
        if a[i-1]+1==a[i]:
            ans+=c[a[i-1]-1]
    print(ans)
resolve()

Measured memory_bytes: 38384