akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        switch(s){
            case "Sunny":
                System.out.println("Cloudy");
                break;
            case "Cloudy":
                System.out.println("Rainy");
                break;
            case "Rainy":
                System.out.println("Sunny");
                break;
            default:

        }


    }
}


Measured memory_bytes: 21716
// https://atcoder.jp/contests/abc159/tasks/abc159_e
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;


#define MAX_H 11
#define MAX_W 1005
const int INF = 1e9;
bool fld[MAX_H][MAX_W];
int count_bit(int bits){
	// 2進数表記時の1の数を数える
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);	
}
int main() {
	int h,w,K;
	cin >> h >> w >> K;
	rep(i,h){
		string s;
		cin >> s;
		rep(j,w) fld[i][j] = s[j]=='1';
	}
	int ans = INF;
	int block_n[MAX_H]; // ブロックごとのホワイトチョコの数
	rep(S,1<<(h-1)){
		int cut_n=0;
		int bn = count_bit(S)+1;
		rep(i,bn)block_n[i]=0;
		bool impossible=false;
		rep(j,w){
			int block_i=0;
			int cur_block_n[MAX_H];
			bool do_cut=false;
			rep(k,bn)cur_block_n[k]=0;
			rep(k,h){
				cur_block_n[block_i] += (int)fld[k][j];
				if(cur_block_n[block_i]>K){
					impossible = true;
					break;
				}
				if(S>>k&1)block_i++;
			}
			if(impossible)break;
			rep(k,bn){
				if(block_n[k]+cur_block_n[k]>K){
					do_cut = true;
					break;
				}
			}
			if(do_cut){
				cut_n++;
				rep(k,bn)block_n[k] = cur_block_n[k];
			}else{
				rep(k,bn)block_n[k] += cur_block_n[k];
			}
		}
		if(!impossible)ans = min(ans,bn-1+cut_n);
	}
	outl(ans);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
  int main(){
    int a,b,c,d,n,sum=0;
      while(scanf("%d",&n) != EOF){
       for(a=0;a<10;a++){
          for(b=0;b<10;b++){
             for(c=0;c<10;c++){
                for(d=0;d<10;d++){
                    if(a+b+c+d==n)
                        sum++;
                          }
                            }
                             }
                               }
                                printf("%d\n",sum);
                                 sum=0;
                                   }
return 0;
}

Measured memory_bytes: 596
st = gets.chomp!
n = st.to_i
num = Array.new(n)

st = gets.chomp!.split(" ")
for i in 0..n-1
    num[i] = st[i].to_i
end

until num.size == 1 do
    n = num.size
    num.sort!
    for i in 1..n-1
        num[n-i] = num[n-i] % num[0]
        if num[n-i] == 0
            num.delete_at(n-i)
        end
    end
end

puts num[0]

Measured memory_bytes: 9328
def levenshtein_distance(s1, s2):
    len_s1 = len(s1)
    len_s2 = len(s2)

    dp = [[0]*(len_s2 + 1) for _ in range(len_s1 + 1)]
    for i in range(len_s1 + 1):
        dp[i][0] = i
    for j in range(len_s2 + 1):
        dp[0][j] = j

    for i in range(len_s1):
        for j in range(len_s2):
            if s1[i] == s2[j]:
                dp[i+1][j + 1] = min(dp[i][j] - 1, dp[i][j + 1], dp[i + 1][j]) + 1
            else:
                dp[i+1][j + 1] = min(dp[i][j], dp[i][j + 1], dp[i + 1][j]) + 1

    return dp[len_s1][len_s2]


s1 = input()
s2 = input()
print(levenshtein_distance(s1, s2))


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

const int MAXN = 707;
int adj[MAXN][MAXN];

int cnt[2];
int color[MAXN];
int n;

void dfs(int u) {
//    cout << u << " -> " << color[u] << endl;
    cnt[color[u]]++;
    for (int v = 1; v <= n; v++) {
        if (v==u) continue;
        if (adj[u][v]==0) {
            if (color[v]==-1) {
                color[v] = color[u]^1;
                dfs(v);
            } else {
                if (color[u]==color[v]) {
                    cout << -1 << endl;
                    exit(0);
                }
            }
        }
    }
}

int C2(int n) {
    return (n*(n-1))/2;
}

typedef pair< int , int >PII;
vector< PII >options;
int dp[MAXN][MAXN];

int main() {
    int m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u][v] = 1;
        adj[v][u] = 1;
    }

    memset(color, -1, sizeof color);
    for (int i = 1; i <= n; i++) {
        if (color[i] == -1) {
            cnt[0] = cnt[1] = 0;
            color[i] = 0;
            dfs(i);
            options.emplace_back(cnt[0], cnt[1]);
//            if (b > w) swap(b, w);
//            ///b <= w
////            cout << cnt[0] << " " << cnt[1] << endl;
//            if (cnt[0] > cnt[1]) swap(cnt[0], cnt[1]);
//            ///cnt[0] <= cnt[1]
//            b += cnt[1];
//            w += cnt[0];
////            cout << b << " " << w << endl;
        }
    }

    m = options.size();
    dp[m][0] = 1;
    for (int i = m; i > 0; i--) {
        for (int j = 0; j <= n; j++) {
            if (dp[i][j]) {
                dp[i-1][j+options[i-1].first] = 1;
                dp[i-1][j+options[i-1].second] = 1;
            }
        }
    }

    for (int i = n/2; i >= 0; i--) {
        if (dp[0][i]) {
            cout << C2(i)+C2(n-i) << endl;
            return 0;
        }
    }

    assert(false);

//    cout << C2(b)+C2(w) << endl;


    return 0;
}


Measured memory_bytes: 7340
//B - Picture Frame 2017/05/20
#include <bits/stdc++.h>
using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    string s[h];
    for(int i=0;i<h;++i) cin >> s[i];
    for(int i=0;i<(w+2);++i) cout << '#';
    cout << endl;
    for(int i=0;i<h;++i){
        cout << '#' << s[i] << '#' <<endl;
    }
    for(int i=0;i<(w+2);++i) cout << '#';
    cout << endl;
}

Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  [n,_] <- readInts
  ps    <- replicateM n readInts
  print $ solve ps

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: [[Int]] -> Int
solve = length . filter good . map distance' . pairs
  where good d    = floor d == ceiling d
        distance' = uncurry distance

distance :: [Int] -> [Int] -> Double
distance p q = isqrt . sum $ zipWith f p q
  where isqrt = sqrt . fromIntegral
        f x y = (x - y) ^ 2

pairs :: [a] -> [(a,a)]
pairs []     = []
pairs (x:xs) = map ((,) x) xs ++ pairs xs


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

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

    int aLen = a.length();
    int bLen = b.length();
    
    if (aLen == bLen) {
        for (int i = 0; i < aLen; i++) {
            int diff = a[i] - b[i];
            if (diff > 0) {
                judge = "GREATER";
                break;
            } else if (diff < 0) {
                judge = "LESS";
                break;
            } else {
                judge = "EQUAL";
            }
        }
    } else if (aLen > bLen) {
        judge = "GREATER";
    } else {
        judge = "LESS";
    }

    cout << judge << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最小公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最大公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s[100005];
    REP(i,n){
      cin >> s[i];
      sort(s[i].begin(),s[i].end());
    }
    ll ans=0;
    string str = "Z^^Z&&kkkasdlkjlkjlkjlkj";
    sort(s,s+n);
    ll b = 0;
    REP(i,n){
      if(str==s[i])b++;
      else b = 0;
      ans += b;
      //cout << s[i] << ":" << b << endl;
      str = s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

long long gcd(long long x, long long y) {
    if (y == 0)
        return x;

    return gcd(y, x % y);
}

int main(void)
{
    long long A, B;
    cin >> A >> B;

    long long n = gcd(A, B);

    cout << A / n * B << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long int
void findAns()
{
    int n;
    cin >> n;

    int a[n + 1];
    int b[n];

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

    for (int i = 0; i < n; i++) cin >> b[i];

    ll sum = 0;


    ll rem = 0;

    for (int i = 0; i < n; i++)
    {
        if (a[i] >= b[i])
        {
            sum += b[i];
            b[i] = 0;
        }
        else
        {
            sum += a[i];
            b[i] -= a[i];

            if (a[i + 1] >= b[i])
            {
                a[i + 1] -= b[i];
                sum += b[i];
            }
            else
            {
                sum += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }


    cout << sum;


}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
//     cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s" << "\n";
// #endif

    FAST;
    ll  t = 1;
    //cin >> t;

    while (t--) findAns();
}


Measured memory_bytes: 4196
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define fi first
#define pb push_back
#define si second
#define int long long int
using namespace std;
int a[20][20],c[20],x,ans=9e18,d[20];
int32_t main(){
	int n,i,j,k,m;
	cin>>n>>m>>x;
	for(i=0;i<n;i++)
	{
		cin>>c[i];
		for(j=0;j<m;j++)cin>>a[i][j];
	}
	int f=0;
	for(i=1;i<(1<<n);i++)
	{
		for(j=0;j<m;j++)
			d[j]=0;
		int cst=0;
		for(j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				cst+=c[j];
				for(k=0;k<m;k++)
					d[k]+=a[j][k];	
			}
		}
		
		for(j=0;j<m;j++)
		{//	cout<<d[j]<<" ";
			if(d[j]<x)
				break;
		}
		//cout<<"\n";
		if(j==m)
		{	//cout<<" cst is "<<cst<<"\n";
			ans=min(ans,cst);
		}
				
		
	}
	if(ans!=9e18)
	cout<<ans<<"\n";
	else cout<<"-1\n";
	
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		while(++i <= n){
			int x = i;
			if(x % 3 == 0){
				System.out.print(" "+i);
			}
			else{
				while(x != 0){
					if(x % 10 == 3){
						System.out.print(" "+i);
						break;
					}
					else {x /= 10;}
				}
			}
		}
		System.out.println();
	}
}

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

int main() {
  int d, n, m; cin >> n >> m >> d;
  long double pos = 0;
  if(d == 0) pos = n;
  else if(2 * d < n) pos = 2 * (n - 2 * d) + 2 * d;
  else pos = n;
  pos /= (1ll * n * n);
  pos *= m - 1;
  cout << fixed << setprecision(10) << pos << endl;
  return 0;
}


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

ll INF = 1000000007;

int main(void){
  ll n; cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  vector<ll> one(60,0);
  vector<ll> zero(60,0);
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= 60; j++){
      if(a[i] >> j & 1LL) one[j]++;
      else zero[j]++;
    }
  }
  ll ans = 0;
  ll via = 1;
  for(int i = 0; i <= 60; i++){
    ans += (one[i]*zero[i])%INF*via%INF;
    via = via*2%INF;
  }
  cout << ans%INF << endl;
  return 0;
}


Measured memory_bytes: 2560
def solve():
    N = int(input())
    A = [int(x) for x in input().split()]
    C = 1000
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            b = C // A[i]
            # print(b)
            C -= A[i] * b
            # print(C)
            C += A[i + 1] * b
            # print(C)
    print(C)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 61852
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n+1);
    for (int i = 1; i < n+1; i++) {
        cin >> h[i];
    }

    vector<int> cost(n+1);
    cost[2] = abs(h[1]-h[2]);
    for (int i = 3; i < n+1; i++) {
        cost[i] = min(cost[i-2]+abs(h[i-2]-h[i]), cost[i-1]+abs(h[i-1]-h[i]));
    }

    cout << cost[n] << endl;
}


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

int main()
{
    int N;
    cin >> N;
    long long L[87];
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= N; ++i){
        L[i] = L[i - 2] + L[i - 1];
    }
    cout << L[N] << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split(' '))
count = [[0 for _ in range(N + 1)] for _ in range(N + 1)]

for i in range(M):
    L, R = map(int, input().split(' '))
    count[L][R] += 1

for i in range(N + 1):
    for j in range(1, N + 1):
        count[i][j] += count[i][j - 1]

for i in range(1, N + 1):
    for j in range(N + 1):
        count[i][j] += count[i - 1][j]

for _ in range(Q):
    p, q = map(int, input().split(' '))
    ans = count[q][q] - count[q][p - 1] - count[p - 1][q] + count[p - 1][p - 1]
    print(ans)

Measured memory_bytes: 57688
n = int(input())
a = list(map(int, input().split()))
accu = [0]*20
ans = 0
r = 0
for l in range(n):
    while r<n:
        tmp = accu[:]
        for i in range(20):
            tmp[i] += a[r]>>i&1
        if max(tmp)==2:
            break
        accu = tmp
        r += 1
    ans += r-l
    for i in range(20):
        accu[i] -= a[l]>>i&1
print(ans)

Measured memory_bytes: 77900
#!/usr/bin/python3 -V
#-*- coding = utf-8 -*-
N = int(input())
a = list(map(int, input().split()))
mi = a[0]
ma = a[0]
for i in range(1,N):
    if a[i] < mi:
        mi = a[i]
    elif a[i] > ma:
        ma = a[i]
print(ma-mi)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());
    ll ans = 0;
    for (ll i = 1; i < n; i++) {
        ll d = a[0] - a[i];
        ll x = (d - 1) / (n + 1);
        ans += i * x;
        for (int j = 0; j < i; j++) a[j] += (-n + i - 1) * x;
        for (int j = i; j < n; j++) a[j] += i * x;
    }
    sort(all(a), greater<ll>());
    ll add = LINF;
    for (ll i = 0; i < n; i++) {
        chmin(add, max(0ll, ((a[i] + i) - (n - 1)) * n) + i);
    }
    ans += add;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX_N 10000
int par[MAX_N]; // ???
int _rank[MAX_N]; // ??¨?????±???
// ?????????
void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    _rank[i] = 0;
  }
}
// ??¨??????????±???????
int find(int x){
  if(par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}
// x??¨y????±??????????????????????
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  
  // ??¨??????????????????????????£??¨??????????????????
  if(_rank[x] < _rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(_rank[x] == _rank[y]) _rank[x]++;
  }
}
// x??¨y?????????????????????true
bool same(int x,int y){
  return find(x) == find(y);
}

int main () {
  int i, n, q;cin >> n >> q;
  init(MAX_N);
  for(i = 0;i < q; ++i) {
    int a, x, y;cin >>a>>x>>y;
    if(a == 0) {
      unite(x,y);
    }else {
      cout<<(same(x,y)?1:0)<<endl;
    }
  }
}

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

int main() {
  string s;
  cin >> s;
  string ans;
  rep(i,(s.size()+1)/2) {
    ans += s[2*i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long K){
	ll N = 50;
	ll initH = N-1+(K+N-1)/N;
	priority_queue<ll> que;
	rep(i, N) {
		que.push(initH);
	}
	ll rc = (N-K%N)%N;
	rep(i, rc) {
		priority_queue<ll> que2;
		que2.push(que.top()-N);
		que.pop();
		while(!que.empty()) {
			que2.push(que.top()+1);
			que.pop();
		}
		while(!que2.empty()) {
			que.push(que2.top());
			que2.pop();
		}
	}
	cout << N << endl;
	rep(i, N-1) {
		cout << que.top() << " ";
		que.pop();
	}
	cout << que.top() << endl;
}

int main(){	
	long long K;
	scanf("%lld",&K);
	solve(K);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    const int MOD = (int)1e9+7;
    int N; cin>>N;
    vvi A(N, vi(N, 0));
    REP(i,N)
        REP(j,N)
            cin>>A[i][j];

    var dp = vvi(N+1, vi((1<<N), 0));
    // dp[i][s] := [0,i) までの男性が女性とペアを作り、女性集合の状態が s となる通り数。

    dp[0][0] = 1;  // スタートのために 1 にする
    REP(i,N) {
        for (int s = 0; s < (1<<N); s++) {
            if (dp[i][s] == 0)  // ここまでの結果が 0 通り、つまりあり得ない
                continue;

            REP(j,N) {
                if (A[i][j] == 0)  // i 番目の男性と j 番目の女性は相性が良くない
                    continue;

                if ((s >> j) & 1 == 1)  // j 番目の女性はすでにペアになっている
                    continue;

                // i 番目の男性と j 番目の女性をペアにする
                int now = s | (1<<j);
                dp[i+1][now] += dp[i][s];
                dp[i+1][now] %= MOD;
            }
        }
    }

    int ans = dp[N][(1<<N)-1];
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 377216
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


A, B = MI()
print(A * B)

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    int t1 = (a - 1) / k + 1;
    int t2 = b / k;
    if (t1 <= t2) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <limits.h>
#include <stack>
#include <set>
#include <map>

#define P pair
#define MP make_pair

typedef long long int llint ;

using namespace std;

int n;
llint mat[2][105];
llint bio[2][105];

llint rek(int x,int y)
{
	if(x==0 && y==0)
	return mat[x][y];
	else if(bio[x][y]!=-1)
	return bio[x][y];
	else
	if(x==0)
	return bio[x][y]=mat[x][y]+rek(x,y-1);
	if(y==0)
	return bio[x][y]=mat[x][y]+rek(x-1,y);
	return bio[x][y]=mat[x][y]+max(rek(x-1,y),rek(x,y-1));
}

int main()
{
	memset(bio,-1,sizeof bio);
	cin>>n;
	for(int i=0;i<2;i++)
	{
		for(int k=0;k<n;k++)
		cin>>mat[i][k];
	}
	cout<<rek(1,n-1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

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

  vector<int> a_sum(n);
  for (int i = n-1; i >= 0; i--) {
    if (i == n-1) {
      a_sum[i] = a[1][i];
    } else {
      a_sum[i] = a_sum[i+1] + a[1][i];
    }
  }

  int current = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    current += a[0][i];
    ans = max(ans, current + a_sum[i]);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int D;
    cin >> D;
    if (D==25) {
        cout << "Christmas" << endl;
    } else if (D==24) {
        cout << "Christmas Eve" << endl;
    } else if (D==23) {
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	println(a - b + 1);
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;
ll sum[100005];

ll solve(int s) {
	ll ret = 0, plus = 0, minus = 0;
	ll ss[100005];
	FOR(i, n) ss[i] = sum[i];
	FOR(i, n) {
		ss[i] += plus - minus;
		// cout << ss[i] << " ";
		if (s > 0 && ss[i] >= 0) {
			ret += ss[i] + 1;
			minus += ss[i] + 1;
		}
		else if (s < 0 && ss[i] <= 0) {
			ret += -ss[i] + 1;
			plus += -ss[i] + 1;
		}
		s *= -1;
	}
	// cout << endl;
	return ret;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	ll last = 0;
	// bool flag = false;
	FOR(i, n) {
		ll a;
		cin >> a;
		sum[i] += a + last;
		// if (i > 0 && sum[i]*sum[i-1] >= 0) flag = true;
		last = sum[i];
	}
	// if (!flag) {
	// 	cout << 0 << endl;
	// 	return 0;
	// }
	// FOR(i, n) cout << sum[i] << " ";
	// cout << endl;
	// cout << solve(1) << endl;
	// cout << solve(-1) << endl;
	cout << min(solve(1), solve(-1)) << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6

int compute(int x, vector<int>& v){
    int res=0;
    for(int i=0; i<v.size(); i++){
        res+=((v[i]-x)*(v[i]-x));
    }
    return res;
}
 
 
int main(){
	fast;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0; i<n; i++)  cin>>v[i];
	int l= *min_element(v.begin(), v.end());
	int h= *max_element(v.begin(), v.end());
	while((h-l)>2){
	    int m1 = l+(h-l)/3;
	    int m2 = h-(h-l)/3;
	    int d1= compute(m1, v);
	    int d2 = compute(m2, v);
	    if(d1<d2){
	        h=m2;
	    }
	    else{
	        l=m1;
	    }
	}
	cout<<compute((h+l)/2, v)<<"\n";
	return 0;
}

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


using namespace std;
#define ll long long

vector<int> primes;
vector<int> facs;

ll N;

int main()
{
	cin>>N;
	int sqt = sqrt(N);
	for(int i = 2; i <= sqt; ++i)
	{
		if(N % i == 0)
		{
			primes.push_back(i);
			int cnt = 0;
			while(N % i == 0)
			{
				++cnt;
				N /= i;
			}
			facs.push_back(cnt);
		}
	}
	if( N != 1)
	{
		primes.push_back(N);
		facs.push_back(1);
	}
	int ans = 0;
	for(int fac: facs)
	{
		int k = 1;
		while(fac >= k)
		{
			++ans;
			fac -= k;
			++k;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 3684
import scala.io.StdIn.readLine
import scala.annotation.tailrec

object Main extends App {
  val n = readLine.toInt

  def candidates(n: Int) = if (n < 4) Nil else 2 +: (3 to math.sqrt(n).toInt by 2)
  def isPrime(n: Int) = candidates(n).forall(n % _ != 0)
  def primeFactorize(n: Int): List[Int] =
    if (isPrime(n)) List(n)
    else {
      @tailrec def recur(n: Int, res: List[Int]): List[Int] =
        candidates(n).reverse.find(k => n % k == 0 && isPrime(k)) match {
          case Some(p) => recur(n / p, p :: res)
          case None => n :: res
        }
      recur(n, Nil)
    }

  def buildPQs(pqs: Map[Int, Int], xs: Seq[Int]): Map[Int, Int] = {
    def helper(pqs: Map[Int, Int], ps: Seq[Int]): Map[Int, Int] =
      if (ps.isEmpty) pqs
      else {
        val p = ps.head
        val q = if (pqs isDefinedAt p) pqs(p) else 0
        helper(pqs + (p -> (q + 1)), ps.tail)
      }
    if (xs.isEmpty) pqs
    else buildPQs(helper(pqs, primeFactorize(xs.head)), xs.tail)
  }

  val pqs = buildPQs(Map[Int, Int](), 2 to n)
  var res = 1L
  pqs foreach {
    case (p, q) => res = res * (q + 1) % 1000000007
    case _ =>
  }
  println(res)
}


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

using ll = long long;

void NO () {
	cout << "No";
	exit (0);
}

void YES (string ans) {
	cout << "Yes\n" << ans;
	exit (0);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, sum = 0, askiiA = 'A';
	cin >> n;
	vector <string> a(n);
	int c[3+askiiA];
	for (int i=askiiA; i<3+askiiA; i++) {
		cin >> c[i];
		sum += c[i];
	}
	if (!sum) NO();
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	string ans = "";
	for (int i=0; i<n; i++) {
		string cur = a[i];
		if (!c[cur[0]] && !c[cur[1]]) NO();
		if (i == n-1) {
			if (c[cur[0]]) {
				ans += cur[1];
			} else {
				ans += cur[0];
			}
			break;
		}
		if (!c[cur[0]] && c[cur[1]]) {
			ans += cur[0];
			c[cur[0]] ++;
			c[cur[1]] --;
		} else if (c[cur[0]] && !c[cur[1]]) {
			ans += cur[1];
			c[cur[1]] ++;
			c[cur[0]] --;
		} else {
			string next = a[i+1];
			if (next[0] == cur[0] || next[1] == cur[0]) {
				ans += cur[0];
				c[cur[0]] ++;
				c[cur[1]] --;
			} else {
				ans += cur[1];
				c[cur[1]] ++;
				c[cur[0]] --;
			}
		}
		ans += "\n";
	}
	YES(ans);
	return 0;
}


Measured memory_bytes: 7312
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int can_n = 0;
		int kaisu = 3;
		int[] num = new int[kaisu];
		for(int i = 0; i < kaisu; i++) {
			num[i] = scan.nextInt();
		}
		for(int i = num[0]; i <= num[1] ;i++) {
			if(num[2] % i == 0) can_n++;
		}
		System.out.println(can_n);

 }
}

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

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

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

#define MAXN (1010)
#define sqr(x) ((1ll) * (x) * (x))

template <class T> void readin(T& x,bool mark=0){char tt=getchar();for(;tt<'0'||'9'<tt;tt=getchar()) if(tt=='-') mark=1;for(x=0;'0'<=tt&&tt<='9';x=(x<<1)+(x<<3)+tt-'0',tt=getchar());x=mark?-x:x;}

struct node{
	int x, y, r;
}cir[MAXN];

int n;
bool vis[MAXN];
double dis[MAXN];
double wjj[MAXN][MAXN];

double diss(int i, int j){
	return sqrt(sqr(cir[i].x - cir[j].x) + sqr(cir[i].y - cir[j].y));
}

double get_dis(int i, int j){
	return std::max(0.0, diss(i, j) - cir[i].r - cir[j].r);
}

std::priority_queue<std::pair<int, int> > pq;  
void dijkstra(){
    for(int i = 0; i < MAXN; ++ i){
	    dis[i] = 1e100;
	}
	dis[1] = 0;
	pq.push({- dis[1], 1});
	while(!pq.empty()){
		int u = pq.top().second; pq.pop();
		if(vis[u]) continue;
		vis[u] = true;
		for(int v = 2; v <= n + 2; ++ v){
			if(v == u) continue;
			double w = wjj[v][u];
			if(!vis[v] && dis[v] > dis[u] + w){
			    dis[v] = dis[u] + w;
				pq.push({- dis[v], v});
			}
		}
	}
}

int main(){
	readin(cir[1].x); readin(cir[1].y); readin(cir[2].x); readin(cir[2].y);
	readin(n);
	for(int i = 3; i <= n + 2; ++ i){
		readin(cir[i].x);
		readin(cir[i].y);
		readin(cir[i].r);
	}
	for(int i = 1; i <= n + 2; ++ i){
		for(int j = 1; j <= n + 2; ++ j){
			wjj[i][j] = get_dis(i, j);
		}
	}
	dijkstra();
	printf("%.10lf\n", dis[2]);
	return 0;
}

Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double pi=3.14159265358979323846;
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double kaku=(h*11*pi/6)+m*11*pi/360;
  double k;
  k=sqrt(a*a+b*b-2*a*b*(cos(kaku)));
  cout << fixed << setprecision(20);
  cout<<k<<endl;
  
}

Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    string k;
    int d;
    cin >> k >> d;
    auto dp = make_v(k.size()+1, 2, d, 0);
    dp[0][0][0] = 1;
    for (int i = 0; i < k.size(); ++i) {
        for (int j = 0; j < 2; ++j) {
            int x =  j ? 9 : k[i] - '0';
            for (int l = 0; l < d; ++l) {
                for (int m = 0; m <= x; ++m) {
                    (dp[i+1][j || m < x][(l+m)%d] += dp[i][j][l]) %= MOD;
                }
            }
        }
    }
    int ans = MOD-1;
    for (int j = 0; j < 2; ++j) {
        (ans += dp[k.size()][j][0]) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    ll mod = 1e9+7;
    vector<vector<char>> v(h, vector<char>(w,0));
    vector<vector<ll>> dp(h+1, vector<ll>(w+1,0));
    rep(i, 0, h)
        rep(j, 0, w)
            cin >> v[i][j];
    if (v[0][0] != '#') 
        dp[0][0] = 1;
    if (v[0][1] != '#')
        dp[0][1] = 1;
    if (v[1][0] != '#')
        dp[1][0] = 1;
    rep(i, 1, w)
        if (v[0][i] != '#')
            dp[0][i] = dp[0][i-1];
    rep(i, 1, h)
        if (v[i][0] != '#')
            dp[i][0] = dp[i-1][0];
    // rep(i, 0, h)
    // {
    //     rep(j, 0, w)
    //         cout << dp[i][j];     
    //     cout << endl;
    // }
    rep(i, 1, h)
        rep(j, 1, w)
        {
            if (v[i][j] != '#')
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
        }           
    cout << dp[h-1][w-1] % mod;
    return 0;
}

Measured memory_bytes: 9088
int main(void)
{
int n,i,max=0,j=0,second=0,num;
  
  scanf("%d",&n);
  int f[n];
  for(i=0; i<n; i++)
    scanf("%d",&f[i]);
  
  for(i=0; i<n; i++){
	if(max <= f[i]) {
      max = f[i];
      num = i;
    }
  }
  for(i=0; i<n; i++){
    if(max == f[i]) j++;
    if(j==2)break;
  }
  if(j==1){
    for(i=0; i<n; i++){
	if((max > f[i]) && (second < f[i])){ 
      second = f[i];
    }
    }
    for(i=0; i<n; i++){
      if(i == num)   {
        printf("%d\n",second);
      }
      else{
        printf("%d\n",max);
      }
    }
  }
  if(j==0){
for(i=0; i<n; i++)
      printf("%d\n",max);
  }
if(j>=2){
    for(i=0; i<n; i++)
      printf("%d\n",max);
}
  return 0;
}

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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if(a+k-1<b-k+1){
        for(int i=a;i<=a+k-1;i++){
            cout<<i<<endl;
        }
        for(int i=b-k+1;i<=b;i++){
            cout<<i<<endl; 
        }
    }else{
        for(int i=a;i<=b;i++){
            cout<<i<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

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

int main() {
  int n;
  scanf("%d", &n);
  vll a(n);
  rep (i, n) {
    scanf("%lld", &a[i]);
    a[i] += (n - i);
  }
  sort(all(a));
  vll accum(n+1, 0);
  rep (i, n) {
    accum[i+1] = accum[i] + a[i];
  }
  ll ans = 1123456789012345;
  rep (i, n) {
    ll cand = 0;
    cand += (a[i] * i - accum[i]);
    cand += (accum[n] - accum[i] - a[i] * (n - i));
    ans = min(ans, cand);
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
char mp[21][21];
int dir[4][2]={1,0, 0,-1, -1,0, 0,1};
int d[500][500];
int h,w;
const int inf=500;
int id(int x,int y){return (x-1)*w+y;}

void add(int x,int y){
    rep(i,0,3){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<1||dx>h||dy<1||dy>w)continue;
        if(mp[dx][dy]=='.')d[id(x,y)][id(dx,dy)]=d[id(dx,dy)][id(x,y)]=1;
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>h>>w;
    int n=h*w;
    rep(i,1,h*w)rep(j,1,h*w)if(i==j)d[i][j]=0;else d[i][j]=inf;
    rep(i,1,h)rep(j,1,w)cin>>mp[i][j];
    rep(i,1,h)rep(j,1,w)if(mp[i][j]=='.')add(i,j);
    rep(k,1,n)rep(i,1,n)rep(j,1,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    int ans=0;
    rep(i,1,n)rep(j,1,n)if(d[i][j]!=inf)ans=max(ans,d[i][j]);
    cout<<ans<<endl;
}
/* 
3 5
...#.
.#.#.
.#...
 */

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int N;
    cin>>N;
    int t[100000],x[100000],y[100000];
    
    for(int i=0;i<N;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    int dx=x[0],dy=y[0],dt=t[0];
    for(int i=0;i<N;i++){
        if((dt-dx-dy)<0||!(((dt-dx-dy)%2==0))){
            cout<<"No"<<endl;
            return 0;
        }
       dx=x[i+1]-x[i];
       dy=y[i+1]-y[i];
       dt=t[i+1]-t[i];
    }

    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 1408
def main():
    n = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))

    ans = 0
    for i in range(n-1, -1, -1):
        if Bs[i] >= As[i+1]:
            Bs[i] -= As[i+1]
            ans += As[i+1]
            As[i+1] = 0
        else:
            As[i+1] -= Bs[i] 
            ans += Bs[i]
            Bs[i] = 0

        if Bs[i] >= As[i]:
            Bs[i] -= As[i]
            ans += As[i]
            As[i] = 0
        else:
            As[i] -= Bs[i]
            ans += Bs[i]
            Bs[i] = 0
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
// ll dp[105][100005];
int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll n, k;
		cin >> n >> k;
		ll arr[n];
		rep(i, 0, n)cin >> arr[i];
		ll dp[n];
		dp[0] = 0;
		rep(i, 1, n){
			dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
			rep(j, 2, k+1)if(i-j >= 0)
				dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
		}
		cout << dp[n-1] ;
	}
}


Measured memory_bytes: 1792
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int sign(int a){
  if(a>0) return 1;
  if(a==0) return 0;
  return -1;
}

int main(){
  int x,y;cin>>x>>y;
  int res;
  if(sign(x)*sign(y)==-1){
    res=abs(abs(x)-abs(y))+1;
  }else if(sign(x)*sign(y)==1){
    if(x<y) res=y-x;
    else res=x-y+2;
  }else{
    if(x==0){
      res=abs(y)+(y>0?0:1);
    }else{
      res=abs(x)+(x>0?1:0);
    }
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 256
N,X = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(len(Alist)):
    Alist[i] = abs(Alist[i]-X)
Alist.sort()
p = []
q = 1
for i in range(1,len(Alist)):
    if Alist[i] % Alist[0] != 0:
        p.append(Alist[i] % Alist[0])
        q = q*0
p.sort()
r = 1
s = []
if p != []:
    for i in range(0,len(Alist)):
        s.append(Alist[i] % p[0])
        if Alist[i] % p[0] != 0:
            p[0] = Alist[i] % p[0]
if len(Alist) > 1:
    if q == 0 and r == 1:
        print(p[0])
    if q == 0 and r == 0:
        print(1)
    if q == 1:
        print(Alist[0])
else:
    print(Alist[0])



Measured memory_bytes: 14480
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

L,R,d  = map(int,input().split())

ans = 0

for i in range(0,1000):
    if d*i >= L and d*i <= R:
        ans += 1

print(ans)

Measured memory_bytes: 27144
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>
#include <stack>
#include <queue>

#define ll long long
#define ld long double

using namespace std;

int main(){
  ll m;

  cin >> m;

  cout << 48 - m << endl;
  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>;
#include <algorithm>
#include <string>

int main()
{
        int Q, ty, f;
        string s, t;
        char c;
        cin >> s >> Q;

        while(Q--) {
                cin >> ty;
                if (ty == 1) {
                        swap(s, t);
                } else {
                        cin >> f;
                        cin >> c;
                        if (f == 1) {
                                t += c;
                        } else {
                                s += c;
                        }
                }
        }

        reverse(t.begin(), t.end());
        t += s;
        cout << t << endl;
        return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

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

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

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

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


int main(){
    SCIN(A,B);
    int a=A.size();
    int b=B.size();
    if(a>b) printf("GREATER\n");
    else if(a<b) printf("LESS\n");
    else{
        rep(i,a){
            if(A[i]>B[i]){
                printf("GREATER\n");
                return 0;
            }
            else if(A[i]<B[i]){
                printf("LESS\n");
                return 0;
            }
        }
        printf("EQUAL\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);
struct LowestCommonAncestor {
  int n, h;
  vector<vector<int>> par;
  vector<vector<pair<int,int>>> g;
  vector<int> dep;
  vector<ll> weight;

  LowestCommonAncestor(int sz) {
    n = sz; h = 1;
    g.resize(n), dep.resize(n), weight.resize(n);
    while ((1 << h) <= n) h++;
    par.assign(h, vector<int>(n, -1));
  }

  void add_edge(int u, int v, int w = 0) {
    g[u].emplace_back(make_pair(v, w));
    g[v].emplace_back(make_pair(u, w));
  }

  void dfs(int u, int p, int depth) {
    par[0][u] = p;
    dep[u] = depth;
    if (p == -1) weight[u] = 0;
    for (auto v : g[u]) {
      if (v.first == p) continue;
      weight[v.first] = weight[u] + v.second;
      dfs(v.first, u, depth + 1);
    }
  }

  void build(int root = 0) {
    dfs(root, -1, 0);
    for (int i = 0; i + 1 < h; i++) {
      for (int j = 0; j < n; j++) {
        if (par[i][j] != -1) par[i+1][j] = par[i][par[i][j]];
        else par[i+1][j] = -1;
      }
    }
  }

  int query(int u, int v) {
    if (dep[u] > dep[v]) swap(u, v);
    for (int i = h-1; i >= 0; i--) {
      if ( ((dep[v] - dep[u]) >> i) & 1) v = par[i][v];
    }
    if (u == v) return u;
    for (int i = h-1; i >= 0; i--) {
      if (par[i][u] != par[i][v]) {
        u = par[i][u];
        v = par[i][v];
      }
    }
    return par[0][u];
  }

  int dist(int u, int v) {
    return dep[u] + dep[v] - 2 * dep[query(u, v)];
  }

  ll weightedsum(int u, int v) {
    return weight[u] + weight[v] - 2 * weight[query(u, v)];
  }
};
int main(){ 
  int n;
  cin >> n;
  LowestCommonAncestor lca(n);
  rep(i,n-1) {
    int u, v, c;
    cin >> u >> v >> c;
    u--; v--;
    lca.add_edge(u, v, c);
  }
  lca.build();
  int q, k;
  cin >> q >> k;
  k--;
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << lca.weightedsum(x, k) + lca.weightedsum(y, k) << endl;
  }
  return 0;
} 

Measured memory_bytes: 18808