akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

s = 0

for i in range(N):
    s = A[i] - s
    # print('A[i]',A[i])
    # print(s)

x = s//2
B = [0]*N

for i in range(N):
    B[i] = x*2
    x = A[i] - x

print(*B)


Measured memory_bytes: 14028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int d[55][55];
int d_tmp[55][55];

void warshall_floyd(int n){
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        d_tmp[j][k] = min(d_tmp[j][k], d_tmp[j][i] + d_tmp[i][k]);
}

int main(){
  int N,M;cin>>N>>M;
  int ans=0;
  vll a(M),b(M);
  rep(i,N)rep(j,N){
    d[i][j]=1;
    if(i==j)d[i][j]=0;
  }
  rep(i,M){
    cin>>a[i]>>b[i];a[i]=a[i]-1,b[i]=b[i]-1;
    d[a[i]][b[i]]=0,d[b[i]][a[i]]=0;
  }
  rep(i,M){
    rep(i,N)rep(j,N)d_tmp[i][j]=d[i][j];
    d_tmp[a[i]][b[i]]=1,d_tmp[b[i]][a[i]]=1;
    warshall_floyd(N);
    bool flag=false;
    rep(i,N)rep(j,N){
      if(d_tmp[i][j]>0) flag=true;
    }
    if(flag) ans++;
    d[a[i]][b[i]]=0,d[b[i]][a[i]]=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

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

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

std::vector<int> Matches(const std::string& haystack,
                         const std::string& needle) {
  const long long base = 100000007;
  if (haystack.size() < needle.size()) {
    return {};
  }
  long long h = 0, n = 0, t = 1;
  for (int i = 0; i < needle.size(); ++i) {
    h = h * base + haystack[i];
    n = n * base + needle[i];
    t *= base;
  }
  std::vector<int> matches;
  for (int i = 0;; ++i) {
    if (h == n) matches.push_back(i);
    int j = i + needle.size();
    if (j == haystack.size()) break;
    h = h * base - t * haystack[i] + haystack[j];
  }
  return matches;
}

int main() {
  in(int, n);
  vector<bitset<30>> a(n), b(n);
  rep(i, n) {
    in(int, x);
    a[i] = x;
  }
  rep(i, n) {
    in(int, x);
    b[i] = x;
  }

  vector matches(30, vector(2, vector(n, false)));
  rep(bit, 30) {
    string as, nas, bs;
    rep(i, n) {
      as += '0' + a[i][bit];
      nas += '1' - a[i][bit];
      bs += '0' + b[i][bit];
    }
    bs += bs;
    // dbg(bs);
    for (int m : Matches(bs, as)) {
      // dbg(as, m);
      matches[bit][0][m] = true;
    }
    for (int m : Matches(bs, nas)) {
      // dbg(nas, m);
      matches[bit][1][m] = true;
    }
  }
  vector<pair<int, int>> ans;
  rep(i, n) {
    bool ok = true;
    rep(j, 30) if (!(matches[j][0][i] || matches[j][1][i])) ok = false;
    if (!ok) continue;
    int x = 0;
    rep(j, 30) x |= (matches[j][1][i]) << j;
    ans.push_back({(n - i) % n, x});
  }
  sort(all(ans));
  for (auto [a, b] : ans) out(a, b);
}


Measured memory_bytes: 10752
import math
 
N = int(input())
 
M = int(math.sqrt(N))

ans = 0 
check = [True for _ in range(M + 1)]
e = [0 for _ in range(M + 1)]

for p in range(2, M + 1):
    if check[p] == True:
        for j in range(2, M // p + 1):
            check[p * j] = False

        while N % p == 0:
            N = N // p
            e[p] += 1
        
        ans += int((math.sqrt(1 + 8 * e[p]) - 1)/2)

if N > 1:
    ans += 1

print(ans)

Measured memory_bytes: 24800
import java.util.Scanner;

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

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();

        if(a>=k){
            System.out.println(k);
        }
        else if(a+b >=k){
            System.out.println(a);
        }
        else{
            System.out.println(a - (k - b -a));
        }
    }
}

Measured memory_bytes: 35808
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	map<ll, ll> mp1,mp2;
	V<ll> sum(N + 1, 0), cnt = {0};
	for(ll i = 1; i <= N; ++i){
		ll a; cin >> a;
		if(!mp1[a]) mp1[a] = i;
		mp2[a]++;
	}

	for (auto itr = mp2.begin(); itr != mp2.end(); ++itr) cnt.push_back((*itr).first);
	sort(ALL(cnt));

	for (int i = cnt.size() - 1; 1 <= i; --i) {
		sum[mp1[cnt[i]]] += mp2[cnt[i]]*(cnt[i]-cnt[i-1]);
		chmin(mp1[cnt[i - 1]], mp1[cnt[i]]);
		mp2[cnt[i - 1]] += mp2[cnt[i]];
	}
	for (ll i = 1; i <= N; ++i) cout << sum[i] << endl;
	
	return 0;
}



Measured memory_bytes: 15224
#include<iostream>
#include<cmath>
using namespace std;
double mini=1000;
int n,t,a,ans;
int h[1009];
int main()
{
    cin>>n>>t>>a;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
        double v=t-h[i]*0.006;
        double s=abs(v-a);
        if(s<mini)
        {
            mini=s;
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    
}


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

int main(){
  ll l,r,ans;
  cin >> l >> r;

  if(r-l >= 2019)ans = 0;
  else{
    ans = (l*(l+1))%2019;
    for(ll i = l; i<r; i++){
      for(ll j = l+1; j<r+1; j++){
        ll t = i*j %2019;
        if(t == 0){
          ans = 0;
          break;
        }
        if(t < ans){
          ans = t;
        }
      }
    }
  }

  cout << ans << endl;
}

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

int n, m, x, y;
int a[105], b[105];

int main(){
	scanf("%d %d %d %d", &n, &m, &x, &y);
	for(int i = 1; i <= n; i++) scanf(" %d", &a[i]);
	for(int i = 1; i <= m; i++) scanf(" %d", &b[i]);
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + m);
	if(a[n] >= b[1]) printf("War\n");
	else {
		bool flag = 0;
		for(int i = a[n] + 1; i <= b[1]; i++){
			if(i <= y && i > x) flag = 1;
		}
		if(flag) printf("No War\n");
		else printf("War\n");
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
an = [int(i) for i in input().split()]
bn = [int(i) for i in input().split()]
difn = [0]*n
cnt = 0
m_ab = 0

for i in range(n):
  difn[i] = an[i] - bn[i]
difn.sort()

for i in range(n):
  if difn[i] < 0:
    m_ab += difn[i]
    cnt += 1
  else:
    break

if cnt == 0:
  print(0)
  exit()

for i in range(1,n+1):
  if difn[-i] <= 0:
    print(-1)
    exit()
  m_ab += difn[-i]
  cnt += 1
  if m_ab >= 0:
    print(cnt)
    exit()

Measured memory_bytes: 18624
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x=a*b;
	int y=c*d;
	if(x<y)
	x=y;
	printf("%d",x);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int n,F,x[101],y[101],h[101];
inline bool check(int X,int Y,int H){
    for(register int i=1;i<=n;i++)if((((H-abs(X-x[i])-abs(Y-y[i]))<0)?0:H-abs(X-x[i])-abs(Y-y[i]))!=h[i])return false;
    return true;
}
int main() {
    scanf("%d",&n);
    for(register int i=1; i<=n; i++) {
        scanf("%d%d%d",&x[i],&y[i],&h[i]);
        if(h[i]!=0)F=i;
    }
    for(register int i=0; i<=100; i++) {
        for(register int j=0; j<=100; j++) {
            if(check(i,j,abs(i-x[F])+abs(j-y[F])+h[F])){
                cout<<i<<" "<<j<<" "<<(int)abs(i-x[F])+abs(j-y[F])+h[F]<<endl;
                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 reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n;
    cin >> n;
    if(n / 10 == 9 || n % 10 == 9) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

main(){
	int n;
	string s[3] = {"Sunny", "Cloudy", "Rainy"};
	string k;
	
	cin>>k;
	if(k[0] == 'S')
		cout<<s[1];
	else if(k[0] == 'C')
		cout<<s[2];
	else
		cout<<s[0];
	
}

Measured memory_bytes: 256
//
//  main.cpp
//  Cookie_Exchanges
//
//  Created by Uttam Datta on 01/06/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
using namespace std;

int a, b,c;

int ans(){
    if(a == b && b == c && a % 2 == 0 && b % 2 == 0 && c % 2 ==0){
        return -1;
    }
    int d = 0/*a*/,e = 0/*b*/,f = 0/*c*/;
    int pos = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 ==0){
        d = (b/2) + (c/2);
        e = (a/2)+(c/2);
        f = (a/2)+(b/2);
        a = d;
        b = e;
        c = f;
        pos++;
    }
    return pos;
}

int main(){
    cin >> a >> b >> c;
    cout << ans() << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

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

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		}
			
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    constexpr int m = 1000000;
    int k, x; cin >> k >> x;

    for(int i=-m; i<=m; i++) {
        if(x - k + 1 <= i && i <= x + k - 1) 
            cout << i << " ";
        else 
            continue;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

int main()
{
    string s,t;
    cin>>s>>t;
    bool flag=true;
    for(int i=s.size()-t.size(); i>=0; i--) 
    //REP(i,s.size()-t.size()+1)
    {
        flag=true;
        REP(j,t.size())
        {
            if(s[i+j]!=t[j]&&s[i+j]!='?')flag=false;
        }
        if(flag)
        {
            REP(j,t.size())
                s[i+j]=t[j];
            REP(j,s.size())
                if(s[j]=='?')s[j]='a';
            cout<<s<<endl;return 0;
        }
    }
 cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    vector<int> v(4); rep(i,4) cin >> v[i];
    sort(all(v));
    int ans = 1000000000;
    do{
        ans = min(ans, abs(v[0]+v[1]-v[2]-v[3]));
    }while(next_permutation(all(v)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3172
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		long ans = 0;
		for(int i = 1; i <= K; i++) {
			for(int j = 1; j <= K; j++) {
				for(int k = 1; k <= K; k++) {
					ans += gcd(i, gcd(j, k));
				}
			}
		}
		System.out.println(ans);
	}
	
	static int gcd (int a, int b) {
		return b > 0 ? gcd(b, a % b) : a;
	}
}


Measured memory_bytes: 35772
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int MD = 1000000007;
	int power(long a, int k) {
		long p = 1;
		while (k > 0) {
			if ((k & 1) == 1)
				p = p * a % MD;
			a = a * a % MD;
			k >>= 1;
		}
		return (int) p;
	}
	int[] ff, gg;
	void init(int n) {
		ff = new int[n];
		gg = new int[n];
		for (int f = 1, i = 0; i < n; i++) {
			gg[i] = power(ff[i] = f, MD - 2);
			f = (int) ((long) f * (i + 1) % MD);
		}
	}
	long choose(int n, int k) {
		return (long) ff[n] * gg[k] % MD * gg[n - k] % MD;
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = 0;
		while (1 << k + 1 <= m)
			k++;
		init(n + k);
		long ans = 1;
		for (int p = 2; p <= m / p; p++)
			if (m % p == 0) {
				k = 0;
				while (m % p == 0) {
					k++;
					m /= p;
				}
				ans = ans * choose(n - 1 + k, k) % MD;
			}
		if (m > 1)
			ans = ans * n % MD;
		println(ans);
	}
}


Measured memory_bytes: 36856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll A,B,M,a[100010],b[100010],c[100010],x[100010],y[100010];
    cin>>A>>B>>M;
    for(int i=1;i<=A;i++) cin>>a[i];
    for(int i=1;i<=B;i++) cin>>b[i];
    for(int i=1;i<=M;i++) cin>>x[i]>>y[i]>>c[i];
    ll ans,m1=1e9,m2=1e9;
    for(int i=1;i<=A;i++){
        m1=min(m1,a[i]);
    }
    for(int i=1;i<=B;i++){
        m2=min(m2,b[i]);
    }
    ans=m1+m2;
    for(int i=1;i<=M;i++){
        ans=min(ans,a[x[i]]+b[y[i]]-c[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 4096
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var x = new int[n];
            var y = new int[n];
            var a = new bool[5001,5001];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var  wx= int.Parse(line[0]);
                 var wy = int.Parse(line[1]);
                x[i] = wx;  y[i] = wy;  a[wx, wy] = true;
            }
            var ans = getAns(x, y, a, n);
            Console.WriteLine(ans);
        }
    }
    static int getAns (int[] x , int[] y, bool[,] a , int n)
    {
        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                var bax1 = y[j] - y[i];
                var bay1 = -x[j] + x[i];
                var bax2 = -y[j] + y[i];
                var bay2 = x[j] - x[i];
                var kax1 = bax1 + x[i];
                var kay1 = bay1 + y[i];
                var kax2 = bax2 + x[i];
                var kay2 = bay2 + y[i];
                var kbx1 = bax1 + x[j];
                var kby1 = bay1 + y[j];
                var kbx2 = bax2 + x[j];
                var kby2 = bay2 + y[j];
                if (kax1 >= 0 && kay1 >= 0 && kbx1 >= 0 && kby1 >= 0  && 
                    kax1 <= 5000 && kay1 <= 5000 && kbx1 <= 5000  && kby1 <= 5000 &&
                    a[kax1,kay1] && a[kbx1,kby1]  ) ans = Max(ans, bax1 * bax1 + bay1 * bay1);
                if (kax2 >= 0 && kay2 >= 0 && kbx2 >= 0 && kby2 >= 0 &&
                    kax2 <= 5000 && kay2 <= 5000 && kbx2 <= 5000 && kby2 <= 5000 &&
                    a[kax2, kay2] && a[kbx2, kby2]) ans = Max(ans, bax1 * bax1 + bay1 * bay1);
            }
        }
        return ans;
    }
}



Measured memory_bytes: 59784
#include <iostream>
using namespace std;
int main()
{
    int n;
    int a[100];
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    cout<<a[n-1];
    for(int i=n-2;i>=0;i--)cout<<' '<<a[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3080
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))

void bfs(int s,int n,vector<vector<int>> &adj,int *c)
{
	int visit[n+1]={0};
	visit[1]=1;
	vector<int> frontier;
	frontier.pb(1);
	while(frontier.size())
	{
		vector<int> next;
		for(auto u:frontier)
		{
			for(auto v:adj[u])
			{
				if(!visit[v])
				{
					visit[v]=1;
					next.pb(v);
					c[v]+=c[u];
				}
			}
		}
		frontier=next;
	}	
}



int main(){ FastIO;

int n,q;cin>>n>>q;
int c[n+1]={0};
vector<vector<int>> adj(n+1,vector<int>());
for(int i=0;i<n-1;i++)
{
	int a,b;cin>>a>>b;
	adj[a].pb(b);adj[b].pb(a);
}
while(q--)
{
	int a,b;cin>>a>>b;
	c[a]+=b;
	
}
bfs(1,n,adj,c);
for(int i=1;i<=n;i++) cout<<c[i]<<" ";

return 0;
}

Measured memory_bytes: 15572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;


int main(){
    ll r,d;
    V x(11);
    cin>>r>>d>>x.at(0);
    rep(1,11,1){
        x.at(i)=r*x.at(i-1)-d;
        cout<<x.at(i)<<endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  
  sort(C.begin(), C.end());
  reverse(C.begin(), C.end());
  
  int answer = 0;
  
   for (int i = 0; i < N; i++) {
     
     if (i % 2 == 0) {
       answer += C.at(i);
     }
     else if (i % 2 == 1) {
       answer -= C.at(i);
     }
     
   }
  
  cout << answer << endl;
}

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

using namespace std;

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

    int X, Y;
    cin >> X >> Y;
    int b = (Y/2) - X;
    int a = X - b;
    if(a >= 0 && b >=0 && (2*a) + (4*b) == Y) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9


int     main()
{
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> AV(A);
    vector<int> BV(B);
    int min_a = INF;
    int min_b = INF;
        
    for (int i = 0; i < A; i++)
    {   
        cin >> AV[i];
        min_a = min(min_a, AV[i]);
    }   
    for (int i = 0; i < B; i++)
    {   
        cin >> BV[i];
        min_b = min(min_b, BV[i]);
    }   
    int ans = min_a + min_b;
    for (int i = 0; i < M; i++)
    {   
        int x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        ans = min(ans, AV[x] + BV[y] - c); 
    }   
    cout << ans << endl;
}


Measured memory_bytes: 1024
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

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

  constexpr int64_t kN = 26;
  int64_t D;
  cin >> D;
  vector<int64_t> C(kN + 1, 0);
  for (int64_t c = 1; c <= kN; ++c) {
    cin >> C[c];
  }
  vector<vector<int64_t>> S(D + 1, vector<int64_t>(kN + 1));
  for (int64_t d = 1; d <= D; ++d) {
    for (int64_t c = 1; c <= kN; ++c) {
      cin >> S[d][c];
    }
  }
  vector<vector<int64_t>> last(D + 1, vector<int64_t>(kN + 1, 0));
  vector<int64_t> contests(D + 1);
  for (int64_t d = 1; d <= D; ++d) {
    cin >> contests[d];
  }

  auto Score = [&](const int64_t day) -> int64_t {
    int64_t score = 0;
    for (int64_t d = 1; d <= day; ++d) {
      last[d] = last[d - 1];
      last[d][contests[d]] = d;
      score += S[d][contests[d]];
      for (int64_t c = 1; c <= kN; ++c) {
        score -= C[c] * (d - last[d][c]);
      }
    }
    return score;
  };

  for (int64_t d = 1; d <= D; ++d) {
    int64_t best_score = INT64_MIN;
    int64_t best_conte = -1;
    for (int64_t c = 1; c <= kN; ++c) {
      contests[d] = c;
      int64_t temp_score = Score(d);
      if (temp_score > best_score) {
        best_score = temp_score;
        best_conte = c;
      }
    }
    contests[d] = best_conte;
  }
  for (int64_t d = 1; d <= D; ++d) {
    cout << contests[d] << endl;
  }
  return 0;
}


Measured memory_bytes: 3852
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
BC = list()
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC.sort(reverse=True, key=lambda x: x[1])
C = []
for b, c in BC:
    C += [c] * b
    if len(C) >= N:
        break
if len(C) < N:
    C += [0] * (N - len(C))

a = 0
c = 0
ans = 0
for _ in range(N):
    if A[a] > C[c]:
        ans += A[a]
        a += 1
    else:
        ans += C[c]
        c += 1

print(ans)


Measured memory_bytes: 23224
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    vector< pair<ll, ll>> A;
    while(true){
        ll x, y;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        A.pb(make_pair(x, y));
    }

    for(pair<ll, ll> p : A){
        pair<ll, ll> n = minmax(p.first, p.second);
        cout << n.first << " " << n.second << endl;
    }

    return 0;
}



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

struct Point{
  int next;
  struct Point *P,*L,*R;
};

struct Point *squrt,*setsu;
void inorder(struct Point *st);
void preorder (struct Point *st);
void insert (int a);
struct Point *find (struct Point *st,int b);
int main()
{
  int i,n,p;
  char hi[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",hi);
    if( hi[0] == 'f'){
     scanf("%d",&p);
     struct Point *q =find(squrt,p);
     if(q!=setsu)
       printf("yes\n");
     else printf("no\n");
    }
    else  if(hi[0]=='i'){        //*insert*//
      scanf("%d",&p);
      insert(p);
    }else if(hi[0]=='p'){   //*print*//
      inorder(squrt);
      printf("\n");
      preorder(squrt);
      printf("\n");
    }
  }
  return 0;
}

void inorder(struct Point *st){
  if(st==setsu)
    return;
  inorder(st->L);
  printf(" %d",st->next);
  inorder(st->R);
  
}

void preorder(struct Point *st){
  if(st==setsu)
    return;
  printf(" %d",st->next);
  preorder(st->L);
  preorder(st->R);

}

void insert (int a){
  struct Point *x=squrt;
  struct Point *y=setsu;
  struct Point *z;

  z=(struct Point *)malloc(sizeof(struct Point));
  z->next=a;
  z->L=setsu;
  z->R=setsu;

  while(x!=setsu){
    y=x;
    if(x->next > z->next){
      x=x->L;
    }else
      x=x->R;
    
  }

  z->P=y;
  if(y==setsu){
    squrt=z;
  }else{
    if(y->next > z->next){
      y->L=z;
    }else
      y->R=z;
    
  }
}
    
    
struct Point *find (struct Point *st,int b){
  while(st !=setsu && b !=st->next){
    if(b < st->next)
      st=st->L;
    else st=st->R;
  }
  return st;
}



Measured memory_bytes: 20540
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
int main()
{
	int k;
	cin>>k;
	ll ans=0;
	for(ll i=1;i<=k;i++)
	 {
	 	for(ll j=1;j<=k;j++)
	 	 {
	 	 	for(ll z=1;z<=k;z++)
	 	 	{
	 	 		ll tmp=gcd(i,j);
	 	 		ll tmp2=gcd(tmp,z);
	 	 		ans+=tmp2;
			}
		  }
	 }
	 cout<<ans<<endl;
}

Measured memory_bytes: 3624
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    i = 0
    cnt = 0
    visn1 = 0
    while i<n:
        if i == n-1:
            visn1 = 1
        if a[i] == i+1:
            cnt += 1
            i += 2
        else:
            i += 1


    
    print(cnt)





solve()


Measured memory_bytes: 14324
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true)
    {
        c -= b;
        a -= d;
        if(c <= 0)
        {
            cout << "Yes\n";
            break;
        }
        if(a <= 0)
        {
            cout << "No\n";
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, count=0, ans;
  std::cin >> N;
  string S;
  std::cin >> S;
  std::vector<int> look(N, 0);
  for(int i=1;i<N;i++) if(S[i]=='W') count++;
  look[0] = count;
  ans = count;
  for(int i=1;i<N;i++){
    look[i]=look[i-1];
    if(S[i]=='W') look[i]--;
    if(S[i-1]=='E') look[i]++;
    ans = max(ans, look[i]);
  }
  std::cout << N - ans - 1 << '\n';
  return 0;
}


Measured memory_bytes: 1916
#include <cstdio>

void swapint(int& x, int& y)
{
    int temp = x;
    x = y;
    y = temp;
}

int main()
{
    while (1)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0) break;
        if (x > y) swapint(x, y);
        printf("%d %d\n", x, y);
    }
    return 0;
}



Measured memory_bytes: 2676
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            long n = Math.abs(sc.nextLong());
            ArrayList<Integer> l = new ArrayList<>();
            for (int i = 0; i < n; i++)
                l.add(sc.nextInt());

            long result = 0;

            for (int i = 0; i < n - 2; i++) {
                for (int j = i + 1; j < n - 1; j++) {
                    for (int k = j + 1; k < n; k++) {
                        int l_i = l.get(i);
                        int l_j = l.get(j);
                        int l_k = l.get(k);
                        if (l_i == l_j || l_j == l_k || l_k == l_i)
                            continue;
                        if (l_i + l_j > l_k && l_j + l_k > l_i && l_k + l_i > l_j)
                            result++;
                    }
                }
            }
            return result;
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}


Measured memory_bytes: 28144
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll n, t; cin >> n >> t;
    vector<pair<ll, ll>> meal(n);
    for (int i = 0; i < n; ++i) {
        int a, b; cin >> a >> b;
        meal[i] = make_pair(a, b);
    }

    sort(meal.begin(), meal.end());
    vector<vector<ll>> dp1(n, vector<ll>(3001));
    vector<vector<ll>> dp2(n, vector<ll>(3001));
    for (int j = 1; j <= 3000; ++j) {
        dp2[0][j] = meal[0].second;
    }
    for (int j = meal[0].first; j <= 3000; ++j) {
        dp1[0][j] = meal[0].second;
    }

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= 3000; ++j) {
            dp1[i][j] = dp1[i - 1][j];
            if (j - meal[i].first >= 0) dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - meal[i].first] + meal[i].second);
        }
    }

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= 3000; ++j) {
            dp2[i][j] = max(dp1[i - 1][j] + meal[i].second, dp2[i - 1][j]);
        }
    }

    cout << dp2.back()[t - 1] << endl;
    return 0;
}

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

char ch[8][8]={};
bool check(int x, int y){
  return (0<=x && x<8 && 0<=y && y<8)&&(ch[x][y]=='1');
}

int main() {
  while(cin >> ch[0][0]) {
    for(int i=1; i<8; i++) cin >> ch[0][i];
    for(int i=1; i<8; i++) {
      for(int j=0; j<8; j++) cin >> ch[i][j];
    }
    int x,y;
    for(int i=0; i<8; i++) {
      for(int j=0; j<8; j++) {
	if(ch[i][j]=='1') {
	  x=i;
	  y=j;
	}
      }
    }
    if(check(x-3,y)) cout << "B" << endl;
    else if(check(x,y-3)) cout << "C" << endl;
    else if(check(x-2,y+1)) cout << "D" << endl;
    else if(check(x-1,y-2)) cout << "E" << endl;
    else if(check(x-2,y-1)) cout << "F" << endl;
    else if(check(x,y-1) && check(x-1,y+1)) cout << "G" << endl;
    else cout << "A" << endl;
  }
  return 0;
}


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

using ll=int64_t;
//#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

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

int extgcd(int a,int b,int&x,int&y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}else{
		int g=extgcd(b,a%b,y,x);
		y-=a/b*x;
		return g;
	}
}

signed main(){
	int w=read(),d=read(),n=read(),m=read(),t=read();
	int g,x,y;
	g=extgcd(m,t,x,y);
	int f=t/g;
	if(x<0)x+=f;
	assert(x>=0);
	int e=gcd(t,w+d);
	int cur=0;
	int cnt=0;
	int remG=0,remE=0;
	int last=-1;
	REP(i,t){
		if(remG==0){
			if(cur<n)last=i;
			cur+=x;
			if(cur>=f)cur-=f;
			remG=g-1;
		}else{
			remG--;
		}
		if(remE==0){
			cnt+=(last<i-w);
			remE=e-1;
		}else{
			remE--;
		}
	}
	cout<<fixed<<setprecision(20)<<double(cnt)/(t/e)<<endl;
}



Measured memory_bytes: 3304
def ge():
    return map(int,input().split())
def main():
    #a,b,c,d=ge()
    #N=int(input())
    #a=list(map(int,input().split()))
    #a=input()
    N=int(input())
    f0=[]
    f1=[]
    for _ in range(N):
        X,Y=ge()
        f0.append(X-Y)
        f1.append(X+Y)
    ans=max(max(f0)-min(f0),max(f1)-min(f1))
    print(ans)
main()

Measured memory_bytes: 24876
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        a: [usize;n],
    }

    let mut tmp = 300;
    let mut num_kabu = 0;
    let mut money = 1000;
    for i in 0..n {
        if tmp < a[i] {
            num_kabu = money / tmp;
            money += (a[i] - tmp) * num_kabu;
        }
        tmp = a[i];
    }

    println!("{}", money);

}

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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s : String= read();
    let t : String = read();
    if s == t {
            println!("Yes");
            return;
    }
    let mut cs:Vec<char>  =s.chars().collect();
    let len = cs.len();
    for i in 0..cs.len(){
        let last = cs[(len-1)as usize];
        let mut  ans:Vec<char> = cs.clone().into_iter().take(len-1).collect();
        ans.insert(0, last);
        
        if (t.chars().collect::<Vec<char>>() ==  ans){
            println!("Yes");
            return;
        }
        cs = ans;
    }
    println!("No");
}

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

int main() {
    long n,k;cin>>n>>k;
//    long c = 200000;
    long a[n];
    
    for(long i=0;i<n;++i){
        a[i] =0;
    }
    
    long tmp;
    for(long i=0;i<n;++i){
        cin>>tmp;
        a[tmp-1] +=1;
    }
    sort(a, a+n, greater<long>());
    long ans=0;
    for(long i=k;i<n;++i){
        if(a[i]==0)break;
        ans+=a[i];
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int i=1,x,y;
  while (1) {
    scanf("%d%d\n", &x, &y);
    if(x == 0 && y == 0){
      break;
    }else if (1 <= x || x <= 10000) {
      if (x < y) {
        printf("%d %d\n", x, y);
      }else{
        printf("%d %d\n", y, x);
      }
    }else{
      break;
    }
    i++;
  }
  return 0;
}

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

using namespace std;

int main(void) {
        vector<int> a(3,0);
        
        for(int i = 0; i < 3; i++) {
                cin >> a[i];
        }

//      sort(a.begin(), a.end(), greater<int>());
        sort(a.begin(), a.end());

        for(int i = 0; i < a.size() - 1; i++) {
                cout << a[i] << " ";
        }
        cout << a.back() << endl;       
                
        return 0;
}

Measured memory_bytes: 1208
s = list(input())
t = list(input())
i = 0

s.sort()
t.sort(reverse=True)

length = min(len(s), len(t))

while i <= length-1:
    if s[i] == t[i]:
        i += 1
    elif s[i] < t[i]:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

print('No' if length == len(t) else 'Yes')


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

#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
const int INF  = 1001001001;
const ll  LINF = 1e18;
const int di[4] = {-1, 0 , 1, 0};
const int dj[4] = {0, -1 , 0, 1 };
typedef pair<int, int> P;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    ll sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }    

    ll ans = LINF;
    ll tmp_ans = 0;
    ll tmp_sum = 0;
    rep(j, n-1){
        tmp_sum += a[j];
        tmp_ans = abs(sum - 2 * tmp_sum);
        ans = min(tmp_ans, ans);    
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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 s;cin >> s;
    ll p=inf-10;
    vl v={0,0,(s+p-1)/p,1,(p-s%p)%p,p};
    /*if(v[2]>p){
        v={0,0,p,1,p*p-s,p};
    }*/
    rep(i,6)cout << v[i]<<" ";
    cout << endl;
    //cout << v[2]*v[5]-v[3]*v[4] <<endl;
}


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

int d[1000];
int main() {
	int n, m, a, b; scanf("%d%d%d%d", &n, &m, &a, &b);
	rep(i, n)scanf("%d", &d[i]);
	stack<int>s;
	rep(i, n) {
		if (d[i] >= a)s.push(i);
		else break;
	}
	if (n - s.size() < m) {
		while (s.size()) {
			if (d[s.top()] <= b)s.pop();
			else break;
		}
	}
	printf("%d\n", s.size());
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    ll n;
    cin>>n;
    ll arr[n+1];
    for(ll i=1;i<=n;i++)
        cin>>arr[i];
        
    vector<pair<ll,ll>> v[n+1];
    ll vis[n+1] = {0};
    ll dist[n+1];
    for(ll i=1;i<=n;i++)
        dist[i] = 1e12;
    dist[1] = 0;
    
    multiset<pair<ll,ll>> ms;
    
    for(ll i=1;i<n-1;i++){
        v[i].push_back({i+1,abs(arr[i+1]-arr[i])});
        v[i].push_back({i+2,abs(arr[i+2]-arr[i])});
    }
    v[n-1].push_back({n,abs(arr[n]-arr[n-1])});
    
    ms.insert({0,1});
    
    while(!ms.empty()){
        pair<ll,ll> p = *ms.begin();
        ms.erase(ms.begin());
        if(vis[p.second])
            continue;
        vis[p.second] = true;
        
        for(auto u: v[p.second]){
            if(dist[p.second]+u.second<dist[u.first]){
                dist[u.first] = dist[p.second] + u.second;
                ms.insert({dist[u.first],u.first});
            }
        }
    }
    
    cout<<dist[n]<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll A, B, K; cin >> A >> B >> K;
  cout << max((ll)0,A-K) << " " << max((ll)0, B-max((ll)0,K-A)) << endl;
  return 0;
} 

Measured memory_bytes: 256
let to_list s =
  let rec loop l = function
      -1 -> l
    | i -> loop (((Char.code s.[i]) - 48)::l) (i-1)
  in loop [] ((String.length s)-1)

let () =
  let n = read_int () in
  let rec read = function
      0 -> ()
    | i ->
       let l = read_line () |> to_list |> List.sort compare in
       let small = List.fold_left (fun x y -> 10*x + y) 0 l and
           large = List.fold_right (fun x y -> x + 10*y) l 0 in
       Printf.printf "%d\n" (large-small);
       read (i-1)
  in read n
;;

Measured memory_bytes: 2252
import java.io.*;

public class Main {
	 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String s;
        while ((s = br.readLine()) != null) {
            String[] lc = s.split(" ");
            int a = Integer.parseInt(lc[0]);
            int b = Integer.parseInt(lc[1]);
            
            int gcd = gcd(a,b);
            int lcm = a / gcd * b;
            
            System.out.println(gcd + " " + lcm);
        }
 
    }
    
    private static int gcd(int a, int b) {
    	while(b!=0){
    		int aa = a;
    		a = b;
    		b = aa%b;
    	}
    	return a;
    }
}

Measured memory_bytes: 24280
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf")]*n
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i-j >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]))
print(dp[n-1])

Measured memory_bytes: 85680