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

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long k = sc.nextLong();
			if(a > k) {
				System.out.println((a - k) + " " + b);
			} else if(b < k - a) {
				System.out.println("0 0");
			} else {
				System.out.println(0 + " " + (b - (k - a)));
			}
		}

	}

}


Measured memory_bytes: 21844
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> A >> B >> C;
    cout << max(A, max(B, C)) - min(A, min(B, C));
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int in[4][3][10]={0};
int main(){
int n;
cin>>n;
rep(i,n){
int a,b,c,d;
cin>>a>>b>>c>>d;
in[--a][--b][--c]+=d;
}
rep(i,4){
rep(j,3){
rep(k,10){
cout<<" "<<in[i][j][k];
}
cout<<endl;
}
if(i==3)break;
cout<<"####################"<<endl;
}
}

Measured memory_bytes: 1164
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 2e5 + 10;
int a[maxn], where[maxn];

int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    --a[i];
    where[a[i]] = i;
  }
  return 1;
}

void solve() {
  set<int> bs;
  bs.insert(-1);
  bs.insert(n);

  long long res = 0;
  for (int i = 0; i < n; ++i) {
    auto right = bs.lower_bound(where[i]);
    auto left = right;
    --left;

    res += (long long) (*right - where[i]) * (where[i] - *left) * (i + 1);
    bs.insert(where[i]);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
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, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	string s;
	int ans = 0;
	cin >> n>>s;
	char last = 0;
	rep(i,n){
		if(last!=s[i]){
			ans++;
		}
		last = s[i];
	}
	cout << ans << endl;
}

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

int main() {
   int n;
  cin>>n;
    vector<int> d(n);
  rep(i,n) cin>>d[i];
  //////////////////
  sort(all(d));
 n/=2;
  int ans=d[n]-d[n-1];
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
		int n,a[10000],ans=0,ans1=0,x1=0;
		cin>>n;
		for(int in=0;in<n;in++){
			cin>>a[in];
		}
		for(int i=0;;i++){
			int x=i/n;
			if(a[i-x*n]%2==0){
				ans++;
				a[i-x*n]=a[i-x*n]/2;
			}
			if(x1!=x){
				if(ans1==ans){
					cout<<ans<<endl;
					return 0;
				}
				ans1=ans;
			}
			x1=x;
		}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void scan(int a[],int n)
{
    for(int i=0;i<n;i++)
    cin>>a[i];
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.size(),m=s2.size();
    int c=INT_MAX;
    for(int i=0;i<=n-m;i++)
    {
        int k=0,p=0;
        for(int j=0;j<m;j++)
        {
            if(s1[i+k]!=s2[j])
            {
                p++;
                k++;
            }
            else
            {
                k++;
            }
        }
        
        c=min(c,p);
        
    }
    cout<<c<<"\n";
}

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

long long mod = 998244353;

long long modplus(long long a, long long b){
	long long ans = a + b;
	ans %= mod;
	return ans;
}

long long modminus(long long a, long long b){
	long long ans = a - b;
	ans %= mod;
	if(ans < 0) ans += mod;
	return ans;
}

long long modmul(long long a, long long b){
	long long ans = (a % mod) * (b % mod);
	ans = ((ans % mod) + mod) % mod;
	return ans;
}

long long modpow(long long A, long long P){
	long long a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	long long adash = modmul(a,a);
	if(p % 2) return modmul(modpow(adash, p / 2), a);
	else return modpow(adash, p / 2);
}

long long moddiv(long long a, long long b){
	long long divisor = modpow(b, mod - 2);
	return modmul(a,divisor);
}

int main(){
	int N, K;
	cin >> N >> K;
	int L[K], R[K];
	for(int i=0;i<K;i++){
		cin >> L[i] >> R[i];
		L[i];
		R[i];
	}
	long long dp[N];
	long long dpsum[N+1];
	dp[N-1] = 1;
	dpsum[N] = 0;
	dpsum[N-1] = 1;
	for(int i=0;i<N-1;i++){
		dp[i] = 0;
		dpsum[i] = 0;
	}
	for(int i=N-2;i>=0;i--){
		for(int j=0;j<K;j++){
			int l = L[j] + i;
			int r = R[j] + i + 1;
			if(l > N-1) continue;
			if(r > N) r = N;
			dp[i] = modplus(dp[i], 
				modminus(dpsum[l], dpsum[r]));
		}
		dpsum[i] = modplus(dp[i],dpsum[i+1]);
	}
	// for(int i=0;i<N;i++){
	// 	cout << i << ":" << dp[i] << endl;
	// }
	cout << dp[0] << endl;
}


Measured memory_bytes: 6760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRingosFavoriteNumbers solver = new BRingosFavoriteNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRingosFavoriteNumbers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int d = in.nextInt(), n = in.nextInt();
            int answer = 1;
            for (int i = 0; i < d; i++) {
                answer *= 100;
            }

            if (n == 100)
                n++;
            answer *= n;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const ll INF = 1e18L + 5;
/////////////////////////////////////////////////////////////////////

int main() {
    int N, W;
    scanf("%d%d", &N, &W);
    vector<int> weight(N), value(N);
    for (int i = 0; i < N; ++i) scanf("%d%d", &weight[i], &value[i]);
    int sum_value = accumulate(value.begin(), value.end(), 0);

    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the maximum total value with weight exactly i
    for (int i = 0; i < N; ++i) {
        for (int value_already = sum_value - value[i]; value_already >= 0; --value_already) {
            chmin(dp[value_already + value[i]], dp[value_already] + weight[i]);
        }
    }
    ll res = 0;
    for (int i = 0; i <= sum_value; ++i) {
        if (dp[i] <= W) {
            chmax(res, (ll) i);
        }
    }
    printf("%lld\n", res);

    return 0;
}

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

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

vector<vector<pi>> g;
vector<int> vis;
vector<int> arr;

void dfs(int v, int val)
{
    vis[v]=1;
    arr[v]+=val;
    F0R(i,sz(g[v]))
    {
        if(!vis[g[v][i].f])
            dfs(g[v][i].f,arr[v]);
    }
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,q;
    cin >> n >> q;
    F0R(i,n+1)
    {
        vector<pi> nv;
        g.pb(nv);
        vis.pb(0);
        arr.pb(0);
    }
    int f,s;
    F0R(i,n-1)
    {
        cin >> f >> s;
        g[f].pb({s,0});
        g[s].pb({f,0});
    }
    F0R(i,q)
    {
        cin >> f >> s;
        arr[f]+=s;
    }
    dfs(1,0);
    FOR(i,1,n+1)
    {
        cout << arr[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 20888
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
  
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}




Measured memory_bytes: 3204
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

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

    int n = s.size();

    int i = 0;
    int j = n-1;
    int cnt = 0;
    while(1){
        if(i == j || i > j){
            cout << cnt << endl;
            return 0;
        }else if(s[i] == 'x' && s[j] != 'x'){
            i++;
            cnt++;
        }else if(s[i] != 'x' && s[j] == 'x'){
            j--;
            cnt++;
        }else if(s[i] == s[j]){
            i++;
            j--;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

int main(void){
    string s;
    // 入力
    cin >> s;
    
    // 隣り合う文字を比較して判定
    bool isgood = true;
    if (s[0] == s[1]) isgood = false;
    if (s[1] == s[2]) isgood = false;
    if (s[2] == s[3]) isgood = false;
    // 出力
    if (isgood) {
        cout << "Good" << endl;
    }
    else {
        cout << "Bad" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
from statistics import median
import math

N = int(input())
A = list(map(int, input().split()))
A = [A[idx]-(idx+1) for idx in range(N)]

ans1 = 0
ans2 = 0
median_A = median(A)
median_floor_A = math.floor(median_A)
median_ceil_A = math.ceil(median(A))

for i in range(N):
    ans1 += abs(median_floor_A - A[i])
    ans2 += abs(median_ceil_A - A[i])
    
print(min(ans1,ans2))

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

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2) {
        if (s[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 1; i < s.size(); i += 2) {
        if (s[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

    vector<string> a(n), b(m);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<m; i++){
        cin >> b[i];
    }

    //solve
    for(int i=0; i<=n-m; i++){
        for(int j=0; j<=n-m; j++){
            bool flag = true;
            for(int k=0; k<m; k++){
                for(int l=0; l<m; l++){// substr is smarter but anyway...
                    if(a[i+k][j+l] != b[k][l]){
                        flag = false;
                        break;
                    }
                }
                if(flag == false) break;
            }
            if(flag == true){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

struct road {
    int u, v, len;
    bool operator < (const road & a) const {
        return len < a.len;
    }
};

int a[305][305];
ll d[305][305];

int main() {
    int n;
    scanf("%d", &n);
    vector <road> v;
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= n; j ++) {
            scanf("%d", &a[i][j]);
            if (i < j)
                v.push_back((road) {i, j, a[i][j]});
        }
    memset(d, 0x3f, sizeof d);
    for (int i = 1; i <= n; i ++)
        d[i][i] = 0;
    sort(v.begin(), v.end());
    ll res = 0;
    for (auto & r : v) {
        if (d[r.u][r.v] < r.len) continue;
        if (d[r.u][r.v] > r.len) res += r.len;
        d[r.v][r.u] = d[r.u][r.v] = r.len;
        for (int k = 1; k <= n; k ++) {
            d[k][r.u] = d[r.u][k] = min(d[r.u][k], r.len + d[k][r.v]);
            d[k][r.v] = d[r.v][k] = min(d[r.v][k], r.len + d[k][r.u]);
        }
    }
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j < i; j ++)
            if (a[i][j] != d[i][j]) return puts("-1"), 0;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 2040
#include <cstring>
#include <iostream>

using namespace std;

int main()
{
	char S[100] = ""; int c = 0;

	while (cin >> S)
	{
		for (int i = 0; i < strlen(S); i++)
		{
			if (S[i] != S[strlen(S) - i - 1]) { goto Exit; }
		}

		c++;

	Exit:;
	}

	cout << c << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;

  int64_t result = 1;
  for (int i = 1; i <= 3; ++i) {
    result *= N;
  }

  cout << (result) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*ll dx[8]={-1,-1,-1,0,0,1,1,1};
ll dy[8]={-1,0,1,-1,1,-1,0,1};*/
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll r,c;
     char arr[105][105];
     cin>>r>>c;
     for(int i=0;i<r;i++)
     {
         for(int j=0;j<c;j++)
         {
             cin>>arr[i][j];
         }
     }
     for(int i=0;i<r;i++)
     {
         ll cnt=0;
         for(int j=0;j<c;j++)
         {
             if(arr[i][j]=='.')
                cnt++;
         }
        // cout<<cnt<<endl;
         if(cnt==c)
         {
             for(int j=0;j<c;j++)
         {
             arr[i][j]='x';
         }
         }
     }
     for(int i=0;i<c;i++)
     {
         ll cnt=0;
         for(int j=0;j<r;j++)
         {
             if(arr[j][i]=='.'|| arr[j][i]=='x')
                cnt++;
         }
         if(cnt==r)
         {
             for(int j=0;j<r;j++)
         {
             arr[j][i]='x';
         }
         }
     }
     for(int i=0;i<r;i++)
     {
         ll pk=0;
         for(int j=0;j<c;j++)
         {
             if(arr[i][j]!='x')
                cout<<arr[i][j],pk++;
         }
         if(pk!=0)
            cout<<endl;
     }


}


Measured memory_bytes: 3636
/*

A try towards peace

*/

#include <bits/stdc++.h>
using namespace std;
#define yo long long int
#define lo mp::cpp_int
#define pb push_back
#define pob pop_back
#define mp make_pair
#define endl "\n"
#define ce(x) cout << x <<"\n"
#define fill(s,v) memset(s,v,sizeof(s))
#define speed  { ios_base::sync_with_stdio(false); cin.tie(0); }
#define for2(i,a,b) for(yo i=a;i<b;i++)
#define for3(i,a,b) for(yo i=a;i<=b;i++)
#define for1(a,b) for(yo i=a;i<b;i++)
#define deb(x) cout<<#x<<" "<<x<<endl; 
#define INFINITE 1000000009
#define ull unsigned long long int
#define take(a,n) for(yo pp=0;pp<n;pp++) { cin>>a[pp]; }
#define take2(a,n) for(yo p=0;p<n;p++) { yo temp;cin>>temp;a.pb(temp); }
#define show(a,n) for(yo p=0;p<n;p++) cout<<a[p]<<" ";
#define _ <<" "<<
#define nl cout<<endl;
#define sq(x) ((x)*(x))
#define call(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ff first
#define ss second
#define lld long double
#define tc(tt) \
    yo tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) 
 
yo dx[] = {1, 0, -1, 0};
yo dy[] = {0, 1, 0, -1};
const yo N = 1000*1000+5;
const yo size = 1000*100*2+5;
const yo mod = 1000*1000*1000+7;
 
yo gcd(yo a, yo b){if(!b)return a;return gcd(b, a % b);} 
yo power_mod(yo x,yo y,yo p){yo res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
yo lcm(yo a, yo b){return (a*b)/gcd(a, b);}
yo sumofdigits(yo n){yo out=0;while(n){out+=(n%10);n/=10;}return out;}
bool isPrime(yo n){if (n <= 1)  return false; if (n <= 3)  return true; if (n%2 == 0 || n%3 == 0) return false; for (yo i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;return true;} 
yo power(yo a,yo b){if(b==0)return 1;if(b&1)return a*power(a,b-1);yo res=power(a,b/2);return res*res;}
yo log(yo d){return log2(d);}
bool isPower(yo x, yo y){if(x==1) return (y==1); yo pow=1; while(pow<y) pow*=x; return(pow == y);}  
bool compare (const pair<yo,yo> &i,const pair<yo,yo> &j){return i.first < j.first;}
yo i,j;

lld polygonArea(lld X[], lld Y[], yo n) 
{   
    lld area = 0.0; 
    yo j = n - 1; 
    for (yo i = 0; i < n; i++) 
    { 
        area += (X[j] + X[i]) * (Y[j] - Y[i]); 
        j = i;  
    }    
    return abs(area); 
} 
bool prime[100200];
vector<yo> dp;
 
void SieveOfEratosthenes(yo n) 
{   
    for (yo p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for ( i=p*p; i<=n; i += p) 
                prime[i] = false;   
        } 
    } 
  
    for (yo p=2; p<=n; p++)  
       if (prime[p]) 
          dp.pb(p); 
} 

int main ()
{
    yo n; cin>>n;
    yo a[n]; take(a,n);
    yo b[n]; take(b,n);

    yo x[n];
    yo t=1;
    for1(0,n) {x[i]=t;t++;}
    t=1;
    yo f1,f2,s1=-1,s2=-1;
    do{
        f1=0,f2=0;
        for1(0,n) if(x[i]==a[i]) f1++;
        for1(0,n) if(x[i]==b[i]) f2++;
        if(f1==n) s1=t;
        if(f2==n) s2=t;
        if(s1>0 && s2>0) break;
        t++;
    }while(next_permutation(x,x+n));

    cout<<abs(s1-s2);
    nl

}
/*


200560490130



*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
auto ____ = [] () {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); };
const int MAXN = 1e5+7;
int n;
char s[MAXN];
int main(){
    ____();
    cin >> n >> s+1;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(s[i]!=s[i-1]) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
               res += arr[a]*arr[b];
         System.out.println(res);
      }
   }

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define mc map<char,ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define M 1000000007


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

ll prime(ll x)
{ fe(i,2,sqrt(x))
   {if(x%i==0)
    return 0;
   }
return 1;
}


int main()
{ ll t=1;
  //cin>>t;
  while(t--)
  { ll n=0,i=0,j=0,k=0,c=0,flag=0,flag1=0;
    cin>>k>>n;
    vi v;
    ll a[n];
    f(i,0,n)
     {cin>>a[i];
      if(i>0)
        v.pb(a[i]-a[i-1]);
     }
    v.pb(k-a[n-1]+a[0]);
    sort(v.begin(),v.end());
    f(i,0,n-1)
     c+=v[i];
    cout<<c<<endl;
  }
return 0;
}


Measured memory_bytes: 4468
N = int(input())
Vlist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

XY = 0

for i in range(0,N):
	if Vlist[i] >= Clist[i]:
		XY += Vlist[i] - Clist[i]

print(XY)

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

// MEMO
//
// O(VE)

// THE BEGINNING OF THE LIBRARY.

struct BipartiteMatching {
	using UnWeightedGraph=vector< vector<int> >;

	int n;
	UnWeightedGraph G;
	vector<int> match,used;

	BipartiteMatching() {}
	BipartiteMatching(int sz):n(sz),G(sz),match(sz),used(sz) {}

	void add_edge(int u,int v) {
		G[u].push_back(v);
		G[v].push_back(u);
	}

	bool dfs(int v) {
		used[v]=true;
		for(auto u:G[v]) {
			int w=match[u];
			if(w<0||(!used[w]&&dfs(w))) {
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}

	int bipartite_matching() {
		int res=0;
		fill(match.begin(),match.end(),-1);
		for(int v=0;v<n;v++) {
			if(match[v]<0) {
				fill(used.begin(),used.end(),0);
				if(dfs(v)) res++;
			}
		}
		return res;
	}
};

int gcd(int a,int b) {
	if(a<b) swap(a,b);
	int r;
	while(a%b!=0) {
		r=b;b=a%b;a=r;
	}
	return b;
}

// THE ENDING OF THE LIBRARY.
// THE FOLLOWING IS AN EXAMPLE OF USE.

int main() {

    while(1) {
	int m,n;
	cin>>m>>n;
    if(m==0) break;
	vector<int> a(m),b(n);
	for(int i=0;i<m;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	BipartiteMatching bimatch(m+n);
	for(int i=0;i<m;i++) {
		for(int j=0;j<n;j++) {
			if(gcd(a[i],b[j])>1) bimatch.add_edge(i,j+m);
		}
	}
	cout<<bimatch.bipartite_matching()<<endl;
    } 
	return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define mp make_pair
#define r0 return 0

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int x, a;
    cin >> x >> a;
    if (x < a)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 10 << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            var D = cin.ReadInt;

            while (true) 
            {
                C -= B;
                if (C <= 0) 
                {
                    WriteLine("Yes");
                    break;
                }

                A -= D;
                if (A <= 0) 
                {
                    WriteLine("No");
                    break;
                }
            }
        }

        public void Display(int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0}", txt);
        }

        public void Display(int index,int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0} : {1}", index,txt);
        }

        public void Display(List<int>[] list) 
        {
            for (int i = 0; i < list.Length; i++)
            {
                Display(i, list[i].ToArray());
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 27912
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {

	int s, w;

	cin >> s >> w;

	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}

	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    
    vector<vector<char>> x(n);
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < s.size(); j++) {
        x[i].emplace_back(s[j]);
      }
    }
    
    for (int i = 1; i < n; i++) {
      for (int j = 1; j < x[i].size(); j++) {
        if (x[i][j - 1] == '.' && x[i][j] != '.') {
          x[i][j - 1] = '+';
          int nowi = i - 1, nowj = j - 1;
          while (nowi > 0) {
            if (x[nowi][nowj] == '.') x[nowi][nowj] = '|';
            else break;
            nowi--;
          }
          break;
        }
      }
    }
    
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < x[i].size(); j++) {
        if (x[i][j] == '.') cout << " ";
        else cout << x[i][j];
      }
      cout << '\n';
    }
  }
}


Measured memory_bytes: 3660
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 * 一堆区域里有一堆城市，要求输出城市的ID
 * @author SDSC
sample input1
2 3
1 32
2 63
1 12
sample output1
000001000002
000002000001
000001000001

sample input2
2 3
2 55
2 77
2 99
sample output2
000002000001
000002000002
000002000003

1 5
1 999
1 888
1 9999999
1 2
1 159875
1000000999 000001000003
1000000888 000001000002
1009999999 000001000005
1000000002 000001000001
1000159875 000001000004


 */
public class Main{
	static int yearLen=10;

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int Pcount=sc.nextInt();//区块的总个数 10的五次方
		int cityCount=sc.nextInt();//城市的总格式 10的五次方
		List<Long> inputList=new ArrayList<Long>();
		List<Long> inputList2=new ArrayList<Long>();
		for(int i=0;i<cityCount;i++) {
			int p=sc.nextInt();
			int year=sc.nextInt();//年份  10的九次方
			String yearZero=Append10Zero(year);
			inputList.add(Long.valueOf(p+yearZero));
			inputList2.add(Long.valueOf(p+yearZero));
		}
		sc.close();
		
		Collections.sort(inputList);
		int index=0;
		Map<Long,String> map=new HashMap<Long,String>();
		for(int i=0;i<inputList.size();i++) {//需要区域
			index++;
			String a=inputList.get(i).toString();
			a=a.substring(0, a.length()-yearLen);//当前的区域ID
			if(i>0){
				String b=inputList.get(i-1).toString();
				b=b.substring(0, b.length()-yearLen);
				if(!a.equals(b)) {//需要重新计数了
					index=1;
				}
			}
			map.put(inputList.get(i), AppendZero(Integer.valueOf(a))+AppendZero(Integer.valueOf(index)));
		}
		for(Long l:inputList2) {
			System.out.println(map.get(l));
		}
		
	}

	private static String AppendZero(int z) {
		int len=6;
		String s=String.valueOf(z);
		int appLen=len-s.length();
		for(int i=0;i<appLen;i++) {
			s="0"+s;
		}
		return s;
	}
	private static String Append10Zero(int z) {
		String s=String.valueOf(z);
		int appLen=yearLen-s.length();
		for(int i=0;i<appLen;i++) {
			s="0"+s;
		}
		return s;
	}
	
	

}


Measured memory_bytes: 138696
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		Scanner in =new Scanner(System.in);
		int n=in.nextInt(),k=in.nextInt();
			
		int[] a = new int[n];
			
		for(int i = 0;i<n;i++) {
				a[i] = in.nextInt();
		}
		
		Arrays.sort(a);
		int sum = 0;
		for(int i = 0;i<k;i++) {
			sum = sum+a[i];
		}
		
		System.out.println(sum);
		
	}

}


Measured memory_bytes: 30104
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(void) {
    int N,M, ans=0;
    cin >> N >> M;

    ans = (N*(N-1))/2 + (M*(M-1))/2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, c, x, y = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    paymin = max(a, b, c) * (x + y) *2
    for ab in range(max(x, y)+1):
        if paymin > (2 * ab * c) + (max((x - ab), 0) * a) + (max((y - ab), 0) * b):
            paymin = (2 * ab * c) + (max((x - ab), 0) * a) + (max((y - ab), 0) * b)

    print(paymin)
resolve()

Measured memory_bytes: 39280
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	vector<int>a(n), b(n), c(n - 1);
	int i;
	int bef = 0, aft = 0;;
	int sum = 0;
	for (i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	for (i = 0; i < n; i++)
	{
		cin >> b.at(i);
	}
	for (i = 0; i < n-1; i++)
	{
		cin >> c.at(i);
	}
	for (i = 0; i < n; i++)
	{
		sum += b.at(a.at(i) - 1);
		if (i >= 1)
		{
			if (a.at(i) - a.at(i - 1) == 1)
			{
				sum += c.at(a.at(i-1) - 1);
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int a,b,c,d;cin>>a>>b>>c>>d;
	int val1=cel(a,d),val2=cel(c,b);
	if(val1 < val2){
		cout<<"No\n";

	}
	else
		cout<<"Yes\n";
	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	string s; cin>>s;
	if(n%2) {
		cout<<"No\n";
		return 0;
	}
	string t=s.substr(0,n/2);
	cout<<(s==t+t?"Yes":"No")<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000
#define INFTY 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2 + 2],R[MAX/2 + 2];

void merge(struct Card S[],int n,int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  
  for(i = 0;i<=n1-1;i++){
    L[i] = S[left + i];
    
  }
  for(i = 0;i<=n2 - 1;i++){
    R[i] = S[mid + i];
  }
  L[n1].value = INFTY;
  R[n2].value = INFTY;
  i = 0;
  j = 0;
  for(k = left;k<=right-1;k++){
    if(L[i].value <= R[j].value){
      S[k] = L[i];
      i = i+1;
    
    }
    else{
      S[k] = R[j];
      j = j+1;
     
    }
  }

}
void mergeSort(struct Card S[],int n, int left,int right){
  int mid;
  if((left+1) < right){
    mid = (left+right)/2;
    mergeSort(S,n,left,mid);
    mergeSort(S,n,mid,right);
    merge(S,n,left,mid,right);
   
  }
}



int partition(struct Card S[],int n,int p,int r){
  int i,j;
  struct Card temp,x;
  x = S[r];
  i = p-1;
  for(j = p;j<=r-1;j++){
    if(S[j].value<= x.value){
      i = i+1;
      temp = S[i];
      S[i] = S[j];
      S[j] = temp;
    }
  }

  temp = S[i+1];
  S[i+1]=S[r];
  S[r] = temp;
    
   
  
  return i+1;
}

void quickSort(struct Card S[],int n,int p,int r){
  int q;
  if(p < r){
    q = partition(S,n,p,r);
    quickSort(S,n,p,q-1);
    quickSort(S,n,q+1,r);
  }
}

int main(){
  int i,n,v;
  struct Card S[MAX],B[MAX];
  char A[10];

  int stable = 1;

  scanf("%d",&n);

  for(i = 0;i<n;i++){
    scanf("%s %d",A,&v);
    S[i].suit = B[i].suit = A[0];
    S[i].value = B[i].value = v;
  }

  mergeSort(S,n,0,n);
  quickSort(B,n,0,n-1);


  for(i = 0;i<n;i++){
    if(S[i].suit != B[i].suit) stable = 0;
    

  }
  if(stable == 1)printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



Measured memory_bytes: 4080
from math import atan2
from math import pi

a, b, x = map(float, input().split())
s = x / a               # 水の量（平面で考慮）

# 水の量が水筒の半分以上
if  s >= a * b / 2:
    air = a * b - s     # 空気の面積
    h = 2 * air / a     # 傾けた時の空気の量の高さ（a * h = air　を変形）
    rad = atan2(h, a)   # 傾けた時のradian

# 水の量が水筒の半分未満
else:
    w = 2 * s / b       # 傾けた時の水の幅
    rad = atan2(b, w)   # 傾けた時のradian

# ラジアン（rad） から 度（deg）に変換
deg = rad * 180 / pi

print(deg)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define fir first
#define sec second
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, H[100001] = {};
bool flag = true, flagDown = false;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> H[i];
		if (i > 1) {
			if (H[i] < H[i - 1]) {
				if (flagDown) {
					flag = false;
					break;
				}
				flagDown = true;
			}
			if (H[i] < H[i - 1] - 1) {
				flag = false;
				break;
			}
			if (H[i] > H[i - 1])flagDown = false;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
N = int(input())

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

A.sort()

npl = A[-1]
nmi = A[0]

del A[0]
del A[-1]
lis = []

for i in A:

    if i < 0:
        lis.append([npl,i])
        npl -= i

    else:
        lis.append([nmi,i])
        nmi -= i

lis.append([npl,nmi])
print (npl-nmi)

for i in lis:

    print (i[0],i[1])

Measured memory_bytes: 68188
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

vector<int> adj[100100];//adjacency list
int main()
{
    int m,i,a,b,v;
    int n;//number of nodes
    int s;//source vertex
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    queue<int> q;
    vector<bool> used(n);
    vector<int> p(n+1);
    q.push(1);
    for(i=1;i<=n;i++){used[i]=false;}
    used[1]=true;
    p[1]=-1;
    while(!q.empty())
    {
        v=q.front();
        q.pop();
        //used[v]=true;
        for(int u:adj[v])
        {
            if(!used[u])
            {used[u]=true;q.push(u);p[u]=v;}
        }
    }
    for(i=1;i<=n;i++){if(!used[i]){cout<<"No";return 0;}}
    cout<<"Yes"<<"\n";
    for(i=2;i<=n;i++)
    {
        cout<<p[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 10056
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 0
max = 0

for a in A:
    if a >= max:
        max = a
    else:
        ans += max-a

print(ans)


Measured memory_bytes: 32300
#include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
int PA[MAX_N],PB[MAX_N];
int Cou = 0;//何回目の勝負か記憶しておく

int main(){
  while(true){
  scanf("%d",&N);//配られるカードの枚数
  if(N==0)
    break;
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA[Cou] += A[i]+B[i];
    else if(A[i] < B[i])
      PB[Cou] += A[i]+B[i];
    else{
      PA[Cou] += A[i];
      PB[Cou] += B[i];
    }
  }
  Cou++;
  }
  for(int j = 0;j < Cou;j++){
      printf("%d %d\n",PA[j],PB[j]);
  }
  return 0;
 
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,1,N+1) cin >> A[i];
    ll p = 1;
    rep(i,0,N){
        p = A[p];
        if(p == 2){
            print(i+1);
            return 0;
        }
    }
    print(-1);
}

Measured memory_bytes: 1024
import itertools
import math
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
count = 0
i = 1
while d <= x and i <= n:
    d = d + l[i - 1]
    count += 1
    i += 1
if d <= x:
    count += 1

print(count)

Measured memory_bytes: 38256
n, x, m = map(int, input().split())
g = x * 1
ans = x
arr = []
res = set([])
loop = (0, 0)
k = 0
for i in range(m + 1):
	tmp = x ** 2 % m
	if tmp in res:
		loop = (i, tmp)
		break
	res.add(tmp)
	arr.append(tmp)
	ans += tmp
	x = tmp

for i, y in enumerate(arr):
	if y == loop[1]:
		k = i
		break

ini = g + sum(arr[:k])
mul = ans - ini
t, v = divmod(n - k - 1, loop[0] - k)
print(ini + mul * t + sum(arr[k:k + v]))


Measured memory_bytes: 76904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = bf.readLine()) != null) {
			char[] c = line.toCharArray();
			if(c.length<=0)break;
			for(int i=0;i<c.length;i++)c[i] -= '0';
			for(int i=c.length-1;i>=0;i--)for(int j=0;j<i;j++)c[j] = (char)((c[j]+c[j+1])%10);
			System.out.println((int)c[0]);
		}
	}
}

Measured memory_bytes: 9040
#include <stdio.h>
#define N 101

char s[N];

int main()
{	
	int i;
	
	scanf("%s", s);
	for(i = 0; s[i] && s[i] != 'C'; i++);
	for( ; s[i] && s[i] != 'F'; i++);
	if(s[i]) puts("Yes");
	else puts("No");
		
	return 0;
}

Measured memory_bytes: 128
n=int(input())
l=[]
t=n
while(t):
    l1=list(map(int,input().split()))
    l.append(l1)
    t-=1
dp=[[0 for i in range(3)] for j in range(n)]
dp[0][0]=l[0][0]
dp[0][1]=l[0][1]
dp[0][2]=l[0][2]
for i in range(1,n):
    dp[i][0]=max(l[i][0]+dp[i-1][1],l[i][0]+dp[i-1][2])
    dp[i][1]=max(l[i][1]+dp[i-1][0],l[i][1]+dp[i-1][2])
    dp[i][2]=max(l[i][2]+dp[i-1][0],l[i][2]+dp[i-1][1])
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

Measured memory_bytes: 50116
/*
      author : Nishikawa
      created: 07.08.2020 15:34:11
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3640