akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

// range add/range max
struct SegTree {
	int n;
	std::vector<int64_t> data;
	std::vector<int64_t> added;
	SegTree (int n_) {
		for (n = 1; n < n_; n <<= 1);
		data.resize(n << 1);
		added.resize(n << 1);
	}
	void flush(int i) {
		if (added[i]) {
			data[i] += added[i];
			if (i < n) {
				added[i << 1] += added[i];
				added[i << 1 | 1] += added[i];
			}
			added[i] = 0;
		}
	}
	void assign(int i, int64_t val, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (node_l == i && node_r == i + 1) {
			data[node] = val;
			return;
		}
		int mid = node_l + ((node_r - node_l) >> 1);
		if (i < mid) assign(i, val, node << 1, node_l, mid);
		else assign(i, val, node << 1 | 1, mid, node_r);
		data[node] = std::max(data[node << 1], data[node << 1 | 1]);
	}
	void add(int l, int r, int val, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (l >= node_r || r <= node_l) return;
		if (l <= node_l && r >= node_r) {
			added[node] = val;
			flush(node);
		} else {
			int mid = node_l + ((node_r - node_l) >> 1);
			add(l, r, val, node << 1, node_l, mid);
			add(l, r, val, node << 1 | 1, mid, node_r);
			data[node] = std::max(data[node << 1], data[node << 1 | 1]);
		}
	}
	int64_t max(int l, int r, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (l >= node_r || r <= node_l) return 0;
		if (l <= node_l && r >= node_r) return data[node];
		else {
			int mid = node_l + ((node_r - node_l) >> 1);
			int64_t res = std::max(max(l, r, node << 1, node_l, mid), max(l, r, node << 1 | 1, mid, node_r));
			data[node] = std::max(data[node << 1], data[node << 1 | 1]);
			return res;
		}
	}
};

int main() {
	int n = ri(), m = ri();
	struct Query {
		int l;
		int r;
		int score;
	};
	Query qs[m];
	for (int i = 0; i < m; i++) qs[i].l = ri() - 1, qs[i].r = ri(), qs[i].score = ri();
	std::sort(qs, qs + m, [] (auto i, auto j) { return i.r < j.r; });
	
	SegTree tree(n);
	int head = 0;
	for (int i = 0; i <= n; i++) {
		while (head < m && qs[head].r == i) tree.add(qs[head].l, qs[head].r, qs[head].score), head++;
		if (i < n) tree.assign(i, tree.max(0, i));
	}
	printf("%lld\n", (long long) std::max<int64_t>(0, tree.max(0, tree.n)));
	return 0;
}


Measured memory_bytes: 10880
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

    double R;
    cin >> R;
    cout << fixed << setprecision(10) << R * 2 * M_PI << endl;
}


Measured memory_bytes: 3824
from sys import exit
h, w = map(int, input().split())
s = [input() for _ in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == '.':
      continue
    if i > 0 and s[i - 1][j] == '#':
      continue
    if i < h - 1 and s[i + 1][j] == '#':
      continue
    if j > 0 and s[i][j - 1] == '#':
      continue
    if j < w - 1 and s[i][j + 1] == '#':
      continue
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 3188
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/abc145/tasks/abc145_c

n_text = input()
n = int(n_text)

class Zahyo:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    @staticmethod
    def parse(text):
        x_txt, y_txt = text.split()
        x = int(x_txt)
        y = int(y_txt)
        zahyo = Zahyo(x, y)
        return zahyo


def calc_kyori(zahyo1, zahyo2):
    kyori = (((zahyo1.x - zahyo2.x) ** 2) + ((zahyo1.y - zahyo2.y) ** 2)) ** 0.5
    return kyori


def calc_kyoris(my_zahyo_list):
    kyori = 0
    for i in range(len(my_zahyo_list)-1):
        kyori += calc_kyori(my_zahyo_list[i], my_zahyo_list[i+1])
    return kyori


zahyo_list = []
for i in range(n):
    zahyo_list.append(Zahyo.parse(input()))

kyori_list = []


def calc(my_kakutei_zahyo_list, my_un_kakutei_zahyo_list, my_kyori_list):
    # print(len(my_kakutei_zahyo_list), len(my_un_kakutei_zahyo_list))
    if len(my_un_kakutei_zahyo_list) == 0:
        kyori = calc_kyoris(my_kakutei_zahyo_list)
        my_kyori_list.append(kyori)
    for i in range(len(my_un_kakutei_zahyo_list)):
        calc(my_kakutei_zahyo_list + [my_un_kakutei_zahyo_list[i]], my_un_kakutei_zahyo_list[0:i] + my_un_kakutei_zahyo_list[i+1:], my_kyori_list)


calc([], zahyo_list, kyori_list)

heikin = sum(kyori_list) / len(kyori_list)
print(heikin)


Measured memory_bytes: 4632
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def dfs(v, k, n):
    if n == 0:
        return v

    return min(dfs(2 * v, k, n - 1), dfs(v + k, k, n - 1))

def solve(N: int, K: int):
    return dfs(1, K, N)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    result = solve(N, K)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5116
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 1e13;

int main() {
    ll i, j, k, n, m, h, d;
    cin >> n >> d;
    ll x[n][d],ret=0;
    for(i = 0; i < n;i++){
        for(j = 0; j < d;j++){
            cin >> x[i][j];
        }
    }

    for(i = 0; i < n;i++){
        for(j = i + 1; j < n; j++) {
            ll sum = 0;
            for(k = 0; k < d;k++){
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            for(h = 1; h * h <= sum;h++){
                if(h * h == sum) ret++;
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define EPS (1e-10)
#define int long long

typedef vector<double> arr;
typedef vector<arr> mat;

double det(mat A){
  int n=A.size();
  double res=1;
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i+1;j<n;j++)
      if(abs(A[j][i])>abs(A[pivot][i])) pivot=j;
    swap(A[pivot],A[i]);
    res*=A[i][i]*(i!=pivot?-1:1);
    if(abs(A[i][i])<EPS) break;
    for(int j=i+1;j<n;j++)
      for(int k=n-1;k>=i;k--)
	A[j][k]-=A[i][k]*A[j][i]/A[i][i];
  }
  return res;
}

bool tri(double a1,double a2,double a3){
  if(a1+a2<=a3||a2+a3<=a1||a3+a1<=a2) return 1;
  return 0;
}
double tetrahedra(double OA,double OB,double OC,double AB,double AC,double BC){
  if(tri(OA,OB,AB)) return 0;
  if(tri(OB,OC,BC)) return 0;
  if(tri(OC,OA,AC)) return 0;
  if(tri(AB,AC,BC)) return 0;
  mat A(5,arr(5,0));
  A[0][0]=    0;A[0][1]=AB*AB;A[0][2]=AC*AC;A[0][3]=OA*OA;A[0][4]=1;
  A[1][0]=AB*AB;A[1][1]=    0;A[1][2]=BC*BC;A[1][3]=OB*OB;A[1][4]=1;
  A[2][0]=AC*AC;A[2][1]=BC*BC;A[2][2]=    0;A[2][3]=OC*OC;A[2][4]=1;
  A[3][0]=OA*OA;A[3][1]=OB*OB;A[3][2]=OC*OC;A[3][3]=    0;A[3][4]=1;
  A[4][0]=    1;A[4][1]=    1;A[4][2]=    1;A[4][3]=    1;A[4][4]=0;
  //cout<<"det(A):"<<det(A)<<endl;
  if(det(A)<=0) return 0; 
  return sqrt(det(A)/288.0);
}
signed main(){
  int n;
  while(cin>>n,n){
    double a[n];
    double ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	for(int k=j+1;k<n;k++){
	  for(int x=0;x<n;x++){
	    if(i==x||j==x||k==x) continue;
	    for(int y=0;y<n;y++){
	      if(i==y||j==y||k==y||x==y) continue;
	      for(int z=0;z<n;z++){
		if(i==z||j==z||k==z||x==z||y==z) continue;
		ans=max(ans,tetrahedra(a[i],a[j],a[k],a[x],a[y],a[z]));
	      }
	    }
	  }
	}
      }
    }
    printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3256
#include <stdio.h>

int main(void)
{
	//range_startは範囲の始まり、range_endは範囲の終わり、count_divisorは約数の数を格納
	int range_start, range_end, base;
	int i, count_divisor;

	scanf("%d %d %d", &range_start, &range_end, &base);
	//初期値は0
	count_divisor = 0;

	//範囲の間だけ繰り返す
	for(i = range_start; i <= range_end; i++){
		//(base / i)の余りが0なら約数
		if(!(base % i)){
			count_divisor++;
		}
	}

	//結果を出力
	printf("%d\n", count_divisor);

	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll a, b;
  cin >> a >> b;
  a--;
  b--;
  COUT(a * b);
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int n, a[100010], ans=100000000;
P cnt[2][100010];

int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (i % 2 == 0)cnt[0][a[i]].fr++;
		else cnt[1][a[i]].fr++;
	}
	for (int i = 1;i <= 100000;i++) {
		cnt[0][i].sc = i;
		cnt[1][i].sc = i;
	}
	sort(cnt[0], cnt[0] + 100000);
	sort(cnt[1], cnt[1] + 100000);
	for (int i = 100000;i > 99995;i--) {
		for (int j = 100000;j > 99995;j--) {
			int sum = 0;
			if (cnt[0][i].sc == cnt[1][j].sc)continue;
			for (int k = 0;k< n;k++) {
				if (k % 2 == 0) {
					if (a[k] !=cnt[0][i].sc)sum++;
				}
				else {
					if (a[k] != cnt[1][j].sc)sum++;
				}
			}
			ans = min(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	int a,b;
	cin>>a>>b;
	if (a<=0 && b>=0){
		cout << "Zero";
		return 0;
	}
	if (a>0 && b>0){
		cout << "Positive";
		return 0;
	}
	if (a<0 && b<0){
		int t = b-a+1;
		if (t%2==1) cout << "Negative";
		else cout << "Positive";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int a,b;
	cin >>a>>b;
	if (b%a==0)
		cout <<a+b;
	else
		cout <<b-a;
}


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

int main(){

    int n;
    cin>>n;
    for(int i=n;i<=999;i++){
        if(i/100==(i/10)%10&&(i/10)%10==i%10){
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}

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

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;

void solve(ll test_case)
{
  string s;
  cin>>s;
  int ans=0;
  if(s[1] != 'R'){
    if(s[0] == 'R' || s[2] == 'R')
        ans++;

    cout<<ans;
    return;
  }
  if(s[1] == 'R'){
    if(s[0] == 'R' && s[2] == 'R'){
        cout<<3;
        return;
    }
    if(s[0] == 'R' || s[2] == 'R'){
        cout<<2;
        return;
    }
    cout<<1;
    return;
  }
  cout<<0;
}

int main()
{

//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1, t1 = 0;
   // cin >> t;
    while (t1 < t)
    {
        solve(t1 + 1);
        t1++;
    }
 return 0;
}


Measured memory_bytes: 3672
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> a(n);
ll k = 1e18;
for(ll i =0 ; i < n; i++){
    cin >> a[i];
}
sort(a.begin(),a.end());

for(ll i = 0; i < n; i++){
    if(a[i] == 0){
        cout << 0 << endl;
        return 0;
    }
   if(k / a[i] == 0){
       cout << -1 << endl;
       return 0;
   }
   k /= a[i];
}
ll ans = 1;
for(ll i = 0; i < n; i++){
    ans *= a[i];
}
cout << ans << endl;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    ll ans = 0;
    REP(i, 1 << (n - 1)) {
        ll t = 0; 
        int p = 0;
        REP(j, n - 1) {
            if ((1 & i >> j) == 1) {
                t += stol(s.substr(p, j + 1 - p));
                p = j + 1;
            }
        }
        ans += t + stol(s.substr(p));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int( input() )
H = list( map( int, input().split() ) )

for i in range( N-1, 0, -1 ):
    if H[i-1] > H[i]:
        H[i-1] = H[i-1] - 1

tmp = 0
for i in range( N-1 ):
    if H[i] > H[i+1]:
        tmp = 1
        break

if tmp == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll K,A,B;
    cin>>K>>A>>B;
    ll ma=B/K;      //切り捨て
    ma = K*ma;      //B以下の最大のKの倍数
    if(A<=ma){cout<<"OK";}else{cout<<"NG";}
    return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>


using namespace std;

typedef long long ll;
typedef long double ld;

ll enable[50][50][400];
int G[50][50];
int dp[50][150];
int n,a[3];


int dfs(int u,int t){
  if(t==150)return 1000000000;
  if(dp[u][t]>=0){
    return dp[u][t];
  }
  if(u==n-1)
    return dp[u][t]=0;

  int ret=0;
  for(int k=0;k<3;k++){
    int res=1000000000;
    for(int i=0;i<n;i++){
      if(i==u)continue;
      if(enable[u][i][a[k]]>0){
          res=min(res,dfs(i,t+1)+1);
      }
    }
    //cout<<u<<" "<<t<<" "<<k<<endl;
    ret=max(res,ret);
  }
  return dp[u][t]=ret;
}

int main(){
  int m;
  cin>>n>>m>>a[0]>>a[1]>>a[2];
  for(int i=0;i<m;i++){
    int u,v;cin>>u>>v;u--;v--;
    G[u][v]=1;
  }
  for(int i=0;i<n;i++){
    enable[i][i][0]=1;
  }
  for(int i=0;i<399;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        for(int t=0;t<n;t++){
          if(enable[j][k][i]&&G[k][t])
            enable[j][t][i+1]=1;
        }
      }
    }
  }
  for(int i=0;i<n;i++)for(int j=0;j<150;j++)dp[i][j]=-1;
  int ans=dfs(0,0);
  if(ans>=1000000000)cout<<"IMPOSSIBLE"<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 10988
#include<stdio.h>

int main(){
 
  int i,j,k,v,N;

  int A[1000];
  

  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  for(k=0;k<N;k++) {
    if(k>0) printf(" ");
    printf("%d",A[k]);
  }
  printf("\n");
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v) {
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<N;k++) {
      if(k>0) printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


void Main() {
    ll N; cin >> N;
    if (N % 2 == 0){
        cout << 0.5 << endl;
    } else {
        cout << (double) (N - (N / 2)) / N << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y,z;
  cin >> x >> y >> z;
  if(x<=y){
    if(y<=z){
      cout << y+x << endl;}
    else{ cout << x+z << endl;}
  }
  else if(x<=z){
    cout << y+x << endl;}
  else{ cout << z+y <<endl;}
}

Measured memory_bytes: 256
num = list(map(int, input().split()))

if num[0]>num[1]:
    num[0], num[1] = num[1], num[0]

if num[1]>num[2]:
    num[1], num[2] = num[2], num[1]

if num[0]>num[1]:
    num[0], num[1] = num[1], num[0]

print(str(num[0])+' '+str(num[1])+' '+str(num[2]))


Measured memory_bytes: 5600
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[3*N];
        for (int i = 0; i < 3*N; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);
        long ans=0;
        int n=3*N-2;
        for(int i=0;i<N;i++){
              ans+=a[n];
              n=n-2;
        }
       System.out.println(ans);
    }
}


Measured memory_bytes: 99440
def islands_war(N: int, M: int, AB: list)->int:
    latest_remvoed = 0
    removed_num = 0
    for a, b in sorted(AB, key=lambda x: x[1]):
        if a <= latest_remvoed:
            continue
        latest_remvoed = b - 1
        removed_num += 1
    return removed_num


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(M)]
    ans = islands_war(N, M, AB)
    print(ans)


Measured memory_bytes: 18940
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
    int num[3];
    for(int i = 0; i < 3; i++){
        scanf("%d", &num[i]);
    }

    int max_num = max(num[0], max(num[1], num[2]));
    
    int a = max_num - num[0];
    int b = max_num - num[1];
    int c = max_num - num[2];

    int sum = a/2 + b/2 + c/2;

    int rem_sum = a % 2 + b % 2 + c % 2;

    if(rem_sum == 1){
        sum += 2;
    }else if(rem_sum == 2){
        sum += 1;
    }

    printf("%d\n", sum);

    return 0;
}



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

const int MAX_N = 101;
const int MAX_W = 114514;
int N,W;

long long int dp[MAX_N][MAX_W];

int main(){
	for(int i=0;i<MAX_W;i++){
		dp[0][i]=0;
	}

	cin>>N>>W;
	for(int i=1;i<N+1;i++){
		int w,v;
		cin >> w >> v;
		for(int j=0;j<W+1;j++){
			if(w>j) dp[i][j]=dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v); 
		}
	}
  /*
	for(int i=0;i<N+1;i++){
		for(int j=0;j<W+1;j++){
			cout << dp[i][j]<< " ";
		}
		cout << endl;
	}*/
	cout << dp[N][W]<< endl;
}


Measured memory_bytes: 90368
#include <stdio.h>

int main(){
	char c;

	scanf("%c", &c);

	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
		printf("vowel\n");
	}else{
		printf("consonant\n");
	}

	return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

	int x, a; 
	cin >> x >> a;

	if (x < a)
		cout << 0;
	else
		cout << 10;





	return 0;	
}

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

int main(void) {
	static char str[200000], strc[200000], strn;
	int cnt0, cnt1, cnt10;
	int i, j, k;
	int ans;

	cnt0 = cnt1 = cnt10 = 0;

	scanf("%s", str);
	strn = strlen(str);

	if (str[0] == '0') {
		for (i = 0; str[i] != '\0'; i++) {
			strc[i] = i % 2 + 0x30;
		}
	}
	else {
		for (i = 0; str[i] != '\0'; i++) {
			strc[i] = (i + 1) % 2 + 0x30;
		}
	}
	strc[i] = '\0';
	//printf("%s\n", strc);
	
	for (i = 0; str[i] != '\0'; i++) {
		if (str[i] != strc[i]) {
			cnt10++;
			if (strc[i] == '0') {
				cnt0++;
			}
			else {
				cnt1++;
			}
		}
	}
	
	ans = (cnt10 - cnt0) + (cnt10 - cnt1);
	

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if (b - a + 1 <= 2 * k) {
        for (int i = a; i <= b; i++) {
            cout << i << endl;
        }
        return 0;
    }
    for (ll i = a; i < a + k; i++) {
        cout << i << endl;
    }
    for (ll i = b - k + 1; i <= b; i++) {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 2020;
const LL INF = 100000000000000LL;
const LL mod = 1e9 + 9;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)


void solve() {
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;
}

int main() {
	int t = 1;
	while(t--) {
		solve();
	}
	int mark_EOF;
	if(scanf("%d", &mark_EOF) == EOF) return 0;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

// UnionFindを示す構造体
struct UnionFind {
  vector<int> par; // 親の番号

  // n要素で初期化する
  // 問題のindexによっては、添字が変化する可能性がある
  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; ++i) par[i] = i;
  }

  // 木の根を求める
  int root(int x) {
    if(par[x] == x) {
      return x; // 根
    } else {
      return par[x] = root(par[x]); // 経路圧縮(根っこを再帰で探る)    
    }
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return; // xとyの根が同じ場合はすでに併合している
    par[rx] = ry;
  }

  bool same(int x, int y) { // x と y が同じ集合に属するか否か
    return root(x) == root(y);
  }
};

int main() {
  int n, q; cin >> n >> q;
  UnionFind uf(n);

  REP(i, q) {
    int a, b, c; cin >> a >> b >> c;
    if(a == 0) {
      uf.unite(b, c);
    } else if(a == 1) {
      int ans = -1;
      if(uf.same(b, c)) ans = 1;
      else ans = 0;
      cout << ans << endl;
    }
  }
}



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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

int main(){
	int a, b;
	std::cin >> a >> b;
	std::cout << ant(a, b) * 2 - (a != b) << std::endl;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string a;
	cin >> a;
	if (a[0] != a[1] and a[1] != a[2] and a[0] != a[2]) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char dt[30],l,r,s;
int n,t[4],k,f,m;
int main(){
	scanf("%d",&n);
	memset(t,0,sizeof(t));
	f=0;
	while(n--){
		scanf("%s",dt);
		s=strlen(dt);
		l=dt[0];
		r=dt[s-1];
		for(int i=1;i<s;i++)if(dt[i]=='B'&&dt[i-1]=='A')f++;
		k=0;
		if(l=='B')k++;
		if(r=='A')k+=2;
		t[k]++;
	}
//		printf("%d\n",f);
	m=t[1]+t[2];
	k=min(t[2],min(t[1],t[3]));
	f+=k<<1;
	t[1]-=k;t[2]-=k;t[3]-=k;
//	printf("%d %d %d\n",t[1],t[2],t[3]);
//	printf("%d\n",f);
	f+=min(t[1],t[2]);
//	printf("%d\n",min(t[1],t[2]));
	if(m)f+=t[3];
	else f+=max(0,t[3]-1);
	printf("%d\n",f);
}

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

int main(){
	int a,b;
	
	cin >> a >> b;

	if (a > b){
		cout << "a > b" << endl;
	}
	else if (a < b){
		cout << "a < b" << endl;
	}
	else{
		cout << "a == b" << endl;
	}

}

Measured memory_bytes: 1156
N=int(input())
S=[input() for i in range(N)]
ac=0
wa=0
tle=0
re=0
for i in S:
  if i=="AC":
    ac+=1
  elif i=="WA":
    wa+=1
  elif i=="TLE":
    tle+=1
  elif i=="RE":
    re+=1
print("AC x"+" "+str(ac))
print("WA x"+" "+str(wa))
print("TLE x"+" "+str(tle))
print("RE x"+" "+str(re))


Measured memory_bytes: 16332
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e){ll ans=1;GG(e<0);while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    struct Matrix
    {
        ll a[2][2];Matrix(){memset(a,0,sizeof a);}
        friend Matrix operator * (Matrix a,Matrix b)
        {
            Matrix c;
            fo(k,0,1) fo(i,0,1) fo(j,0,1) add(c.a[i][j],a.a[i][k]*b.a[k][j]%MOD);
            return c;
        }
        friend Matrix operator ^ (Matrix a,ll e)
        {
            Matrix ans;fo(i,0,1) ans.a[i][i]=1;
            while(e){if(e&1)ans=ans*a;a=a*a;e>>=1;}return ans;
        }
    };
    char mp[2][1100][1100];ll e;int pp;
    int count(int op,int n,int m)
    {
        int cnt=0;
        fo(i,1,n) cnt+=(mp[op][i][1]=='#' and mp[op][i][m]=='#');
        return cnt;
    }
    void solve(int op,int n,int m,int cnt)
    {
        int S=0;fo(i,1,n) fo(j,2,m)S+=(mp[op][i][j-1]==mp[op][i][j] and mp[op][i][j]=='#');
        Matrix A;A.a[0][0]=pp;A.a[0][1]=S;A.a[1][1]=cnt;
        Matrix B;B.a[1][0]=1;B=(A^(e-1))*B;
        write( mm(qpower(pp,e-1)+MOD-B.a[0][0]) );
    }
    void main()
    {
        int n=qread(),m=qread();e=qread();
        if(e<=1) {write(1);return;}
        pp=0;
        fo(i,1,n) {scanf("%s",mp[0][i]+1);fo(j,1,m)mp[1][j][i]=mp[0][i][j],pp+=(mp[0][i][j]=='#');}
        int a=count(0,n,m),b=count(1,m,n);
        if(a and b) puts("1"); else if(!a and !b) write(qpower(pp,e-1));
        else if(a) solve(0,n,m,a); else solve(1,m,n,b);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll p=998244353ll;
const int N=1005;
char a[N][N];
int main(){
	int n,i,j,m;
	scanf("%d",&n);
	if(n<3)puts("-1");
	else{
		if(n==3){
			puts("aab");
			puts("b.b");
			puts("baa");
		}else if(n==5){
			puts("eefii");
			puts("h.fjj");
			puts("hgg.k");
			puts("nm..k");
			puts("nmll.");
		}else if(n==7){
			puts("aabc...");
			puts("b.bc...");
			puts("baadd..");
			puts("ccd..ee");
			puts("..d.xxy");
			puts("...ey.y");
			puts("...eyxx");
		}else{
			for(i=1;i<=n;++i)for(j=1;j<=n;++j)a[i][j]='.';
			m=(n&1)?n-5:n;
			a[1][  1]=a[1][  2]='a';
			a[2][  1]=a[2][  2]='b';
			a[1][m-1]=a[2][m-1]='c';
			a[1][m  ]=a[2][m  ]='d';
			for(i=3;i<=m;i+=2){
				a[i  ][i  ]=a[i  ][i+1]='a';
				a[i+1][i  ]=a[i+1][i+1]='b';
				a[i  ][i-2]=a[i+1][i-2]='c';
				a[i  ][i-1]=a[i+1][i-1]='d';
			}
			if(n&1){
//				puts("eefii");
//				puts("h.fjj");
//				puts("hgg.k");
//				puts("nm..k");
//				puts("nmll.");
				a[n-4][n-4]='e';a[n-4][n-3]='e';a[n-4][n-2]='f';a[n-4][n-1]='i';a[n-4][n]='i';
				a[n-3][n-4]='h';a[n-3][n-3]='.';a[n-3][n-2]='f';a[n-3][n-1]='j';a[n-3][n]='j';
				a[n-2][n-4]='h';a[n-2][n-3]='g';a[n-2][n-2]='g';a[n-2][n-1]='.';a[n-2][n]='k';
				a[n-1][n-4]='n';a[n-1][n-3]='m';a[n-1][n-2]='.';a[n-1][n-1]='.';a[n-1][n]='k';
				a[n  ][n-4]='n';a[n  ][n-3]='m';a[n  ][n-2]='l';a[n  ][n-1]='l';a[n  ][n]='.';
			}
			for(i=1;i<=n;++i)puts(a[i]+1);
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int h, w;
char a[100][101];
char b[100][101];
char c[100][101];

int main() {
	int i, j;
	int cor;
	
	cin >> h >> w;
	rep(i, h) cin >> a[i];
	
	cor = 0;
	rep(i, h) {
		rep(j, w) if (a[i][j] == '#') break;
		if (j == w) continue;
		rep(j, w) b[cor][j] = a[i][j];
		cor++;
	}
	int row = cor;
	
	cor = 0;
	rep(j, w) {
		rep(i, row) if (b[i][j] == '#') break;
		if (i == row) continue;
		rep(i, row) c[i][cor] = b[i][j];
		cor++;
	}
	int col = cor;
	
	rep(i, row) {
		rep(j, col) {
			cout << c[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    string odd = "RUD";
    string even = "LUD";
    bool is_good = true;
    for (int i = 0; i < S.size(); i++)
    {
        if ((i + 1) % 2 == 1 && odd.find(S[i]) != string::npos)
        {
            continue;
        }
        else if ((i + 1) % 2 == 0 && even.find(S[i]) != string::npos)
        {
            continue;
        }
        else
        {
            is_good = false;
        }
    }
    if (is_good)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int i;
  string x = " ";
  string y = " ";
  vector<char> xx;
  vector<char> yy;
  for(i=0;i<s.size();i++) xx.push_back(s[i]);
  for(i=0;i<t.size();i++) yy.push_back(t[i]);
  sort(xx.begin(),xx.end());
  sort(yy.begin(),yy.end());
  for(i=0;i<s.size();i++) x += xx[i];
  for(i=t.size()-1;i>=0;i--) y += yy[i];
  if(x<y) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <functional>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
constexpr int INF = 1LL << 50;
using P = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n; cin >> n;
    int ans = n*(n + 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
def digit_sum(x):
    a = range(1, x)
    min_n = x
    for i in a:
        b = x - i
        p = sum(list(map(int, list(str(i)))))
        q = sum(list(map(int, list(str(b)))))
        if min_n > (p+q):
            min_n = p+q
        if a == b:
            break
    return min_n
N = int(input())
print(digit_sum(N))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int width,height;
	int x,y;
	int direction_x,direction_y;
	int dist;
	char command[100];
	char* token;
	while(1) {
		scanf("%d%d",&width,&height);
		if(width==0 && height==0)break;
		x=y=1;
		direction_x=0;direction_y=1;
		while(1) {
			fgets(command,sizeof(command),stdin);
			token=strchr(command,'\n');
			if(token)*token=0;
			token=strtok(command," ");
			if(token==NULL)token=command;
			if(strcmp(token,"FORWARD")==0) {
				token=strtok(NULL," ");
				if(token)dist=atoi(token); else dist=0;
				x+=direction_x*dist;
				y+=direction_y*dist;
				if(x<1)x=1;
				if(x>width)x=width;
				if(y<1)y=1;
				if(y>height)y=height;
			} else if(strcmp(token,"BACKWARD")==0) {
				token=strtok(NULL," ");
				if(token)dist=atoi(token); else dist=0;
				x-=direction_x*dist;
				y-=direction_y*dist;
				if(x<1)x=1;
				if(x>width)x=width;
				if(y<1)y=1;
				if(y>height)y=height;
			} else if(strcmp(token,"LEFT")==0) {
				if(direction_x!=0) {
					direction_y=direction_x;
					direction_x=0;
				} else if(direction_y!=0) {
					direction_x=-direction_y;
					direction_y=0;
				}
			} else if(strcmp(token,"RIGHT")==0) {
				if(direction_x!=0) {
					direction_y=-direction_x;
					direction_x=0;
				} else if(direction_y!=0) {
					direction_x=direction_y;
					direction_y=0;
				}
			} else if(strcmp(token,"STOP")==0) {
				break;
			}
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;

int main() {

	FAST;

	int n, k;
	cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i ++) {
		int m = i;
		double p = 1;
		while (m < k) {
			m *= 2;
			p /= 2;
		}
		ans += p / n;
	}
	cout << setprecision(9) << fixed << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 n;
	cin >> n;
	if(n >= 64) cout << 64 << endl;
	else if(n >= 32) cout << 32 << endl;
	else if(n >= 16) cout << 16 << endl;
	else if(n >= 8) cout << 8 << endl;
	else if(n >= 4) cout << 4 << endl;
	else if(n >= 2) cout << 2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 3600
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let odd_count = a.iter().filter(|&&x| x % 2 == 0).count();
    let ans = 3i64.pow(n as u32) - 2i64.pow(odd_count as u32);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main()
{
	int n;
	while (cin >> n)
	{
		int ans = 0;
		for (int a = 0; a < 10; a++){
		for (int b = 0; b < 10; b++){
		for (int c = 0; c < 10; c++){
		for (int d = 0; d < 10; d++){
			if (a + b + c + d == n) ans++;
		}}}}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.math.BigInteger;

class Main
{
	public static void main( String[] args ) throws IOException
	{
		BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );

		int n;
		n = Integer.parseInt( reader.readLine() );
	
		for ( int i = 0; i < n; i++ )
		{
			BigInteger a, b, res;
			String in;

			in = reader.readLine();
			a = new BigInteger( in );

			in = reader.readLine();
			b = new BigInteger( in );

			res = a.add( b );

			String str = res.toString();

			if ( str.length() <= 80 )
			{
				System.out.println( a.add( b ) );
			}
			else
			{
				System.out.println( "overflow" );
			}
		}
	}
}

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

int main() {
  long X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  long A = X / D;
  A = min(A, K);
  long NX = X - A * D;
  long NK = K - A;
  if (!NK) return cout << NX << "\n", 0;
  cout << ((NK % 2) ? D - NX : NX) << "\n";
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

//const
#define EPS 1e-8
#define EQ (abs((a) - (b)) < EPS)
#define EQP(a, b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

inline int signum(double x) { return (abs(x) < EPS) ? 0 : (x > 0) ? 1 : -1; }

//-----definition-----
typedef complex<double> P;

//-----standard-----
pair<P, P> norm_vec(P a) {
    return make_pair(a * P(0, 1), a * P(0, -1));
}

P unit_vec(P a) { a / abs(a); }

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    int sign = signum(cross(b, c));
    if (sign != 0) return sign;
    if (signum(dot(b, c)) < 0) return 2;//left
    if (abs(b) < abs(c)) return -2;//right
    return 0; //mid
}

//-----line-----
bool is_paral(P a1, P a2, P b1, P b2) {
    return signum(cross(a2 - a1, b2 - b1)) == 0;
}

bool is_orth(P a1, P a2, P b1, P b2) {
    return signum(dot(a2 - a1, b2 - b1)) == 0;
}

bool is_p_on_li(P a, P b, P c) {
    b -= a;
    c -= a;
    return signum(cross(b, c)) == 0;
}

bool is_p_on_li_s(P a, P b, P c) {
    return abs(c - a) + abs(b - c) < abs(b - a) + EPS;
}

double dis_p_li(P a, P b, P c) {
    b -= a;
    c -= a;
    return abs(cross(b, c)) / abs(b);
}

double dis_p_li_ss(P a, P b, P c) {
    P x1 = b - a;
    P y1 = c - a;
    P x2 = a - b;
    P y2 = c - b;
    if (cross(x1, y1) < EPS) return abs(y1);
    if (cross(x2, y2) < EPS) return abs(y2);
    return dis_p_li(a, b, c);
}

bool is_inter_li_ss(P a1, P a2, P b1, P b2) {
    return (ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0) && (ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0);

}

int main() {

    int Q;
    cin >> Q;

    while (Q--) {

        vector<P> p(4);
        for (int i = 0; i < 4; i++) {
            double x, y;
            cin >> x >> y;
            p[i] = P(x, y);
        }

        if (is_inter_li_ss(p[0], p[1], p[2], p[3])) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }

    }

}














































Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl;
#define y() cout << "Yes" << endl;
#define n() cout << "No" << endl;
using lint = long long;
using vi = vector<int>;

int main() {
	int N;
	cin >> N;
	vector<string> str(N);
	vector<string> st;
	string s;
	map<string, int> count;

	rep(i, N) {
		cin >> s;
		str[i] = s;
		if (!count.count(s)) {
			count[s] = 1;
			st.push_back(s);
		}
		else {
			count[s]++;
		}
	}
	int max = 0;
	vector<string> stri;
	rep(i, st.size()) {
		if (count[st[i]] > max) {
			while (stri.size()) {
				stri.pop_back();
			}
			stri.push_back(st[i]);
			max = count[st[i]];
		}
		else if (count[st[i]] == max) {
			stri.push_back(st[i]);
		}
	}
	sort(stri);
	rep(i, stri.size()) {
		cou(stri[i])
	}
}

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

int main() {
	int n,a[1000000];
	cin >> n;
	for(int i=1;i<=n;i++)cin>>a[i];
	a[0]=0;
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
     for(int i=3;i<=n;i++){
      dp[i]=min(dp[i-1]+(abs(a[i]-a[i-1])),dp[i-2]+abs(a[i]-a[i-2])); 
     // cout<<dp[i]<<" ";
    }
   // for(int i=1;i<=n;i++)cout<<dp[i]<<" ";
    cout<<dp[n];
	return 0;
}


Measured memory_bytes: 4416
#include <stdio.h>

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

    int k;
    scanf("%d", &k);

    int x[n];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &x[i]);

    int min;
    int sum = 0;
    for (i = 0; i < n; i++) {
        if (x[i] >= k - x[i])
            min = 2 * (k - x[i]);
        else
            min = 2 * x[i];
        sum += min;
    }

    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void){

  long n, m;
  cin >> n >> m;

  if (abs(n - m) >= 2) {
      printf("0 \n");
      return 0;
  }

  long facn, facm;

  facn = 1; facm = 1;

  for (long i = 1; i <= n; i++) {
      facn = (facn * i) % (1000000000+7);
  }

  for (long i = 1; i<= m; i++) {
      facn = (facn * i) % (1000000000+7);
  }

  long ans = 0;
  if (abs(n - m) == 0) {
      ans = (facn * facm * 2 ) % (1000000000+7);
  } else if (abs(n-m) == 1) {
      ans = (facn * facm) % (1000000000+7);
  }


  printf("%lu \n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, R;
    cin >> N >> R;
    if(N >= 10) output(R);
    else output(R + (10 - N) * 100);
    
    return 0;
}


Measured memory_bytes: 256