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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< int > C(N);
  vector< int > S(N);
  vector< int > F(N);
  REP(i, N - 1) {
    cin >> C[i] >> S[i] >> F[i];
  }

  int tm;
  REP(i, N - 1) {
    tm = 0;
    FOR(j, i, N - 1) {
      if (tm < S[j]) {
	tm = S[j];
      } else {
	if (tm % F[j] != 0) {
	  tm += F[j] - tm % F[j];
	}
      }
      tm += C[j];
    }
    cout << tm << endl;
  }

  cout << 0 << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;



//Round one 

int main()
{
	int a,b;

	cin >> a >> b;


	cout << 6 - a - b << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var k = int.Parse(Console.ReadLine());
            var queue = new Queue<long>();
            for (var i = 1; i < 10; i++)
            {
                queue.Enqueue(i);
            }

            for (var i = 1; i <= k; i++)
            {
                var x = queue.Dequeue();
                if (i == k) Console.WriteLine(x);

                if (x % 10 != 0) queue.Enqueue((x * 10) + (x % 10) - 1);
                queue.Enqueue((x * 10) + (x % 10));
                if (x % 10 != 9) queue.Enqueue((x * 10) + (x % 10) + 1);
            }
        }
    }
}


Measured memory_bytes: 17120
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  long long X, a, b, surplus, happy;
  cin >> X;

  a = int(X/500);
  surplus = X - 500*a;
  b = int(surplus/5);

  happy = 1000 * a + 5 * b;
  cout << happy;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=3e2+10,mod=1e9+7;
int n;
bool a[22][22];
ll dp[22][1<<21];

ll solve(int i,int mask){
    if(i==n)return 1;
    ll &ret=dp[i][mask];
    if(ret+1)return ret;
    ret = 0;
    for(int j=0;j<n;j++){
        if(a[i][j]==1 && (mask&(1<<j))==0){
            ret += solve(i+1,mask^(1<<j));
            ret %= mod;
        }
    }
    return ret;
}

int main()
{
    FASTIO
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
        }
    }
    cout << solve(0,0) << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 360704
num = [int(i) for i in input().split()]
coefficient = [int(i) for i in input().split()]
source_code_set = [[int(i) for i in input().split()]for j in range(num[0])]
sum = 0
count = 0

for i in range(num[0]):
    for j in range(num[1]):
        sum += source_code_set[i][j] * coefficient[j]
    if sum + num[2] > 0:
        count += 1
    sum = 0

print(count)


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


int main (){

    string A,B;
    cin >> A >> B;

    if(A.size() > B.size()) {
        cout << "GREATER" << endl;
    }else if(A.size() < B.size()) {
        cout << "LESS" << endl;
    }else if(A > B) {
        cout << "GREATER" << endl;
    }else if(A < B) {
        cout << "LESS" << endl;
    }else {
        cout << "EQUAL" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    s = [1]*n
    f = [0]*n
    f[0] = 1
    for _ in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        s[a] -= 1
        s[b] += 1
        if f[a]:
            f[b] = 1
            if s[a] == 0:
                f[a] = 0
    print(sum(f))
    return

#Solve
if __name__ == "__main__":
    solve()


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

typedef long long ll;
typedef pair<int,int> P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i = 1;i <= (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);

int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    int maxx=-1;
    for(int i=2;i<=32;i++){
        int beki=2;
        int tmp;
        if((int)pow(i,beki)<=n)
        {//cout<<(int)pow(i,beki)<<endl;
            while((int)(pow(i,beki)<=n)){beki++;}tmp=pow(i,--beki);
            //printf("i=%d,beki=%d,tmp=%d\n",i,beki,tmp);
        }
        if(tmp>maxx)maxx=tmp;
    }
    cout<<((n==1)?1
           :maxx)<<endl;
}



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;

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int q,x,n;
    string query;
    cin >> n;
    vector<int> vec;
    rep(i,n){
        cin >> q;
        if(q == 0){
            cin >> x;
            vec.push_back(x);
        }else if(q==1){
            cin >>x;
            cout << vec[x] <<endl;
        }else if(q==2){
            vec.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 3784
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.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 main()
{
  ll N,M; cin>>N>>M;
  vector<vector<ll>> vec(N,vector<ll>(3)); rep(i,N) rep(j,3) cin>>vec[i][j];
  
  ll ans=-INF;
  rep(S,1<<3){
    vector<ll> svec(N);
    rep(i,N){
      ll ele=0;
      rep(j,3){
        if(S&(1<<j)) ele+=vec[i][j];
        else ele-=vec[i][j];
      }
      svec[i]=ele;
    }
    sort(svec.rbegin(),svec.rend());
    ll sans=0;
    rep(i,M) sans+=svec[i];
    chmax(ans,sans);
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int res=1e9;
  int tmp;
  for(int i=-100;i<=100;i++){
    tmp=0;
    for(int j=0;j<n;j++){
      tmp+=(a[j]-i)*(a[j]-i);
    }
    res=min(res,tmp);
  }
  cout <<res<<endl;
  return 0;
}


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

using namespace std;
#define ll long long
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define _all(a) a.begin(), a.end()

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int inf = 1e9 + 7;
const ll linf  = 1ll * inf * inf;
const int N = 51;
const int M = 51;
const int multipleTest = 0;

bool dp[N][N];
int n;
int a[N], b[N];

bool build(int mx, vector<int>& must) {
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < N; ++i) {
		dp[i][i] = 1;
		rep(j, 1, mx) dp[i][i % j] = 1;
		for (int x : must) dp[i][i % x] = 1;
	}
	
	for (int k = 0; k < N; ++k) {
		for (int u = 0; u < N; ++u) {
			for (int v = 0; v < N; ++v) dp[u][v] |= dp[u][k] & dp[k][v];
		}
	}
	
	bool can = true;
	for (int i = 0; i < n; ++i) can &= dp[a[i]][b[i]];
	return can;
}

void solve() {
	cin >> n;
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) cin >> b[i];
	
	vi must;
	
	for (int i = 50; i > 0; --i) {
		if (!build(i, must)) must.push_back(i);
	}
	ll res = 0;
	for (int x : must) res |= 1ll << x;
//	cout << res;
	if (res == 2251799813685246ll) res = -1;
	cout << res;
}

int main() {
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
	//    freopen("out.txt", "w", stdout);
#endif
	int Test = 1;
	if (multipleTest) {
		cin >> Test;
	}
	for(int i = 0; i < Test; ++i) {
//		printf("Case #%d: ", i + 1);
		solve();
	}
#ifdef _LOCAL_
		cout << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

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

  vector<int> v;
  each(i, 101) {
    if (i == 0)
      continue;

    if ( (a % i == 0) &&  (b % i == 0) ) {
      v.push(i);
    }
  }

  sort_desc(v);
  cout << v[k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,X = map(int,read().split())

def F(A,B):
    # (A,B)の平行四辺形の120度の対角から出た状態
    if A > B:
        A,B = B,A
    q,r = divmod(B,A)
    if not r:
        return A * (q+q-1)
    return F(A,r) + q * (2 * A)

answer = N + F(X,N-X)
print(answer)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	string a, b;
	cin >> a >> b;
	if (b.substr(0, sz(a)) == a) {
		cout << "Yes" << endl;

	}
	else {
		cout << "No" << endl;
	}
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

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()
{
	long long l, r;
	cin >> l >> r;

	r = min(r, l + 2019 * 2);

	long long ans = INT_MAX;
	for (long long i = l; i < r; i++)
	{
		for (long long j = i + 1; j <= r; j++)
		{
			ans = min(ans, (i * j) % 2019);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int N,M;
  cin>>N>>M;
  VI A(M),B(M);
  rep(i,M) cin>>A[i]>>B[i];
  VVI X(N,VI(0));
  rep(i,M){
    X[A[i]-1].pb(B[i]-1);
    X[B[i]-1].pb(A[i]-1);
  }
  VI Y(N,-1);
  Y[0]=0;
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int now=Q.front();
    Q.pop();
    rep(i,X[now].size()){
      int nxt=X[now][i];
      if(Y[nxt]==-1){
        Y[nxt]=now+1;
        Q.push(nxt);
      }
    }
  }
  rep(i,N){
    if(Y[i]==-1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  rep(i,N-1) cout<<Y[i+1]<<endl;
}


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


int main()
{
	int n, x, k, t = 0;
	
	while (true)
	{
		cin >> n >> x;

		if (n == 0 && x == 0) {
			break;
		}
		else if (x > 3 * n - 3) {
			cout << 0 << endl;
			continue;
		}

		for (int i = 1;i <= n;i++) {
			if (i > x - 3) {
				break;
			}
			for (int j = i + 1;j <= n;j++) {
				if (j > x - 3) {
					break;
				}
				
				k = x - i - j;
				if (k <= j || k > n) {
					continue;
				}

				t++;
			}
		}

		cout << t << endl;
		t = 0;
	}

    return 0;
}



Measured memory_bytes: 3084
P = 998244353

def val(x):
	return (x+P)%P

n, k = map(int,input().split())
plages = []
for _ in range(k):
	x,y=map(int,input().split())
	plages+=[[x,y]]
#plages.sort()

pref = [0]*(n+1)
ans = [0]*(n+1)
ans[1] = pref[1] = 1

for i in range(2,n+1):
	for p in plages:
		l = max(0,i-p[1])
		r = max(0,i-p[0])
		add= 0
		if l==0 and r==0:add=0
		elif l==0: add = pref[r]
		else:
			add = val(pref[r]-pref[l-1])
		# ~ print("i = ",i,"p = ",p,"l = ",l, "r = ",r, "add = ",add)
		ans[i] += add
		ans[i]%=P
	pref[i] = pref[i-1]+ans[i]
	pref[i]%=P
	
# ~ print("pref : ",pref)
# ~ print("ans  : ",ans)

print(ans[n])


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

using namespace std;

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
int main()
{
    // #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
    fio;
    ll n;
    cin>>n;
    set<string> s;
    forin(i,0,n-1)
    {
        string s1;
        cin>>s1;
        s.insert(s1);
    }
    cout<<s.size()<<endl;
    
    return 0;
}

Measured memory_bytes: 19244
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main(void) {
	int x, y;
	int ans;

	cin >> x >> y;

	if (x > 0) {
		if (y > x) ans = y - x;
		else if (y == x) ans = 0;
		else if (y > 0) ans = 2 + x - y;
		else if (y == 0) ans = 1 + x;
		else if (y > -x) ans = 1 + x + y;
		else ans = 1 - y - x;
	}
	else if (x == 0) {
		if (y >= 0) ans = y;
		else ans = 1 - y;
	}
	else {
		if (y >= -x) ans = 1 + y + x;
		else if (y > 0) ans = 1 - x - y;
		else if (y == 0) ans = -x;
		else if (y > x)ans = y - x;
		else ans = 2 + x - y;
	}

	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
n, k = gets.chomp.split(" ").map(&:to_i)

if n % 2 < 1 && n / 2 >= k
  print("YES\n")
else
  if  n % 2 > 0 && n / 2 + 1 >= k
    print("YES\n")
  else
    print("NO\n")
  end
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int h, w;
    cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = min(h, w);
    for(int x = 1; x < h; ++x){
        ll S1 = (ll)x * w;
        ll S2 = (ll)(h - x) * (w / 2);
        ll S3 = (ll)(h - x) * (w - w / 2);
        chmin(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
    }
    for(int x = 1; x < w; ++x){
        ll S1 = (ll)x * h;
        ll S2 = (ll)(w - x) * (h / 2);
        ll S3 = (ll)(w - x) * (h - h / 2);
        chmin(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int B[100];

void solve() {
  int N; cin >> N;
  int ans = 0;
  REP1(i, N-1) {
    cin >> B[i];
    if (i == 1) {
      ans += B[1];
    } else {
      ans += min(B[i-1], B[i]);
    }
  }
  ans += B[N-1];
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h> 
 
using namespace std;
 
 
#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")
#define         FILEIN                     freopen("in.txt","r",stdin)
#define         FILEOUT                    freopen("out.txt","w",stdout)

int main(){
    string s;
    cin>>s;
    if(s=="SAT"){
        printf("1");
    }
    else if(s=="SUN"){
        printf("7");
    }
    else if(s=="MON"){
        printf("6");
    }
    else if(s=="TUE"){
        printf("5");
    }
    else if(s=="WED"){
        printf("4");
    }
    else if(s=="THU"){
        printf("3");
    }
    else {
        printf("2");
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline


class SEGMENT_TREE:
    def __init__(self, N):
        self.N = N
        inf = (1 << 31) - 1
        self.inf = inf
        self.tree = [inf] * (2 * N + 1)  # 問題により修正

    def init(self, arr):
        N = self.N
        for i in range(N):
            self.tree[N + i] = arr[i]
        for i in range(N - 1, 0, -1):
            self.tree[i] = self.tree[i * 2] + self.tree[i * 2 + 1]  # 問題により修正

    def update(self, p, value):
        """配列arr[p]をvalueに変更"""
        i = p + self.N
        self.tree[i] = value
        while i > 1:
            self.tree[i // 2] = min(self.tree[i], self.tree[i ^ 1])
            i //= 2

    def query(self, l, r):
        """
        l, r: 0-indexed
        半開区間[l, r)から条件を満たす数を返す
        """
        N = self.N
        res = self.inf   # 問題により修正
        l += N
        r += N
        while l < r:
            if (l & 1):
                res = min(res, self.tree[l])
                l += 1
            if (r & 1):
                r -= 1
                res = min(res, self.tree[r])
            l //= 2
            r //= 2
        return res


if __name__ == "__main__":
    N, Q = map(int, input().split())
    seg = SEGMENT_TREE(N)

    ans = []

    for _ in range(Q):
        com, x, y = map(int, input().split())
        if com:
            ans.append(seg.query(x, y+1))
        else:
            seg.update(x, y)

    print(*ans, sep="\n")



Measured memory_bytes: 9868
n = int(input())
dic = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(n):
  s = input()
  dic[s] += 1
  
for s in ('AC', 'WA', 'TLE', 'RE'):
  print(s + ' x ' + str(dic[s]))

Measured memory_bytes: 9164
fun main(arr:Array<String>) {
    val (k,n) = readLine()!!.split(" ").map { it.toInt() }
    val houses = readLine()!!.split(" ").map { it.toInt() }
    val space = mutableListOf(houses.first() + k - houses.last())
    space.addAll((1 until n).map { houses[it] - houses[it-1] })
    val ans = k - space.max()!!
    println(ans)
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int a[N], max;
  max = 0;
  for(int i=0; i < N; ++i) {
    cin >> a[i];
    max += a[i];
  }
  int count = 0;
  double b = 0;
  b = (double) max / (4 * M);
  for(int j=0; j < N; ++j) {
    if(b <= a[j]) ++count;
  }
  if(count >= M) cout << "Yes";
  if(count < M) cout << "No";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    cout << (in() - 2) * 180 << endl;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
int pp(int n) {
  return n*n*n*n*n;
}
/***** MAIN *****/
signed main() {
  int n = in();
  REP(a,1000) {
    REPS(b,-1000,1000) {
      if(pp(a)-pp(b)==n) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3640
(* O(|s|) *)
let s = read_line ()
let i = ref @@ String.length s - 1
let ws = [|"dream"; "dreamer"; "erase"; "eraser"|]
let _ =
  while !i >= 0 do
    let f b w =
      if b then b
      else
        let m = String.length w in
        if String.sub s (max 0 @@ !i - m + 1) @@ m = w then (i := !i - m; true) else b in
    if not @@ Array.fold_left f false ws then (print_endline "NO"; exit 0) done;
  print_endline "YES"

Measured memory_bytes: 1280
import sys
readline = sys.stdin.readline


def main():
    S = readline().rstrip()
    T = readline().rstrip()

    N, M = len(S), len(T)
    dp = [[0] * (M+1) for _ in range((N+1))]
    dp[0] = [i for i in range(M+1)]
    for i in range(N+1):
        dp[i][0] = i
    
    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if s == t:
                dp[i+1][j+1] = dp[i][j]
            else:
                dp[i+1][j+1] = min(dp[i][j], dp[i+1][j], dp[i][j+1]) + 1

    print(dp[N][M])


if __name__ == '__main__':
    main()


Measured memory_bytes: 41852
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAx = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAx, min_index = -1;

typedef long long ll;
typedef pair<ll, ll> Pa;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}
int main() {
    cin >> A >> B;
    cout << lcm(A, B);
}


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

char s[10005];
int main(void) {
	scanf("%s", s);
	int flaga = 0, flagb = 0, flagc = 0;
	for(int i = 0; i < 3; ++i) {
		if (s[i] == 'a') flaga = 1;
		if (s[i] == 'b') flagb = 1;
		if (s[i] == 'c') flagc = 1;
	}
	// printf("%d%d%d", flaga, flagb, flagc);
	if (flaga + flagb + flagc == 3) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

char arr[M][M];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int bestX[M][M], bestY[M][M];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, m;
  vector<pair<int, int>> vv;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> arr[i][j];
      if(arr[i][j] == '.')
        vv.push_back({i, j});
    }
  }
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    for (int j = 0; j < m; ++j) {
      if(arr[i][j] == '#') {
        if(cur) {
          int temp = cur;
          bestX[i][j - temp] = temp;
          while(cur--) {
            if(!cur)
              break;
            bestX[i][j - cur] = temp;
          }
        }
        cur = 0;
        continue;
      }
      ++cur;
    }
    int temp = cur;
    if(cur > 0) {
      bestX[i][m - temp] = temp;
    }
    while(cur--) {
      if(cur <= 0)
        break;
      bestX[i][m - cur] = temp;
    }
  }
  for (int i = 0; i < m; ++i) {
    int cur = 0;
    for (int j = 0; j < n; ++j) {
      if(arr[j][i] == '#') {
        if(cur) {
          int temp = cur;
          bestY[j - temp][i] = temp;
          while(cur--) {
            if(!cur)
              break;
            bestY[j - cur][i] = temp;
          }
        }
        cur = 0;
        continue;
      }
      ++cur;
    }
    int temp = cur;
    if(cur > 0) {
      bestY[0][i] = temp;
    }
    while(cur--) {
      if(cur <= 0)
        break;
      bestY[n - cur][i] = temp;
    }
  }
  int best = 0;
//  cerr << bestX[1][1] << ' ' << bestY[1][1];

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      best = max(best, bestX[i][j] + bestY[i][j] - 1);
    }
  }
  cout << best;
  return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 205;
int main()
{
    FAST
    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        string s;
        cin>>s;
        ll ans=0;
        for(i=0; i<s.size(); i++)
        {
            if(s[i]=='R')
            {
                j=i;
                ll cnt=0;
                while(j<3 && s[j]=='R')
                {
                    cnt++;
                    j++;
                }
                ans=max(ans,cnt);
                i=j-1;

            }
        }
        cout<<ans;
    }
    return 0;
}





Measured memory_bytes: 3596
//https://agc027.contest.atcoder.jp/tasks/agc027_c
#include<bits/stdc++.h>

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


using V=vector<int>;
using VV = vector<V>;
int main() {
    int N,M;
    string s;
    cin>>N>>M>>s;
    VV g(N*4);
    const int AA=0,AB=N,BA=N+N,BB=N+N+N;
    for(int i:range(M)){
        int u,v;
        cin>>u>>v;
        u--;v--;
        if(s[u]!=s[v]){
            if(s[u]>s[v])swap(u,v);
            g[AB+u].push_back(BB+v);
            g[BA+v].push_back(AA+u);
        }
        else{
            if(s[u]=='A'){
                g[AA+u].push_back(AB+v);
                g[AA+v].push_back(AB+u);
            }
            else{
                g[BB+u].push_back(BA+v);
                g[BB+v].push_back(BA+u);
            }
        }
    }
    queue<int> que;
    V in(4*N);
    
    for(int f:range(4*N)){
        for(int t:g[f]){
            in[t]++;
        }
    }
    for(int i:range(4*N)){
        if(in[i]==0)que.push(i);
    }
    while(que.size()){
        int v=que.front();que.pop();
        for(int u:g[v]){
            in[u]--;
            if(in[u]==0)que.push(u);
        }
    }

    for(int i:range(4*N)){
        if(in[i]!=0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 30928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
vector<ll> ans;
ll dp[0][0];

int main()
{
ll x,y,z,k;

cin >> x>>y>>z>>k;
ll tabx[x]={};
rep(i,x) {
    cin >> tabx[i];
}
ll taby[y]={};
rep(i,y) {
    cin >> taby[i];
}
ll tabz[z]={};
rep(i,z) {
    cin >> tabz[i];
}
/* sort(tabx, tabx + x);
sort(taby, taby + y);
sort(tabz, tabz + z);
 */
ll sum[x*y];
rep(i,x)rep(j,y){
    sum[i*y+j]=tabx[i]+taby[j];
}
sort(sum, sum + x*y, greater<ll>());
ll kk=k;
if(k>x*y){
    kk=x*y;
}
rep(i,kk)rep(j,y){
    ans.push_back(sum[i]+tabz[j]);
}

sort(ans.rbegin(), ans.rend());
rep(i,k){
cout << ans[i]<< endl;
}

return 0;
}





Measured memory_bytes: 42980
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		long m = stdIn.nextInt();
		long n = stdIn.nextInt();
		long k = m;
		for(int i=2;i<=n;i++){
			k = k * m;
			if(k>1000000007){
				k = k % 1000000007;
				long y = k;
				for(long j=2;j<=n/i;j++){
					k = (k*y)%1000000007;
				}
				for(long j=1;j<=n%i;j++){
					k = (k*m)%1000000007;
				}
				break;
			}
		}
		System.out.println(k);
	}

}

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

const int MAX_N = (int)(1e5 + 5);

int n, k;
int a[MAX_N];

int minind;

int ans = MAX_N;

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

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

  for (int i = 0; i < k; ++i) {
    int right = max(0, (n - 1) - minind - i);
    int left = max(0, minind - (k - 1) + i);
    int rscore = ceil((double)(right) / (double)(k - 1));
    int lscore = ceil((double)(left) / (double)(k - 1));
    ans = min(ans, rscore + lscore + 1);
  }

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

  return 0;
}

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

ans = 0
cur = 0
for i in range(1, len(A)):
    if (A[i-1] >= A[i]):
        cur += 1
    else:
        ans = max(ans, cur)
        cur = 0
else:
    ans = max(ans, cur)
print(ans)


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

using namespace std;

// Returns 1 if the i-th bit of x is set, 0 otherwise.
#define BIT_SET(x, i) (((x) & (1<<(i))) != 0)
// Sets the i-th bit of x to 1
#define SET_BIT(x, i) ((x) | (1<<(i)))
// Sets the i-th bit of x to 0
#define UNSET_BIT(x, i) ((x) & ~(1<<(i)))

class Task {
    public:
        void solve(istream& in, ostream& out) {
        	vector<vector<int>> A(3);
        	A[0].resize(3);
        	A[1].resize(3);
        	A[2].resize(3);
        	in >> A[0][0]>>A[0][1]>>A[1][1];

        	for (int j = 0; ; j++) {
        		if (challenge(A, j)) {
        			int s = A[0][0]+A[0][1]+j;
        			A[0][2] = j;
					fill20(s, A);
		        	fill10(s, A);
		        	fill12(s, A);
		        	fill21(s, A);
		        	fill22(s, A);
        			out << A[0][0] << " " << A[0][1] << " " << A[0][2] << endl;
        			out << A[1][0] << " " << A[1][1] << " " << A[1][2] << endl;
        			out << A[2][0] << " " << A[2][1] << " " << A[2][2] << endl;
        			return;
        		}
        	}
        }

        bool challenge(const vector<vector<int>>& A, int j) {
        	int s = A[0][0]+A[0][1]+j;
        	vector<vector<int>> B(3);
        	B[0].resize(3);
        	B[1].resize(3);
        	B[2].resize(3);
        	B[0][0] = A[0][0];
        	B[0][1] = A[0][1];
        	B[1][1] = A[1][1];
        	B[0][2] = j;
        	fill20(s, B);
        	fill10(s, B);
        	fill12(s, B);
        	fill21(s, B);
        	fill22(s, B);
        	return check(s, B);
        }

        bool check(int s, const vector<vector<int>>& A) {
        	return (A[0][0]+A[0][1]+A[0][2]==s)
        		&& (A[1][0]+A[1][1]+A[1][2]==s)
        		&& (A[2][0]+A[2][1]+A[2][2]==s)
        		&& (A[0][0]+A[1][0]+A[2][0]==s)
        		&& (A[0][1]+A[1][1]+A[2][1]==s)
        		&& (A[0][2]+A[1][2]+A[2][2]==s)
        		&& (A[0][0]+A[1][1]+A[2][2]==s)
        		&& (A[0][2]+A[1][1]+A[2][0]==s);
        }
        
        void fill12(int s, vector<vector<int>>& B) {
			B[1][2] = s - B[1][0] - B[1][1];
		}

		void fill21(int s, vector<vector<int>>& B) {
			B[2][1] = s - B[0][1] - B[1][1];
		}

		void fill22(int s, vector<vector<int>>& B) {
			B[2][2] = s - B[0][0] - B[1][1];
		}

        void fill10(int s, vector<vector<int>>& B) {
			B[1][0] = s - B[0][0] - B[2][0];
		}

        void fill20(int s, vector<vector<int>>& B) {
			B[2][0] = s - B[0][2] - B[1][1];
		}

} task;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    task.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n=1000001;
    vector<int> dp(n,inf),dp2(n,inf);
    dp[0]=dp2[0]=0;
    vector<int> a;
    rep(i,300){
        int x=(i+1)*(i+2)*(i+3)/6;
        if(x>n)break;
        a.push_back(x);
    }
    rep(i,a.size()){
        rep(j,n)if(j+a[i]<n)dp[j+a[i]]=min(dp[j+a[i]],dp[j]+1);
        if(a[i]%2==0)continue;
        rep(j,n)if(j+a[i]<n)dp2[j+a[i]]=min(dp2[j+a[i]],dp2[j]+1);
    }
    int x;
    while(cin>>x,x!=0){
        cout<<dp[x]<<" "<<dp2[x]<<endl;
    }
    return 0;
}


Measured memory_bytes: 10536
#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, K;
  cin >> N >> K;
  vector<int> P(N);
  rep(i,N) cin >> P.at(i);
  sort(P.begin(), P.end());
  
  int ans = 0;
  rep(i, K) {
    ans +=P.at(i);
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007

using namespace std;

int total_path(char c[1002][1002],int n,int m) {
	// bottom up dp
	int dp[n][m];
	
	int f=0;
	// if there is single columm than max path would be 1 if there is empty square else 0
	for(int i=n-1;i>=0;i--) {
		if(c[i][m-1] == '.' && f == 0) {
			dp[i][m-1] = 1;
		}
		else {
			dp[i][m-1] = 0;
			f = 1;
		}
	}
	
	f=0;
	// if there is single row than max path would be 1 if there is empty square else 0
	for(int i=m-2;i>=0;i--) {
		if(c[n-1][i] == '.' && f == 0) {
			dp[n-1][i] = 1;
		}
		else {
			dp[n-1][i] = 0;
			f = 1;
		}
	}
	
	for(int i=n-2;i>=0;i--) {
		for(int j=m-2;j>=0;j--) {
			if(c[i][j] == '.') {
				// calculate from right and down path
				ll temp;
				temp = (dp[i+1][j]+ dp[i][j+1])%mod;
				dp[i][j] = temp;
			}
			else {
				dp[i][j] = 0;
			}
		}
	}
	
	// return total path from position 0
	return dp[0][0];
}

void input() {
	int h,w;
	cin>>h>>w;
	
	char c[1002][1002];
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			cin>>c[i][j];
		}
	}
	
	int ans = total_path(c,h,w);
	
	cout<<ans;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	input();
	
	return 0;
}


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

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e18;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


vector<double>  w, p;
vector<double>  q;


int main() {

  ll N, K;
  int count = 0;
  cin >> N >> K;

  while(N > 0){
    N /= K;
    count++;
  }
  cout << count << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
H,W,M = map(int,input().split())
listh = [0] * H
listw = [0] * W
s = set()
for i in range(M):
    hm,wm = map(int,input().split())
    listh[hm-1] += 1
    listw[wm-1] += 1
    s.add((hm-1,wm-1))
mh = max(listh)
mw = max(listw)
maxh = [i for i,v in enumerate(listh) if v == mh]
maxw = [i for i,v in enumerate(listw) if v == mw]

import sys
for i in maxh:
    for j in maxw:
        if (i,j) not in s:
            print(mh + mw)
            sys.exit()
print(mh + mw - 1)

Measured memory_bytes: 83560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    bool flag=true;
    for(int i=0; i<s.size(); i++){
        if(i%2==1){
            if((s[i]=='L'|| s[i]=='U'|| s[i]=='D')){
                flag = true;
            }else{
                flag = false;
                break;
            }
        }

        if(i%2==0){
            if((s[i]=='R'|| s[i]=='U'|| s[i]=='D')){
                flag = true;
            }else{
                flag = false;
                break;
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int t, n, m;
string s;

int32_t main()
{
	IOS;
	cin >> s;
	rep(i, 0, s.length())
	{
		if (s[i] == '7')
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3652