akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  forn(i,n) cin >> a[i];
  forn(i,n) cin >> b[i];
  if (a > b) swap(a,b);
  int ans = 0;
  while (a < b){
    next_permutation(all(a));
    ans++;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

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

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

typedef long long ll;

using namespace std;




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  vector<int>a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(all(a));
  sort(all(c));
  ll res=0;
  rep(i,n)
  {
    res+=((lower_bound(all(a),b[i])-a.begin())*(c.end()-upper_bound(all(c),b[i])));
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(void)
{
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	
	int min = (a[0] - 1) % 10;
	int p = 0;
	for (int i = 1; i < 5; i++) {
		if (min > (a[i] - 1) % 10) {
			min = (a[i] - 1) % 10;
			p = i;
		}
	}

	int sum = 0;
	for (int i = 0; i < 5; i++) {
		sum += (p == i) ? 0 : a[i];
		sum += (sum % 10 == 0) ? 0 : 10 - sum % 10;
	}
	cout << sum + a[p] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a[51],n,b,i,j,c[51],d[51];
    b=999999;
    cin>>n;
    for (i=0;i<n;i++){
        cin>>a[i];
        d[i]=a[i];
    }
    for (i=0;i<n;i++){
        for (j=0;j<n;j++){
            if (b>a[j]){
                b=a[j];
            }
        }
        c[i]=b;
        for (j=0;j<n;j++){
            if (a[j]==b){
                a[j]=9999999;
                break;
            }
        }
        b=999999;
    }
    b=0;
    for  (i=0;i<n;i++){
        if (d[i]!=c[i]){
            b=b+1;
        }
    }
    if (b<=2){
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import math
import sys


def solve(A: int, B: int):
    r = str(A*B)
    if len(r) > 3:
        print(r[:len(r)-2])
    else:
        print(0)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = next(tokens)
    startWithZero = True
    everyZero =True
    l = 0
    bstr = ""
    for c in B:
        if c==".":
            continue
        if c == "0":
            l += 1
            if startWithZero:
                pass
            else:
                bstr += "0"
        else:
            everyZero = False
            l += 1
            startWithZero = False
            bstr += c
    for i in range(3-l):
        bstr+= "0"
    if everyZero:
        print(0)
        exit()
    solve(A, int(bstr))
#
if __name__ == '__main__':
    main()


Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
long long l[86];
int n;
int main() {
    l[0]=2; l[1]=1;
    for (int i=2; i<=86; i++) l[i]=l[i-1]+l[i-2];
    
    cin >> n; cout << l[n]; 
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		a *= sc.nextInt();
		int b = sc.nextInt();
		b *= sc.nextInt();
		sc.close();
		System.out.println(Math.max(a,b));

	}

}


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

int main(void) {
	int n, d, x, a[100];
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (d % a[i] == 0) x += d / a[i];
		else x += d / a[i] + 1;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int N,ans[531441];
static inline void OUT(int x){if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline int Pow(int a,int b){return b?Pow(a*a,b>>1)*(b&1?a:1):1;}
string reduce(string T)
{
  string res="";
  for(auto ch:T){if(res.size()&&res.back()=='S'&&ch=='S')res.pop_back();else res+=ch;}
  return res;
}
void solve(int m,string T,int i,int p)
{
  if(m==N){ans[i]=p;return;}
  rep(d,3)
  {
    string nextT="";int x=d;
    for(auto ch:T){if(ch=='S'){x=(3-x)%3;nextT+='S';}else{x=(x+1)%3;if(x==0)nextT+='R';}}
    solve(m+1,reduce(nextT),i+d*Pow(3,m),p+x*Pow(3,m));
  }
}
int main(){string T;cin>>N>>T;solve(0,reduce(T),0,0);rep(i,Pow(3,N)){OUT(ans[i]),putchar(' ');}}

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

ll N, M, K, A[200000]={0}, B[200000]={0}, C[200000]={0}, ans=0;
const int MAX = 200000;
const int MOD = 998244353;

ll fac[MAX], finv[MAX], inv[MAX];

ll powmod(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
    cin >> N >> M >> K;
    // 前処理
    COMinit();

    // 計算例
    for(ll t=0;t<=K;t++) {
        ans += (M*powmod(M-1,N-1-t,MOD)%MOD)*COM(N-1, t)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "\n[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "\n[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]\n";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}


int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    ll ret = k * 500;
    if (ret >= x) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
N = int(input())
D,X = map(int,input().split())
A = [int(input()) for _ in range(N)] 

chocolate = 0
for i in range(N):
    count = 0
    for j in range(D+1):
        if j == (count * A[i] + 1):
            chocolate += 1
            count += 1
print(chocolate + X)

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

using namespace std;

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

    long r,D,x; cin>>r>>D>>x;
    auto func = [&](long x) {
        return r*x-D;
    };
    for (long i = 2000; i < 2010; i++) {
        x = func(x);
        cout << x << endl;
    }

    
    return 0;
}



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

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  ll k;
  cin >> s >> k;

  char ans = '1';
  for (int i = 0; i < k; i++) if (s[i] != '1') {
    ans = s[i];
    break;
  }

  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException{
		AirportBus solver = new AirportBus();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}


	static class AirportBus {

		private int n;
		private int c;
		private int k;
		private int t[];

		private Scanner scanner;
		private int output;

		public AirportBus() {
			scanner = new Scanner(System.in);
			output=1;
		}

		public void readInput() {
			n = Integer.parseInt(scanner.next());
			c = Integer.parseInt(scanner.next());
			k = Integer.parseInt(scanner.next());

			t = new int[n];

			for(int i=0; i<n; i++) {
				t[i] = Integer.parseInt(scanner.next());
			}

			Arrays.sort(t);

		}

		public void solve() {
			int temp = 0;
			for(int i=0; i<n; i++) {
				if(t[i]-t[temp]>k || (i-temp)>=c) {
					output++;
					temp = i;
				}
			}
		}

		public void writeOutput() {
			System.out.println(output);
		}
	}

}


Measured memory_bytes: 47264
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())
E=[[] for i in range(N)]
E_INV=[[] for i in range(N)]

for i in range(M):
    x,y=map(int,input().split())
    E[x].append(y)
    E_INV[y].append(x)

QUE = list(range(N))
check=[0]*N
TOP_SORT=[]

def dfs(x):
    if check[x]==1:
        return
    check[x]=1
    
    for to in E[x]:
        if check[to]==0:
            dfs(to)

    TOP_SORT.append(x) # 全ての点からDFSを行い, 帰りがけに点を答えに入れる
    check[x]=1

while QUE:
    x=QUE.pop()
    dfs(x)

USE=[0]*N
SCC=[]

def dfs2(x):
    Q=[x]
    USE[x]=1
    ANS=[]

    while Q:
        x=Q.pop()
        ANS.append(x)
        for to in E_INV[x]:
            if USE[to]==0:
                USE[to]=1
                Q.append(to)
    return ANS

for x in TOP_SORT[::-1]:
    if USE[x]==0:
        SCC.append(dfs2(x))

print(len(SCC))
for x in SCC:
    print(len(x),*x)
        
    


Measured memory_bytes: 207436
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-15 14:22:40
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-15 20:47:40
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const int maxn=200000;
ll N,K,ans;
vector<ll> P;
set<ll> se;
vector<ll> G[maxn];
void addedge(ll x,ll y)
{
    G[x].push_back(y);G[y].push_back(x);
}
ll vis[maxn];
void dfs(int u)
{
    vis[u]=1;
    for(auto v:G[u])
    {
        if(!vis[v])
        dfs(v);
    }
}
vector<ll> eq;
int main()
{
    memset(vis,0,sizeof(vis));
    read(N);read(K);P.reserve(N+1);
    for(ll i=0;i<N;i++) read(P[i]);
    ans=0;
    int cnt=1;
    for(int i=1;i<N;i++)
    {
        if(P[i]>P[i-1]) cnt++;
        else cnt=1;
        if(cnt==K) {eq.push_back(i-K+1);cnt=K-1;}
    }
    for(int i=1;i<eq.size();i++){
    addedge(eq[i],eq[i-1]);
    }
    for(int i=0;i<=K-1;i++)se.insert(P[i]);
    for(int i=1;i<=N-K;i++)
    {
        bool ok=false;
        if(P[i-1]==*(se.begin())) ok=true;
        // cout<<i<<" "<<ok<<endl;
        se.erase(P[i-1]);
        se.insert(P[i+K-1]);
        // for(auto p:se) cout<<p<<" ";
        // cout<<endl;
        if(P[i+K-1]==*(--se.end())&&ok)
        addedge(i,i-1);
    }
    for(int i=0;i<=N-K;i++)
    {
        if(!vis[i])
        {
            dfs(i);
            ans++;
        }
    }
    cout<<ans;
}

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

using namespace std;
#define DIM  3007
#define DIM2 100007
#define INF 10E16
#define MAXN 107
#define LG 18
#define MODULO 1000000007
#define MODULO2 MODULO*2
typedef long long  ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pll parr[DIM];
//typedef ll table[DIM][DIM2];
typedef ll arr2[DIM2];
struct pp {
	ll a, b;
	bool operator <(const pp& V)const {
		if (a == V.a)return b < V.b;
		return a < V.a;
	}
	bool operator ==(const pp& V)const {
		if (a == V.a && b == V.b)return 1;
		return 0;
	}
};
ll n, A[DIM], D[DIM][DIM],sum[DIM][DIM];

int main()

{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> A[i];
	for (int i = 1; i <= n; i++) {
		ll r = 0;
		for (int j = i; j <= n; j++) {
			r += A[j];
			sum[i][j] = r;
		}
	}
	for (int i = n; i >= 1; i--) {
		for (int j = i; j <= n; j++) {
			D[i][j] = sum[i][j] - min(D[i + 1][j], D[i][j - 1]);
		}
	}
	cout << D[1][n] - min(D[2][n], D[1][n - 1]) << endl;
	
}


Measured memory_bytes: 141568
N = int(input())
Hs = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(Hs[1] - Hs[0])
for i in range(2, N):
    dp[i] = min(abs(Hs[i] - Hs[i - 1]) + dp[i - 1], abs(Hs[i] - Hs[i - 2]) + dp[i - 2])
print(dp[N - 1])

Measured memory_bytes: 52208
#include <bits/stdc++.h>
using namespace std;
int n, x[1010], y[1010];
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d%d", y + i, x + i);
    int tag = !!((x[1] + y[1]) % 2);
    for(int i = 1; i <= n; i++) if(tag != !!((x[i] + y[i]) % 2)) return puts("-1"), 0;
    int m = tag ? 40 : 39;
    puts("40");
    if(tag == 0) printf("1 ");
    for(int i = 0; i < m; i++) printf("%lld ", 1ll << i);
    puts("");
    for(int i = 1; i <= n; i++) {
        int dx = x[i], dy = y[i];
        if(tag == 0) dx--, putchar('U');
        for(int i = 1; i < m; i++) {
            assert((dx + dy) % 2);
            long long tt = ((dx + dy) % 4 + 4) % 4;
            if(dx % 2) {
                if(tt == 3) putchar('U'), dx--, dx /= 2, dy /= 2;
                else putchar('D'), dx++, dx /= 2, dy /= 2;
            }
            else {
                if(tt == 3) putchar('R'), dy--, dx /= 2, dy /= 2;
                else putchar('L'), dy++, dx /= 2, dy /= 2;
            }
            // cerr << dx << ' ' << dy << endl;
        }
        assert(abs(dx) + abs(dy) == 1);
        if(dx == 1) puts("U");
        else if(dx == -1) puts("D");
        else if(dy == 1) puts("R");
        else puts("L");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
 
int al[30] = {0};
char b[2000]= {0};
int i,j,n;
 
i=0;
 
while( scanf("%c",&b[i]) != EOF) {
 
if (b[i] >= 'A' && 'Z' >= b[i] ) {
n = b[i] - 'A';
al[n] += 1;
 
} else if(b[i] >=  'a' && b[i] <= 'z' ) {
n = b[i] - 'a';
al[n] += 1;
}
i=i+1;
}
 
for(j=97; j<=122; j++) {
n = j - 'a';
printf("%c : %d\n",j,al[n]);
}
 
return 0;
 
}


Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s, _ := Scanner(), Scanner()
	a, b := intScanner(), intScanner()
	u := Scanner()
	if u == s {
		fmt.Println(a-1, b)
	} else {
		fmt.Println(a, b-1)
	}
}


Measured memory_bytes: 1772
use proconio::{fastout, input};

use proconio::marker::Chars;
use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize,
        cc: Chars,
    }
    let mut ws = vec![0; n + 1];
    let mut rs = vec![0; n + 1];
    for i in 0..n {
        ws[i + 1] = ws[i] + if cc[i] == 'W' { 1 } else { 0 };
        rs[i + 1] = rs[i] + if cc[i] == 'R' { 1 } else { 0 };
    }
    let rn = rs[n];
    let mut ans = n + 1;
    for i in 0..=n {
        ans = min(ans, max(ws[i], rn - rs[i]));
    }
    println!("{}", ans);
}


Measured memory_bytes: 6284
l = int(input())
m = input().split()

x = []
z = 0
c = 0

for i in range(l):
    if int(m[i]) < 3200:
        y = int(int(m[i]) / 400)
        if y not in x:
            x.append(y)
            z += 1
    elif int(m[i]) >= 3200:
        c += 1
        
if c == 0:
    print(str(z) + " " + str(z))
elif c > 0 and z > 0:
    z2 = c + z
    print(str(z) + " " + str(z2))
elif z == 0:
    print("1" + " " + str(c))


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

int main(){
    int X;
    cin >> X;
    int max_expo = 1;
    for (int i = 2; i < 32; i++){
        int p = i * i;
        while (p <= X){
            max_expo = max(max_expo, p);
            p *= i;
        }
    }
    cout << max_expo << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1],t;

void maxHeapify(int i){
	int l,r,largest;
	l=2*i;
	r=l+1;
	
	if(l<=H&&A[l]>A[i]) largest=l;
	else largest=i;
	if(r<=H&&A[r]>A[largest]) largest=r;
	
	if(largest!=i){
		t=A[i]; A[i]=A[largest]; A[largest]=t;
		maxHeapify(largest);
	}
}

int extract(){
	int maxv;
	if(H<1) return -INFTY;
	maxv=A[1];
	A[1]=A[H--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(int i,int key){
	if(key<A[i]) return;
	A[i]=key;
	for(;i>1&&A[i/2]<A[i];i/=2){
		t=A[i];
		A[i]=A[i/2];
		A[i/2]=t;
	}
}

void insert(int key){
	A[++H]=-INFTY;
	increaseKey(H,key);
}

int main(){
	int key;
	char com[10];
	
	while(1){
		scanf("%s",com);
		if(com[2]=='d') break;
		if(com[0]=='i'){
			scanf("%d",&key);
			insert(key);
		}else{
			printf("%d\n",extract());
		}
	}
	return 0;
}



Measured memory_bytes: 6616
#!/usr/bin/env python3
S = input()
ans = 0
zero = 0
one = 0
for c in S:
    if c == '0':
        zero += 1
        if one > 0:
            zero -= 1
            one -= 1
            ans += 1
    else:
        one += 1
        if zero > 0:
            zero -= 1
            one -= 1
            ans += 1
print(ans * 2)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    vector<int> L(N*2);
    rep(i, 0, 2 * N) cin >> L[i];
    sort(ALL(L));
    ll ans = 0;
    for(int i = 0; i < 2 * N; i += 2){
        ans += L[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k,a,b;
    cin>>k>>a>>b;
    if(b-a<=2){cout<<k+1<<endl;return 0;}
    else{
        int bis = 1;
        while(k){
            if(bis>=a&&k>=2){bis+=(b-a);k-=2;}
            else{
                k--;bis++;
            }
        }
        cout<<bis<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
#include <stdio.h>
#include <math.h>
int main(){
  int A,P;
  cin >> A >> P;
  cout << (A*3 + P)/2 << endl;
  return 0;
}



// ./compile.sh main


Measured memory_bytes: 256
num = int(input())

l = [int(x) for x in input().split()]

l_sort = sorted(l)


a = 0

for x, y in zip(l, l_sort):
  if x != y:
    a += 1
    
if a == 0 or a == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

vector<ll>date[100000];
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll>P(M);
vector<ll>Y(M);
  
  rep(i,M){
    cin>>P[i]>>Y[i];
    date[P[i]].push_back(Y[i]);
  }
  
  rep(i,N){
sort(all(date[i+1]));
  }

  
  rep(i,M){
    printf("%06d",P[i]);
    printf("%06d",lower_bound(all(date[P[i]]),Y[i])-date[P[i]].begin()+1);
    printf("\n");
  }
  
}
  
    

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(a.rbegin(), a.rend());
  if(a[0] == a[1] + a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
	int x[30],w;
	cin >> w;
	for(int i = 1; i <= w; i++){
		x[i] = i;
	}
	
	int n, a, b;
	char c;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a >> c >> b;
		swap(x[a],x[b]);
	}
	
	for(int i = 1; i <= w; i++){
		cout << x[i] << endl;
	}
}

Measured memory_bytes: 1164
from bisect import bisect_left,bisect_right,insort_left
dict = {}
keytbl = []
cnt = 0
q = int(input())
for i in range(q):
    a = list(input().split())
    ki = int(a[1])
    if a[0] == "0":
        if ki not in dict:
            dict[ki] =1
            insort_left(keytbl,ki)
        else:dict[ki] += 1
        cnt += 1
        print(cnt)
    elif a[0] == "1":print(dict[ki] if ki in dict else 0)
    elif a[0] == "2":
        if ki in dict:
            cnt -= dict[ki]
            dict[ki] =0
    else:
        L = bisect_left(keytbl,int(a[1]))
        R = bisect_right(keytbl,int(a[2]),L)
        r = []
        for j in range(L,R):r += [keytbl[j]]*dict[keytbl[j]]
        if r != []:print(*r,sep="\n")




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

int main() {
  int A, B, a1, a2, a3, a4, a5, i;
  cin >> A >> B;
  
  i=0;
  
  while(A <= B){
    a5 = A / 10000;
    a4 = A / 1000 % 10;
    a3 = A / 100 % 10;
    a2 = A / 10 % 10;
    a1 = A % 10;
      
      if(a1 == a5 && a2 == a4){
        i += 1;
      }
    A += 1;
  }
  
  cout << i << endl;
}


Measured memory_bytes: 256
data_ls = []
for i in range(5):
    data_ls.append(int(input()))
data_ls.sort(key= lambda x:x%10)
_sum = 0
flg = 0
for i in data_ls:
    if flg == 0:
        if i % 10 == 0:
            _sum += i
        else:
            _sum += i
            flg = 1
    else:
        _sum += (i // 10 + 1) * 10
print(_sum)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n;
    cin>>n;
    int cnt[100001]={};
    ll ans=0;
    rep(i,n){
        int v;
        cin>>v;
        ++cnt[v];
        ans+=v;
    }
    int q;
    cin>>q;
    rep(i,q){
        ll b,c;
        cin>>b>>c;
        ans+=(c-b)*cnt[b];
        cout<<ans<<endl;
        cnt[c]+=cnt[b];
        cnt[b]=0;
    }
}


Measured memory_bytes: 3932
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    int a, z;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }
    for(int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == 'Z') {
            z = i;
            break;
        }
    }
    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <cassert>
#include <cstring>

using namespace std;

const int N = 1e5 + 7;

int n, w[N];
vector<long long> rem[N];
vector<int> adj[N];

void fail() {
	puts("NO");
	exit(0);
}

void accept() {
	puts("YES");
	exit(0);
}

int fahter[N], deg[N];

long long dfs(int u, int from = 0) {
	if (adj[u].size() == 1) {
		return w[u];
	}
	vector<long long> rem;
	for (auto v : adj[u]) {
		if (v == from) continue;
		rem.push_back(dfs(v, u));
	}
	long long tot = 0, mc = 0;
	for (auto r : rem) {
		tot += r, mc = max(mc, r);
	}
	long long one = 0, two = 0;
	// one + two * 2 = tot
	// one + two = w[u]

	if (w[u] > tot) fail();
	two = tot - w[u];
	one = w[u] - two;
	if (two > tot / 2 || two > tot - mc) fail();
	// printf("%d %lld\n", u, one);
	return one;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
 	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
		deg[u]++, deg[v]++;
	}
	if (n == 2) {
		if (w[1] == w[2]) accept();
		fail();
	}
	int s = 1;
	for (int i = 1; i <= n; i++) {
		if (deg[i] > 1) {
			s = i;
		}
	}
	if (dfs(s) == 0) {
		accept();
	} else {
		fail();
	}
	return 0;
}


Measured memory_bytes: 17536
/**************************************
 * Au: Hany01
 * Prob: agc002f
 * Date: Oct 20th, 2018
 * Email: hany01@foxmail.com
**************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define Rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define X first
#define Y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline T read() {
    register char c_; register T _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


const int maxn = 2048, maxm = 2048 * 2048, MOD = 1e9 + 7;

int n, k, fac[maxm], ifac[maxm], f[maxn][maxn];

inline int fpm(int a, int b) {
	register int ans = 1;
	for ( ; b; b >>= 1, a = (LL)a * a % MOD)
		if (b & 1) ans = (LL)ans * a % MOD;
	return ans;
}

inline void inc(int &x, int y) { if ((x += y) >= MOD) x -= MOD; }

inline void init(int n) {
	fac[0] = 1;
	For(i, 1, n) fac[i] = (LL)fac[i - 1] * i % MOD;
	ifac[n] = fpm(fac[n], MOD - 2);
	Fordown(i, n, 1) ifac[i - 1] = (LL)ifac[i] * i % MOD;
}

inline LL C(int n, int m) { return (LL)fac[n] * ifac[m] % MOD * ifac[n - m] % MOD; }

int main()
{
#ifdef hany01
    File("agc002f");
#endif

	n = read<int>(), k = read<int>(), init(n * k);

	//Pay attention!!
	if (k == 1) { puts("1"); return 0; }

	f[0][0] = 1;
	For(i, 0, n) For(j, 0, i) {
		inc(f[i + 1][j], f[i][j]);
		if (i > j) inc(f[i][j + 1], C(n * k - (k - 1) * j - i - 1, k - 2) * f[i][j] % MOD);
	}
	cout << (LL)f[n][n] * fac[n] % MOD << endl;

    return 0;
}

//Analysis:
//先考虑按顺序加入编号1~n的球，最后乘一个n!
//从前往后考虑, 那么0球的数量一定不小于已经出现的颜色的数量
//f[i][j]表示加入了i个0球、j种颜色 (i >= j)
//
//转移:
//加入0球: dp[i][j] ==> dp[i+1][j]
//加入一种新的颜色: f[i][j] * C(n*k-(k-1)*j-i-1, k-2) ==> dp[i][j+1]
//(一共n*k个格子, 已经用掉了(k-1)*j+i个, 由于要保证不重复, 得有个新颜色放在最前面, 所以是n*k-(k-1)*j-i-1个空位
//k个球, 除掉0球, 除掉固定的最前面的球, 所以是k-2个球要放进去)
//
//注意特判k=1的情况

Measured memory_bytes: 48384
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

ll sv(ll H){
	if(H==1){
		return 1;
	}else{
		return 2*sv(H/2)+1;
	}
}
int main()
{
	ll i,H,P;
	cin>>H;
	P=sv(H);
	
	cout<< P <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'

int N, K;
int x[55], y[55];

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

  cin >> N >> K;
  rep(i, N) cin >> x[i] >> y[i];

  ll ans = (ll)4e18;

  rep(i, N) {
    int lx = x[i];
    rep(j, N) {
      int rx = x[j];
      if (lx >= rx) continue;
      rep(k, N) {
        int uy = y[k];
        rep(l, N) {
          int dy = y[l];
          if (dy >= uy) continue;
          int cnt = 0;
          rep(m, N) {
            if (lx <= x[m] && x[m] <= rx && dy <= y[m] && y[m] <= uy) cnt++;
          }
          if (cnt >= K) {
            ans = min(ans, (ll)(rx - lx)*(uy - dy));
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<vector<ll> > G(N, vector<ll>(N));
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> G[i][j];

    ll ans = 0;
    // floyd
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
        if (i == j) continue;
        bool use = true;
            for (int k = 0; k < N; k++) {
                if (k == i || k == j) continue;
                ll d = G[i][k] + G[k][j];
                if (d < G[i][j]) {
                    cout << -1 << '\n';
                    return 0;
                }
                else if (d == G[i][j]) use = false;
            }
        if (use) ans += G[i][j];
        }
    }
    cout << ans / 2LL << '\n';
}


Measured memory_bytes: 1024
import java.util.*;public class Main{public static void main(String[]a){Scanner s=new Scanner(System.in);List<Integer>h=new ArrayList<Integer>();for(int i=0;i++<10;)h.add(s.nextInt());Collections.sort(h,Collections.reverseOrder());System.out.printf("%d\n%d\n%d\n",h.toArray());}}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
   char s[200005],t[200005];
   cin>>s;cin>>t;
   int i,l,ans=0;
   l=strlen(s);
   for(i=0;i<l;i++)
   {
       if(s[i]!=t[i])ans++;
   }
   cout<<ans<<endl;
}


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

int main() {
    int N;
    cin >> N;
    int A_max = N / 4;
    int B_max = N / 7;
    for(int A = 0; A <= A_max; A++)
    {
        for(int B = 0; B <= B_max; B++)
        {
            if(N == 4 * A + 7 * B)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans = a + a*a + a*a*a;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>

#define N 10000
#define INT(X) \
  ( *( (int *)(X) ) )

int cmpr (
  const void  * a,
  const void  * b
  )
{
  return ( INT( b ) - INT( a ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int d[ N ][ 2 ];
    int res = 0;
    int n, m;

    scanf ( "%d%d", &n, &m );
    if ( !( n | m ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d%d", &d[ i ][ 1 ], &d[ i ][ 0 ] );
    }
    qsort ( d, n, sizeof ( int ) * 2, cmpr );

    for ( i = 0; i < n && m > 0; ++i )
    {
      if ( d[ i ][ 1 ] <= m )
      {
        m -= d[ i ][ 1 ];
        d[ i ][ 1 ] = 0;
      }
      else
      {
        d[ i ][ 1 ] -= m;
        m = 0;
      }
    }

    for ( i = 0; i < n; ++i )
    {
      res += d[ i ][ 1 ] * d[ i ][ 0 ];
    }
    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import sys

N,M = list(map(int, input().rstrip().split()))
S = input().strip()
T = input().strip()
#-----

def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return (a * b) // gcd(a, b)

lcm = lcm(N,M)
L = lcm
X1_dic={}

X1_dic[0] = S[0]
for i in range(1,N):
    X1_dic[ int(i*(L/N)+1) - 1 ] = S[i]


if X1_dic[0] != T[0]:
    print(-1)
    sys.exit()

for i in range(1,M):
    key = int(i*(L/M)+1) - 1
    if (key in X1_dic) and  X1_dic[key] != T[i]:
        print(-1)
        sys.exit()
    
print(L)


Measured memory_bytes: 15396
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			long goukei=0;
			for(int i = 1;i<=K;i++) {
				for(int j = 1;j<=K;j++) {
					for(int z = 1;z<=K;z++) {
						
						goukei+=gcd(gcd(i,j),z);
						
						
						
					}
				}
			}
			
			
			System.out.println(goukei);
			
		}
		
		
	}
		
	
	private static int gcd(int A,int B){//最大公約数
		return B==0?A:gcd (B,A%B);
	}

}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll x;
	cin >> x;

	ll eleven = ( x + 10 ) / 11;
	ll ans ;
	if(x%11<=6){
		ans = 2 * eleven - 1;
		if(x%11==0){
			ans++;
		}
	}else{
		ans = 2 * eleven ;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a[200560];
int main()
{
        int n;
        while(~scanf("%d",&n))
        {
                int t;
                for(int i=1;i<=n;i++)
                        scanf("%d",&a[i]);
                if(n%2==1)
                {
                        for(int i=n;i>=1;i-=2)
                        printf("%d ",a[i]);
                        for(int i=2;i<=n-1;i+=2)
                        {
                                if(i==n-1)
                                        printf("%d",a[i]);
                                else
                                        printf("%d ",a[i]);
                        }
                }
                else if(n%2==0)
                {
                        for(int i=n;i>0;i-=2)
                                printf("%d ",a[i]);
                        for(int i=1;i<=n-1;i+=2)
                        {
                                if(i==n-1)
                                        printf("%d",a[i]);
                                else
                                        printf("%d ",a[i]);
                        }
                }
                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE tmp(n); rep(i, n)tmp[i] = i + 1;
	VE p(n), q(n); rep(i, n)cin >> p[i]; rep(i, n)cin >> q[i];
	int a = 0; int b = 0;
	int now = 1;
	do {
		bool ta = true; bool tb = true;
		rep(i, n) {
			if (tmp[i] != p[i])ta = false;
			if (tmp[i] != q[i])tb = false;
		}
		if (ta)a = now;
		if (tb)b = now;
		now++;
	} while (next_permutation(ALL(tmp)));
	cout << abs(a - b) << endl;
	return 0;
}

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

ll h,w;
char a[101][101];

int search(ll x,ll y){
    ll flag=0;
    for(ll i=0;i<w;++i){
        if(a[x][i]=='#'){
            flag++;
        }
    }
    if(flag==0){
        return false;
    }
    flag=0;
    for(ll i=0;i<h;++i){
        if(a[i][y]=='#'){
            flag++;
        }
    }
    if(flag==0){
        return false;
    }
    return true;
}

int main(){
    cin>>h>>w;
    bool bol=false;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            cin>>a[i][j];
        }
    }

    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(a[i][j]=='#'){
                cout<<'#';
                bol = true;
            }else{
                if(search(i,j)){
                    cout<<'.';
                    bol = true;
                }
            }
        }
        if(bol){
            cout<<endl;
        }
        bol = false;
    }
    return 0;
}

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

int main()
{
    ll a,b,x;
    cin>>a>>b>>x;
    ll p,q,r;

    p=(a)/x;
    q=b/x;
    ll ans=q-p;
    if(a%x==0) ans++;
    cout<<ans<<endl;

}


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

int main() {
  int H,W;
  cin >>H>>W;
  vector<char> F(W+2,'#'); 
  char T;
  for(int i=0;i<W+2;i++){
    cout<<F.at(i);
  }
  cout<<endl;
  for(int i=0;i<H;i++){
    cout<<'#';
    for(int u=0;u<W;u++){
      cin>>T;
      cout<<T;
    }
      cout<<'#'<<endl;
  }
    for(int i=0;i<W+2;i++){
    cout<<F.at(i);
  }
  cout<<endl;
}


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

int main(void){
        char s[100],t[100],p;
        int i,j,m=0;

        gets(s);
        gets(t);

        for(i=0;i<strlen(s);i++){
            if(strcmp(s,t)==0){
                m++;
                break;
            }
            else{
                p=s[strlen(s)-1];
                for(j=strlen(s)-1;j>0;j--){
                    s[j]=s[j-1];
                }
                s[0]=p;
            }
        }

        if(m==0){printf("No");}
        else{printf("Yes");}

        return 0;
}


Measured memory_bytes: 1604
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

tasks = inl()
tasks.sort()
ans = 0
for i in range(len(tasks)-1):
    ans += tasks[i+1] - tasks[i]

print(ans)

Measured memory_bytes: 9140